Browse Source

合同修复

ly 1 năm trước cách đây
mục cha
commit
15eb941990

+ 86 - 25
src/main/java/cn/ezhizao/project/business/order/controller/BizArchiveInputController.java

@@ -25,6 +25,10 @@ import cn.ezhizao.project.business.taskType.domain.BizTaskTypeDetail;
 import cn.ezhizao.project.business.taskType.service.IBizTaskTypeDetailService;
 import cn.ezhizao.project.business.taskType.service.IBizTaskTypeService;
 import cn.ezhizao.project.business.workOrder.domain.BizWorkOrder;
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderDetail;
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord;
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderDetailService;
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderRecordService;
 import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderService;
 import cn.ezhizao.project.system.domain.SysFileStorage;
 import cn.ezhizao.project.system.domain.SysUser;
@@ -85,6 +89,14 @@ public class BizArchiveInputController extends BaseController {
     private IBizWorkOrderService workOrderService;
     @Resource
     private IBizCollectionDetailService bizCollectionDetailService;
+
+    @Resource
+    private IBizWorkOrderDetailService bizWorkOrderDetailService;
+
+    @Resource
+    private IBizWorkOrderRecordService workOrderRecordService;
+
+
     /**
      * 查询档案入库列表
      */
@@ -191,6 +203,19 @@ public class BizArchiveInputController extends BaseController {
     @Transactional(rollbackFor = Exception.class)
     public AjaxResult alter(@RequestBody BizArchiveInput bizArchiveInput) {
         Long userId = SecurityUtils.getUserId();
+        //防止前端没传明细id
+        List<BizArchiveInputDetail> list = archiveInputDetailService
+                .list(new LambdaQueryWrapper<BizArchiveInputDetail>().eq(BizArchiveInputDetail::getContractId, bizArchiveInput.getId()));
+        for (BizArchiveInputDetail detail : bizArchiveInput.getDetails()) {
+            if (detail.getFreeNum() == null) {
+                detail.setFreeNum(0);
+            }
+            for (BizArchiveInputDetail bizArchiveInputDetail : list) {
+                if (detail.getTaskTypeId().equals(bizArchiveInputDetail.getTaskTypeId())) {
+                    detail.setId(bizArchiveInputDetail.getId());
+                }
+            }
+        }
 
         BizArchiveInput oldBizArchiveInput = getById(bizArchiveInput.getId());
         checkAlter(bizArchiveInput, oldBizArchiveInput);
@@ -245,6 +270,22 @@ public class BizArchiveInputController extends BaseController {
             BizArchiveInputDetailProcess conditionProcess = new BizArchiveInputDetailProcess();
             List<SysFileStorage> sysFileStorages = fileStorageService.query().eq("master_table_name", "biz_archive_input").eq("master_id", bizArchiveInput.getId()).list();
             List<BizArchiveInputDetail> details = archiveInputDetailService.getList(conditionDetail);
+            for (BizArchiveInputDetail detail : details) {
+                BizWorkOrderDetail one = bizWorkOrderDetailService.getOne(new LambdaQueryWrapper<BizWorkOrderDetail>()
+                        .eq(BizWorkOrderDetail::getContractDetailId, detail.getId())
+                        .eq(BizWorkOrderDetail::getIsStop, 0)
+                        .eq(BizWorkOrderDetail::getTaskTypeId, detail.getTaskTypeId()));
+                if (one != null) {
+                    List<BizWorkOrderRecord> list = workOrderRecordService.list(new LambdaQueryWrapper<BizWorkOrderRecord>()
+                            .eq(BizWorkOrderRecord::getWorkOrderId, one.getWorkOrderId()));
+                    if (CollectionUtils.isNotEmpty(list)){
+                        detail.setDisabled(true);
+                    }else {
+                        detail.setDisabled(false);
+                    }
+                }
+            }
+
             List<BizArchiveInputDetailProcess> processes = archiveInputDetailProcessService.getList(conditionProcess);
             details.forEach(l -> l.setProcesses(processes.stream().filter(v -> v.getContractDetailId().equals(l.getId())).collect(Collectors.toList())));
             bizArchiveInput.setDetails(details);
@@ -284,10 +325,12 @@ public class BizArchiveInputController extends BaseController {
                 delList.add(l);
                 delProcess.addAll(l.getProcesses());
             } else {
-                BizArchiveInputDetail newItem = newBizArchiveInput.getDetails().stream().filter(v -> v.getId().equals(l.getId())).findFirst().orElse(new BizArchiveInputDetail());
+                BizArchiveInputDetail newItem = newBizArchiveInput.getDetails().stream().filter(v -> l.getId().equals(v.getId())).findFirst().orElse(new BizArchiveInputDetail());
                 delProcess.addAll(l.getProcesses().stream().filter(v -> newItem.getProcesses().stream().noneMatch(e -> e.getId().equals(v.getId()))).collect(Collectors.toList()));
                 if (newBizArchiveInput.getServiceType().equals(1)) {
-                    if ((newItem.getFreeNum() + newItem.getServiceNum()) != (l.getServiceNum() + l.getFreeNum())) {
+                    boolean a = (newItem.getFreeNum() + newItem.getServiceNum()) != (l.getServiceNum() + l.getFreeNum());
+                    boolean b = (newItem.getPrice().subtract(newItem.getDiscountAmount())).compareTo(l.getPrice().subtract(l.getDiscountAmount())) != 0;
+                    if (a || b) {
                         changeList.add(l);
                     }
                 }
@@ -296,30 +339,46 @@ public class BizArchiveInputController extends BaseController {
         // 假设是单次任务判断删掉的任务是否已开始
         if (newBizArchiveInput.getServiceType().equals(2)) {
             if (!(delProcess.isEmpty() || bizArchiveInputService.checkWorkOrderStatusProcess(delProcess))) {
-                throw new ServiceException("存在任务已完成,不能删除合同明细。");
+                throw new ServiceException("存在任务已完成,不能删除合同明细。");
             }
 //            newBizArchiveInput.get
         }
         if (newBizArchiveInput.getServiceType().equals(1)) {
             // 假设是循环任务判断判断删掉的任务是否已经开始
             if (!delList.isEmpty() && !bizArchiveInputService.checkWorkOrderStatus(delList)) {
-                throw new ServiceException("存在任务已完成,不能删除合同明细");
+                throw new ServiceException("存在任务已完成或填报,不能删除或修改该合同明细");
             }
-            // 假设是循环任务判断修改数量的任务是否和已完成的任务数量相符
-            if (!changeList.isEmpty() && !bizArchiveInputService.checkWorkOrderChangeStatus(changeList)) {
-                throw new ServiceException("修改任务月数小于已完成月数。");
+            //任务开始就不可以修改
+            for (BizArchiveInputDetail item : changeList) {
+                BizWorkOrderDetail one = bizWorkOrderDetailService.getOne(new LambdaQueryWrapper<BizWorkOrderDetail>()
+                        .eq(BizWorkOrderDetail::getContractDetailId, item.getId())
+                        .eq(BizWorkOrderDetail::getIsStop, 0));
+                //通过明细查询workorderID 进而查询record表
+                if (one != null) {
+                    Long workOrderId = one.getWorkOrderId();
+                    List<BizWorkOrderRecord> list = workOrderRecordService.list(new LambdaQueryWrapper<BizWorkOrderRecord>()
+                            .eq(BizWorkOrderRecord::getWorkOrderId, workOrderId));
+                    if (CollectionUtils.isNotEmpty(list)) {
+                        throw new ServiceException("存在已开始的任务,不能修改该合同明细");
+                    }
+                }
             }
-        for (BizArchiveInputDetail item : delList) {
-
-            List<BizCollectionDetail> list = bizCollectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>()
-                    .eq(BizCollectionDetail::getContractId, newBizArchiveInput.getId())
-                    .eq(BizCollectionDetail::getContractDetailId, item.getId())
-                    .eq(BizCollectionDetail::getTaskTypeId, item.getTaskTypeId()));
-            if(CollectionUtils.isNotEmpty(list)){
-                throw new RuntimeException("已存在该任务类型的收款合同,无法删除");
+
+            // 假设是循环任务判断修改数量的任务是否和已完成的任务数量相符
+//            if (!changeList.isEmpty() && !bizArchiveInputService.checkWorkOrderChangeStatus(changeList)) {
+//                throw new ServiceException("修改任务月数小于已完成月数。");
+//            }
+            for (BizArchiveInputDetail item : delList) {
+
+                List<BizCollectionDetail> list = bizCollectionDetailService.list(new LambdaQueryWrapper<BizCollectionDetail>()
+                        .eq(BizCollectionDetail::getContractId, newBizArchiveInput.getId())
+                        .eq(BizCollectionDetail::getContractDetailId, item.getId())
+                        .eq(BizCollectionDetail::getTaskTypeId, item.getTaskTypeId()));
+                if (CollectionUtils.isNotEmpty(list)) {
+                    throw new RuntimeException("已存在该任务类型的收款合同,无法删除");
+                }
             }
         }
-        }
         return true;
     }
 
@@ -333,7 +392,7 @@ public class BizArchiveInputController extends BaseController {
         // 获取 入Excel 表头字段
         List<String> excelHeaders = util.readExcelHeaders(file.getInputStream());
         //获取实体类字段
-        List<String> names=getExcelAnnotatedFields(OrderExcelImportLoopModel.class);
+        List<String> names = getExcelAnnotatedFields(OrderExcelImportLoopModel.class);
         //如果不存在模板中的字段,返回错误
         if (!names.containsAll(excelHeaders)) {
             return error("导入数据与模板不匹配!");
@@ -341,6 +400,7 @@ public class BizArchiveInputController extends BaseController {
         String message = bizArchiveInputService.importLoop(orderList, SecurityUtils.getUserId(), getTenantId() == null ? 0 : getTenantId());
         return success(message);
     }
+
     @Log(title = "合同导入", businessType = BusinessType.IMPORT)
     @PreAuthorize("@ss.hasPermi('business:archive:order:import')")
     @PostMapping("/importOnce")
@@ -351,7 +411,7 @@ public class BizArchiveInputController extends BaseController {
         // 获取 入Excel 表头字段
         List<String> excelHeaders = util.readExcelHeaders(file.getInputStream());
         //获取实体类字段
-        List<String> names=getExcelAnnotatedFields(OrderExcelImportOnceModel.class);
+        List<String> names = getExcelAnnotatedFields(OrderExcelImportOnceModel.class);
         //如果不存在模板中的字段,返回错误
         if (!names.containsAll(excelHeaders)) {
             return error("导入数据与模板不匹配!");
@@ -360,7 +420,7 @@ public class BizArchiveInputController extends BaseController {
         return success(message);
     }
 
-    public  List<String> getExcelAnnotatedFields(Class<?> clazz) {
+    public List<String> getExcelAnnotatedFields(Class<?> clazz) {
         Field[] fields = clazz.getDeclaredFields();
         List<String> result = new ArrayList<>();
         for (Field field : fields) {
@@ -398,6 +458,7 @@ public class BizArchiveInputController extends BaseController {
             }
         }
     }
+
     @Log(title = "合同模板导出", businessType = BusinessType.EXPORT)
     @PreAuthorize("@ss.hasPermi('business:archive:order:export')")
     @PostMapping("/exportOnceTemplate")
@@ -438,22 +499,22 @@ public class BizArchiveInputController extends BaseController {
                 List<BizArchiveInputDetail> details = archiveInputDetailService.getList(conditions);
                 List<BizArchiveInputDetail> checkResult = new ArrayList<>();
                 // 判断循环工单是否有旧工单
-                for (BizArchiveInputDetail detail: details) {
+                for (BizArchiveInputDetail detail : details) {
                     BizWorkOrder workOrder = workOrderService.query().eq("company_id", item.getCompanyId()).eq("task_type_id", detail.getTaskTypeId()).orderByDesc("end_month").eq("is_stop", 0).last("limit 1").one();
                     if (workOrder != null && workOrder.getEndMonth() != null) {
                         DateTime endMonth = DateTime.of(workOrder.getEndMonth());
                         if (workOrder.getTaskTypeId().equals(1L)) {
                             // 记账报税做前一个月的所以结束月为上上个月的要判断是否接着上个工单
-                            if (DateTime.now().offset(DateField.MONTH, -2).toString("yyyyMM").compareTo( endMonth.toString("yyyyMM")) > 0) {
+                            if (DateTime.now().offset(DateField.MONTH, -2).toString("yyyyMM").compareTo(endMonth.toString("yyyyMM")) > 0) {
                                 detail.setEndMonth(workOrder.getEndMonth());
                                 checkResult.add(detail);
                             }
                         } else {
                             // 社保公积金还有返税申报是这个月的所以结束月是上个月的判断是否接上个工单。
-                             if (DateTime.now().offset(DateField.MONTH, -1).toString("yyyyMM").compareTo( endMonth.toString("yyyyMM")) > 0) {
-                                 detail.setEndMonth(workOrder.getEndMonth());
-                                 checkResult.add(detail);
-                             }
+                            if (DateTime.now().offset(DateField.MONTH, -1).toString("yyyyMM").compareTo(endMonth.toString("yyyyMM")) > 0) {
+                                detail.setEndMonth(workOrder.getEndMonth());
+                                checkResult.add(detail);
+                            }
                         }
                     }
                 }

+ 40 - 13
src/main/java/cn/ezhizao/project/business/order/domain/BizArchiveInputDetail.java

@@ -20,15 +20,18 @@ import cn.ezhizao.framework.aspectj.lang.annotation.Excel;
  */
 @Data
 @TableName(value = "biz_archive_input_detail")
-public class BizArchiveInputDetail extends BaseEntity
-{
+public class BizArchiveInputDetail extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 合同外键 */
+    /**
+     * 合同外键
+     */
     @ApiModelProperty(value = "${comment}")
     private Long contractId;
 
-    /** 任务类型外键 */
+    /**
+     * 任务类型外键
+     */
     @ApiModelProperty(value = "${comment}")
     private Long taskTypeId;
 
@@ -44,22 +47,30 @@ public class BizArchiveInputDetail extends BaseEntity
 //    @ApiModelProperty(value = "月数")
 //    private Integer monthNum;
 
-    /** 单价 */
+    /**
+     * 单价
+     */
     @Excel(name = "单价")
     @ApiModelProperty(value = "单价")
     private BigDecimal price;
 
-    /** 总金额 */
+    /**
+     * 总金额
+     */
     @Excel(name = "总金额")
     @ApiModelProperty(value = "总金额")
     private BigDecimal amount;
 
-    /** 总金额 */
+    /**
+     * 总金额
+     */
     @Excel(name = "总金额")
     @ApiModelProperty(value = "总金额")
     private BigDecimal addressAmount;
 
-    /** $column.columnComment */
+    /**
+     * $column.columnComment
+     */
     @ApiModelProperty(value = "租户外键")
     private Long tenantId;
 
@@ -85,27 +96,37 @@ public class BizArchiveInputDetail extends BaseEntity
     @ApiModelProperty(value = "注册省份编码")
     private String provinceCode;
 
-    /** 省 */
+    /**
+     * 省
+     */
     @Excel(name = "省")
     @ApiModelProperty(value = "省")
     private String province;
 
-    /** 注册城市编码 */
+    /**
+     * 注册城市编码
+     */
     @Excel(name = "注册城市编码")
     @ApiModelProperty(value = "注册城市编码")
     private String cityCode;
 
-    /** 市 */
+    /**
+     * 市
+     */
     @Excel(name = "市")
     @ApiModelProperty(value = "市")
     private String city;
 
-    /** 注册行政区编码 */
+    /**
+     * 注册行政区编码
+     */
     @Excel(name = "注册行政区编码")
     @ApiModelProperty(value = "注册行政区编码")
     private String districtCode;
 
-    /** 区 */
+    /**
+     * 区
+     */
     @Excel(name = "区")
     @ApiModelProperty(value = "区")
     private String district;
@@ -138,4 +159,10 @@ public class BizArchiveInputDetail extends BaseEntity
     @ApiModelProperty("所属区")
     @TableField(exist = false)
     private String regionName;
+
+    @TableField(exist = false)
+    private String fictionAddress;
+    //禁用状态
+    @TableField(exist = false)
+    private boolean isDisabled;
 }

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

@@ -176,9 +176,9 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
                         if (l.getRedirect() != null && l.getRedirect()) {
                             // 重建任务将旧任务停止
                             workOrders.forEach(v -> v.setIsStop(1));
-                            changeWorkOrders.addAll(workOrders);
+                            stopWorkOrders.addAll(workOrders);
                             workOrderDetails.forEach(v -> v.setIsStop(1));
-                            changeWorkOrderDetails.addAll(workOrderDetails);
+                            stopWorkOrderDetails.addAll(workOrderDetails);
                             // 新建新任务。
                             BizWorkOrder workOrder = new BizWorkOrder();
                             workOrder.setCompanyId(bizArchiveInput.getCompanyId());
@@ -242,15 +242,7 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
                     // 停用的工单判断是否为空
                     workOrders.forEach(l -> {
                         BizWorkOrderDetail detail = stopWorkOrderDetails.stream().filter(v -> v.getWorkOrderId().equals(l.getId())).findFirst().orElse(null);
-                        if (changeWorkOrders.stream().noneMatch(v -> v.getId().equals(l.getId())) && detail != null) {
-                            BizWorkOrder v = changeWorkOrders.stream().filter(e -> e.getId().equals(l.getId())).findFirst().orElse(l);
-                            int monthNum = v.getMonthNum() - (detail.getServiceNum() == null ? 0 : detail.getServiceNum()) - (detail.getFreeNum() == null ? 0 : detail.getFreeNum());
-                            v.setMonthNum(monthNum);
-                            if (v.getStartMonth() != null) {
-                                DateTime startMonth = DateTime.of(v.getStartMonth());
-                                v.setEndMonth(startMonth.offset(DateField.MONTH, monthNum - 1).toSqlDate());
-                            }
-                        } else if (detail != null) {
+                        if (detail != null) {
                             int monthNum = l.getMonthNum() - (detail.getServiceNum() == null ? 0 : detail.getServiceNum()) - (detail.getFreeNum() == null ? 0 : detail.getFreeNum());
 
                             if (monthNum == 0) {
@@ -265,14 +257,6 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
                                 changeWorkOrders.add(l);
                             }
                         }
-//                        Integer workMonth = l.getMonthNum() - (detail != null ? detail.getFreeNum() + detail.getServiceNum() : 0);
-//                        if (workMonth.equals(0)) {
-//                            l.setIsStop(1);
-//                            stopWorkOrders.add(l);
-//                        } else {
-//                            l.setMonthNum(workMonth);
-//                            changeWorkOrders.add(l);
-//                        }
                     });
                 }
             } else if (bizArchiveInput.getServiceType().equals(2)) {
@@ -312,7 +296,8 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
             }
         }
 
-
+        stopWorkOrders.forEach(order -> order.setIsStop(1));
+        stopWorkOrderDetails.forEach(orderDetail -> orderDetail.setIsStop(1));
 
         boolean status = (newWorkOrderDetails.isEmpty() || workOrderDetailService.saveBatch(newWorkOrderDetails))
                 && (newWorkOrders.isEmpty() || workOrderService.saveBatch(newWorkOrders))
@@ -603,12 +588,15 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
 
     @Override
     public boolean checkWorkOrderStatus(List<BizArchiveInputDetail> delList) {
-        List<BizWorkOrderDetail> details = workOrderDetailService.query().in("contract_detail_id", delList.stream().map(BizArchiveInputDetail::getId).collect(Collectors.toList())).list();
-        List<BizWorkOrder> workOrders = workOrderService.query().in("id", details.stream().map(BizWorkOrderDetail::getWorkOrderId).collect(Collectors.toList())).list();
-        List<BizWorkOrderDetail> otherDetails = workOrderDetailService.query().eq("is_stop", 0).in("work_order_id", workOrders.stream().map(BizWorkOrder::getId).collect(Collectors.toList())).notIn("id", details.stream().map(BizWorkOrderDetail::getId).collect(Collectors.toList())).list();
+        List<BizWorkOrderDetail> details = workOrderDetailService.query()
+                .in("contract_detail_id", delList.stream().map(BizArchiveInputDetail::getId).collect(Collectors.toList())).list();
+        List<BizWorkOrder> workOrders = workOrderService.query()
+                .in("id", details.stream().map(BizWorkOrderDetail::getWorkOrderId).collect(Collectors.toList())).list();
+        List<BizWorkOrderDetail> otherDetails = workOrderDetailService.query()
+                .eq("is_stop", 0).in("work_order_id", workOrders.stream().map(BizWorkOrder::getId).collect(Collectors.toList()))
+                .notIn("id", details.stream().map(BizWorkOrderDetail::getId).collect(Collectors.toList())).list();
         List<BizWorkOrderRecord> records = workOrderRecordService.query().in("work_order_id", workOrders.stream().map(BizWorkOrder::getId).collect(Collectors.toList())).list();
-        AtomicBoolean status = new AtomicBoolean(true);
-        workOrders.forEach(l -> {
+        for (BizWorkOrder l : workOrders) {
             if (otherDetails.size() > 0 && records.size() > 0) {
                 // 除了删除的工单明细之外的工单
                 l.setDetails(otherDetails.stream().filter(v -> v.getWorkOrderId().equals(l.getId())).collect(Collectors.toList()));
@@ -620,16 +608,14 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
                     DateTime startDate = DateTime.of(l.getStartMonth());
                     DateTime endDate = startDate.offsetNew(DateField.MONTH, monthNun - 1);
                     if (records.stream().noneMatch(v -> (v.getYear() + v.getMonth()).compareTo(endDate.toString("yyyyMM")) >= 0)) {
-                        status.set(false);
-                    } else {
-                        status.set(status.get());
+                        return false;
                     }
-                } else {
-                    status.set(status.get());
                 }
+            } else if (CollectionUtils.isEmpty(otherDetails) && CollectionUtils.isNotEmpty(records)) {
+                return false;
             }
-        });
-        return status.get();
+        }
+        return true;
     }
 
     @Override

+ 25 - 15
src/main/java/cn/ezhizao/project/business/workOrder/controller/BizWorkOrderController.java

@@ -102,7 +102,9 @@ public class BizWorkOrderController extends BaseController {
             if (!bizWorkOrder.getCompanyName().equals(""))
                 bizWorkOrder.setCompanyName(bizWorkOrder.getCompanyName().trim());
         }
-        List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
+//        List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
+        //有合并工单情况 不可以用合同明细联查
+        List<BizWorkOrder> list = bizWorkOrderService.getList2(bizWorkOrder);
         BizEntrust entrustConditions = new BizEntrust();
         entrustConditions.setWorkOrderIds(list.stream().map(BizWorkOrder::getId).collect(Collectors.toList()));
         List<BizEntrust> entrusts = entrustService.getList(entrustConditions);
@@ -146,7 +148,7 @@ public class BizWorkOrderController extends BaseController {
                     //判断是否全部收款
                     if (collectionMoney.compareTo(money) == 0) {
                         v.setOnceContractStatus("已收款");
-                    } else if (collectionMoney.compareTo(money) < 0 &&collectionMoney.compareTo(new BigDecimal(0))>0) {
+                    } else if (collectionMoney.compareTo(money) < 0 && collectionMoney.compareTo(new BigDecimal(0)) > 0) {
                         v.setOnceContractStatus("部分收款");
                     } else if (collectionMoney.compareTo(new BigDecimal(0)) == 0) {
                         v.setOnceContractStatus("未收款");
@@ -156,10 +158,13 @@ public class BizWorkOrderController extends BaseController {
                 if (v.getType() == 1 && detailList.size() > 0) {
 
                     //判断是否有起始月份
-                    BizArchiveInputDetail detail = new BizArchiveInputDetail();
-                    detail.setContractId(v.getContractId());
-                    detail.setTaskTypeId(v.getTaskTypeId());
-                    detail = bizArchiveInputDetailService.getDetail(detail);
+//                    BizArchiveInputDetail detail = new BizArchiveInputDetail();
+////                    detail.setContractId(v.getContractId());
+//                    detail.setFromId(0L);
+//                    detail.setCompanyId(v.getCompanyId());
+//                    detail.setDeleted(0);
+//                    detail.setTaskTypeId(v.getTaskTypeId());
+//                    detail = bizArchiveInputDetailService.getDetail(detail);
                     Integer monthNum = 0;
                     if (v.getStartMonth() != null) {
 
@@ -206,11 +211,15 @@ public class BizWorkOrderController extends BaseController {
                         } else {
                             //根据单价计算月数
                             for (BizWorkOrderDetail d : detailList) {
+                                Long contractDetailId = d.getContractDetailId();
+                                //判断是否有起始月份
+
+                                BizArchiveInputDetail detail = bizArchiveInputDetailService.getById(contractDetailId);
                                 // 该明细的合同总金额
                                 BizArchiveInput e = bizArchiveInputService.getById(d.getContractId());
                                 money = e.getAmount();
                                 //如果收款金额大于0
-                                if (d.getTotalityMoney() != null && d.getTotalityMoney().compareTo(new BigDecimal(0)) > 0 && d.getServiceNum()>0)  {
+                                if (d.getTotalityMoney() != null && d.getTotalityMoney().compareTo(new BigDecimal(0)) > 0 && d.getServiceNum() > 0) {
                                     detail.setContractId(d.getContractId());
                                     detail.setTaskTypeId(d.getTaskTypeId());
                                     detail = bizArchiveInputDetailService.getDetail(detail);
@@ -220,12 +229,13 @@ public class BizWorkOrderController extends BaseController {
                                 if (money.compareTo(BigDecimal.ZERO) == 0) {
                                     monthNum = monthNum + detail.getServiceNum() + detail.getFreeNum();
                                 }
+                                //判断收款月数是否等于服务月数
+                                if (detail.getServiceNum() == monthNum) {
+                                    //如果服务月数等于收款月数则加上赠送月数
+                                    monthNum += detail.getFreeNum();
+                                }
                             }
-                            //判断收款月数是否等于服务月数
-                            if (detail.getServiceNum() == monthNum) {
-                                //如果服务月数等于收款月数则加上赠送月数
-                                monthNum += detail.getFreeNum();
-                            }
+
                             //设置收款截止月
                             Calendar rightNow = Calendar.getInstance();
                             rightNow.setTime(v.getStartMonth());
@@ -379,9 +389,9 @@ public class BizWorkOrderController extends BaseController {
             Long id = item.getId();
             Long companyId = item.getCompanyId();
             List<BizEntrust> bizEntrusts = entrustService.list(new LambdaQueryWrapper<BizEntrust>().eq(BizEntrust::getWorkOrderId, id).eq(BizEntrust::getCompanyId, companyId));
-            if (!CollectionUtils.isEmpty(bizEntrusts)){
-                String  compName = companyService.getById(companyId).getName();
-                return error( compName + "该工单已经委托给工厂,请先取消委托!");
+            if (!CollectionUtils.isEmpty(bizEntrusts)) {
+                String compName = companyService.getById(companyId).getName();
+                return error(compName + "该工单已经委托给工厂,请先取消委托!");
             }
         }
         return toAjax(bizWorkOrderService.removeBatchByIds(list));

+ 2 - 0
src/main/java/cn/ezhizao/project/business/workOrder/mapper/BizWorkOrderMapper.java

@@ -48,4 +48,6 @@ public interface BizWorkOrderMapper extends BaseMapper<BizWorkOrder>
     public int stopTasks(List<Map<String, Object>> tableValues);
 
     int setContinue(List<Long> ids, Integer state);
+
+    List<BizWorkOrder> getList2(BizWorkOrder bizWorkOrder);
 }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/workOrder/service/IBizWorkOrderService.java

@@ -49,4 +49,6 @@ public interface IBizWorkOrderService extends IService<BizWorkOrder>
     public int stopTasks(List<Map<String, Object>>tableValues);
 
     int setContinue(List<Long> ids, Integer state);
+
+    List<BizWorkOrder> getList2(BizWorkOrder bizWorkOrder);
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/workOrder/service/impl/BizWorkOrderServiceImpl.java

@@ -61,4 +61,9 @@ public class BizWorkOrderServiceImpl  extends ServiceImpl<BizWorkOrderMapper, Bi
         return bizWorkOrderMapper.setContinue(ids, state);
     }
 
+    @Override
+    public List<BizWorkOrder> getList2(BizWorkOrder bizWorkOrder) {
+        return bizWorkOrderMapper.getList2(bizWorkOrder);
+    }
+
 }

+ 14 - 13
src/main/resources/mybatis/business/BizArchiveInputDetailMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.ezhizao.project.business.order.mapper.BizArchiveInputDetailMapper">
 
     <resultMap type="cn.ezhizao.project.business.order.domain.BizArchiveInputDetail" id="BizArchiveInputDetailResult">
@@ -10,19 +10,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="getList" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
-
-        SELECT t1.*, t2.name as task_type_name, t2.pay_address,t3.dict_label as regionName
+        SELECT t1.*, t2.name as task_type_name, t2.pay_address,t3.dict_label as regionName,t4.dict_label as fictionAddress
         FROM biz_archive_input_detail t1
         left join biz_task_type t2 on t2.id = t1.task_type_id
         left join sys_dict_data t3 on t1.belong_region = t3.dict_code
-
+        left join sys_dict_data t4 on t1.fiction_address_id = t4.dict_code
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
-            <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
-            <if test="contractId != null "> AND t1.contract_id = #{contractId}</if>
-            <if test="serviceNum != null "> AND t1.service_num = #{serviceNum}</if>
-            <if test="price != null "> AND t1.price = #{price}</if>
-            <if test="amount != null "> AND t1.amount = #{amount}</if>
+            <if test="companyId != null ">AND t1.company_id = #{companyId}</if>
+            <if test="contractId != null ">AND t1.contract_id = #{contractId}</if>
+            <if test="serviceNum != null ">AND t1.service_num = #{serviceNum}</if>
+            <if test="price != null ">AND t1.price = #{price}</if>
+            <if test="amount != null ">AND t1.amount = #{amount}</if>
         </trim>
     </select>
     <select id="getDetail" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
@@ -30,8 +29,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM biz_archive_input_detail
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             deleted = 0
-            <if test="contractId != null "> AND contract_id = #{contractId}</if>
-            <if test="taskTypeId != null "> AND task_type_id = #{taskTypeId}</if>
+            <if test="contractId != null ">AND contract_id = #{contractId}</if>
+            <if test="taskTypeId != null ">AND task_type_id = #{taskTypeId}</if>
+            <if test="fromId  !=  null ">AND from_id = #{fromId}</if>
+            <if test="companyId  !=  null ">AND company_id = #{companyId}</if>
         </trim>
 
     </select>
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null ">
                 company_id = #{companyId} AND
             </if>
-       <!-- 删除条件为其他外键可以在这里加 -->
+            <!-- 删除条件为其他外键可以在这里加 -->
         </trim>
     </delete>
 </mapper>

+ 35 - 0
src/main/resources/mybatis/business/BizWorkOrderMapper.xml

@@ -107,6 +107,41 @@
         </trim>
 
     </select>
+    <select id="getList2" parameterType="BizWorkOrder" resultMap="BizWorkOrderResult">
+        SELECT t1.*, t2.name as company_name, t2.social_credit_code, t3.name as task_type_name, t4.name as
+        task_type_detail_name, t5.nick_name as service_name, t2.is_zero,t2.tax_type FROM biz_work_order t1
+        left join biz_company t2 on t2.id = t1.company_id
+        left join biz_task_type t3 on t3.id = t1.task_type_id
+        left join biz_task_type_detail t4 on t4.id = t1.task_type_detail_id
+        left join sys_user t5 on t5.user_id = t1.service_id
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            t1.deleted = 0 and t1.is_stop = 0
+            <if test="id != null "> AND t1.id = #{id}</if>
+            <if test="contractDetailId != null "> AND t1.contract_detail_id = #{contractDetailId}</if>
+            <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
+            <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
+            <if test="type != null ">AND t1.type = #{type}</if>
+            <if test=" serviceId != null">AND t1.service_id = #{serviceId}</if>
+            <if test="noContract != null ">AND t1.no_contract = #{noContract}</if>
+            <if test="workOrderNo != null  and workOrderNo != ''">AND t1.work_order_no = #{workOrderNo}</if>
+            <if test="startMonth != null ">AND t1.start_month = #{startMonth}</if>
+            <if test="endMonth != null ">AND t1.end_month = #{endMonth}</if>
+            <if test="monthNum != null ">AND t1.month_num = #{monthNum}</if>
+            <if test="companyName != null and companyName != '' "> AND t2.name like concat('%', #{companyName}, '%')</if>
+            <if test="isStop != null ">AND t1.is_stop = #{isStop}</if>
+            <if test="year != null ">
+                AND t1.start_month > 0
+                <if test="month != null and month != ''">
+                    AND concat(#{year}, '-', #{month}, '-01') &gt;= (case when t1.task_type_id = 1 then DATE_ADD(t1.start_month, interval 1 month) else t1.start_month end) and concat(#{year}, '-', #{month}, '-01') &lt;= (case when t1.task_type_id = 1 then DATE_ADD(t1.end_month,interval 1 month) else t1.end_month end)
+                </if>
+                <if test="month == null or month == ''">
+                    AND #{year} >= (case when t1.task_type_id = 1 then DATE_FORMAT(DATE_ADD(t1.start_month,interval 1 month), '%Y') else DATE_FORMAT(t1.start_month, '%Y') end) AND #{year} &lt;= (case when t1.end_month = 0 then #{year} when t1.task_type_id = 1 then DATE_FORMAT(DATE_ADD(t1.end_month,interval 1 month), '%Y') else DATE_FORMAT(t1.end_month, '%Y') end)
+                </if>
+            </if>
+
+
+        </trim>
+    </select>
 
     <delete id="physicalDelete">
         DELETE FROM biz_work_order