Browse Source

案件管理组织管理员

lyhzzz 1 year ago
parent
commit
895d6772e0

+ 2 - 0
src/main/java/com/fdkankan/fusion/entity/CaseEntity.java

@@ -62,4 +62,6 @@ public class CaseEntity implements Serializable {
     @TableField("dept_id")
     private String deptId;
 
+    @TableField(exist = false)
+    private String deptName;
 }

+ 3 - 0
src/main/java/com/fdkankan/fusion/service/ITmProjectService.java

@@ -10,6 +10,7 @@ import com.fdkankan.fusion.request.ProjectRequestDto;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -40,4 +41,6 @@ public interface ITmProjectService extends IService<TmProject> {
     HashMap<String, CaseEntity> getCaseMap(List<String> ids);
 
     void updateIdenTityStatus(String tmProjectId, Integer status);
+
+    HashMap<String, TmProject> getMapByIds(Set<String> tmProIds);
 }

+ 27 - 4
src/main/java/com/fdkankan/fusion/service/impl/CaseServiceImpl.java

@@ -4,12 +4,9 @@ import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.fusion.common.ResultCode;
-import com.fdkankan.fusion.entity.Model;
-import com.fdkankan.fusion.entity.TmDepartment;
-import com.fdkankan.fusion.entity.TmUser;
+import com.fdkankan.fusion.entity.*;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.PageInfo;
-import com.fdkankan.fusion.entity.CaseEntity;
 import com.fdkankan.fusion.mapper.ICaseMapper;
 import com.fdkankan.fusion.request.CaseParam;
 import com.fdkankan.fusion.request.ScenePram;
@@ -22,6 +19,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.time.Period;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -70,6 +68,31 @@ public class CaseServiceImpl extends ServiceImpl<ICaseMapper, CaseEntity> implem
         wrapper.eq(CaseEntity::getType,0);
         wrapper.orderByDesc(CaseEntity::getCreateTime);
         Page<CaseEntity> page = this.page( new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
+
+
+        Set<String> tmProIds = page.getRecords().stream().filter(entity -> StringUtils.isNotBlank(entity.getTmProjectId()))
+                .map(CaseEntity::getTmProjectId).collect(Collectors.toSet());
+        HashMap<String, TmProject> proMap =  tmProjectService.getMapByIds(tmProIds);
+
+        for (CaseEntity record : page.getRecords()) {
+            if(StringUtils.isNotBlank(record.getTmProjectId())){
+                TmProject project = proMap.get(record.getTmProjectId());
+                if(project != null){
+                    record.setDeptId(project.getDeptId());
+                }
+            }
+        }
+
+        Set<String> deptIds1 = page.getRecords().stream().filter(entity -> StringUtils.isNotBlank(entity.getDeptId()))
+                .map(CaseEntity::getDeptId).collect(Collectors.toSet());
+        HashMap<String, TmDepartment> mapByDeptIds = tmDepartmentService.getMapByDeptIds(deptIds1);
+
+        for (CaseEntity record : page.getRecords()) {
+            TmDepartment department = mapByDeptIds.get(record.getDeptId());
+            if(department != null){
+                record.setDeptName(department.getName());
+            }
+        }
         return PageInfo.PageInfo(page);
     }
 

+ 13 - 0
src/main/java/com/fdkankan/fusion/service/impl/TmProjectServiceImpl.java

@@ -24,6 +24,7 @@ import com.fdkankan.fusion.response.ProjectRandCodeVo;
 import com.fdkankan.fusion.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.redis.util.RedisUtil;
+import com.sun.deploy.panel.ITreeNode;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -333,4 +334,16 @@ public class TmProjectServiceImpl extends ServiceImpl<ITmProjectMapper, TmProjec
             this.update(wrapper);
         }
     }
+
+    @Override
+    public HashMap<String, TmProject> getMapByIds(Set<String> tmProIds) {
+        HashMap<String, TmProject> map  = new HashMap<>();
+        if(tmProIds.size() >0){
+            List<TmProject> tmProjects = this.listByIds(tmProIds);
+            for (TmProject tmProject : tmProjects) {
+                map.put(tmProject.getId(),tmProject);
+            }
+        }
+        return map;
+    }
 }