فهرست منبع

Merge remote-tracking branch 'origin/master'

sangwenwei 5 ماه پیش
والد
کامیت
e9f2eaaa4c

+ 13 - 2
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/workCollectAccessory/controller/WorkCollectAccessoryController.java

@@ -94,9 +94,9 @@ public class WorkCollectAccessoryController {
     }
 
     /**
-     * 根据id查询
+     * 根据id查询当前附件信息
      */
-    @ApiOperation(value = "根据id查询")
+    @ApiOperation(value = "根据id查询当前附件信息")
     @GetMapping(value = "/queryById")
     public ResponseEntity queryById( @RequestParam("id")String id) throws ParseException {
         WorkCollectAccessory workCollectAccessory = workCollectAccessoryService.queryById(id);
@@ -122,4 +122,15 @@ public class WorkCollectAccessoryController {
         List<DictValue> dictList = workCollectAccessoryService.getDictValueByName(dictName);
         return ResponseEntity.ok(dictList);
     }
+
+    /**
+     * 根据分类去重查询
+     */
+    @ApiOperation(value = "根据分类去重查询")
+    @GetMapping(value = "/getClassificationList")
+    public ResponseEntity getClassificationList(WorkCollectAccessory workCollectAccessory ) throws Exception {
+        List<WorkCollectAccessory> classificationList = workCollectAccessoryService.getClassificationList(workCollectAccessory);
+        return ResponseEntity.ok(classificationList);
+    }
+
 }

+ 5 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/workCollectAccessory/mapper/WorkCollectAccessoryMapper.java

@@ -34,4 +34,9 @@ public interface WorkCollectAccessoryMapper extends BaseMapper<WorkCollectAccess
     @InterceptorIgnore(tenantLine = "true")
     List<DictValue> getDictValueByName(@Param("dictName") String dictName,@Param("userId") String userId);
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<WorkCollectAccessory> getClassificationList(@Param(Constants.WRAPPER) QueryWrapper<WorkCollectAccessory> workCollectAccessoryMapperQueryWrapper);
+
+
+
 }

+ 9 - 1
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/workCollectAccessory/mapper/xml/WorkCollectAccessoryMapper.xml

@@ -89,11 +89,19 @@
     <select id="getDictValueByName" resultType="com.jeeplus.pubmodules.workCollectAccessory.service.dto.DictValue">
         SELECT v.label,
                v.value,
-               v.sort
+               v.sort,
+               v.create_by_id
         FROM `sys_dict_value` v
         LEFT JOIN `sys_dict_type` t ON v.dict_type_id = t.id
         WHERE t.type = #{dictName} and v.create_by_id = #{userId}
         AND t.del_flag = 0
         AND v.del_flag = 0
     </select>
+
+    <select id="getClassificationList" resultType="com.jeeplus.pubmodules.workCollectAccessory.domain.WorkCollectAccessory">
+        SELECT DISTINCT a.classification
+        FROM work_collect_accessory a
+            ${ew.customSqlSegment}
+    </select>
+
 </mapper>

+ 139 - 120
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/workCollectAccessory/service/WorkCollectAccessoryService.java

