|
@@ -822,13 +822,13 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
// monthClock = monthClock.stream().filter(e -> e.getAid() == 48).collect(Collectors.toList());
|
|
// monthClock = monthClock.stream().filter(e -> e.getAid() == 48).collect(Collectors.toList());
|
|
|
LocalDate lastDay = startDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
LocalDate lastDay = startDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
List<Map<String,Object>> listData = new ArrayList<>();
|
|
List<Map<String,Object>> listData = new ArrayList<>();
|
|
|
-
|
|
|
|
|
|
|
+ List<Map<String, Object>> daysMap = getDaysMap(lastDay, startDate);
|
|
|
//将数据与表头匹配
|
|
//将数据与表头匹配
|
|
|
for (ProjectStaffRecord e : monthClock) {
|
|
for (ProjectStaffRecord e : monthClock) {
|
|
|
//先匹配是否存在这个人,不存证则需要新增
|
|
//先匹配是否存在这个人,不存证则需要新增
|
|
|
LocalDate recordTime = e.getRecordTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
LocalDate recordTime = e.getRecordTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
if (listData.isEmpty()){
|
|
if (listData.isEmpty()){
|
|
|
- pushDate(e, getDaysMap(lastDay, startDate), recordTime, listData);
|
|
|
|
|
|
|
+ pushDate(e, daysMap, recordTime, listData);
|
|
|
}else {
|
|
}else {
|
|
|
boolean flag = false;
|
|
boolean flag = false;
|
|
|
for (Map<String, Object> m : listData) {
|
|
for (Map<String, Object> m : listData) {
|
|
@@ -855,7 +855,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!flag){
|
|
if (!flag){
|
|
|
- pushDate(e, getDaysMap(lastDay, startDate), recordTime, listData);
|
|
|
|
|
|
|
+ pushDate(e, daysMap, recordTime, listData);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -950,6 +950,13 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param e 打卡数据
|
|
|
|
|
+ * @param list 表头
|
|
|
|
|
+ * @param recordTime 打卡书剑
|
|
|
|
|
+ * @param listData
|
|
|
|
|
+ */
|
|
|
private void pushDate(ProjectStaffRecord e, List<Map<String, Object>> list, LocalDate recordTime, List<Map<String, Object>> listData) {
|
|
private void pushDate(ProjectStaffRecord e, List<Map<String, Object>> list, LocalDate recordTime, List<Map<String, Object>> listData) {
|
|
|
Map<String,Object> map = new LinkedHashMap<>();
|
|
Map<String,Object> map = new LinkedHashMap<>();
|
|
|
map.put("name", e.getName());
|
|
map.put("name", e.getName());
|
|
@@ -1020,6 +1027,104 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
|
|
|
return failureMsg.toString();
|
|
return failureMsg.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Object getNewMonthClock(Integer id, String yearMonth,String duration) {
|
|
|
|
|
+ OutMontClockBo out = new OutMontClockBo();
|
|
|
|
|
+ ProjectTask projectTask = getProjectTask(id);
|
|
|
|
|
+ SysDept sysDept = deptService.selectDeptByPid(projectTask.getId());
|
|
|
|
|
+ out.setProjectName(projectTask.getName());
|
|
|
|
|
+ out.setDepartmentName(sysDept.getDeptName());
|
|
|
|
|
+ if (sysDept.getCompanyName()!=null){
|
|
|
|
|
+ out.setCompanyName(sysDept.getCompanyName());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ out.setCompanyName(sysDept.getDeptName());
|
|
|
|
|
+ }
|
|
|
|
|
+ String dateYMD=yearMonth+"-01";
|
|
|
|
|
+ LocalDate startDate = LocalDate.parse(dateYMD, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
+ startDate=startDate.withDayOfMonth(1);
|
|
|
|
|
+ int year=startDate.getYear();
|
|
|
|
|
+ int month=startDate.getMonthValue();
|
|
|
|
|
+ out.setTableName(year+"年"+month+"月工时记录表");
|
|
|
|
|
+ int lastMonth = month;
|
|
|
|
|
+ if(startDate.getMonthValue()== Month.DECEMBER.getValue()){
|
|
|
|
|
+ lastMonth=1;
|
|
|
|
|
+ year=startDate.getYear()+1;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ lastMonth=startDate.getMonthValue()+1;
|
|
|
|
|
+ }
|
|
|
|
|
+ LocalDate endDate = LocalDate.of(year,lastMonth,1);
|
|
|
|
|
+ List<ProjectStaffRecord> monthClock = projectStaffRecordMapper.getMonthClock(id, startDate, endDate);
|
|
|
|
|
+// monthClock = monthClock.stream().filter(e -> e.getAid() == 48).collect(Collectors.toList());
|
|
|
|
|
+ LocalDate lastDay = startDate.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
|
|
+ List<Map<String,Object>> listData = new ArrayList<>();
|
|
|
|
|
+ List<Map<String, Object>> daysMap = getDaysMap(lastDay, startDate);
|
|
|
|
|
+ //将数据与表头匹配
|
|
|
|
|
+ for (ProjectStaffRecord e : monthClock) {
|
|
|
|
|
+ //先匹配是否存在这个人,不存证则需要新增
|
|
|
|
|
+ LocalDate recordTime = e.getRecordTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
|
|
+ if (listData.isEmpty()){
|
|
|
|
|
+ pushDate(e, daysMap, recordTime, listData,duration);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ boolean flag = false;
|
|
|
|
|
+ for (Map<String, Object> m : listData) {
|
|
|
|
|
+ String name = (String) m.get("name");
|
|
|
|
|
+ if (name.equals(e.getName())){
|
|
|
|
|
+ flag=true;
|
|
|
|
|
+ //存在则需要匹配存入
|
|
|
|
|
+ List<Map<String, Object>> maps = (List<Map<String, Object>>) m.get("data");
|
|
|
|
|
+ for (Map<String, Object> map2 : maps) {
|
|
|
|
|
+ Integer date = (Integer) map2.get("date");
|
|
|
|
|
+ Integer dayOfMonth = recordTime.getDayOfMonth();
|
|
|
|
|
+
|
|
|
|
|
+ //比对日期,如果日期有参数相加,没有则赋值
|
|
|
|
|
+ if (dayOfMonth.equals(date)) {
|
|
|
|
|
+ BigDecimal projectDuration = (BigDecimal) map2.get("projectDuration");
|
|
|
|
|
+ BigDecimal added = projectDuration.add(BigDecimal.valueOf(e.getDuration()));
|
|
|
|
|
+ BigDecimal checkDuration = new BigDecimal(duration);
|
|
|
|
|
+ map2.put("projectDuration", added);
|
|
|
|
|
+ map2.put("checkDuration", checkDuration);
|
|
|
|
|
+ BigDecimal subtract = checkDuration.subtract(added);
|
|
|
|
|
+ if (subtract.compareTo(BigDecimal.ZERO)==-1)subtract=BigDecimal.ZERO;
|
|
|
|
|
+ map2.put("notDuration", subtract);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!flag){
|
|
|
|
|
+ pushDate(e, daysMap, recordTime, listData,duration);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //将数据统计,计算出所有工时与分摊率
|
|
|
|
|
+ pushDurationAndProportion(listData);
|
|
|
|
|
+ out.setList(listData);
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void pushDate(ProjectStaffRecord e, List<Map<String, Object>> daysMap, LocalDate recordTime, List<Map<String, Object>> listData, String duration) {
|
|
|
|
|
+ {
|
|
|
|
|
+ Map<String,Object> map = new LinkedHashMap<>();
|
|
|
|
|
+ map.put("name", e.getName());
|
|
|
|
|
+ //找出匹配的日期并设置时间
|
|
|
|
|
+ for (Map<String, Object> map2 : daysMap) {
|
|
|
|
|
+ Integer date = (Integer) map2.get("date");
|
|
|
|
|
+ if (recordTime.getDayOfMonth()==date) {
|
|
|
|
|
+ BigDecimal projectDuration = BigDecimal.valueOf(e.getDuration());
|
|
|
|
|
+ BigDecimal checkDuration = new BigDecimal(duration);
|
|
|
|
|
+ map2.put("projectDuration", projectDuration);
|
|
|
|
|
+ map2.put("checkDuration", checkDuration);
|
|
|
|
|
+ BigDecimal subtract = checkDuration.subtract(projectDuration);
|
|
|
|
|
+ if (subtract.compareTo(BigDecimal.ZERO)==-1)subtract=BigDecimal.ZERO;
|
|
|
|
|
+ map2.put("notDuration", subtract);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("data", new ArrayList<>(daysMap));
|
|
|
|
|
+ listData.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public List<UserClockDataBo> clockDataToList(List<Map<Integer,String >> list) {
|
|
public List<UserClockDataBo> clockDataToList(List<Map<Integer,String >> list) {
|
|
|
List<UserClockDataBo> listData = new ArrayList<>();
|
|
List<UserClockDataBo> listData = new ArrayList<>();
|