Преглед изворни кода

日报待审核统计修改

yurk пре 2 година
родитељ
комит
29c9eeb000

+ 25 - 20
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -6634,20 +6634,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,Integer pageIndex,Integer pageSize,String startDate,String endDate,Integer departmentId) {
         HttpRespMsg msg=new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
-        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()));
-        List<DepartmentOtherManager> otherManagers = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
-        //获取全部子部门
-        List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
-        List<Integer> collect = departmentList.stream().map(Department::getDepartmentId).distinct().collect(Collectors.toList());
-        List<Integer> collect1 = otherManagers.stream().map(DepartmentOtherManager::getDepartmentId).distinct().collect(Collectors.toList());
-        List<Integer> deptIds=new ArrayList<>();
-        for (Integer dpId : collect) {
-            List<Integer> ids = departmentService.getDeptIncludeSubDeptIds(dpId, allDeptList);
-            deptIds.addAll(ids);
-        }
-        for (Integer dpId : collect1) {
-            List<Integer> ids = departmentService.getDeptIncludeSubDeptIds(dpId, allDeptList);
-            deptIds.addAll(ids);
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
+        List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
+        List<Department> userDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+        List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
+        List<Integer> deptIds=null;
+        if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
+            List<Integer> collect = userDepartmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+            List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
+            collect.addAll(otherCollect);
+            for (Integer integer : collect) {
+                List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
+                deptIds.addAll(branchDepartment);
+            }
         }
         Integer size;
         Integer start;
@@ -6663,17 +6664,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         for (Map<String, Object> map : list) {
             Department dept = null;
             Integer deptId = Integer.valueOf(map.get("deptId").toString());
-            for (Department department : allDeptList) {
+            for (Department department : allDepartmentList) {
                 if (deptId.equals(department.getDepartmentId())){
                     dept = department;
                 }
             }
-            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                String wxDeptName = departmentService.getWxDepartment(dept, allDeptList);
-                map.put("departmentName",wxDeptName);
+            if(dept==null){
+                map.put("departmentName","未分配");
             }else {
-                String deptName = departmentService.getSupDepartment(dept, allDeptList);
-                map.put("departmentName",deptName);
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    String wxDeptName = departmentService.getWxDepartment(dept, allDepartmentList);
+                    map.put("departmentName",wxDeptName);
+                }else {
+                    String deptName = departmentService.getSupDepartment(dept, allDepartmentList);
+                    map.put("departmentName",deptName);
+                }
             }
         }
         long total=projectMapper.findCount(stateKey,user.getCompanyId(),userId,null,null,startDate,endDate,departmentId,deptIds);

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -924,7 +924,7 @@
     <select id="getWaitingReviewList" resultType="java.util.Map">
         <choose>
             <when test="stateKey==0">
-                SELECT 	dept_manager.name as userName,`user`.corpwx_userid as corpwxUserId,department.department_id as deptId,department.corpwx_deptid as wxDeptId,COUNT(1) as num
+                SELECT 	dept_manager.name as userName,`user`.corpwx_userid as corpwxUserId,IFNULL(department.department_id,0) as deptId,department.corpwx_deptid as wxDeptId,COUNT(1) as num
                 FROM report AS a
                 left join user on user.id = a.creator_id
                 JOIN project AS b ON a.project_id=b.id
@@ -959,7 +959,7 @@
                 ORDER BY a.create_date desc, a.creator_id asc
             </when>
             <otherwise>
-                SELECT 	u.name as userName,u.corpwx_userid as corpwxUserId,dp.department_id as deptId,dp.corpwx_deptid as wxDeptId,COUNT(1) as num
+                SELECT 	u.name as userName,u.corpwx_userid as corpwxUserId,IFNULL(dp.department_id,0) as deptId,dp.corpwx_deptid as wxDeptId,COUNT(1) as num
                 FROM report AS a
                 left join user on user.id = a.creator_id
                 JOIN project AS b ON a.project_id=b.id