소스 검색

部门项目参与表bug修复

cs 2 년 전
부모
커밋
ac59d0a581

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

@@ -7258,17 +7258,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         }
     }
 
-    private List<Department> getSubDepts(Department dp, List<Department> list) {
-        List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
-        List<Department> allList = new ArrayList<>();
-        allList.addAll(collect);
-        if (collect.size() > 0) {
-            collect.forEach(c->{
-                allList.addAll(getSubDepts(c, list));
-            });
-        }
-        return allList;
-    }
     private  List<LocalDateTime> getDays(LocalDateTime start, LocalDateTime end) {
         List<LocalDateTime> result = new ArrayList();
         while (start.isBefore(end)) {
@@ -7502,6 +7491,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         return msg;
     }
 
+    //递归获取所有子部门
+    private List<Department> getSubDepts(Department dp, List<Department> list) {
+        List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;
+        List<Department> allList = new ArrayList<>();
+        allList.addAll(collect);
+        if (collect.size() > 0) {
+            collect.forEach(c->{
+                allList.addAll(getSubDepts(c,list));
+            });
+        }
+        return allList;
+    }
+
     //部门参与项目情况表
     @Override
     public HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String startDate,String endDate, Integer departmentId, HttpServletRequest request){
@@ -7559,15 +7561,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 }else {
                     stringObjectMap.put("deptName",getSupDepartment(department));
                 }
-                if (stringObjectMap.get("projectCount")==null){
-                    stringObjectMap.put("projectCount",0);
-                }
-                if (stringObjectMap.get("tripCount")==null){
-                    stringObjectMap.put("tripCount",0);
-                }
-                if (stringObjectMap.get("peopleCount")==null){
-                    stringObjectMap.put("peopleCount",0);
-                }
+                stringObjectMap.put("projectCount",stringObjectMap.get("projectCount")==null?0:stringObjectMap.get("projectCount"));
+                stringObjectMap.put("tripCount",stringObjectMap.get("tripCount")==null?0:stringObjectMap.get("tripCount"));
+                stringObjectMap.put("peopleCount",stringObjectMap.get("peopleCount")==null?0:stringObjectMap.get("peopleCount"));
             }
         }
         HashMap<String, Object> result = new HashMap<>();

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -97,6 +97,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
 
     @Resource
     LeaveSheetMapper leaveSheetMapper;
+    @Resource
+    TimeTypeMapper timeTypeMapper;
 
 
     //获取服务商provider_access_token
@@ -1396,7 +1398,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                             }else{
                                 leaveSheet.setTimeType(0);
                                 leaveSheet.setTimeHours(time/3600);
-                                leaveSheet.setTimeDays(time/3600/24);
+                                TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", wxCorpInfo.getCompanyId()));
+                                leaveSheet.setTimeDays(time/3600/allDay.getAllday());
                             }
                             result.add(leaveSheet);
                         }

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

@@ -1283,18 +1283,18 @@
         department.department_name AS deptName,
         u.projectCount,
         u.peopleCount,
-        u.tripCount
+        t.trip AS tripCount
         from department
         left JOIN (
         SELECT `user`.department_id AS departmentId,
         project.create_date,
         COUNT(DISTINCT(project.id)) AS projectCount,
-        COUNT(`user`.id) AS peopleCount,
-        (select COUNT(DISTINCT(business_trip.id)) from business_trip where owner_id = user.id) AS tripCount
+        COUNT(`user`.id) AS peopleCount
         from  `user`
         LEFT JOIN participation ON `user`.id = participation.user_id
         LEFT JOIN project ON project.id = participation.project_id
         WHERE user.company_id = #{companyId}
+        and project.id is not null
         <if test="branchDepartment!=null and branchDepartment.size()>0">
             and user.department_id in
             <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
@@ -1315,6 +1315,23 @@
         </if>
         GROUP BY `user`.department_id
         ) u ON department.department_id = u.departmentId
+        left join (
+            SELECT u.deptId AS deptId,SUM(tripCount) AS trip
+            FROM (
+            SELECT `user`.department_id AS deptId,SUM(day_count) AS tripCount from business_trip
+            LEFT JOIN `user` ON business_trip.owner_id = `user`.id
+            where STATUS  = 0
+            AND user.company_id = #{companyId}
+            <if test="endDate!= null and endDate!= ''" >
+                and business_trip.start_date &lt;=#{endDate}
+            </if>
+            <if test="startDate!= null and startDate!= ''">
+                and business_trip.end_date &gt;= #{startDate}
+            </if>
+            GROUP BY `user`.id
+            ) u
+            GROUP BY u.deptId
+        ) t on t.deptId = department.department_id
         WHERE department.company_id = #{companyId}
         <if test="branchDepartment!=null and branchDepartment.size()>0">
             and department.department_id in