Răsfoiți Sursa

商品列表接口优化

yzc 2 ani în urmă
părinte
comite
0a1dc5037b

+ 1 - 1
sckw-modules/sckw-product/src/main/java/com/sckw/product/controller/KwpGoodsController.java

@@ -88,7 +88,7 @@ public class KwpGoodsController {
      */
     @PostMapping(value = "/select", produces = MediaType.APPLICATION_JSON_VALUE)
     public HttpResult select(@RequestBody SelectGoodsListParam params) {
-        return HttpResult.ok(kwpGoodsService.select(params));
+        return HttpResult.ok(kwpGoodsService.select(params, true));
     }
 
     /**

+ 16 - 7
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -397,8 +397,8 @@ public class KwpGoodsService {
      * @Param params:
      * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
      */
-    public PageResult select(SelectGoodsListParam params) {
-        IPage<KwpGoods> goodsIpage = getGoodsLists(params, true);
+    public PageResult select(SelectGoodsListParam params, Boolean isPage) {
+        IPage<KwpGoods> goodsIpage = getGoodsLists(params, isPage);
         List<KwpGoods> goodsLists = goodsIpage.getRecords();
         if (CollectionUtils.isEmpty(goodsLists)) {
             return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), Collections.emptyList());
@@ -409,9 +409,15 @@ public class KwpGoodsService {
         List<Long> userIds = new ArrayList<>();
         goodsLists.forEach(e -> {
             goodsIds.add(e.getId());
-            supplyEntIds.add(e.getSupplyEntId());
-            userIds.add(e.getManager());
-            userIds.add(e.getCreateBy());
+            if (Objects.nonNull(e.getSupplyEntId())){
+                supplyEntIds.add(e.getSupplyEntId());
+            }
+            if (Objects.nonNull(e.getManager())){
+                supplyEntIds.add(e.getManager());
+            }
+            if (Objects.nonNull(e.getCreateBy())){
+                supplyEntIds.add(e.getCreateBy());
+            }
         });
         //地址信息
         Map<Long, KwpGoodsAddress> addressMap = kwpGoodsAddressService.getByGoodsIds(goodsIds)
@@ -423,7 +429,10 @@ public class KwpGoodsService {
         List<UserCacheResDto> userList = remoteSystemService.queryUserCacheByIds(userIds);
         Map<Long, UserCacheResDto> userMap = userList.stream().collect(Collectors.toMap(UserCacheResDto::getId, e -> e, (k1, k2) -> k1));
         //供应企业信息
-        List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        List<EntCacheResDto> entList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(supplyEntIds)) {
+            entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
+        }
         Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
         goodsLists.forEach(e -> {
             Long id = e.getId();
@@ -523,7 +532,7 @@ public class KwpGoodsService {
      * @return: void
      */
     public List<GoodsListExport> export(ExportGoodsListParam params) {
-        PageResult pageResult = select(BeanUtils.copyProperties(params, SelectGoodsListParam.class));
+        PageResult pageResult = select(BeanUtils.copyProperties(params, SelectGoodsListParam.class), false);
         List<GoodsList> goodsLists = pageResult.getList();
         if (CollectionUtils.isEmpty(goodsLists)) {
             return Collections.emptyList();