|
@@ -489,7 +489,9 @@ public class WorkGroupServiceImpl implements WorkGroupService {
|
|
|
Map<LocalDate, List<ChuanyunReimbursementDO>> reimbursementMap = new HashMap<>();
|
|
|
Map<LocalDate, List<ChuanyunSelfWorkHourDO>> workHoursMap = new HashMap<>();
|
|
|
Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> laborCostMap = new HashMap<>();
|
|
|
- List<ChuanyunReimbursementDO> reimbursements = reimbursementDao.findAllByGroupProjectIdAndStatusIn(chuanyunGroupProjectDO.getObjectId(), List.of(1, 2));
|
|
|
+ // 通过项目id只查询2022年8月份之后的
|
|
|
+ LocalDate date = LocalDate.of(2022, 8, 1);
|
|
|
+ List<ChuanyunReimbursementDO> reimbursements = reimbursementDao.findAllByGroupProjectIdAndStatusInAndBusinessDateGreaterThanEqual(chuanyunGroupProjectDO.getObjectId(), List.of(1, 2), date.atStartOfDay());
|
|
|
// 查询用户在该项目的报销单
|
|
|
// 报销单按日期分组
|
|
|
Map<LocalDate, List<ChuanyunReimbursementDO>> map1 = reimbursements.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> {
|
|
@@ -512,7 +514,7 @@ public class WorkGroupServiceImpl implements WorkGroupService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- List<ChuanyunSelfWorkHourDO> workHours = selfWorkHourDao.findAllByProjectIdAndStatusIn(groupProjectObjectId, List.of("1", "2"));
|
|
|
+ List<ChuanyunSelfWorkHourDO> workHours = selfWorkHourDao.findAllByProjectIdAndStatusInAndDayLogDateGreaterThanEqual(groupProjectObjectId, List.of("1", "2"), date.atStartOfDay());
|
|
|
Map<LocalDate, List<ChuanyunSelfWorkHourDO>> map2 = workHours.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> {
|
|
|
if (!Objects.isNull(chuanyunSelfWorkHourDO.getDayLogDate())) {
|
|
|
return LocalDate.of(chuanyunSelfWorkHourDO.getDayLogDate().getYear(), chuanyunSelfWorkHourDO.getDayLogDate().getMonthValue(), 1);
|
|
@@ -532,7 +534,7 @@ public class WorkGroupServiceImpl implements WorkGroupService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- List<ChuanyunMonthLaborCostWgDTO> laborCostWgs = chuanyunMonthLaborCostWgDao.findAllByProjectCode(groupProjectCode);
|
|
|
+ List<ChuanyunMonthLaborCostWgDTO> laborCostWgs = chuanyunMonthLaborCostWgDao.findAllByProjectCodeAndProjectIdAndLogDateGreaterThanEqual(groupProjectCode, groupProjectObjectId, date.atStartOfDay());
|
|
|
Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> map3 = laborCostWgs.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
|
|
|
if (!Objects.isNull(chuanyunMonthLaborCostWgDTO.getLogDate())) {
|
|
|
return LocalDate.of(chuanyunMonthLaborCostWgDTO.getLogDate().getYear(), chuanyunMonthLaborCostWgDTO.getLogDate().getMonthValue(), 1);
|
|
@@ -564,82 +566,162 @@ public class WorkGroupServiceImpl implements WorkGroupService {
|
|
|
List<ChuanyunReimbursementDO> reimbursementList = reimbursementMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
List<ChuanyunSelfWorkHourDO> selfWorkHourList = workHoursMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
List<ChuanyunMonthLaborCostWgDTO> laborCostWgList = laborCostMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
- if (!localDate.isBefore(LocalDate.of(2022, 8, 1))) {
|
|
|
- Map<String, List<ChuanyunReimbursementDO>> workGroupIdReimbursementMap = reimbursementList.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> {
|
|
|
- if (Objects.isNull(chuanyunReimbursementDO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunReimbursementDO.getWorkGroupId())) {
|
|
|
- return ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
- } else {
|
|
|
- return chuanyunReimbursementDO.getWorkGroupId();
|
|
|
- }
|
|
|
- }));
|
|
|
- Map<String, List<ChuanyunSelfWorkHourDO>> workGroupIdSelfWorkHourMap = selfWorkHourList.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> {
|
|
|
- if (Objects.isNull(chuanyunSelfWorkHourDO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunSelfWorkHourDO.getWorkGroupId())) {
|
|
|
- return ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
- } else {
|
|
|
- return chuanyunSelfWorkHourDO.getWorkGroupId();
|
|
|
- }
|
|
|
- }));
|
|
|
- Map<String, List<ChuanyunMonthLaborCostWgDTO>> workGroupIdLaborCostMap = laborCostWgList.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
|
|
|
- if (Objects.isNull(chuanyunMonthLaborCostWgDTO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunMonthLaborCostWgDTO.getWorkGroupId())) {
|
|
|
- return ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
- } else {
|
|
|
- return chuanyunMonthLaborCostWgDTO.getWorkGroupId();
|
|
|
- }
|
|
|
- }));
|
|
|
|
|
|
- Set<String> workGroup1 = workGroupIdReimbursementMap.keySet();
|
|
|
- Set<String> workGroup2 = workGroupIdSelfWorkHourMap.keySet();
|
|
|
- Set<String> workGroup3 = workGroupIdLaborCostMap.keySet();
|
|
|
+ Map<String, List<ChuanyunReimbursementDO>> workGroupIdReimbursementMap = reimbursementList.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> {
|
|
|
+ if (Objects.isNull(chuanyunReimbursementDO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunReimbursementDO.getWorkGroupId())) {
|
|
|
+ return ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
+ } else {
|
|
|
+ return chuanyunReimbursementDO.getWorkGroupId();
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ Map<String, List<ChuanyunSelfWorkHourDO>> workGroupIdSelfWorkHourMap = selfWorkHourList.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> {
|
|
|
+ if (Objects.isNull(chuanyunSelfWorkHourDO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunSelfWorkHourDO.getWorkGroupId())) {
|
|
|
+ return ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
+ } else {
|
|
|
+ return chuanyunSelfWorkHourDO.getWorkGroupId();
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ Map<String, List<ChuanyunMonthLaborCostWgDTO>> workGroupIdLaborCostMap = laborCostWgList.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
|
|
|
+ if (Objects.isNull(chuanyunMonthLaborCostWgDTO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunMonthLaborCostWgDTO.getWorkGroupId())) {
|
|
|
+ return ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
+ } else {
|
|
|
+ return chuanyunMonthLaborCostWgDTO.getWorkGroupId();
|
|
|
+ }
|
|
|
+ }));
|
|
|
|
|
|
+ Set<String> workGroup1 = workGroupIdReimbursementMap.keySet();
|
|
|
+ Set<String> workGroup2 = workGroupIdSelfWorkHourMap.keySet();
|
|
|
+ Set<String> workGroup3 = workGroupIdLaborCostMap.keySet();
|
|
|
|
|
|
- Set<String> workGroupMergeCollections = CollectionsUtils.mergeStringCollections(workGroup1, workGroup2, workGroup3);
|
|
|
- // 避免默认工作与实际工作组数据重复,可能会存在历史数据没有工作组,后面标准化的时候又补充了工作组信息。
|
|
|
- workGroupMergeCollections.add(ChuanYunConstant.DEFAULT_WORK_GROUP);
|
|
|
|
|
|
- workGroupMergeCollections.forEach(workGroupId -> {
|
|
|
- List<ChuanyunReimbursementDO> reimbursementDOList = workGroupIdReimbursementMap.getOrDefault(workGroupId, Collections.emptyList());
|
|
|
- List<ChuanyunSelfWorkHourDO> selfWorkHourDOS = workGroupIdSelfWorkHourMap.getOrDefault(workGroupId, Collections.emptyList());
|
|
|
- List<ChuanyunMonthLaborCostWgDTO> monthLaborCostWgDTOS = workGroupIdLaborCostMap.getOrDefault(workGroupId, Collections.emptyList());
|
|
|
+ Set<String> workGroupMergeCollections = CollectionsUtils.mergeStringCollections(workGroup1, workGroup2, workGroup3);
|
|
|
+ // 避免默认工作与实际工作组数据重复,可能会存在历史数据没有工作组,后面标准化的时候又补充了工作组信息。
|
|
|
+ workGroupMergeCollections.add(ChuanYunConstant.DEFAULT_WORK_GROUP);
|
|
|
|
|
|
- BigDecimal totalReimbursement;
|
|
|
- BigDecimal totalManDay;
|
|
|
- BigDecimal totalLaborCost;
|
|
|
+ workGroupMergeCollections.forEach(workGroupId -> {
|
|
|
+ List<ChuanyunReimbursementDO> reimbursementDOList = workGroupIdReimbursementMap.getOrDefault(workGroupId, Collections.emptyList());
|
|
|
+ List<ChuanyunSelfWorkHourDO> selfWorkHourDOS = workGroupIdSelfWorkHourMap.getOrDefault(workGroupId, Collections.emptyList());
|
|
|
+ List<ChuanyunMonthLaborCostWgDTO> monthLaborCostWgDTOS = workGroupIdLaborCostMap.getOrDefault(workGroupId, Collections.emptyList());
|
|
|
|
|
|
- if (reimbursementDOList.isEmpty()) {
|
|
|
- totalReimbursement = new BigDecimal("0.00");
|
|
|
- } else {
|
|
|
- totalReimbursement = reimbursementDOList.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- }
|
|
|
+ BigDecimal totalReimbursement;
|
|
|
+ BigDecimal totalManDay;
|
|
|
+ BigDecimal totalLaborCost;
|
|
|
|
|
|
- if (selfWorkHourDOS.isEmpty()) {
|
|
|
- totalManDay = new BigDecimal("0.00");
|
|
|
- } else {
|
|
|
- BigDecimal totalWorkHours = selfWorkHourDOS.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- totalManDay = totalWorkHours.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
|
|
|
- }
|
|
|
+ if (reimbursementDOList.isEmpty()) {
|
|
|
+ totalReimbursement = new BigDecimal("0.00");
|
|
|
+ } else {
|
|
|
+ totalReimbursement = reimbursementDOList.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
|
|
|
- if (monthLaborCostWgDTOS.isEmpty()) {
|
|
|
- totalLaborCost = new BigDecimal("0.00");
|
|
|
- } else {
|
|
|
- totalLaborCost = monthLaborCostWgDTOS.stream().map(ChuanyunMonthLaborCostWgDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- }
|
|
|
+ if (selfWorkHourDOS.isEmpty()) {
|
|
|
+ totalManDay = new BigDecimal("0.00");
|
|
|
+ } else {
|
|
|
+ BigDecimal totalWorkHours = selfWorkHourDOS.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ totalManDay = totalWorkHours.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
|
|
|
+ }
|
|
|
|
|
|
- ChuanyunImplCostDO old = implCostDao.findByProjectIdAndProjectCodeAndWorkGroupAndLocalDate(groupProjectObjectId, groupProjectCode, workGroupId, localDate.atStartOfDay());
|
|
|
- checkDataChange(chuanyunGroupProjectDO, groupProjectCode, localDate, workGroupId, totalReimbursement, totalManDay, totalLaborCost, old);
|
|
|
+ if (monthLaborCostWgDTOS.isEmpty()) {
|
|
|
+ totalLaborCost = new BigDecimal("0.00");
|
|
|
+ } else {
|
|
|
+ totalLaborCost = monthLaborCostWgDTOS.stream().map(ChuanyunMonthLaborCostWgDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
- } else {
|
|
|
- // 为2022年8月之前的数据,数据汇总到一个组内
|
|
|
- BigDecimal totalReimbursement = reimbursementList.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal totalWorkHours = selfWorkHourList.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal totalManDay = totalWorkHours.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
|
|
|
- BigDecimal totalLaborCost = laborCostWgList.stream().map(ChuanyunMonthLaborCostWgDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- // 统一汇总到默认组内
|
|
|
- String workGroupId = ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
- ChuanyunImplCostDO old = implCostDao.findByProjectCodeAndWorkGroupAndLocalDate(groupProjectCode, workGroupId, localDate.atStartOfDay());
|
|
|
+ ChuanyunImplCostDO old = implCostDao.findByProjectIdAndProjectCodeAndWorkGroupAndLocalDate(groupProjectObjectId, groupProjectCode, workGroupId, localDate.atStartOfDay());
|
|
|
checkDataChange(chuanyunGroupProjectDO, groupProjectCode, localDate, workGroupId, totalReimbursement, totalManDay, totalLaborCost, old);
|
|
|
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ // 处理2022年8月份之前的数据
|
|
|
+ Map<LocalDate, List<ChuanyunReimbursementDO>> beforeReimbursementMap = new HashMap<>();
|
|
|
+ Map<LocalDate, List<ChuanyunSelfWorkHourDO>> beforeWorkHoursMap = new HashMap<>();
|
|
|
+ Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> beforeLaborCostMap = new HashMap<>();
|
|
|
+ List<ChuanyunReimbursementDO> beforeReimbursements = reimbursementDao.findAllByGroupProjectCodeAndStatusInAndBusinessDateLessThan(groupProjectCode, List.of(1, 2), date.atStartOfDay());
|
|
|
+ // 查询用户在该项目的报销单
|
|
|
+ // 报销单按日期分组
|
|
|
+ Map<LocalDate, List<ChuanyunReimbursementDO>> brforeMap1 = beforeReimbursements.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> {
|
|
|
+ if (!Objects.isNull(chuanyunReimbursementDO.getBusinessDate())) {
|
|
|
+ return LocalDate.of(chuanyunReimbursementDO.getBusinessDate().getYear(), chuanyunReimbursementDO.getBusinessDate().getMonthValue(), 1);
|
|
|
+ } else {
|
|
|
+ return LocalDate.of(2015, 1, 1);
|
|
|
+ }
|
|
|
+ }));
|
|
|
+
|
|
|
+ brforeMap1.forEach((localDate, chuanyunReimbursementDOS) -> {
|
|
|
+ boolean containsKey = beforeReimbursementMap.containsKey(localDate);
|
|
|
+ if (containsKey) {
|
|
|
+ // 表示已经存在该key
|
|
|
+ List<ChuanyunReimbursementDO> reimbursementDOList = beforeReimbursementMap.get(localDate);
|
|
|
+ reimbursementDOList.addAll(chuanyunReimbursementDOS);
|
|
|
+ beforeReimbursementMap.put(localDate, reimbursementDOList);
|
|
|
+ } else {
|
|
|
+ beforeReimbursementMap.put(localDate, chuanyunReimbursementDOS);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<ChuanyunSelfWorkHourDO> beforeWorkHours = selfWorkHourDao.findAllByProjectCodeAndStatusInAndDayLogDateLessThan(groupProjectCode, List.of("1", "2"), date.atStartOfDay());
|
|
|
+ Map<LocalDate, List<ChuanyunSelfWorkHourDO>> beforeMap2 = beforeWorkHours.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> {
|
|
|
+ if (!Objects.isNull(chuanyunSelfWorkHourDO.getDayLogDate())) {
|
|
|
+ return LocalDate.of(chuanyunSelfWorkHourDO.getDayLogDate().getYear(), chuanyunSelfWorkHourDO.getDayLogDate().getMonthValue(), 1);
|
|
|
+ } else {
|
|
|
+ return LocalDate.of(2015, 1, 1);
|
|
|
}
|
|
|
+ }));
|
|
|
+ beforeMap2.forEach((localDate, chuanyunSelfWorkHourDOS) -> {
|
|
|
+ boolean containsKey = beforeWorkHoursMap.containsKey(localDate);
|
|
|
+ if (containsKey) {
|
|
|
+ // 表示已经存在该key
|
|
|
+ List<ChuanyunSelfWorkHourDO> selfWorkHours = beforeWorkHoursMap.get(localDate);
|
|
|
+ selfWorkHours.addAll(chuanyunSelfWorkHourDOS);
|
|
|
+ beforeWorkHoursMap.put(localDate, selfWorkHours);
|
|
|
+ } else {
|
|
|
+ beforeWorkHoursMap.put(localDate, chuanyunSelfWorkHourDOS);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<ChuanyunMonthLaborCostWgDTO> beforeLaborCostWgs = chuanyunMonthLaborCostWgDao.findAllByProjectCodeAndLogDateLessThan(groupProjectCode, date.atStartOfDay());
|
|
|
+ Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> beforeMap3 = beforeLaborCostWgs.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
|
|
|
+ if (!Objects.isNull(chuanyunMonthLaborCostWgDTO.getLogDate())) {
|
|
|
+ return LocalDate.of(chuanyunMonthLaborCostWgDTO.getLogDate().getYear(), chuanyunMonthLaborCostWgDTO.getLogDate().getMonthValue(), 1);
|
|
|
+ } else {
|
|
|
+ return LocalDate.of(2015, 1, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }));
|
|
|
+ beforeMap3.forEach((localDate, chuanyunMonthLaborCostWgDTOS) -> {
|
|
|
+ boolean containsKey = beforeLaborCostMap.containsKey(localDate);
|
|
|
+ if (containsKey) {
|
|
|
+ // 表示已经存在该key
|
|
|
+ List<ChuanyunMonthLaborCostWgDTO> monthLaborCostWgs = beforeLaborCostMap.get(localDate);
|
|
|
+ monthLaborCostWgs.addAll(chuanyunMonthLaborCostWgDTOS);
|
|
|
+ beforeLaborCostMap.put(localDate, monthLaborCostWgs);
|
|
|
+ } else {
|
|
|
+ beforeLaborCostMap.put(localDate, chuanyunMonthLaborCostWgDTOS);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Set<LocalDate> beforeLocalDates1 = beforeReimbursementMap.keySet();
|
|
|
+ Set<LocalDate> beforeLocalDates2 = beforeWorkHoursMap.keySet();
|
|
|
+ Set<LocalDate> beforeLocalDates3 = beforeLaborCostMap.keySet();
|
|
|
+
|
|
|
+ Set<LocalDate> beforeLocalDateCollections = CollectionsUtils.mergeCollections(beforeLocalDates1, beforeLocalDates2);
|
|
|
+ Set<LocalDate> beforeMergeCollections = CollectionsUtils.mergeCollections(beforeLocalDateCollections, beforeLocalDates3);
|
|
|
+
|
|
|
+ // 为2022年8月之前的数据,数据汇总到一个组内
|
|
|
+ beforeMergeCollections.forEach(localDate -> {
|
|
|
+ List<ChuanyunReimbursementDO> beforeReimbursementList = beforeReimbursementMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
+ List<ChuanyunSelfWorkHourDO> beforeWorkHourList = beforeWorkHoursMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
+ List<ChuanyunMonthLaborCostWgDTO> beforeLaborCostWgList = beforeLaborCostMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
+ BigDecimal totalReimbursement = beforeReimbursementList.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalWorkHours = beforeWorkHourList.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalManDay = totalWorkHours.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
|
|
|
+ BigDecimal totalLaborCost = beforeLaborCostWgList.stream().map(ChuanyunMonthLaborCostWgDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ // 统一汇总到默认组内
|
|
|
+ String workGroupId = ChuanYunConstant.DEFAULT_WORK_GROUP;
|
|
|
+ ChuanyunImplCostDO old = implCostDao.findByProjectCodeAndWorkGroupAndLocalDate(groupProjectCode, workGroupId, localDate.atStartOfDay());
|
|
|
+ checkDataChange(chuanyunGroupProjectDO, groupProjectCode, localDate, workGroupId, totalReimbursement, totalManDay, totalLaborCost, old);
|
|
|
|
|
|
});
|
|
|
|