From 11f925fdce0f58d1f321f3a13a3f3e84221c6912 Mon Sep 17 00:00:00 2001
From: futian.liu <liufutianyoo@163.com>
Date: 星期一, 13 十一月 2023 09:27:14 +0800
Subject: [PATCH] 整理代码

---
 consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java |   87 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java b/consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java
index e1e7a75..24fa924 100644
--- a/consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java
+++ b/consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java
@@ -3,23 +3,24 @@
 import com.consum.base.Constants;
 import com.consum.base.core.CodeGeneratorService;
 import com.consum.base.pojo.BaseGoodsTemplateParam;
-import com.consum.base.util.IdUtil;
+import com.consum.base.core.utils.IdUtil;
 import com.consum.model.po.BaseCategory;
 import com.consum.model.po.BaseGoodsModels;
 import com.consum.model.po.BaseGoodsTemplate;
+import com.consum.model.po.S_dict_data;
 import com.consum.model.vo.BaseGoodsTemplateVo;
 import com.iplatform.model.po.S_user_core;
 import com.walker.db.page.GenericPager;
 import com.walker.infrastructure.utils.DateUtils;
 import com.walker.infrastructure.utils.StringUtils;
 import com.walker.jdbc.service.BaseServiceImpl;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
-
-import java.util.HashMap;
-import java.util.List;
 
 /**
  * @Description 鐗╁搧妯℃澘
@@ -71,6 +72,7 @@
         //鏍规嵁鍒嗙被id鏌ヨ鍒嗙被
         BaseCategory baseCategory = this.baseCategoryService.get(new BaseCategory(param.getCategoryId()));
         if (baseCategory != null) {
+            baseGoodsTemplate.setCategoryName(baseCategory.getCategoryName());
             String classification = baseCategory.getClassification();
             //鐗╁搧缂栫爜
             String goodsCode = codeGeneratorService.createGoodsTemplateCode(classification);
@@ -109,7 +111,7 @@
     }
 
     /**
-     * @Description  鐗╁搧妯℃澘鍒楄〃鏌ヨ
+     * @Description 鐗╁搧妯℃澘鍒楄〃鏌ヨ
      * @Author 鍗㈠簡闃�
      * @Date 2023/10/24
      */
@@ -146,8 +148,6 @@
         if (param.getStates() != null) {
             sql.append(" and states =:states ");
             paramts.put("states", param.getStates());
-        } else {
-            sql.append(" and states !=3 ");
         }
         sql.append(" ORDER BY CREATE_DATE DESC ");
 
@@ -156,6 +156,7 @@
 
     /**
      * 鏍规嵁鐗╁搧id鏌ヨ鐗╁搧璇︽儏
+     *
      * @author 鍗㈠簡闃�
      * @date 2023/9/26
      */
