Просмотр исходного кода

运需管理、求购管理相关字典映射走字典查询接口

yzc 2 лет назад
Родитель
Сommit
027271834e

+ 1 - 1
sckw-modules/sckw-message/src/main/java/com/sckw/message/model/vo/res/KwmMessageListResVO.java

@@ -59,7 +59,7 @@ public class KwmMessageListResVO implements Serializable {
     /**
      * 提交人
      */
-    private Long creatBy;
+    private Long createBy;
 
     /**
      * 提交人姓名

+ 46 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/TransportDemandStatusEnum.java

@@ -0,0 +1,46 @@
+package com.sckw.order.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @desc: 运需状态枚举
+ * @author: yzc
+ * @date: 2023-09-19 9:42
+ */
+@AllArgsConstructor
+@Getter
+public enum TransportDemandStatusEnum {
+
+    /**
+     * 运需状态枚举
+     */
+    SAVED(0, "已保存"),
+    PUT_ON_SHELVES(1, "已上架"),
+    TAKE_OFF_SHELVES(2, "已下架");
+
+    private final Integer code;
+    private final String msg;
+
+
+    public static String getNameByCode(Integer code) {
+        TransportDemandStatusEnum[] enums = TransportDemandStatusEnum.values();
+        for (TransportDemandStatusEnum instance : enums) {
+            if (Objects.equals(instance.getCode(), code)) {
+                return instance.getMsg();
+            }
+        }
+        return null;
+    }
+
+    public static List<TransportDemandStatusEnum> getSortList() {
+        TransportDemandStatusEnum[] enums = TransportDemandStatusEnum.values();
+        return Arrays.stream(enums).sorted(Comparator.comparingInt(TransportDemandStatusEnum::getCode)).collect(Collectors.toList());
+    }
+}

+ 2 - 2
sckw-modules/sckw-order/src/main/java/com/sckw/order/enums/WantBuyStatusEnum.java

@@ -19,10 +19,10 @@ import java.util.stream.Collectors;
 public enum WantBuyStatusEnum {
 
     /**
-     * 产品状态枚举
+     * 求购状态枚举
      */
     SAVED(0, "已保存"),
-    PUT_ON_SHELVES(1, "上架"),
+    PUT_ON_SHELVES(1, "上架"),
     TAKE_OFF_SHELVES(2, "已下架");
 
     private final Integer code;

+ 77 - 22
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTransportDemandService.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
@@ -21,6 +20,7 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.excel.utils.DateUtil;
 import com.sckw.order.dao.KwoTransportDemandMapper;
+import com.sckw.order.enums.TransportDemandStatusEnum;
 import com.sckw.order.model.KwoTransportDemand;
 import com.sckw.order.model.dto.TransportDemandExport;
 import com.sckw.order.model.vo.req.*;
@@ -65,7 +65,7 @@ public class KwoTransportDemandService {
      */
     public void addDraft(AddTransportDemandDraftParam param) {
         KwoTransportDemand transportDemand = BeanUtils.copyProperties(param, KwoTransportDemand.class);
-        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_0.getValue()));
+        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(TransportDemandStatusEnum.SAVED.getCode());
         kwoTransportDemandMapper.insert(transportDemand);
     }
 
@@ -78,7 +78,7 @@ public class KwoTransportDemandService {
      */
     public void addShelves(AddTransportDemandParam param) {
         KwoTransportDemand transportDemand = BeanUtils.copyProperties(param, KwoTransportDemand.class);
-        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()));
+        transportDemand.setEntId(LoginUserHolder.getEntId()).setStatus(TransportDemandStatusEnum.PUT_ON_SHELVES.getCode());
         kwoTransportDemandMapper.insert(transportDemand);
     }
 
@@ -94,10 +94,25 @@ public class KwoTransportDemandService {
         if (Objects.isNull(transportDemand)) {
             throw new BusinessException("数据不存在!");
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()));
+        Map<String, String> productNameMap, tradeMap, statusMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+            statusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
+        }
         TransportDemandDetailRes res = BeanUtils.copyProperties(transportDemand, TransportDemandDetailRes.class);
