package com.consum.base.service;
|
|
import com.consum.base.core.utils.MapperUtil;
|
import com.consum.base.pojo.query.WhWarningConfigQry;
|
import com.walker.db.page.GenericPager;
|
import com.walker.infrastructure.utils.CollectionUtils;
|
import com.walker.infrastructure.utils.StringUtils;
|
import com.walker.jdbc.service.BaseServiceImpl;
|
import org.springframework.stereotype.Service;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @ClassName LWhWarningConfigServiceImpl
|
* @Author cy
|
* @Date 2023/11/20
|
* @Description
|
* @Version 1.0
|
**/
|
@Service
|
public class LWhWarningConfigServiceImpl extends BaseServiceImpl {
|
private static String GET_CONFIG_LIST_WITH_PAGE = "SELECT wareConf.*,ware.AGENCY_NAME,ware.WAREHOUSE_NAME,goodsTemp.CATEGORY_NAME,CONCAT(cate.CLASSIFICATION,'类') cost_Type,goodsTemp.GOODS_NAME,baseModel.MODEL_NAME FROM WH_WARNING_CONFIG wareConf LEFT JOIN BASE_GOODS_MODELS baseModel ON baseModel.ID=wareConf.BASE_GOODS_MODELS_ID LEFT JOIN BASE_GOODS_TEMPLATE goodsTemp ON wareConf.BASE_GOODS_TEMPLATE_ID=goodsTemp.id LEFT JOIN BASE_CATEGORY cate ON cate.id=goodsTemp.CATEGORY_ID LEFT JOIN BASE_WAREHOUSE ware ON ware.id=wareConf.BASE_WAREHOUSE_ID WHERE 1=1 ";
|
|
public GenericPager<Map<String, Object>> getConfigListWithPage(WhWarningConfigQry param) {
|
Map<String, Object> configListQueryMap = getConfigListQueryMap(param);
|
StringBuilder sql = (StringBuilder) configListQueryMap.get("sql");
|
HashMap<String, Object> paramts = (HashMap<String, Object>) configListQueryMap.get("paramts");
|
return selectSplit(sql.toString(), paramts, param.getPageNum(), param.getPageSize(), new MapperUtil());
|
}
|
|
|
private Map<String, Object> getConfigListQueryMap(WhWarningConfigQry param) {
|
Map<String, Object> configListQueryMap = new HashMap<>();
|
StringBuilder sql = new StringBuilder(GET_CONFIG_LIST_WITH_PAGE);
|
HashMap<String, Object> paramts = new HashMap<>();
|
//机构
|
if (param.getAgencyId() != null) {
|
sql.append(" and left(ware.AGENCY_ID, length(:lengthAgencyId)) = :agencyId");
|
paramts.put("lengthAgencyId", param.getAgencyId());
|
paramts.put("agencyId", param.getAgencyId());
|
}
|
//仓库类型
|
if (param.getWarehouseType() != null) {
|
sql.append(" AND wareConf.WAREHOUSE_TYPE = :warehouseType");
|
paramts.put("warehouseType", param.getWarehouseType());
|
}
|
if (param.getBaseWarehouseId() != null) {
|
sql.append(" AND wareConf.BASE_WAREHOUSE_ID = :warehouseId");
|
paramts.put("warehouseId", param.getBaseWarehouseId());
|
}
|
//物品名称
|
if (StringUtils.isNotEmpty(param.getGoodsTemplateName())) {
|
sql.append(" AND goodsTemp.GOODS_NAME like :goodsTemplateName");
|
paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT);
|
}
|
if (param.getBaseGoodsTemplateId() != null) {
|
sql.append(" AND wareConf.BASE_GOODS_TEMPLATE_ID=:baseGoodsTemplateId");
|
paramts.put("baseGoodsTemplateId", param.getBaseGoodsTemplateId());
|
}
|
//分类
|
if (param.getCategoryId() != null) {
|
sql.append(" AND cate.id=:categoryId");
|
paramts.put("categoryId", param.getCategoryId());
|
}
|
//价值类型
|
if (param.getCostType() != null) {
|
// 将数字转换为对应的字符
|
char costType = (char) ('A' + param.getCostType() - 1);
|
sql.append(" AND cate.CLASSIFICATION=:costType");
|
paramts.put("costType", costType);
|
}
|
sql.append(" ORDER BY wareConf.id DESC ");
|
configListQueryMap.put("sql", sql);
|
configListQueryMap.put("paramts", paramts);
|
return configListQueryMap;
|
}
|
|
private String QUERY_MODEL_IS_EXIST = "";
|
|
public List<Map<String, Object>> queryModelIsExist(Integer warehouseType, Long baseWarehouseId, List<Long> modelIds) {
|
StringBuilder sql = new StringBuilder("select WAREHOUSE_TYPE, BASE_WAREHOUSE_ID, BASE_GOODS_MODELS_ID from WH_WARNING_CONFIG where 1=1");
|
HashMap<String, Object> paramts = new HashMap<>();
|
|
//仓库类型
|
if (warehouseType != null) {
|
sql.append(" AND WAREHOUSE_TYPE = :warehouseType");
|
paramts.put("warehouseType", warehouseType);
|
}
|
if (baseWarehouseId != null) {
|
sql.append(" AND BASE_WAREHOUSE_ID = :warehouseId");
|
paramts.put("warehouseId", baseWarehouseId);
|
}
|
if (!CollectionUtils.isEmpty(modelIds)) {
|
sql.append(" AND BASE_GOODS_MODELS_ID in(:modelIds)");
|
paramts.put("modelIds", org.apache.commons.lang3.StringUtils.join(modelIds, ","));
|
}
|
return select(sql.toString(), paramts, new MapperUtil());
|
}
|
|
|
}
|