package com.consum.base.service; import com.consum.base.core.utils.MapperUtil; import com.consum.base.pojo.query.LWhLedgerQry; import com.walker.db.page.GenericPager; import com.walker.infrastructure.utils.StringUtils; import com.walker.jdbc.service.BaseServiceImpl; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.Map; /** * @ClassName FinWarehouseLedgerServiceImpl * @Author cy * @Date 2023/11/20 * @Description * @Version 1.0 **/ @Service public class FinWarehouseLedgerServiceImpl extends BaseServiceImpl { private static String LEDGER_LIST_QUERY_PREFIX = "SELECT ware.AGENCY_NAME ,ware.WAREHOUSE_NAME ,goodsTemp.CATEGORY_NAME ,CASE goods.COST_TYPE WHEN 1 THEN 'A类' WHEN 2 THEN 'B类' WHEN 3 THEN 'C类' END AS cost_Type,goods.GOODS_TEMPLATE_NAME ,goods.BASE_GOODS_MODELS_NAME ,goods.UNIT unit,COUNt(goods.id) kucun FROM L_WH_GOODS goods LEFT JOIN BASE_GOODS_TEMPLATE goodsTemp ON goods.BASE_GOODS_TEMPLATE_ID=goodsTemp.id LEFT JOIN BASE_WAREHOUSE ware ON ware.id=goods.WAREHOUSE_ID where 1=1 "; public GenericPager> ledgerList(LWhLedgerQry param) { StringBuilder sql = new StringBuilder(LEDGER_LIST_QUERY_PREFIX); Map paramts = new HashMap<>(); //状态(0=在途调拨;1=入库未分发;2=已下发;3=报废 4 零星出库) if (param.getStates() != null) { sql.append(" and goods.states = :states"); paramts.put("states", param.getStates()); } //机构 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 goods.WAREHOUSE_TYPE = :warehouseType"); paramts.put("warehouseType", param.getWarehouseType()); } if (param.getWarehouseId() != null) { sql.append(" AND goods.WAREHOUSE_ID = :warehouseId"); paramts.put("warehouseId", param.getWarehouseId()); } //物品名称 if (StringUtils.isNotEmpty(param.getGoodsTemplateName())) { sql.append(" AND goods.GOODS_TEMPLATE_NAME like :goodsTemplateName"); paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT); } //分类 if (param.getCategoryId() != null) { sql.append(" AND goodsTemp.CATEGORY_ID=:categoryId"); paramts.put("categoryId", param.getCategoryId()); } //价值类型 if (param.getCostType() != null) { sql.append(" AND goods.COST_TYPE=:costType"); paramts.put("costType", param.getCostType()); } sql.append(" GROUP BY ware.AGENCY_NAME,ware.WAREHOUSE_NAME,goodsTemp.CATEGORY_NAME,goods.COST_TYPE,goods.GOODS_TEMPLATE_NAME,goods.BASE_GOODS_MODELS_NAME,goods.UNIT"); return selectSplit(sql.toString(), paramts, param.getPageNum(), param.getPageSize(), new MapperUtil()); } }