-        res.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), res.getGoodsType()))
-                .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), res.getTrading()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(res.getStatus())));
+        res.setGoodsTypeLabel(productNameMap.get(res.getGoodsType()))
+                .setTradingLabel(tradeMap.get(res.getTrading()))
+                .setStatusLabel(statusMap.get(String.valueOf(res.getStatus())));
         return res;
     }
 
@@ -193,6 +208,21 @@ public class KwoTransportDemandService {
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         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.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRADE_TYPE.getType(), DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()));
+        Map<String, String> productNameMap, tradeMap, statusMap;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            productNameMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType()) : new HashMap<>();
+            tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
+            statusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType())) ?
+                    dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()) : new HashMap<>();
+        } else {
+            productNameMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        }
         List<TransportDemandListRes> result = Lists.newArrayList();
         list.forEach(e -> {
             TransportDemandListRes demand = BeanUtils.copyProperties(e, TransportDemandListRes.class);
@@ -200,9 +230,9 @@ public class KwoTransportDemandService {
             String loadDetailAddress = Objects.nonNull(e.getLoadDetailAddress()) ? e.getLoadDetailAddress() : "";
             String unloadAreaName = Objects.nonNull(e.getUnloadAreaName()) ? e.getUnloadAreaName() : "";
             String unloadDetailAddress = Objects.nonNull(e.getUnloadDetailAddress()) ? e.getUnloadDetailAddress() : "";
-            demand.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
-                    .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(e.getStatus())))
+            demand.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setTradingLabel(tradeMap.get(e.getTrading()))
+                    .setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
                     .setLoadAddress(loadAreaName + loadDetailAddress)
                     .setUnloadAddress(unloadAreaName + unloadDetailAddress)
                     .setEntName(entMap.get(e.getEntId()));
@@ -278,9 +308,9 @@ public class KwoTransportDemandService {
         all.setName("全部").setTotal(CollectionUtils.isEmpty(demands) ? 0 : demands.size());
         tableTops.add(all);
 
-        List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
+        List<TransportDemandStatusEnum> enums = TransportDemandStatusEnum.getSortList();
         enums.forEach(e -> {
-            Integer value = Integer.valueOf(e.getValue());
+            Integer value = e.getCode();
             Integer systemType = LoginUserHolder.getSystemType();
             if (Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode()) && Objects.equals(value, Global.NO)) {
                 return;
@@ -288,7 +318,7 @@ public class KwoTransportDemandService {
             List<KwoTransportDemand> list = map.get(value);
             int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
             TableTop tableTop = new TableTop();
-            tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
+            tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
             tableTops.add(tableTop);
 
         });
@@ -319,18 +349,30 @@ public class KwoTransportDemandService {
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         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.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType()));
+        Map<String, String> productNameMap, statusMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            statusMap = new HashMap<>();
+        } else {
+            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.TRANSPORT_DEMAND_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType());
+        }
         List<TransportDemandExport> result = Lists.newArrayList();
         AtomicInteger i = new AtomicInteger(1);
         demands.forEach(e -> {
             TransportDemandExport export = BeanUtils.copyProperties(e, TransportDemandExport.class);
-            export.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setStatusLabel(DictEnum.getLabel(DictTypeEnum.TRANSPORT_DEMAND_STATUS.getType(), String.valueOf(e.getStatus())))
+            export.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setStatusLabel(statusMap.get(String.valueOf(e.getStatus())))
                     .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress()).setSerialNumber(String.valueOf(i.getAndIncrement()))
                     .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress())
                     .setDeadline(Objects.isNull(e.getDeadline()) ? null : DateUtil.dateToStr(e.getDeadline()))
                     .setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()))
                     .setUpdateTime(Objects.isNull(e.getUpdateTime()) ? null : DateUtil.getDateTime(e.getUpdateTime()))
-                    .setEntName(entMap != null ? entMap.get(e.getEntId()) : null);
+                    .setEntName(entMap.get(e.getEntId()));
             result.add(export);
         });
         return result;