@@ -173,7 +174,7 @@
         //3.灏佽
         BaseGoodsTemplateVo vo = new BaseGoodsTemplateVo();
         if (goodsTemplate != null) {
-            BeanUtils.copyProperties(goodsTemplate,vo);
+            BeanUtils.copyProperties(goodsTemplate, vo);
         }
         if (!CollectionUtils.isEmpty(modelsList)) {
             vo.setModels(modelsList);
@@ -190,9 +191,18 @@
         //1.淇敼鐗╁搧妯℃澘
         BaseGoodsTemplate baseGoodsTemplate = new BaseGoodsTemplate();
         BeanUtils.copyProperties(param, baseGoodsTemplate);
+        BaseCategory baseCategory = this.baseCategoryService.get(new BaseCategory(param.getCategoryId()));
+        if (baseCategory != null) {
+            baseGoodsTemplate.setCategoryName(baseCategory.getCategoryName());
+        }
         int flag1 = this.update(baseGoodsTemplate);
         //2.淇敼瑙勬牸鍨嬪彿鐨勫崟浣�
+        // TODO id 鐗╁搧鍨嬪彿淇敼寰呮暣鐞�
         List<BaseGoodsModels> modelsList = param.getModels();
+        for (BaseGoodsModels baseGoodsModel : modelsList) {
+            BaseGoodsModels baseGoodsModels = new BaseGoodsModels();
+            BeanUtils.copyProperties(baseGoodsModel, baseGoodsModels);
+        }
         int flag2 = this.update(modelsList);
 
         if (flag1 > 0 && flag2 > 0) {
@@ -203,7 +213,7 @@
     }
 
     /**
-     * @Description  鏍规嵁鐗╁搧鍚嶇О鍜屽垎绫籭d鏌ヨ鐗╁搧
+     * @Description 鏍规嵁鐗╁搧鍚嶇О鍜屽垎绫籭d鏌ヨ鐗╁搧
      * @Author 鍗㈠簡闃�
      * @Date 2023/10/24
      */
@@ -222,7 +232,30 @@
     }
 
     /**
+     * 鏍规嵁鍨嬪彿ID鏌ヨ鐗╁搧淇℃伅
+     *
+     * @param modelId
+     * @return
+     */
+    private static String QUERY_GOODSINFO_BY_MODELID = "SELECT model.MODEL_NAME modelName,model.UNIT,temp.id goodsId, temp.GOODS_CODE goodsCode,temp.GOODS_NAME goodsName,temp.CLASSIFICATION classification,temp.CATEGORY_ID categoryId FROM BASE_GOODS_MODELS model LEFT JOIN BASE_GOODS_TEMPLATE temp ON model.GOODS_TEMPLATES_ID=temp.id WHERE 1=1 ";
+
+    public Map<String, Object> queryGoodsInfoByModelId(Long modelId) {
+        StringBuilder sqlStr = new StringBuilder(QUERY_GOODSINFO_BY_MODELID);
+        Map<String, Object> params = new HashMap<>();
+        if (modelId != null) {
+            sqlStr.append(" AND model.id=:modelId");
+            params.put("modelId", modelId);
+        }
+        List<Map<String, Object>> tempGoodsInfo = this.select(sqlStr.toString(), params);
+        if (CollectionUtils.isEmpty(tempGoodsInfo)) {
+            return null;
+        }
+        return tempGoodsInfo.get(0);
+    }
+
+    /**
      * 淇敼鐘舵��
+     *
      * @author 鍗㈠簡闃�
      * @date 2023/10/25
      */
@@ -244,4 +277,40 @@
         goodsTemplate.setDUserName(currentUser.getUser_name());
         return this.update(goodsTemplate);
     }
+
+    /**
+     * @return
+     * @Description 鏌ヨ浠撳簱绫诲瀷(鏁版嵁瀛楀吀)
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/10/30
+     */
+    public List<S_dict_data> queryClassificationCode() {
+        StringBuilder sql = new StringBuilder("SELECT * FROM s_dict_data WHERE dict_type = 'CLASSIFICATION_CODE' order by dict_sort");
+        return this.select(sql.toString(), new Object[]{}, new S_dict_data());
+    }
+
+    /**
+     * @Description 鏍规嵁鍒嗙被id鏌ヨ鐗╁搧妯℃澘
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/10/30
+     */
+    public List<BaseGoodsTemplate> queryByCategoryId(Long categoryId) {
+        BaseGoodsTemplate goodsTemplate = new BaseGoodsTemplate();
+        goodsTemplate.setCategoryId(categoryId);
+        return this.select(goodsTemplate);
+    }
+
+    public List<BaseGoodsTemplate> queryGoodsTemplateByCategoryId(Long agencyId, Long categoryId) {
+        StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_template WHERE 1=1 ");
+        Map<String, Object> params = new HashMap<>();
+        if (agencyId != null) {
+            sql.append("AND AGENCY_ID=:agencyId");
+            params.put("agencyId", agencyId);
+        }
+        if (categoryId != null) {
+            sql.append("AND CATEGORY_ID=:categoryId");
+            params.put("categoryId", categoryId);
+        }
+        return this.select(sql.toString(), params, new BaseGoodsTemplate());
+    }
 }

--
Gitblit v1.9.1