Răsfoiți Sursa

求购导出优化

yzc 2 ani în urmă
părinte
comite
6c70e6e323

+ 19 - 9
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -173,19 +173,19 @@ public class KwpWantBuyService {
         Map<Long, String> entMap = entList.stream()
                 .collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
         Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRADE_TYPE.getType(),
-                DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.GOODS_STATUS.getType()));
-        Map<String, String> tradeMap, productNameMap, goodsStatusMap;
+                DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.WANT_BUY_STATUS.getType()));
+        Map<String, String> tradeMap, productNameMap, statusMap;
         if (CollectionUtils.isEmpty(dict)) {
             tradeMap = new HashMap<>();
             productNameMap = new HashMap<>();
-            goodsStatusMap = new HashMap<>();
+            statusMap = new HashMap<>();
         } else {
             tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
                     new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
             productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
                     new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
-            goodsStatusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.GOODS_STATUS.getType())) ?
-                    new HashMap<>() : dict.get(DictTypeEnum.GOODS_STATUS.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.WANT_BUY_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.WANT_BUY_STATUS.getType());
         }
         //把查询出来的集合wantBuyTradings里面对的tranding 转成字符串放在String里面
         wantBuyDto.forEach(wantBuySelectRes -> {
@@ -194,7 +194,7 @@ public class KwpWantBuyService {
                     .collect(Collectors.toList());
             wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
             wantBuySelectRes.setGoodsTypeLabel(productNameMap.get(wantBuySelectRes.getGoodsType()));
-            wantBuySelectRes.setStatusLabel(goodsStatusMap.get(String.valueOf(wantBuySelectRes.getStatus())));
+            wantBuySelectRes.setStatusLabel(statusMap.get(String.valueOf(wantBuySelectRes.getStatus())));
             wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
         });
 
@@ -543,17 +543,24 @@ public class KwpWantBuyService {
         if (CollectionUtils.isEmpty(wantBuyDto)) {
             return Collections.emptyList();
         }
+        // 获取供应企业信息
+        Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(
+                wantBuyDto.stream().map(WantBuySelectRes::getEntId).collect(Collectors.toList()));
+        // 字典信息
         Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRADE_TYPE.getType(),
-                DictTypeEnum.PRODUCT_NAME_TYPE.getType()));
-        Map<String, String> tradeMap, productNameMap;
+                DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.WANT_BUY_STATUS.getType()));
+        Map<String, String> tradeMap, productNameMap, statusMap;
         if (CollectionUtils.isEmpty(dict)) {
             tradeMap = new HashMap<>();
             productNameMap = new HashMap<>();
+            statusMap = new HashMap<>();
         } else {
             tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
                     new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
             productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
                     new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.WANT_BUY_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.WANT_BUY_STATUS.getType());
         }
         List<WantBuyExport> result = new ArrayList<>();
         AtomicInteger i = new AtomicInteger(1);
@@ -562,7 +569,10 @@ public class KwpWantBuyService {
             List<String> tradings = e.getWantBuyTradings().stream()
                     .map(wantBuyTradingRes -> tradeMap.get(wantBuyTradingRes.getTrading()))
                     .collect(Collectors.toList());
-            export.setSerialNumber(String.valueOf(i.getAndIncrement())).setTradings(String.join(Global.COMMA, tradings))
+            export.setSerialNumber(String.valueOf(i.getAndIncrement()))
+                    .setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
+                    .setEntName(Objects.nonNull(entMap.get(e.getEntId())) ? entMap.get(e.getEntId()).getFirmName() : null)
+                    .setTradings(String.join(Global.COMMA, tradings))
                     .setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
                     .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()))
                     .setUpdateTime(Objects.isNull(e.getUpdateTime()) ? null : DateUtil.getDateTime(e.getUpdateTime()));