@@ -346,14 +388,14 @@ public class KwoTransportDemandService {
     public void batchPutOnShelves(List<Long> ids) {
         LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(KwoTransportDemand::getId, ids)
-                .ne(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+                .ne(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
         List<KwoTransportDemand> list = kwoTransportDemandMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据!");
         }
         LambdaUpdateWrapper<KwoTransportDemand> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+        updateWrapper.set(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .in(KwoTransportDemand::getId, ids);
         kwoTransportDemandMapper.update(null, updateWrapper);
     }
@@ -368,14 +410,14 @@ public class KwoTransportDemandService {
     public void batchTakeOffShelves(List<Long> ids) {
         LambdaQueryWrapper<KwoTransportDemand> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(KwoTransportDemand::getId, ids)
-                .eq(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+                .eq(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoTransportDemand::getEntId, LoginUserHolder.getEntId()).eq(KwoTransportDemand::getDelFlag, Global.NO);
         List<KwoTransportDemand> list = kwoTransportDemandMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("下架操作仅针对“已上架”状态的单据");
         }
         LambdaUpdateWrapper<KwoTransportDemand> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_2.getValue()))
+        updateWrapper.set(KwoTransportDemand::getStatus, TransportDemandStatusEnum.TAKE_OFF_SHELVES.getCode())
                 .in(KwoTransportDemand::getId, ids);
         kwoTransportDemandMapper.update(null, updateWrapper);
     }
@@ -417,7 +459,7 @@ public class KwoTransportDemandService {
                 wrapper.in(KwoTransportDemand::getGoodsType, goodsTypes);
             }
         }
-        wrapper.eq(KwoTransportDemand::getStatus, Integer.valueOf(DictEnum.TRANSPORT_DEMAND_STATUS_1.getValue()))
+        wrapper.eq(KwoTransportDemand::getStatus, TransportDemandStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoTransportDemand::getDelFlag, Global.NO);
         Integer loadCode = param.getLoadAreaCode();
         if (Objects.nonNull(loadCode) && Objects.nonNull(param.getLoadAreaLevel())) {
@@ -456,12 +498,25 @@ public class KwoTransportDemandService {
         }
         List<Long> entIds = list.stream().map(KwoTransportDemand::getEntId).toList();
         Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(entIds);
+
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.TRADE_TYPE.getType()));
+        Map<String, String> productNameMap, tradeMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+        }
         List<TransportDemandSquaresListRes> result = Lists.newArrayList();
         list.forEach(e -> {
             TransportDemandSquaresListRes res = BeanUtils.copyProperties(e, TransportDemandSquaresListRes.class);
             EntCacheResDto ent = entMap.get(e.getEntId());
-            res.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
-                    .setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading()))
+            res.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()))
+                    .setTradingLabel(tradeMap.get(e.getTrading()))
                     .setLoadAddress(e.getLoadAreaName() + e.getLoadDetailAddress())
                     .setUnloadAddress(e.getUnloadAreaName() + e.getUnloadDetailAddress())
                     .setCreateTime(DateUtils.format(e.getCreateTime()))

+ 84 - 26
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwpWantBuyService.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.Global;
@@ -21,6 +20,7 @@ import com.sckw.excel.utils.DateUtil;
 import com.sckw.order.dao.KwpWantBuyAddressMapper;
 import com.sckw.order.dao.KwpWantBuyMapper;
 import com.sckw.order.dao.KwpWantBuyTradingMapper;
+import com.sckw.order.enums.WantBuyStatusEnum;
 import com.sckw.order.model.KwoWantBuy;
 import com.sckw.order.model.KwoWantBuyAddress;
 import com.sckw.order.model.KwoWantBuyTrading;
@@ -92,7 +92,7 @@ public class KwpWantBuyService {
                 wantBuySelectParam.setEntIds(entIds);
             }
         }
-        wantBuySelectParam.setStatus(Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()));
+        wantBuySelectParam.setStatus(WantBuyStatusEnum.PUT_ON_SHELVES.getCode());
 
         // 分页查询求购列表
         PageHelper.startPage(wantBuySelectParam.getPage(), wantBuySelectParam.getPageSize());
