From 279e16eab8872fc85c1dadc1302fbf04569fdaf9 Mon Sep 17 00:00:00 2001 From: cy <1664593601@qq.com> Date: 星期三, 22 十一月 2023 10:23:00 +0800 Subject: [PATCH] feat: 台账SQL调整 --- consum-base/src/main/java/com/consum/base/service/BaseGoodsTemplateServiceImpl.java | 88 ++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 81 insertions(+), 7 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 6221a8c..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,25 +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; -import java.util.Map; /** * @Description 鐗╁搧妯℃澘 @@ -62,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); @@ -72,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); @@ -83,7 +85,9 @@ //褰撳墠鏈烘瀯鐨勭埗绾ф満鏋勭紪鍙� //鏈烘瀯灞傜骇 //鏈烘瀯缂栧彿 + baseGoodsTemplate.setAgencyId(Long.valueOf(currentUser.getTenantId())); //鏈烘瀯鍚嶇О + baseGoodsTemplate.setAgencyName(currentUser.getTenantName()); //鍒涘缓鏃堕棿 long createTime = DateUtils.getDateTimeNumber(System.currentTimeMillis()); baseGoodsTemplate.setCreateDate(createTime); @@ -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) { @@ -227,7 +240,7 @@ * @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 FROM BASE_GOODS_MODELS model LEFT JOIN BASE_GOODS_TEMPLATE temp ON model.GOODS_TEMPLATES_ID=temp.id WHERE 1=1 "; + 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); @@ -242,4 +255,65 @@ } 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<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