From aec9ada120e275d927d297a3caf054a6ca84660a Mon Sep 17 00:00:00 2001
From: jiaosong <jiaosong6760@dingtalk.com>
Date: 星期二, 19 九月 2023 18:45:51 +0800
Subject: [PATCH] #文件地址

---
 server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java |   58 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
index 43775a3..853942b 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
@@ -301,16 +301,16 @@
         MPJLambdaWrapper<BaseGoods> queryWrapper = new MPJLambdaWrapper<>();
 
         queryWrapper.leftJoin(Brand.class,Brand::getId,BaseGoods::getBrandId)
-                .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getBaseDataId)
+                .leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId)
                 .selectAll(BaseGoods.class)
                 .selectAs(Brand::getName,BaseGoodsDTO::getBrandName)
-                .selectAs(BaseCategory::getSortnum,BaseGoodsDTO::getCategoryName)
+                .selectAs(BaseCategory::getName,BaseGoodsDTO::getCategoryName)
                 .eq(BaseGoods::getId,id);
 
         BaseGoodsDTO baseGoodsDTO = baseGoodsJoinMapper.selectJoinOne(BaseGoodsDTO.class, queryWrapper);
         String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
                 + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
-        baseGoodsDTO.setImgfullurl(prefixUrl+baseGoodsDTO.getImgurl());
+        baseGoodsDTO.setImgfullurl(StringUtils.isNotBlank(baseGoodsDTO.getImgurl()) ? prefixUrl+baseGoodsDTO.getImgurl() : null);
 
         List<Multifile> multifiles = multifileMapper.selectList(new QueryWrapper<Multifile>()
                 .eq("OBJ_ID", id)
@@ -530,30 +530,38 @@
 
                 String baseGoodsParamString = s.getBaseGoodsParamString();
                 List<List<String>> collect = Arrays.asList(baseGoodsParamString.split("\n"))
-                        .stream().map(s1 -> Arrays.asList(s1.split("[锛�,:]")) ).collect(Collectors.toList());
-                if (!CollectionUtils.isEmpty(collect)) {
-                    for (int i = 0; i < collect.size(); i++) {
-                        if (!CollectionUtils.isEmpty(baseCategory.getBaseCateParamList())) {
-                            List<String> s2 = collect.get(i);
-                            BaseCateParam baseCateParam = baseCategory.getBaseCateParamList()
-                                    .stream().filter(s3 -> s3.getName().equals(s2.get(0))).findFirst()
-                                    .orElseThrow(() -> new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "閰嶇疆鍙傛暟銆愩�戜笉瀛樺湪"));
-                            BaseGoodsParam baseGoodsParam = new BaseGoodsParam();
-                            baseGoodsParam.setCreator(user.getId());
-                            baseGoodsParam.setCreateDate(new Date());
-                            baseGoodsParam.setEditor(user.getId());
-                            baseGoodsParam.setEditDate(new Date());
-                            baseGoodsParam.setIsdeleted(Constants.ZERO);
-                            baseGoodsParam.setName(baseCateParam.getName());
-                            baseGoodsParam.setRemark(baseCateParam.getRemark());
-                            baseGoodsParam.setStatus(Constants.ZERO);
-                            baseGoodsParam.setSortnum(i + Constants.ONE);
-                            baseGoodsParam.setPramaId(baseCateParam.getId());
-                            baseGoodsParam.setVal(s2.size() > 1 ? s2.get(1) : null);
-                            baseGoodsParam.setGoodsId(baseGoods.getId());
-                            baseGoodsParamMapper.insert(baseGoodsParam);
+                        .stream()
+                        .map(s1 -> Arrays.asList(s1.split("[锛�,:]")) )
+                        .filter(s1->!CollectionUtils.isEmpty(s1))
+                        .collect(Collectors.toList());
 
+                if (!CollectionUtils.isEmpty(baseCategory.getBaseCateParamList())) {
+                    for (int i = 0; i < baseCategory.getBaseCateParamList().size(); i++) {
+
+                        BaseCateParam baseCateParam = baseCategory.getBaseCateParamList().get(i);
+
+                        BaseGoodsParam baseGoodsParam = new BaseGoodsParam();
+                        baseGoodsParam.setCreator(user.getId());
+                        baseGoodsParam.setCreateDate(new Date());
+                        baseGoodsParam.setEditor(user.getId());
+                        baseGoodsParam.setEditDate(new Date());
+                        baseGoodsParam.setIsdeleted(Constants.ZERO);
+                        baseGoodsParam.setName(baseCateParam.getName());
+                        baseGoodsParam.setRemark(baseCateParam.getRemark());
+                        baseGoodsParam.setStatus(Constants.ZERO);
+                        baseGoodsParam.setSortnum(i + Constants.ONE);
+                        baseGoodsParam.setPramaId(baseCateParam.getId());
+                        baseGoodsParam.setGoodsId(baseGoods.getId());
+
+                        if (!CollectionUtils.isEmpty(collect)) {
+                            List<String> list = collect.stream()
+                                    .filter(s3 -> s3.get(0).equals(baseCateParam.getName()))
+                                    .findFirst()
+                                    .orElse(new ArrayList<>());
+                            baseGoodsParam.setVal(list.size() > 1 ? list.get(1) : null);
                         }
+
+                        baseGoodsParamMapper.insert(baseGoodsParam);
                     }
                     ;
                 }

--
Gitblit v1.9.3