@@ -112,14 +112,29 @@ 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;
+        if (CollectionUtils.isNotEmpty(dict)) {
+            tradeMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.TRADE_TYPE.getType()) : new HashMap<>();
+            productNameMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType()) : new HashMap<>();
+            goodsStatusMap = CollectionUtils.isNotEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    dict.get(DictTypeEnum.GOODS_STATUS.getType()) : new HashMap<>();
+        } else {
+            tradeMap = new HashMap<>();
+            productNameMap = new HashMap<>();
+            goodsStatusMap = new HashMap<>();
+        }
         // 对求购列表进行数据处理
         res.forEach(e -> {
             List<String> tradings = e.getWantBuyTradings().stream()
-                    .map(f -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), f.getTrading()))
+                    .map(f -> tradeMap.get(f.getTrading()))
                     .collect(Collectors.toList());
             e.setTradings(String.join(Global.COMMA, tradings));
-            e.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()));
-            e.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(e.getStatus())));
+            e.setGoodsTypeLabel(productNameMap.get(e.getGoodsType()));
+            e.setStatusLabel(goodsStatusMap.get(String.valueOf(e.getStatus())));
             e.setEntName(Objects.nonNull(entMap.get(e.getEntId())) ? entMap.get(e.getEntId()) : null);
         });
 
@@ -157,14 +172,29 @@ public class KwpWantBuyService {
         List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
         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;
+        if (CollectionUtils.isEmpty(dict)) {
+            tradeMap = new HashMap<>();
+            productNameMap = new HashMap<>();
+            goodsStatusMap = 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());
+        }
         //把查询出来的集合wantBuyTradings里面对的tranding 转成字符串放在String里面
         wantBuyDto.forEach(wantBuySelectRes -> {
             List<String> tradings = wantBuySelectRes.getWantBuyTradings().stream()
-                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .map(wantBuyTradingRes -> tradeMap.get(wantBuyTradingRes.getTrading()))
                     .collect(Collectors.toList());
             wantBuySelectRes.setTradings(String.join(Global.COMMA, tradings));
-            wantBuySelectRes.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), wantBuySelectRes.getGoodsType()));
-            wantBuySelectRes.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(wantBuySelectRes.getStatus())));
+            wantBuySelectRes.setGoodsTypeLabel(productNameMap.get(wantBuySelectRes.getGoodsType()));
+            wantBuySelectRes.setStatusLabel(goodsStatusMap.get(String.valueOf(wantBuySelectRes.getStatus())));
             wantBuySelectRes.setEntName(Objects.nonNull(entMap.get(wantBuySelectRes.getEntId())) ? entMap.get(wantBuySelectRes.getEntId()) : null);
         });
 
@@ -206,8 +236,7 @@ public class KwpWantBuyService {
      **/
     @Transactional(rollbackFor = Exception.class)
     public void addDraft(AddDraftWantBuyParam param) {
-        Integer status = Integer.valueOf(DictEnum.WANT_BUY_STATUS_0.getValue());
-        addWantBuy(BeanUtils.copyProperties(param, AddWantBuyParam.class), status);
+        addWantBuy(BeanUtils.copyProperties(param, AddWantBuyParam.class), WantBuyStatusEnum.SAVED.getCode());
     }
 
     /**
@@ -219,8 +248,7 @@ public class KwpWantBuyService {
      **/
     @Transactional(rollbackFor = Exception.class)
     public void addShelves(AddWantBuyParam param) {
-        Integer status = Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue());
-        addWantBuy(param, status);
+        addWantBuy(param, WantBuyStatusEnum.PUT_ON_SHELVES.getCode());
     }
 
     /**
@@ -263,14 +291,14 @@ public class KwpWantBuyService {
      **/
     public void batchPutOnShelves(List<Long> ids) {
         LambdaQueryWrapper<KwoWantBuy> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(KwoWantBuy::getId, ids).ne(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()))
+        wrapper.in(KwoWantBuy::getId, ids).ne(KwoWantBuy::getStatus, WantBuyStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoWantBuy::getEntId, LoginUserHolder.getEntId()).eq(KwoWantBuy::getDelFlag, Global.NO);
         List<KwoWantBuy> list = kwpWantBuyMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据!");
         }
         LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()))
