| | |
| | | import me.zhengjie.weixin.cp.bean.smartsheet.record.*; |
| | | import me.zhengjie.weixin.cp.bean.smartsheet.sheet.*; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.SerializationUtils; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.aggregation.Aggregation; |
| | |
| | | |
| | | // 开始查询 |
| | | List<TaskDaliyMongo> daliyMongoList = mongoTemplate.find(query, TaskDaliyMongo.class); |
| | | List<TaskDaliyMongoDto> daliyMongoDtoList = daliyMongoList.stream().collect( |
| | | // TODO:本段代码Collectors.reducing修改了源数据,需要处理前用map深拷贝对象再操作 |
| | | List<TaskDaliyMongoDto> daliyMongoDtoList = daliyMongoList.stream().map(i -> SerializationUtils.clone(i)).collect( |
| | | Collectors.groupingBy( |
| | | (TaskDaliyMongo taskDaliyMongo) -> { |
| | | Project project; |
| | |
| | | return new BigDecimal(leave.getLeaveDuration()); |
| | | } |
| | | }).reduce(BigDecimal.ZERO, (res, cur) -> res.add(cur)); |
| | | // 统计加班信息 |
| | | // 统计换休信息 |
| | | AttendanceOvertimeQueryCriteria overtimeQueryCriteria = new AttendanceOvertimeQueryCriteria(); |
| | | overtimeQueryCriteria.setUserId(userId); |
| | | overtimeQueryCriteria.setApprovalStatus(Constant.OVERTIME_PASS); |
| | |
| | | overtimeQueryCriteria.setOvertimeEndTimeLessThan(overtimeQueryEndTime); |
| | | List<AttendanceOvertime> overtimeList = attendanceOvertimeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,overtimeQueryCriteria,criteriaBuilder)); |
| | | BigDecimal overtimeCountHour = overtimeList.stream().map(overtime -> new BigDecimal(overtime.getOvertimeDuration())).reduce(BigDecimal.ZERO, (res, cur) -> res.add(cur)); |
| | | // 统计加班信息 |
| | | BigDecimal workOvertimeCountHour = daliyMongoList.stream().collect(Collectors.groupingBy(TaskDaliyMongo::getFillDate, Collectors.summingDouble(TaskDaliyMongo::getConsumedHours))) |
| | | .values().stream().map(i -> new BigDecimal(i).subtract(new BigDecimal(8)).max(BigDecimal.ZERO)).reduce(BigDecimal.ZERO, (res, cur) -> res.add(cur)); |
| | | |
| | | // 项目周报 |
| | | SheetProperties weeklyReportProjectSheet = sheetInfo.getSheetList().stream().reduce(null, (res, cur) -> cur.getTitle().equals(reportParamMap.get(Constant.WEEKLY_REPORT_PROJECT_SHEET_NAME)) ? cur : res); |
| | |
| | | } |
| | | |
| | | // 假勤周报 |
| | | if (!(leaveCountHour.compareTo(BigDecimal.ZERO) == 0) || !(overtimeCountHour.compareTo(BigDecimal.ZERO) == 0)) { |
| | | if (!(leaveCountHour.compareTo(BigDecimal.ZERO) == 0) || !(overtimeCountHour.compareTo(BigDecimal.ZERO) == 0) || !(workOvertimeCountHour.compareTo(BigDecimal.ZERO) == 0)) { |
| | | SheetProperties weeklyReportAttendanceSheet = sheetInfo.getSheetList().stream().reduce(null, (res, cur) -> cur.getTitle().equals(reportParamMap.get(Constant.WEEKLY_REPORT_ATTENDANCE_SHEET_NAME)) ? cur : res); |
| | | if (ObjectUtils.isNotEmpty(weeklyReportAttendanceSheet)) { |
| | | // 获取旧记录 |
| | |
| | | userName.setText(user.getNickName()); |
| | | values.put("人员名称", new Record.TypedValue(Record.DataType.FIELD_TYPE_TEXT, Arrays.asList(userName)).getValue()); |
| | | // 加班 |
| | | values.put("加班(H)", new Record.TypedValue(Record.DataType.FIELD_TYPE_NUMBER, overtimeCountHour.doubleValue()).getValue()); |
| | | values.put("加班(H)", new Record.TypedValue(Record.DataType.FIELD_TYPE_NUMBER, workOvertimeCountHour.doubleValue()).getValue()); |
| | | // 换休 |
| | | values.put("换休(H)", new Record.TypedValue(Record.DataType.FIELD_TYPE_NUMBER, overtimeCountHour.doubleValue()).getValue()); |
| | | // 请假 |
| | | values.put("请假(H)", new Record.TypedValue(Record.DataType.FIELD_TYPE_NUMBER, leaveCountHour.doubleValue()).getValue()); |
| | | // 提交日期 |