From f3529363cc63b4729a429f80a4827b71df0cd5dd Mon Sep 17 00:00:00 2001
From: cy <1664593601@qq.com>
Date: 星期五, 10 十一月 2023 11:26:23 +0800
Subject: [PATCH] feat: 上传

---
 consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java |   98 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 92 insertions(+), 6 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 c5b0200..4db2cf8 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
@@ -7,19 +7,20 @@
 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
      */
@@ -154,6 +156,7 @@
 
     /**
      * 鏍规嵁鐗╁搧id鏌ヨ鐗╁搧璇︽儏
+     *
      * @author 鍗㈠簡闃�
      * @date 2023/9/26
      */
@@ -171,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);
@@ -188,6 +191,10 @@
         //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.淇敼瑙勬牸鍨嬪彿鐨勫崟浣�
         List<BaseGoodsModels> modelsList = param.getModels();
@@ -201,7 +208,7 @@
     }
 
     /**
-     * @Description  鏍规嵁鐗╁搧鍚嶇О鍜屽垎绫籭d鏌ヨ鐗╁搧
+     * @Description 鏍规嵁鐗╁搧鍚嶇О鍜屽垎绫籭d鏌ヨ鐗╁搧
      * @Author 鍗㈠簡闃�
      * @Date 2023/10/24
      */
@@ -218,4 +225,83 @@
 
         return this.get(sql.toString(), paramts, new BaseGoodsTemplate());
     }
+
+    /**
+     * 鏍规嵁鍨嬪彿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
+     */
+    public int updateStatus(BaseGoodsTemplate goodsTemplate) {
+        return this.update(goodsTemplate);
+    }
+
+    /**
+     * @Description 鏍规嵁鐗╁搧id鍒犻櫎鐗╁搧
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/10/25
+     */
+    public int updateById(BaseGoodsTemplate goodsTemplate, S_user_core currentUser) {
+        goodsTemplate.setStates(Constants.STATES_DELETED);
+        //鍒犻櫎鏃堕棿
+        goodsTemplate.setDTime(DateUtils.getDateTimeNumber(System.currentTimeMillis()));
+        //鍒犻櫎浜篿d鍜屽垹闄や汉濮撳悕
+        goodsTemplate.setDUserId(currentUser.getId());
+        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> queryByAgencyId(Long agencyId) {
+        StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_template WHERE 1=1 ");
+        Map<String, Object> params = new HashMap<>();
+        if (agencyId != null) {
+            sql.append(" AND model.id=:modelId");
+            params.put("agencyId", agencyId);
+        }
+        return this.select(sql.toString(), params, new BaseGoodsTemplate());
+    }
 }

--
Gitblit v1.9.1