@@ -46,37 +46,30 @@ public class WorkCollectAccessoryService {
      */
     public IPage<WorkCollectAccessory> findPageList(WorkCollectAccessory workCollectAccessory, Page<WorkCollectAccessory> page) throws Exception {
         QueryWrapper<WorkCollectAccessory> workCollectAccessoryMapperQueryWrapper = QueryWrapperGenerator.buildQueryCondition(workCollectAccessory, WorkCollectAccessory.class);
-
         // 确保 del_flag = 0 条件正确应用
         workCollectAccessoryMapperQueryWrapper.eq("a.del_flag", 0);
-
         // 附件名称
         if (StringUtils.isNotBlank(workCollectAccessory.getFileName())) {
             workCollectAccessoryMapperQueryWrapper.like("a.file_name", workCollectAccessory.getFileName());
         }
-
         // 上传人
         if (StringUtils.isNotBlank(workCollectAccessory.getUserName())) {
             workCollectAccessoryMapperQueryWrapper
                     .like("b.name", workCollectAccessory.getUserName()); // 使用 b.name 作为条件
         }
-
         // 收藏分类
         if (StringUtils.isNotBlank(workCollectAccessory.getClassification())) {
             workCollectAccessoryMapperQueryWrapper
                     .eq("a.classification", workCollectAccessory.getClassification()); // 使用 b.name 作为条件
         }
-
         // 公司
         if (StringUtils.isNotBlank(workCollectAccessory.getCompanyId())) {
             workCollectAccessoryMapperQueryWrapper.eq("a.company_id", workCollectAccessory.getCompanyId());
         }
-
         // 部门
         if (StringUtils.isNotBlank(workCollectAccessory.getOfficeId())) {
             workCollectAccessoryMapperQueryWrapper.eq("a.office_id", workCollectAccessory.getOfficeId());
         }
-
         if (StringUtils.isNotBlank(workCollectAccessory.getCreateById())) {
             // 明确查询条件的优先级
             workCollectAccessoryMapperQueryWrapper
@@ -108,33 +101,33 @@ public class WorkCollectAccessoryService {
         workCollectAccessory.setCollectType("1");
         workCollectAccessory.setCollectUserId(userId);
         workCollectAccessory.setCreateTime(new Date());
-        String classification = workCollectAccessory.getClassification();
-        if(StringUtils.isNotEmpty(classification)){
-            List<DictValue> dictList = getDictValueByName("classification");
-            boolean containsValue = false;
-            for (DictValue dictValue : dictList) {
-                if (dictValue.getValue().equals(workCollectAccessory.getClassification())) {
-                    containsValue = true;
-                    break; // 一旦找到匹配值,退出循环
-                }
-            }
-            if(!containsValue){
-                DictType dictType = getDictByName("classification");
-                DictValueDTO dictValue = new DictValueDTO();
-                dictValue.setDictTypeId(dictType.getId());
-                dictValue.setValue(classification);
-                dictValue.setLabel(classification);
-                dictValue.setSort(generateRandomString());
-                dictValue.setId(generateId());
-                dictValue.setCreateById(userId);
-                dictValue.setCreateTime(new Date());
-                dictValue.setUpdateById(userId);
-                dictValue.setUpdateTime(new Date());
-                dictValue.setDelFlag(0);
-                dictValue.setTenantId("10000");
-                workCollectAccessoryMapper.insertDictValue(dictValue);
-            }
-        }
+//        String classification = workCollectAccessory.getClassification();
+//        if(StringUtils.isNotEmpty(classification)){
+//            List<DictValue> dictList = getDictValueByName("classification");
+//            boolean containsValue = false;
+//            for (DictValue dictValue : dictList) {
+//                if (dictValue.getValue().equals(workCollectAccessory.getClassification())) {
+//                    containsValue = true;
+//                    break; // 一旦找到匹配值,退出循环
+//                }
+//            }
+//            if(!containsValue){
+//                DictType dictType = getDictByName("classification");
+//                DictValueDTO dictValue = new DictValueDTO();
+//                dictValue.setDictTypeId(dictType.getId());
+//                dictValue.setValue(classification);
+//                dictValue.setLabel(classification);
+//                dictValue.setSort(generateRandomString());
+//                dictValue.setId(generateId());
+//                dictValue.setCreateById(userId);
+//                dictValue.setCreateTime(new Date());
+//                dictValue.setUpdateById(userId);
+//                dictValue.setUpdateTime(new Date());
+//                dictValue.setDelFlag(0);
+//                dictValue.setTenantId("10000");
+//                workCollectAccessoryMapper.insertDictValue(dictValue);
+//            }
+//        }
 
         workCollectAccessoryMapper.insert(workCollectAccessory);
     }
@@ -149,7 +142,6 @@ public class WorkCollectAccessoryService {
 //        判断并设置共享状态
         if(StringUtils.isNotEmpty(companyId)){
             if("1".equals(shareType)){
-
                 newAttachment.setOfficeId(companyId);
                 newAttachment.setOfficeShare("1");
             }else{
@@ -195,34 +187,35 @@ public class WorkCollectAccessoryService {
             WorkAttachmentInfo firstAttachment = workAttachments.get(0);
             workCollectAccessory.setId(id);
             workCollectAccessory.setFileDescription(workCollectAccessoryDTO.getFileDescription());
-            String classification = workCollectAccessoryDTO.getClassification();
-            if(StringUtils.isNotEmpty(classification)){
-                workCollectAccessory.setClassification(classification);
-                List<DictValue> dictList = getDictValueByName("classification");
-                boolean containsValue = false;
-                for (DictValue dictValue : dictList) {
-                    if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById()) ) {
-                        containsValue = true;
-                        break; // 一旦找到匹配值,退出循环
-                    }
-                }
-                if(!containsValue){
-                    DictType dictType = getDictByName("classification");
-                    DictValueDTO dictValue = new DictValueDTO();
-                    dictValue.setDictTypeId(dictType.getId());
-                    dictValue.setValue(classification);
-                    dictValue.setLabel(classification);
-                    dictValue.setSort(generateRandomString());
-                    dictValue.setId(generateId());
-                    dictValue.setCreateById(userDTO.getId());
-                    dictValue.setCreateTime(new Date());
-                    dictValue.setUpdateById(userDTO.getId());
-                    dictValue.setUpdateTime(new Date());
-                    dictValue.setDelFlag(0);
-                    dictValue.setTenantId("10000");
-                    workCollectAccessoryMapper.insertDictValue(dictValue);
-                }
-            }
+//            String classification = workCollectAccessoryDTO.getClassification();
+//            if(StringUtils.isNotEmpty(classification)){
+//                workCollectAccessory.setClassification(classification);
+//                List<DictValue> dictList = getDictValueByName("classification");
+//                boolean containsValue = false;
+//                for (DictValue dictValue : dictList) {
+//                    if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById()) ) {
+//                        containsValue = true;
+//                        break; // 一旦找到匹配值,退出循环
+//                    }
+//                }
+//                if(!containsValue){
+//                    DictType dictType = getDictByName("classification");
+//                    DictValueDTO dictValue = new DictValueDTO();
+//                    dictValue.setDictTypeId(dictType.getId());
+//                    dictValue.setValue(classification);
+//                    dictValue.setLabel(classification);
+//                    dictValue.setSort(generateRandomString());
+//                    dictValue.setId(generateId());
+//                    dictValue.setCreateById(userDTO.getId());
+//                    dictValue.setCreateTime(new Date());
+//                    dictValue.setUpdateById(userDTO.getId());
+//                    dictValue.setUpdateTime(new Date());
+//                    dictValue.setDelFlag(0);
+//                    dictValue.setTenantId("10000");
+//                    workCollectAccessoryMapper.insertDictValue(dictValue);
+//                }
+//            }
+            workCollectAccessory.setClassification(workCollectAccessoryDTO.getClassification());
             workCollectAccessory.setUrl(firstAttachment.getUrl());
             workCollectAccessory.setFileName(firstAttachment.getName());
             workCollectAccessory.setType("1");
@@ -235,7 +228,7 @@ public class WorkCollectAccessoryService {
     }
 
     /**
-     * 上传附件
+     * 根据id修改
      * @return
      */
     public void updateById(WorkCollectAccessory workCollectAccessory)  {
@@ -249,33 +242,33 @@ public class WorkCollectAccessoryService {
                 saveFiles(workAttachments, userDTO, id);
             }
             WorkAttachmentInfo firstAttachment = workAttachments.get(0);
-            String classification = workCollectAccessory.getClassification();
-            if(StringUtils.isNotEmpty(classification)){
-                List<DictValue> dictList = getDictValueByName("classification");
-                boolean containsValue = false;
-                for (DictValue dictValue : dictList) {
-                    if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById())) {
-                        containsValue = true;
-                        break; // 一旦找到匹配值,退出循环
-                    }
-                }
-                if(!containsValue){
-                    DictType dictType = getDictByName("classification");
-                    DictValueDTO dictValue = new DictValueDTO();
-                    dictValue.setDictTypeId(dictType.getId());
-                    dictValue.setValue(classification);
-                    dictValue.setLabel(classification);
-                    dictValue.setSort(generateRandomString());
-                    dictValue.setId(generateId());
-                    dictValue.setCreateById(userDTO.getId());
-                    dictValue.setCreateTime(new Date());
-                    dictValue.setUpdateById(userDTO.getId());
-                    dictValue.setUpdateTime(new Date());
-                    dictValue.setDelFlag(0);
-                    dictValue.setTenantId("10000");
-                    workCollectAccessoryMapper.insertDictValue(dictValue);
-                }
-            }
+//            String classification = workCollectAccessory.getClassification();
+//            if(StringUtils.isNotEmpty(classification)){
+//                List<DictValue> dictList = getDictValueByName("classification");
+//                boolean containsValue = false;
+//                for (DictValue dictValue : dictList) {
+//                    if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById())) {
+//                        containsValue = true;
+//                        break; // 一旦找到匹配值,退出循环
+//                    }
+//                }
+//                if(!containsValue){
+//                    DictType dictType = getDictByName("classification");
+//                    DictValueDTO dictValue = new DictValueDTO();
+//                    dictValue.setDictTypeId(dictType.getId());
+//                    dictValue.setValue(classification);
+//                    dictValue.setLabel(classification);
+//                    dictValue.setSort(generateRandomString());
+//                    dictValue.setId(generateId());
+//                    dictValue.setCreateById(userDTO.getId());
+//                    dictValue.setCreateTime(new Date());
+//                    dictValue.setUpdateById(userDTO.getId());
+//                    dictValue.setUpdateTime(new Date());
+//                    dictValue.setDelFlag(0);
+//                    dictValue.setTenantId("10000");
+//                    workCollectAccessoryMapper.insertDictValue(dictValue);
+//                }
+//            }
             workCollectAccessory.setUrl(firstAttachment.getUrl());
             workCollectAccessory.setFileName(firstAttachment.getName());
             workCollectAccessory.setFileSize(firstAttachment.getSize());
@@ -285,28 +278,6 @@ public class WorkCollectAccessoryService {
     }
 
     /**
-     * 生成uuid
-     * @return
-     */
-    public static String generateId() {
-        UUID uuid = UUID.randomUUID();
-        BigInteger id = new BigInteger(uuid.toString().replace("-", ""), 16);
-        return id.toString();
-    }
-
-    /**
-     * 随机生成
-     * @return
-     */
-    public static String generateRandomString() {
-        Random random = new Random();
-        // 随机生成一个 99 到 1000 之间的整数
-        int randomNumber = 99 + random.nextInt(1000 - 99);
-        // 返回整数转为字符串
-        return String.valueOf(randomNumber);
-    }
-
-    /**
      * 保存附件信息
      * @param list 待保存的附件列表
      * @param userDTO 当前登录用户
@@ -347,24 +318,72 @@ public class WorkCollectAccessoryService {
     }
 
     /**
-     * 根据名称获取字典值
+     * 根据分类去重
+     */
+    public List<WorkCollectAccessory> getClassificationList(WorkCollectAccessory workCollectAccessory)  throws Exception{
+        QueryWrapper<WorkCollectAccessory> workCollectAccessoryMapperQueryWrapper = QueryWrapperGenerator.buildQueryCondition(workCollectAccessory, WorkCollectAccessory.class);
+        // 确保 del_flag = 0 条件正确应用
+        workCollectAccessoryMapperQueryWrapper.eq("a.del_flag", 0);
+        // 公司
+        if (StringUtils.isNotBlank(workCollectAccessory.getCompanyId())) {
+            workCollectAccessoryMapperQueryWrapper.eq("a.company_id", workCollectAccessory.getCompanyId());
+        }
+        // 部门
+        if (StringUtils.isNotBlank(workCollectAccessory.getOfficeId())) {
+            workCollectAccessoryMapperQueryWrapper.eq("a.office_id", workCollectAccessory.getOfficeId());
+        }
+        if (StringUtils.isNotBlank(workCollectAccessory.getCreateById())) {
+            // 明确查询条件的优先级
+            workCollectAccessoryMapperQueryWrapper
+                    .and(wrapper -> wrapper
+                            .and(innerWrapper -> innerWrapper
+                                    .eq("a.create_by_id", workCollectAccessory.getCreateById())
+                                    .ne("a.collect_type", 1)) // 在 create_by_id 条件中添加 collect_type != 1
+                            .or().eq("a.collect_user_id", workCollectAccessory.getCreateById())); // collect_user_id 条件单独处理
+        }
+        return workCollectAccessoryMapper.getClassificationList(workCollectAccessoryMapperQueryWrapper);
+    }
+
+
+    /**
+     * 根据id查询当前附件信息
+     */
+    public WorkCollectAccessory queryById(String id) {
+        WorkCollectAccessory workCollectAccessory = workCollectAccessoryMapper.selectById(id);
+        return workCollectAccessory;
+    }
+    /**
+     * 根据字典名称获取字典值
      */
     @Transactional(rollbackFor = Exception.class)
     public DictType getDictByName(String dictName) {
-      return  workCollectAccessoryMapper.getDictByName(dictName);
+        return  workCollectAccessoryMapper.getDictByName(dictName);
     }
     public List<DictValue> getDictValueByName(String dictName){
         UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
         String userId = userDTO.getId();
         return workCollectAccessoryMapper.getDictValueByName(dictName,userId);
     }
+
     /**
-     * 查询字典值
+     * 生成uuid
+     * @return
      */
-    public WorkCollectAccessory queryById(String id) {
-        WorkCollectAccessory workCollectAccessory = workCollectAccessoryMapper.selectById(id);
-        return workCollectAccessory;
+    public static String generateId() {
+        UUID uuid = UUID.randomUUID();
+        BigInteger id = new BigInteger(uuid.toString().replace("-", ""), 16);
+        return id.toString();
     }
 
-
+    /**
+     * 随机生成
+     * @return
+     */
+    public static String generateRandomString() {
+        Random random = new Random();
+        // 随机生成一个 99 到 1000 之间的整数
+        int randomNumber = 99 + random.nextInt(1000 - 99);
+        // 返回整数转为字符串
+        return String.valueOf(randomNumber);
+    }
 }