|
@@ -11270,16 +11270,22 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
int dayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, 0);//应报工时天数
|
|
|
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", 936));
|
|
|
+
|
|
|
for (Department department : departments) {
|
|
|
LaborHourRateVo laborHourRateVo = new LaborHourRateVo();
|
|
|
laborHourRateVo.setRoot_id(department.getDepartmentId());
|
|
|
laborHourRateVo.setDepartment_name(department.getDepartmentName());
|
|
|
+
|
|
|
ArrayList<Integer> deptIds = new ArrayList<>();
|
|
|
- setDeptIdList(department.getDepartmentId(),deptIds);
|
|
|
+
|
|
|
+// setDeptIdList(department.getDepartmentId(),deptIds);
|
|
|
+ setSubDepts(department,departmentList,deptIds);
|
|
|
deptIds.add(department.getDepartmentId());
|
|
|
laborHourRateVo.setChild_ids(deptIds);
|
|
|
//查询该公司下某头部部门及子部门在四种项目下的工时之和,某个时间段内
|
|
|
List<Report> reportList= reportMapper.getSumWorkingTime(deptIds,startDate,endDate);
|
|
|
+
|
|
|
ArrayList<Report> reports = new ArrayList<>();//按时填报的report
|
|
|
for (Report report : reportList) {
|
|
|
LocalDate createDate = report.getCreateDate();
|
|
@@ -11303,34 +11309,78 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String inactiveDate = user.getInactiveDate().format(formatter);
|
|
|
inActiveDays+=WorkDayCalculateUtils.getWorkDaysCountInRange(startDate,inactiveDate,0);
|
|
|
}
|
|
|
+
|
|
|
//-- 查询 有多少个 入职时间早于起始时间 并且是在职的员工
|
|
|
int isActiveCount=userMapper.getIsActiveCount(deptIds,startDate,endDate);
|
|
|
|
|
|
+ //-- 查询 有多少个 入职时间晚于起始时间 并且在这段时间离职的员工
|
|
|
+ List<User> inActiveBewttenStartAndEndList=userMapper.getInActiveBewttenStartAndEndList(deptIds,startDate,endDate);
|
|
|
+ //获取入职时间晚于起始时间 并且在这段时间离职的员工在此期间工作多少天
|
|
|
+ for (User user : inActiveBewttenStartAndEndList) {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ String inactiveDate = user.getInactiveDate().format(formatter);
|
|
|
+ String inductionDate = user.getInductionDate().format(formatter);
|
|
|
+ inActiveDays+=WorkDayCalculateUtils.getWorkDaysCountInRange(inductionDate,inactiveDate,0);
|
|
|
+ }
|
|
|
+
|
|
|
laborHourRateVo.setWorking_time(timeSum);
|
|
|
laborHourRateVo.setDate_count(dayCount);
|
|
|
laborHourRateVo.setCount(isActiveCount);
|
|
|
- laborHourRateVo.setTotal_time((long) (inActiveList.size()*8*inActiveDays+isActiveCount*8*dayCount));//应报工时还少了在职的加上可能辞职的
|
|
|
- System.out.println("============="+inActiveDays);
|
|
|
- System.out.println("============="+isActiveCount);
|
|
|
+ laborHourRateVo.setTotal_time((long) (8*inActiveDays+isActiveCount*8*dayCount));//应报工时还少了在职的加上可能辞职的
|
|
|
+// System.out.println("============="+inActiveDays);
|
|
|
+// System.out.println("============="+isActiveCount);
|
|
|
laborHourRateVo.setDay_time(8);
|
|
|
+
|
|
|
+ BigDecimal bd = new BigDecimal(timeSum/(8*inActiveDays+isActiveCount*8*dayCount)*100);
|
|
|
+ bd = bd.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ laborHourRateVo.setRate(bd.doubleValue());
|
|
|
laborHourRateVos.add(laborHourRateVo);
|
|
|
}
|
|
|
+
|
|
|
+ double totalWorkTime = laborHourRateVos.stream().mapToDouble(LaborHourRateVo::getWorking_time).sum();
|
|
|
+ int totalPeopleCount = laborHourRateVos.stream().mapToInt(LaborHourRateVo::getCount).sum();
|
|
|
+ long sumTotalTime = laborHourRateVos.stream().mapToLong(LaborHourRateVo::getTotal_time).sum();
|
|
|
+ LaborHourRateVo laborHourRateVo = new LaborHourRateVo();
|
|
|
+ laborHourRateVo.setDepartment_name("合计");
|
|
|
+ laborHourRateVo.setWorking_time(totalWorkTime);
|
|
|
+ laborHourRateVo.setCount(totalPeopleCount);
|
|
|
+ laborHourRateVo.setTotal_time(sumTotalTime);
|
|
|
+ laborHourRateVo.setDay_time(8);
|
|
|
+ laborHourRateVo.setDate_count(dayCount);
|
|
|
+
|
|
|
+ BigDecimal bd = new BigDecimal(totalWorkTime/sumTotalTime*100);
|
|
|
+ bd = bd.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ laborHourRateVo.setRate(bd.doubleValue());
|
|
|
+
|
|
|
+ laborHourRateVos.add(laborHourRateVo);
|
|
|
+
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
msg.setData(laborHourRateVos);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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());
|
|
|
deptIds.addAll(collect);
|
|
|
- for (Integer id : collect) {
|
|
|
- setDeptIdList(id,deptIds);
|
|
|
+ for (Department department : departmentList) {
|
|
|
+ setSubDepts(department,list,deptIds);
|
|
|
}
|
|
|
}
|
|
|
}
|