+        updateWrapper.set(KwoWantBuy::getStatus, WantBuyStatusEnum.PUT_ON_SHELVES.getCode())
                 .in(KwoWantBuy::getId, ids);
         kwpWantBuyMapper.update(null, updateWrapper);
     }
@@ -283,14 +311,14 @@ public class KwpWantBuyService {
     public void batchTakeOffShelves(WantBuyDels param) {
         List<Long> ids = StringUtils.splitStrToList(param.getIds(), Long.class);
         LambdaQueryWrapper<KwoWantBuy> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(KwoWantBuy::getId, ids).eq(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_1.getValue()))
+        wrapper.in(KwoWantBuy::getId, ids).eq(KwoWantBuy::getStatus, WantBuyStatusEnum.PUT_ON_SHELVES.getCode())
                 .eq(KwoWantBuy::getEntId, LoginUserHolder.getEntId()).eq(KwoWantBuy::getDelFlag, Global.NO);
         List<KwoWantBuy> list = kwpWantBuyMapper.selectList(wrapper);
         if (!Objects.equals(ids.size(), list.size())) {
             throw new BusinessException("下架操作仅针对“已上架”状态的单据");
         }
         LambdaUpdateWrapper<KwoWantBuy> updateWrapper = new LambdaUpdateWrapper<>();
-        updateWrapper.set(KwoWantBuy::getStatus, Integer.valueOf(DictEnum.WANT_BUY_STATUS_2.getValue())).in(KwoWantBuy::getId, ids);
+        updateWrapper.set(KwoWantBuy::getStatus, WantBuyStatusEnum.TAKE_OFF_SHELVES.getCode()).in(KwoWantBuy::getId, ids);
         kwpWantBuyMapper.update(null, updateWrapper);
     }
 
@@ -331,14 +359,32 @@ public class KwpWantBuyService {
             throw new BusinessException("求购信息不存在");
         }
         WantBuyDetailRes responseData = BeanUtils.copyProperties(kwoWantBuy, WantBuyDetailRes.class);
-        responseData.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), responseData.getGoodsType()))
-                .setStatusLabel(DictEnum.getLabel(DictTypeEnum.WANT_BUY_STATUS.getType(), String.valueOf(responseData.getStatus())));
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
+                DictTypeEnum.WANT_BUY_STATUS.getType(), DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), DictTypeEnum.TRADE_TYPE.getType()));
+        Map<String, String> productNameMap, wantBuyStatusMap, orderAddressMap, tradeMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            productNameMap = new HashMap<>();
+            wantBuyStatusMap = new HashMap<>();
+            orderAddressMap = new HashMap<>();
+            tradeMap = new HashMap<>();
+        } else {
+            productNameMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
+            wantBuyStatusMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.WANT_BUY_STATUS.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.WANT_BUY_STATUS.getType());
+            orderAddressMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TORDER_ADDRESS_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TORDER_ADDRESS_TYPE.getType());
+            tradeMap = CollectionUtils.isEmpty(dict.get(DictTypeEnum.TRADE_TYPE.getType())) ?
+                    new HashMap<>() : dict.get(DictTypeEnum.TRADE_TYPE.getType());
+        }
+        responseData.setGoodsTypeLabel(productNameMap.get(responseData.getGoodsType()))
+                .setStatusLabel(wantBuyStatusMap.get(String.valueOf(responseData.getStatus())));
         //求购地址信息
         KwoWantBuyAddress address = kwpWantBuyAddressMapper.selectOne(new LambdaQueryWrapper<KwoWantBuyAddress>()
                 .eq(KwoWantBuyAddress::getWantBuyId, id).eq(KwoWantBuyAddress::getDelFlag, Global.NO).last("LIMIT 1"));
         if (Objects.nonNull(address)) {
             WantBuyAddressDetailRes wantBuyAddressInfo = BeanUtils.copyProperties(address, WantBuyAddressDetailRes.class);
-            wantBuyAddressInfo.setTypeLabel(DictEnum.getLabel(DictTypeEnum.TORDER_ADDRESS_TYPE.getType(), wantBuyAddressInfo.getType()));
+            wantBuyAddressInfo.setTypeLabel(orderAddressMap.get(wantBuyAddressInfo.getType()));
             responseData.setAddressInfo(wantBuyAddressInfo);
         }
         //获取求购企业信息
