소스 검색

1批量导入对模板中的客户编码去重

Xiaojh 4 년 전
부모
커밋
914a965a4a
1개의 변경된 파일16개의 추가작업 그리고 1개의 파일을 삭제
  1. 16 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

+ 16 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/importfile/AsyncTaskImportService.java

@@ -41,7 +41,10 @@ import java.io.File;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -925,6 +928,7 @@ public class AsyncTaskImportService {
         String msg = "";
         BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
         BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
+        Map<String,String> number_maps = new HashMap<String,String>();
         if(file != null){
             try{
                 InputStream inputStream = new FileInputStream(record.getImportFilePath());
@@ -1011,6 +1015,17 @@ public class AsyncTaskImportService {
                                String housetype = housetypeCell.getStringCellValue().trim();
                                String customerGroup = customergroupCell.getStringCellValue().trim();
 
+                               //去重
+                               if(!number_maps.containsKey(accountnumber)){
+                                   number_maps.put(accountnumber,accountnumber);
+                               }else{
+                                   failTime++ ;
+                                   msg +="客户编码【"+accountnumber+"】在模板中已重复,";
+                                   log.info("客户编码【"+accountnumber+"】在模板中已重复,");
+                                   c_remark.setCellValue("客户编码【"+accountnumber+"】在模板中已重复,");
+                                   continue;
+                               }
+
                                //校验手机号是否正确
                                if(StringUtils.isNotBlank(telephone)){
                                    String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
@@ -1267,7 +1282,6 @@ public class AsyncTaskImportService {
                 messageContent.append("导入失败");
                 messageContent.append(failTime);
                 messageContent.append("条。");
-                messageContent.append("失败原因:"+msg);
                 //失败列表
                 if(failTime > 0){
                     String FailFilePath = this.getFilePath();
@@ -1275,6 +1289,7 @@ public class AsyncTaskImportService {
                     hssfWorkbook.write(os);
                     os.close();
                     record.setFailFilePath(FailFilePath);
+                    messageContent.append("失败原因:"+msg);
                 }
 
                 inputStream.close();