lyhzzz 1 рік тому
батько
коміт
a1db06b66f
1 змінених файлів з 18 додано та 16 видалено
  1. 18 16
      src/main/java/com/cdf/service/impl/ExcelService.java

+ 18 - 16
src/main/java/com/cdf/service/impl/ExcelService.java

@@ -239,7 +239,6 @@ public class ExcelService {
         HashMap<String, List<String>> productSourceProductMap = new HashMap<>();
         HashMap<String, List<String>> resultPMap = new HashMap<>();
         HashMap<String, List<String>> numMap = new HashMap<>();
-        HashMap<String, Integer> sourceMap = new HashMap<>();
         HashMap<String,ProductSource> productMap = new HashMap<>();
 
         for (HashMap<Integer, String> map : excelRowList) {
@@ -280,34 +279,23 @@ public class ExcelService {
             }
             if(numMap.get(sceneNum) == null){
                 List<HotRelation> hotRelations = hotRelationService.getByNum(sceneNum);
-                for (HotRelation hotRelation : hotRelations) {
-                    sourceMap.put(hotRelation.getHotId(),hotRelation.getProductSourceId());
-                }
                 List<String> sidList = hotRelations.stream().map(HotRelation::getHotId).collect(Collectors.toList());
                 numMap.put(sceneNum,sidList);
             }
-            if(sourceMap.get(sid) == null){
-                continue;
-            }
-            if(!productMap.isEmpty() && !productMap.containsKey(mchId)){
-                errorList.add(colum.toString());
-                continue;
-            }
-            if(productMap.get(mchId) == null){
+            if(productMap.get(sid) == null){
                 ProductSource productSource = productSourceService.getByMchId(mchId);
                 if(productSource == null){
                     errorList.add(colum.toString());
                     continue;
                 }
-                productMap.put(mchId,productSource);
+                productMap.put(sid,productSource);
             }
-            ProductSource productSource = productMap.get(mchId);
-            if(!productSource.getId().equals(sourceMap.get(sid))){
+            ProductSource productSource = productMap.get(sid);
+            if(!mchId.equals(productSource.getCdfMchId())){
                 errorList.add(colum.toString());
                 continue;
             }
 
-
             if(!numMap.get(sceneNum).contains(sid)){
                 errorList.add(colum.toString());
                 continue;
@@ -419,6 +407,7 @@ public class ExcelService {
         Integer colum = 1;
         List<HashMap<Integer, String>> excelRowList = ExcelUtil.getExcelRowList(file);
         HashMap<String,HashMap<String,HashSet<String>>> numMap = new HashMap<>();
+        HashMap<String,ProductSource> sidProMap = new HashMap<>();
         for (HashMap<Integer, String> map : excelRowList) {
             colum ++;
             if(errorList.contains(colum.toString())){
@@ -432,10 +421,18 @@ public class ExcelService {
             if(StringUtils.isBlank(mchId) || StringUtils.isBlank(sceneNum)  || StringUtils.isBlank(pid) || StringUtils.isBlank(sid)){
                 continue;
             }
+
+            if(sidProMap.get(sid) == null){
+                ProductSource productSource = productSourceService.getByMchId(mchId);
+                if(productSource != null){
+                    sidProMap.put(sid,productSource);
+                }
+            }
             numMap.computeIfAbsent(sceneNum, k -> new HashMap<>());
             numMap.get(sceneNum).computeIfAbsent(sid,k -> new HashSet<>());
             numMap.get(sceneNum).get(sid).add(pid);
         }
+
         List<HotRelation> updateList = new ArrayList<>();
         for (String num : numMap.keySet()) {
             HashMap<String, HashSet<String>> sidMap = numMap.get(num);
@@ -444,8 +441,13 @@ public class ExcelService {
                 if(hotRelation == null){
                     continue;
                 }
+                ProductSource productSource = sidProMap.get(sid);
+                if(productSource == null){
+                    continue;
+                }
                 HashSet<String> pidSet = sidMap.get(sid);
                 hotRelation.setRelationIds(JSONArray.toJSONString(pidSet));
+                hotRelation.setProductSourceId(productSource.getId());
                 updateList.add(hotRelation);
             }
         }