@@ -353,7 +399,7 @@ public class KwpWantBuyService {
             responseData.setTradings(tradings);
             //改成stream流的方式
             List<String> result = tradings.stream()
-                    .map(trading -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), trading))
+                    .map(tradeMap::get)
                     .collect(Collectors.toList());
             String tradingLabels = String.join(Global.COMMA, result);
             //获取到的是一个集合,需要转换成字符串
@@ -454,9 +500,9 @@ public class KwpWantBuyService {
         TableTop all = new TableTop();
         all.setName("全部").setTotal(CollectionUtils.isEmpty(result) ? 0 : result.size());
         tableTops.add(all);
-        List<DictEnum> enums = DictEnum.getEnumsByType(DictTypeEnum.WANT_BUY_STATUS.getType());
+        List<WantBuyStatusEnum> enums = WantBuyStatusEnum.getSortList();
         enums.forEach(e -> {
-            Integer value = Integer.valueOf(e.getValue());
+            Integer value = e.getCode();
             Integer systemType = LoginUserHolder.getSystemType();
             if (Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode()) && Objects.equals(value, Global.NO)) {
                 return;
@@ -464,7 +510,7 @@ public class KwpWantBuyService {
             List<WantBuySelectRes> list = map.get(value);
             int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
             TableTop tableTop = new TableTop();
-            tableTop.setName(e.getLabel()).setValue(value).setTotal(total);
+            tableTop.setName(e.getMsg()).setValue(value).setTotal(total);
             tableTops.add(tableTop);
         });
         TableBottom tableBottom = new TableBottom();
@@ -497,15 +543,27 @@ public class KwpWantBuyService {
         if (CollectionUtils.isEmpty(wantBuyDto)) {
             return Collections.emptyList();
         }
+        Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.TRADE_TYPE.getType(),
+                DictTypeEnum.PRODUCT_NAME_TYPE.getType()));
+        Map<String, String> tradeMap, productNameMap;
+        if (CollectionUtils.isEmpty(dict)) {
+            tradeMap = new HashMap<>();
+            productNameMap = 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());
+        }
         List<WantBuyExport> result = new ArrayList<>();
         AtomicInteger i = new AtomicInteger(1);
         wantBuyDto.forEach(e -> {
             WantBuyExport export = BeanUtils.copyProperties(e, WantBuyExport.class);
             List<String> tradings = e.getWantBuyTradings().stream()
-                    .map(wantBuyTradingRes -> DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), wantBuyTradingRes.getTrading()))
+                    .map(wantBuyTradingRes -> tradeMap.get(wantBuyTradingRes.getTrading()))
                     .collect(Collectors.toList());
             export.setSerialNumber(String.valueOf(i.getAndIncrement())).setTradings(String.join(Global.COMMA, tradings))
-                    .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
+                    .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()));
             result.add(export);
@@ -526,7 +584,7 @@ public class KwpWantBuyService {
                 .eq(KwoWantBuy::getDelFlag, Global.NO)
                 .last("LIMIT 1");
         KwoWantBuy wantBuy = kwpWantBuyMapper.selectOne(wrapper);
-        if (Objects.isNull(wantBuy)){
+        if (Objects.isNull(wantBuy)) {
             throw new BusinessException("求购信息不存在");
         }
         WantBuyContactInfoRes res = new WantBuyContactInfoRes();

+ 1 - 1
sckw-modules/sckw-product/src/main/java/com/sckw/product/enums/GoodsStatusEnum.java

@@ -22,7 +22,7 @@ public enum GoodsStatusEnum {
      * 产品状态枚举
      */
     SAVED(0, "已保存"),
-    PUT_ON_SHELVES(1, "上架"),
+    PUT_ON_SHELVES(1, "上架"),
     TAKE_OFF_SHELVES(2, "已下架");
 
     private final Integer code;