Browse Source

合同导入,是否续签

rainwer 6 months ago
parent
commit
7124b0de70

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

@@ -504,7 +504,7 @@ public class BizArchiveInputController extends BaseController {
     @PreAuthorize("@ss.hasPermi('business:archive:order:import')")
     @PostMapping("/importLoopNew")
     @Transactional
-    public AjaxResult importLoopNew(MultipartFile file) throws Exception {
+    public AjaxResult importLoopNew(@RequestParam Integer renew, MultipartFile file) throws Exception {
         ExcelUtil<OrderExcelImportLoopNewModel> util = new ExcelUtil<>(OrderExcelImportLoopNewModel.class);
         List<OrderExcelImportLoopNewModel> orderList = util.importExcel(file.getInputStream());
         // 获取 入Excel 表头字段
@@ -515,7 +515,7 @@ public class BizArchiveInputController extends BaseController {
 //        if (!names.containsAll(excelHeaders)) {
 //            return error("导入数据与模板不匹配!");
 //        }
-        String message = bizArchiveInputService.importLoopNew(orderList, SecurityUtils.getUserId(), getTenantId() == null ? 0 : getTenantId());
+        String message = bizArchiveInputService.importLoopNew(orderList, SecurityUtils.getUserId(), getTenantId() == null ? 0 : getTenantId(), renew);
         return success(message);
     }
 

+ 1 - 1
src/main/java/cn/ezhizao/project/business/order/service/IBizArchiveInputService.java

@@ -44,7 +44,7 @@ public interface IBizArchiveInputService extends IService<BizArchiveInput>
 
     String importLoop(List<OrderExcelImportLoopModel> orderList, Long userId, long l);
 
-    String importLoopNew(List<OrderExcelImportLoopNewModel> orderList, Long userId, long l);
+    String importLoopNew(List<OrderExcelImportLoopNewModel> orderList, Long userId, long l, Integer renew);
 
     String importOnce(List<OrderExcelImportOnceModel> orderList, Long userId, long l);
 

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

@@ -135,8 +135,8 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
         Long userId = SecurityUtils.getUserId();
         List<BizArchiveInputDetail> details = archiveInputDetailService.query().eq("contract_id", bizArchiveInput.getId()).list();
         details.forEach(l -> {
-            BizArchiveInputDetail detail = bizArchiveInput.getDetails().stream().filter(v -> v.getId().equals(l.getId())).findFirst().orElse(l);
-            l.setRedirect(detail.getRedirect() != null ? detail.getRedirect() : false);
+//            BizArchiveInputDetail detail = bizArchiveInput.getDetails().stream().filter(v -> v.getId().equals(l.getId())).findFirst().orElse(l);
+            l.setRedirect(l.getRedirect() != null ? l.getRedirect() : false);
         });
         List<BizArchiveInputDetailProcess> processes = archiveInputDetailProcessService.query().eq("contract_id", bizArchiveInput.getId()).list();
         List<BizWorkOrder> newWorkOrders = new ArrayList<>();
@@ -1321,7 +1321,7 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
     }
 
     @Override
-    public String importLoopNew(@Validated List<OrderExcelImportLoopNewModel> orderList, Long userId, long tenantId) {
+    public String importLoopNew(@Validated List<OrderExcelImportLoopNewModel> orderList, Long userId, long tenantId, Integer renew) {
         if (StringUtils.isNull(orderList) || orderList.size() == 0) {
             throw new ServiceException("导入数据不能为空!");
         }
@@ -1717,10 +1717,22 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
             successMsg.append("<br/>").append(successNum).append("、订单 ").append(item.getContractNo()).append(" 导入成功");
         }
         super.saveBatch(archiveInputs);
+
+
         archiveInputDetailService.saveBatch(archiveInputDetails);
-        workOrderService.saveBatch(bizWorkOrders);
-        workOrderDetailService.saveBatch(bizWorkOrderDetails);
-        bizWorkOrders.forEach(this::addLoopTasks);
+
+        if(renew == 1) {
+            for(BizArchiveInput bizArchiveInput : archiveInputs) {
+                BizArchiveInput byId = getById(bizArchiveInput.getId());
+                verify(byId);
+                saveDetailMonth(byId);
+            }
+        } else {
+            workOrderService.saveBatch(bizWorkOrders);
+            workOrderDetailService.saveBatch(bizWorkOrderDetails);
+            bizWorkOrders.forEach(this::addLoopTasks);
+        }
+
         archiveInputs.forEach(this::saveDetailMonth);
         if (failureNum > 0) {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");