| | |
| | | package com.consum.base.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | 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 com.consum.base.Constants; |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.utils.IdUtil; |
| | |
| | | import com.consum.base.service.BaseCategoryService; |
| | | import com.consum.base.service.BaseGoodsModelsService; |
| | | import com.consum.base.service.BaseGoodsTemplateService; |
| | | import com.consum.model.po.*; |
| | | 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 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; |
| | | import cn.hutool.core.convert.Convert; |
| | | |
| | | /** |
| | | * @Description 物品模板 |
| | |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_template WHERE 1 = 1 "); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //分类id |
| | | // 分类id |
| | | if (categoryId != null) { |
| | | sql.append(" and category_id =:category_id "); |
| | | paramts.put("category_id", categoryId); |
| | |
| | | */ |
| | | @Override |
| | | public int add(BaseGoodsTemplateParam param, FinSysTenantUser currentUser) { |
| | | //1.新增物品模板 |
| | | // 1.新增物品模板 |
| | | BaseGoodsTemplate baseGoodsTemplate = new BaseGoodsTemplate(); |
| | | BeanUtils.copyProperties(param, baseGoodsTemplate); |
| | | long goodsTemplatesId = IdUtil.generateId(); |
| | | baseGoodsTemplate.setId(goodsTemplatesId); |
| | | //根据分类id查询分类 |
| | | // 根据分类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(Convert.toStr(classification,"C")); |
| | | // 物品编码 |
| | | String goodsCode = codeGeneratorService.createGoodsTemplateCode(Convert.toStr(classification, "C")); |
| | | baseGoodsTemplate.setGoodsCode(goodsCode); |
| | | //类别 |
| | | // 类别 |
| | | baseGoodsTemplate.setClassification(classification); |
| | | } |
| | | //TODO 一级二级三级机构编号 |
| | | //当前机构的父级机构编号 |
| | | //机构层级 |
| | | //机构编号 |
| | | baseGoodsTemplate.setAgencyId(Long.valueOf(currentUser.getTenantId())); |
| | | //机构名称 |
| | | baseGoodsTemplate.setAgencyName(currentUser.getTenantName()); |
| | | //创建时间 |
| | | // TODO 一级二级三级机构编号 |
| | | // 当前机构的父级机构编号 |
| | | // 机构层级 |
| | | if (currentUser != null) { |
| | | // 机构编号 |
| | | baseGoodsTemplate.setAgencyId(Long.valueOf(currentUser.getTenantId())); |
| | | // 机构名称 |
| | | baseGoodsTemplate.setAgencyName(currentUser.getTenantName()); |
| | | } |
| | | |
| | | // 创建时间 |
| | | long createTime = DateUtils.getDateTimeNumber(System.currentTimeMillis()); |
| | | baseGoodsTemplate.setCreateDate(createTime); |
| | | int flag1 = this.insert(baseGoodsTemplate); |
| | | |
| | | //2.新增规格型号 |
| | | // 2.新增规格型号 |
| | | List<BaseGoodsModels> models = param.getModels(); |
| | | int flag2 = 0; |
| | | if (!CollectionUtils.isEmpty(models)) { |
| | |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_template WHERE 1 = 1 "); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //物品名称 |
| | | // 物品名称 |
| | | if (!StringUtils.isEmpty(param.getGoodsName())) { |
| | | sql.append(" and goods_name like:goods_name "); |
| | | paramts.put("goods_name", StringUtils.CHAR_PERCENT + param.getGoodsName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //物品编号 |
| | | // 物品编号 |
| | | if (!StringUtils.isEmpty(param.getGoodsCode())) { |
| | | sql.append(" and goods_code like:goods_code "); |
| | | paramts.put("goods_code", StringUtils.CHAR_PERCENT + param.getGoodsCode() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //分类id |
| | | // 分类id |
| | | if (param.getCategoryId() != null) { |
| | | sql.append(" and category_id =:category_id "); |
| | | paramts.put("category_id", param.getCategoryId()); |
| | | } |
| | | //类别 |
| | | // 类别 |
| | | if (!StringUtils.isEmpty(param.getClassification())) { |
| | | sql.append(" and classification =:classification "); |
| | | paramts.put("classification", param.getClassification()); |
| | | } |
| | | //所属机构 |
| | | // 所属机构 |
| | | if (param.getAgencyId() != null) { |
| | | sql.append(" and agency_id =:agency_id "); |
| | | paramts.put("agency_id", param.getAgencyId()); |
| | | } |
| | | //状态 |
| | | // 状态 |
| | | if (param.getStates() != null) { |
| | | sql.append(" and states =:states "); |
| | | paramts.put("states", param.getStates()); |
| | |
| | | */ |
| | | @Override |
| | | public BaseGoodsTemplateVo getById(Long id) { |
| | | //1.根据物品id查询物品模板 |
| | | // 1.根据物品id查询物品模板 |
| | | BaseGoodsTemplate goodsTemplate = this.get(new BaseGoodsTemplate(id)); |
| | | //2.根据物品id查询规格型号 |
| | | // 2.根据物品id查询规格型号 |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_models WHERE 1 = 1 "); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | //所属物品模版编号 |
| | | // 所属物品模版编号 |
| | | sql.append(" and goods_templates_id =:goods_templates_id "); |
| | | paramts.put("goods_templates_id", id); |
| | | List<BaseGoodsModels> modelsList = this.select(sql.toString(), paramts, new BaseGoodsModels()); |
| | | |
| | | //3.封装 |
| | | // 3.封装 |
| | | BaseGoodsTemplateVo vo = new BaseGoodsTemplateVo(); |
| | | if (goodsTemplate != null) { |
| | | BeanUtils.copyProperties(goodsTemplate, vo); |
| | |
| | | */ |
| | | @Override |
| | | public int updateBaseGoodsTemplate(BaseGoodsTemplateParam param) { |
| | | //1.修改物品模板 |
| | | // 1.修改物品模板 |
| | | BaseGoodsTemplate baseGoodsTemplate = new BaseGoodsTemplate(); |
| | | BeanUtils.copyProperties(param, baseGoodsTemplate); |
| | | BaseCategory baseCategory = this.baseCategoryService.get(new BaseCategory(param.getCategoryId())); |
| | |
| | | baseGoodsTemplate.setCategoryName(baseCategory.getCategoryName()); |
| | | } |
| | | int flag1 = this.update(baseGoodsTemplate); |
| | | //2.修改规格型号的单位 |
| | | // 2.修改规格型号的单位 |
| | | // TODO id 物品型号修改待整理 |
| | | List<BaseGoodsModels> modelsList = param.getModels(); |
| | | for (BaseGoodsModels baseGoodsModel : modelsList) { |
| | |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_template WHERE 1 = 1 "); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //物品名称 |
| | | // 物品名称 |
| | | sql.append(" and goods_name =:goods_name "); |
| | | paramts.put("goods_name", goodsName); |
| | | //分类id |
| | | // 分类id |
| | | sql.append(" and category_id =:category_id "); |
| | | paramts.put("category_id", categoryId); |
| | | |
| | |
| | | * @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 "; |
| | | 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 "; |
| | | |
| | | @Override |
| | | public Map<String, Object> queryGoodsInfoByModelId(Long modelId) { |
| | | StringBuilder sqlStr = new StringBuilder(QUERY_GOODSINFO_BY_MODELID); |
| | |
| | | @Override |
| | | public int updateById(BaseGoodsTemplate goodsTemplate, S_user_core currentUser) { |
| | | goodsTemplate.setStates(Constants.STATES_DELETED); |
| | | //删除时间 |
| | | // 删除时间 |
| | | goodsTemplate.setDTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | //删除人id和删除人姓名 |
| | | // 删除人id和删除人姓名 |
| | | goodsTemplate.setDUserId(currentUser.getId()); |
| | | goodsTemplate.setDUserName(currentUser.getUser_name()); |
| | | return this.update(goodsTemplate); |
| | |
| | | */ |
| | | @Override |
| | | 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()); |
| | | 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()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param agencyId |
| | | * @param categoryId |
| | | * @param states |
| | | * @param goodsName 全匹配!!! |
| | | * @param goodsName 全匹配!!! |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<BaseGoodsTemplate> queryGoodsTemplateByCategoryId(Long agencyId, Long categoryId, Short states, String goodsName) { |
| | | public List<BaseGoodsTemplate> queryGoodsTemplateByCategoryId(Long agencyId, Long categoryId, Short states, |
| | | String goodsName) { |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_goods_template WHERE 1=1 "); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | if (agencyId != null) { |