From 209d9c6f60d96fc29fad0bd2f9dad8fe8424f91f Mon Sep 17 00:00:00 2001 From: futian.liu <liufutianyoo@163.com> Date: 星期五, 17 十一月 2023 18:10:47 +0800 Subject: [PATCH] 调拨管理 --- consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java | 92 +++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 82 insertions(+), 10 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..7db3e79 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 @@ -2,24 +2,26 @@ import com.consum.base.Constants; import com.consum.base.core.CodeGeneratorService; +import com.consum.base.core.utils.IdUtil; import com.consum.base.pojo.BaseGoodsTemplateParam; -import com.consum.base.util.IdUtil; import com.consum.model.po.BaseCategory; import com.consum.model.po.BaseGoodsModels; import com.consum.model.po.BaseGoodsTemplate; +import com.consum.model.po.FinSysTenantUser; +import com.consum.model.po.SDictData; 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 鐗╁搧妯℃澘 @@ -61,7 +63,7 @@ * @Author 鍗㈠簡闃� * @Date 2023/10/24 */ - public int add(BaseGoodsTemplateParam param, S_user_core currentUser) { + public int add(BaseGoodsTemplateParam param, FinSysTenantUser currentUser) { //1.鏂板鐗╁搧妯℃澘 BaseGoodsTemplate baseGoodsTemplate = new BaseGoodsTemplate(); BeanUtils.copyProperties(param, baseGoodsTemplate); @@ -71,6 +73,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); @@ -82,7 +85,9 @@ //褰撳墠鏈烘瀯鐨勭埗绾ф満鏋勭紪鍙� //鏈烘瀯灞傜骇 //鏈烘瀯缂栧彿 + baseGoodsTemplate.setAgencyId(Long.valueOf(currentUser.getTenantId())); //鏈烘瀯鍚嶇О + baseGoodsTemplate.setAgencyName(currentUser.getTenantName()); //鍒涘缓鏃堕棿 long createTime = DateUtils.getDateTimeNumber(System.currentTimeMillis()); baseGoodsTemplate.setCreateDate(createTime); @@ -109,7 +114,7 @@ } /** - * @Description 鐗╁搧妯℃澘鍒楄〃鏌ヨ + * @Description 鐗╁搧妯℃澘鍒楄〃鏌ヨ * @Author 鍗㈠簡闃� * @Date 2023/10/24 */ @@ -146,8 +151,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 +159,7 @@ /** * 鏍规嵁鐗╁搧id鏌ヨ鐗╁搧璇︽儏 + * * @author 鍗㈠簡闃� * @date 2023/9/26 */ @@ -173,7 +177,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 +194,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 +216,7 @@ } /** - * @Description 鏍规嵁鐗╁搧鍚嶇О鍜屽垎绫籭d鏌ヨ鐗╁搧 + * @Description 鏍规嵁鐗╁搧鍚嶇О鍜屽垎绫籭d鏌ヨ鐗╁搧 * @Author 鍗㈠簡闃� * @Date 2023/10/24 */ @@ -222,7 +235,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 +280,40 @@ goodsTemplate.setDUserName(currentUser.getUser_name()); return this.update(goodsTemplate); } + + /** + * @return + * @Description 鏌ヨ浠撳簱绫诲瀷(鏁版嵁瀛楀吀) + * @Author 鍗㈠簡闃� + * @Date 2023/10/30 + */ + public List<SDictData> 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 SDictData()); + } + + /** + * @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