瀏覽代碼

有效工时率编写,待威派格提供人员名单,添加优化查询语句

yusm 1 年之前
父節點
當前提交
fdb6059b8e

+ 26 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -11270,17 +11270,22 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
 
         int dayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, 0);//应报工时天数
         int dayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, 0);//应报工时天数
 
 
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", 936));
+
         for (Department department : departments) {
         for (Department department : departments) {
             LaborHourRateVo laborHourRateVo = new LaborHourRateVo();
             LaborHourRateVo laborHourRateVo = new LaborHourRateVo();
             laborHourRateVo.setRoot_id(department.getDepartmentId());
             laborHourRateVo.setRoot_id(department.getDepartmentId());
             laborHourRateVo.setDepartment_name(department.getDepartmentName());
             laborHourRateVo.setDepartment_name(department.getDepartmentName());
 
 
             ArrayList<Integer> deptIds = new ArrayList<>();
             ArrayList<Integer> deptIds = new ArrayList<>();
-            setDeptIdList(department.getDepartmentId(),deptIds);
+
+//            setDeptIdList(department.getDepartmentId(),deptIds);
+            setSubDepts(department,departmentList,deptIds);
             deptIds.add(department.getDepartmentId());
             deptIds.add(department.getDepartmentId());
             laborHourRateVo.setChild_ids(deptIds);
             laborHourRateVo.setChild_ids(deptIds);
             //查询该公司下某头部部门及子部门在四种项目下的工时之和,某个时间段内
             //查询该公司下某头部部门及子部门在四种项目下的工时之和,某个时间段内
             List<Report> reportList= reportMapper.getSumWorkingTime(deptIds,startDate,endDate);
             List<Report> reportList= reportMapper.getSumWorkingTime(deptIds,startDate,endDate);
+
             ArrayList<Report> reports = new ArrayList<>();//按时填报的report
             ArrayList<Report> reports = new ArrayList<>();//按时填报的report
             for (Report report : reportList) {
             for (Report report : reportList) {
                 LocalDate createDate = report.getCreateDate();
                 LocalDate createDate = report.getCreateDate();
@@ -11322,8 +11327,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             laborHourRateVo.setDate_count(dayCount);
             laborHourRateVo.setDate_count(dayCount);
             laborHourRateVo.setCount(isActiveCount);
             laborHourRateVo.setCount(isActiveCount);
             laborHourRateVo.setTotal_time((long) (8*inActiveDays+isActiveCount*8*dayCount));//应报工时还少了在职的加上可能辞职的
             laborHourRateVo.setTotal_time((long) (8*inActiveDays+isActiveCount*8*dayCount));//应报工时还少了在职的加上可能辞职的
-            System.out.println("============="+inActiveDays);
-            System.out.println("============="+isActiveCount);
+//            System.out.println("============="+inActiveDays);
+//            System.out.println("============="+isActiveCount);
             laborHourRateVo.setDay_time(8);
             laborHourRateVo.setDay_time(8);
 
 
             BigDecimal bd = new BigDecimal(timeSum/(8*inActiveDays+isActiveCount*8*dayCount)*100);
             BigDecimal bd = new BigDecimal(timeSum/(8*inActiveDays+isActiveCount*8*dayCount)*100);
@@ -11355,16 +11360,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
     }
 
 
 
 
-    public void setDeptIdList(Integer departmentId,List<Integer> deptIds){
-        LambdaQueryWrapper<Department> lqw = new LambdaQueryWrapper<>();
-        lqw.eq(Department::getSuperiorId,departmentId);
-        List<Department> departmentList = departmentMapper.selectList(lqw);
+//    public void setDeptIdList(Integer departmentId,List<Integer> deptIds){
+//        LambdaQueryWrapper<Department> lqw = new LambdaQueryWrapper<>();
+//        lqw.eq(Department::getSuperiorId,departmentId);
+//        List<Department> departmentList = departmentMapper.selectList(lqw);
+//
+//        if (departmentList!=null&&departmentList.size()>0){
+//            List<Integer> collect = departmentList.stream().map(Department::getDepartmentId).collect(Collectors.toList());
+//            deptIds.addAll(collect);
+//            for (Integer id : collect) {
+//                setDeptIdList(id,deptIds);
+//            }
+//        }
+//    }
 
 
-        if (departmentList!=null&&departmentList.size()>0){
+    public void setSubDepts(Department dp, List<Department> list,List<Integer> deptIds) {
+        List<Department> departmentList = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());;
+        if (departmentList.size() > 0) {
             List<Integer> collect = departmentList.stream().map(Department::getDepartmentId).collect(Collectors.toList());
             List<Integer> collect = departmentList.stream().map(Department::getDepartmentId).collect(Collectors.toList());
             deptIds.addAll(collect);
             deptIds.addAll(collect);
-            for (Integer id : collect) {
-                setDeptIdList(id,deptIds);
+            for (Department department : departmentList) {
+                setSubDepts(department,list,deptIds);
             }
             }
         }
         }
     }
     }

+ 4 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -969,14 +969,15 @@
     </select>
     </select>
 
 
     <select id="getSumWorkingTime" resultType="com.management.platform.entity.Report">
     <select id="getSumWorkingTime" resultType="com.management.platform.entity.Report">
-        SELECT * FROM report r
+        SELECT r.create_time,r.create_date,r.working_time FROM report r
         LEFT JOIN project p
         LEFT JOIN project p
         ON r.project_id=p.id
         ON r.project_id=p.id
-        WHERE p.company_id=936 AND p.category IN(168,169,171,172)
-        AND r.dept_id IN
+        WHERE
+        r.dept_id IN
         <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
         <foreach collection="deptIds" item="id" open="(" close=")" separator=",">
             #{id}
             #{id}
         </foreach>
         </foreach>
+        AND p.company_id=936 AND p.category IN(168,169,171,172)
         AND r.create_date BETWEEN #{startDate} AND #{endDate}
         AND r.create_date BETWEEN #{startDate} AND #{endDate}
     </select>
     </select>
 </mapper>
 </mapper>