Sfoglia il codice sorgente

fix:单次合同导入时添加重复判断

ly 9 mesi fa
parent
commit
e1428d10ea

+ 14 - 0
src/main/java/cn/ezhizao/project/business/order/service/impl/BizArchiveInputServiceImpl.java

@@ -1327,6 +1327,9 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
         if (StringUtils.isNull(orderList) || orderList.size() == 0) {
             throw new ServiceException("导入数据不能为空!");
         }
+        List<String> contractNo = orderList.stream().map(m -> m.getContractNo()).collect(Collectors.toList());
+        Map<String, Long> nameCountMap = contractNo.stream()
+                .collect(Collectors.groupingBy(name -> name, Collectors.counting()));
         List<BizArchiveInput> archiveInputs = new ArrayList<>();
         List<BizWorkOrder> bizWorkOrders = new ArrayList<>();
         List<BizArchiveInputDetail> archiveInputDetails = new ArrayList<>();
@@ -1335,6 +1338,7 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
         BizSource sourceCondition = new BizSource();
         sourceCondition.setTenantId(tenantId);
         List<BizSource> sources = bizSourceService.getList(sourceCondition);
+        List<String> contNOs = this.query().eq("service_type", 2).eq("tenant_id", tenantId).list().stream().map(m -> m.getContractNo()).collect(Collectors.toList());
         int successNum = 0;
         int failureNum = 0;
         StringBuilder successMsg = new StringBuilder();
@@ -1347,6 +1351,16 @@ public class BizArchiveInputServiceImpl extends ServiceImpl<BizArchiveInputMappe
                 failureMsg.append("<br/>").append(failureNum).append("、客户 ").append(item.getCompanyName()).append(" 不存在");
                 continue;
             }
+            if (contNOs.contains(item.getContractNo())) {
+                failureNum++;
+                failureMsg.append("<br/>").append(failureNum).append("合同编号 ").append(item.getContractNo()).append("已存在不能重复导入");
+                continue;
+            }
+            if (nameCountMap.get(item.getContractNo()) > 1L) {
+                failureNum++;
+                failureMsg.append("<br/>").append(failureNum).append("导入的合同编号 ").append(item.getContractNo()).append("不能重复");
+                continue;
+            }
             SysUser user = userService.selectUserByUserNameAndTenantId(item.getSignerName(), String.valueOf(tenantId));
 //            if (user == null) {
 //                failureNum++;