Эх сурвалжийг харах

fix:为工作的工单修改合同月数

ly 10 сар өмнө
parent
commit
47baf96c66

+ 32 - 26
src/main/java/cn/ezhizao/project/business/order/service/impl/BizArchiveInputServiceImpl.java

@@ -606,37 +606,13 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
                             // 停止工单
                             l.setIsStop(1);
                             l.setIsContinue(0);
+                            //updateMonth(bizArchiveInput, l, details);
                         } else {
                             // 不停止工单 只修改工单完成时间
                             l.setMonthNum(months);
                             l.setEndMonth(endDate);
                             l.setIsContinue(0);
-                            List<BizArchiveInputDetail> inputDetailList = archiveInputDetailService
-                                    .query()
-                                    .eq("contract_id",bizArchiveInput.getId())
-                                    .list();
-                            for(BizArchiveInputDetail inputDetail : inputDetailList){
-                                TimeVo time = getTime(bizArchiveInput.getId(),inputDetail.getId(),l.getTaskTypeId(),l.getCompanyId());
-
-                                if(null != time){
-                                    // 获取当前日期的 LocalDate 对象
-                                    LocalDate now = LocalDate.now();
-                                    // 将 LocalDate 对象的日期设置为当前月份的第一天
-                                    LocalDate firstDayOfMonth = now.withDayOfMonth(1);
-                                    // 将 LocalDate 对象转换为 Date 对象
-                                    endDate = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
-                                    int i = DateDifferenceMonths(time.getStartTime(),endDate);
-                                    //   workOrderDetailService.updateByContractDetailId(i,l.getCompanyId(),inputDetail.getContractId(),inputDetail.getId(),l.getTaskTypeId());
-                                    details.stream()
-                                            .filter(v->v.getContractId().equals(inputDetail.getContractId())
-                                                    && v.getContractDetailId().equals(inputDetail.getId())
-                                                    && v.getTaskTypeId().equals(inputDetail.getTaskTypeId())
-                                            ).forEach(v->{
-                                                v.setServiceNum(i+1);
-                                                v.setFreeNum(0);
-                                            });
-                                }
-                            }
+                            updateMonth(bizArchiveInput, l, details);
                             // 当前这个工单所对应的委托根据endDate去查询,查询条件是大于endDate的,更新字段deleted为1
                             bizArchiveInputMapper.deleteByDate(l.getId(),endDate,l.getTaskTypeId(),SecurityUtils.getUserId());
                             // 旧任务明细 停止
@@ -655,6 +631,36 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
             return true;
         }
     }
+
+    private void updateMonth(BizArchiveInput bizArchiveInput, BizWorkOrder l, List<BizWorkOrderDetail> details) {
+        List<BizArchiveInputDetail> inputDetailList = archiveInputDetailService
+                .query()
+                .eq("contract_id", bizArchiveInput.getId())
+                .list();
+        for(BizArchiveInputDetail inputDetail : inputDetailList){
+            TimeVo time = getTime(bizArchiveInput.getId(),inputDetail.getId(), l.getTaskTypeId(), l.getCompanyId());
+
+            if(null != time){
+                // 获取当前日期的 LocalDate 对象
+                LocalDate now = LocalDate.now();
+                // 将 LocalDate 对象的日期设置为当前月份的第一天
+                LocalDate firstDayOfMonth = now.withDayOfMonth(1);
+                // 将 LocalDate 对象转换为 Date 对象
+                Date endDateTime = Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
+                int i = DateDifferenceMonths(time.getStartTime(),endDateTime);
+                //   workOrderDetailService.updateByContractDetailId(i,l.getCompanyId(),inputDetail.getContractId(),inputDetail.getId(),l.getTaskTypeId());
+                details.stream()
+                        .filter(v->v.getContractId().equals(inputDetail.getContractId())
+                                && v.getContractDetailId().equals(inputDetail.getId())
+                                && v.getTaskTypeId().equals(inputDetail.getTaskTypeId())
+                        ).forEach(v->{
+                            v.setServiceNum(i+1);
+                            v.setFreeNum(0);
+                        });
+            }
+        }
+    }
+
     public TimeVo getTime(Long contractId, Long contractDetailId, Long typeId, Long companyId) {
         //排序获取当前索引位置
         BizWorkOrderDetail one = workOrderDetailService.getOne(