| | |
| | | package com.consum.base.core; |
| | | |
| | | import com.consum.base.core.po.WhFormInventory; |
| | | import com.consum.base.core.po.WhFormProcure; |
| | | import com.consum.base.core.po.WhFormTransfer; |
| | | import com.consum.base.core.tools.SqlParameter; |
| | | import com.consum.base.core.tools.SuperMap; |
| | | import com.consum.base.core.util.DateUtil; |
| | | import com.consum.model.po.*; |
| | | import com.walker.infrastructure.utils.NumberGenerator; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 进出库 业务处 类 |
| | | */ |
| | | @Service |
| | | public class WarehouseBusinessService { |
| | | public class WarehouseBusinessService extends BaseServiceImpl { |
| | | |
| | | |
| | | @Autowired |
| | | private WarehouseCoreService coreService; |
| | | |
| | | /** |
| | |
| | | * @param procure |
| | | */ |
| | | public void doProcure(WhFormProcure procure){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(true); |
| | | param.setWarehouseId(procure.getId()); |
| | | param.setIsCheckIn(true); |
| | | |
| | | coreService.unifyCheck(param); |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_PROCURE_MODEL A \n" + |
| | | "WHERE\n" + |
| | | " A.WH_FORM_PROCURE_ID = :PROCURE_ID"; |
| | | |
| | | List<WhFormProcureModel> modelList = this.select(sql,new SqlParameter().put("PROCURE_ID",procure.getId()),new WhFormProcureModel()); |
| | | |
| | | for (WhFormProcureModel model : modelList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(true); |
| | | param.setWarehouseId(procure.getId()); |
| | | param.setCount(model.getCounts()); |
| | | param.setFirstInputCode(model.getId().toString()); |
| | | param.setFirst_input_type(1); |
| | | param.setModelId(model.getBaseGoodsModelsId()); |
| | | CheckWarehouseResult result = coreService.unifyCheck(param).get(0); |
| | | |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setId(result.getWhGoods().getFirstInputHisId()); |
| | | details.setBusinessFormId(procure.getId()); |
| | | details.setBusinessFormCode(procure.getBusinessFormCode()); |
| | | details.setBusinessFormName(procure.getWarehouseName() + "采购入库单:" + details.getBusinessFormCode()); |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(1); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(param.getWarehouseId()); |
| | | details.setWarehouseName(procure.getWarehouseName()); |
| | | details.setClassification(1); |
| | | details.setOperatorId(procure.getOperatorId2()); |
| | | details.setOperatorName(procure.getOperatorName2()); |
| | | details.setDealTime(procure.getIncomeTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | |
| | | this.insert(details); |
| | | |
| | | |
| | | model.setInWhGoodsDetailsId(details.getId()); |
| | | update(model); |
| | | |
| | | procure.setStates(2); |
| | | update(procure); |
| | | } |
| | | } |
| | | public void doOutPut(WhFormOutput output){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_OUTPUT_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.WH_FORM_OUTPUT_ID = :OUTPUT_ID"; |
| | | |
| | | List<WhFormOutputGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("OUTPUT_ID",output.getId()),new WhFormOutputGoods()); |
| | | |
| | | for (WhFormOutputGoods goods : goodsList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setWarehouseId(output.getWarehouseId()); |
| | | param.setCount(goods.getCounts()); |
| | | |
| | | List<CheckWarehouseResult> results = coreService.unifyCheck(param); |
| | | for (CheckWarehouseResult result : results){ |
| | | WhFormOutputModel model = new WhFormOutputModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setCounts(result.getInitial_count() - result.getEnd_count()); |
| | | model.setOutWhGoodsDetailsId(result.getWhGoods().getId()); |
| | | model.setWhGoodsId(result.getWhGoods().getId()); |
| | | model.setWhFormOutputId(output.getId()); |
| | | model.setWhFormOutputGoodsId(goods.getId()); |
| | | insert(model); |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setBusinessFormId(output.getId()); |
| | | details.setBusinessFormCode(output.getBusinessFormCode()); |
| | | details.setBusinessFormName("出库单:" + output.getBusinessFormCode()); |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(2); |
| | | details.setThisCount(result.getInitial_count() - result.getEnd_count()); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(result.getWhGoods().getWarehouseId()); |
| | | details.setWarehouseName(result.getWhGoods().getWarehouseName()); |
| | | details.setClassification(3); |
| | | details.setOperatorId(output.getOperatorId()); |
| | | details.setOperatorName(output.getOperatorName()); |
| | | details.setDealTime(output.getDealTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 执行调拨出库操作 |
| | |
| | | * @param transfer |
| | | */ |
| | | public void doTransferOutPut(WhFormTransfer transfer){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_TRANSFER_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.WH_FORM_TRANSFER_ID = :TRANSFER_ID"; |
| | | |
| | | List<WhFormTransferGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("TRANSFER_ID",transfer.getId()),new WhFormTransferGoods()); |
| | | |
| | | for (WhFormTransferGoods goods : goodsList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setWarehouseId(transfer.getOutWarehouseId()); |
| | | param.setCount(goods.getCounts()); |
| | | List<CheckWarehouseResult> results = coreService.unifyCheck(param); |
| | | for (CheckWarehouseResult result : results){ |
| | | WhFormTransferModel model = new WhFormTransferModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setWhFormTransferId(transfer.getId()); |
| | | model.setWorehouseCount(result.getInitial_count()); |
| | | model.setCounts(result.getInitial_count() - result.getEnd_count()); |
| | | model.setOutWhGoodsDetailsId(result.getWhGoods().getId()); |
| | | model.setWhFormTransferGoodsId(goods.getId()); |
| | | insert(model); |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setBusinessFormId(transfer.getId()); |
| | | details.setBusinessFormCode(transfer.getBusinessFormCode()); |
| | | details.setBusinessFormName("调拨出库单:" + transfer.getBusinessFormCode()); |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(2); |
| | | details.setThisCount(result.getInitial_count() - result.getEnd_count()); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(result.getWhGoods().getWarehouseId()); |
| | | details.setWarehouseName(result.getWhGoods().getWarehouseName()); |
| | | details.setClassification(5); |
| | | details.setOperatorId(transfer.getOperatorId()); |
| | | details.setOperatorName(transfer.getOperatorName()); |
| | | details.setDealTime(transfer.getOutputTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void doTransferInPut(WhFormTransfer transfer){ |
| | | |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_TRANSFER_MODEL A \n" + |
| | | "WHERE\n" + |
| | | " A.WH_FORM_TRANSFER_ID = :TRANSFER_ID"; |
| | | |
| | | List<WhFormTransferModel> modelsList = this.select(sql,new SqlParameter() |
| | | .put("TRANSFER_ID",transfer.getId()),new WhFormTransferModel()); |
| | | |
| | | for (WhFormTransferModel model : modelsList) { |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(true); |
| | | param.setWarehouseId(transfer.getInWarehouseId()); |
| | | param.setCount(model.getCounts()); |
| | | param.setWh_goods_id(model.getWhGoodsId()); |
| | | CheckWarehouseResult result = coreService.unifyCheck(param).get(0); |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setBusinessFormId(transfer.getId()); |
| | | details.setBusinessFormCode(transfer.getBusinessFormCode()); |
| | | details.setBusinessFormName("调拨入库单:" + transfer.getBusinessFormCode()); |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(1); |
| | | details.setThisCount(result.getEnd_count()-result.getInitial_count()); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(result.getWhGoods().getWarehouseId()); |
| | | details.setWarehouseName(result.getWhGoods().getWarehouseName()); |
| | | details.setClassification(4); |
| | | details.setOperatorId(transfer.getOperatorId2()); |
| | | details.setOperatorName(transfer.getOperatorName2()); |
| | | details.setDealTime(transfer.getIninputTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | |
| | | model.setInWhGoodsDetailsId(details.getId()); |
| | | update(model); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 报废单 |
| | | * @param scrapped |
| | | */ |
| | | public void doScrapped(WhFormScrapped scrapped){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_SCRAPPED_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.DEP_FORM_SCRAPPED_ID = :SCRAPPED_ID"; |
| | | |
| | | List<WhFormScrappedGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("SCRAPPED_ID",scrapped.getId()),new WhFormScrappedGoods()); |
| | | |
| | | for (WhFormScrappedGoods goods : goodsList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setWarehouseId(scrapped.getWarehouseId()); |
| | | param.setCount(goods.getCounts()); |
| | | List<CheckWarehouseResult> results = coreService.unifyCheck(param); |
| | | for (CheckWarehouseResult result : results){ |
| | | |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setBusinessFormId(scrapped.getId()); |
| | | details.setBusinessFormCode(scrapped.getBusinessFormCode()); |
| | | details.setBusinessFormName("报废单:" + scrapped.getBusinessFormCode()); |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(2); |
| | | details.setThisCount(result.getInitial_count() - result.getEnd_count()); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(result.getWhGoods().getWarehouseId()); |
| | | details.setWarehouseName(result.getWhGoods().getWarehouseName()); |
| | | details.setClassification(10); |
| | | details.setOperatorId(scrapped.getOperatorId()); |
| | | details.setOperatorName(scrapped.getOperatorName()); |
| | | details.setDealTime(scrapped.getDealTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | |
| | | |
| | | WhFormScrappedModel model = new WhFormScrappedModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setCounts(result.getWhGoods().getWhCount()); |
| | | model.setScrappedCode(goods.getScrappedCode()); |
| | | model.setScrappedName(goods.getScrappedName()); |
| | | model.setDepGoodsDetailsId(details.getId()); |
| | | model.setDepFormScrappedId(scrapped.getId()); |
| | | model.setWhGoodsId(result.getWhGoods().getId()); |
| | | model.setWhFormScrappedGoodsId(goods.getId()); |
| | | insert(model); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * 期初数量INIT_COUNTS,和 库存物品编号WH_GOODS_ID字段 |
| | | * @param inventory |
| | | */ |
| | | public void createInventory(WhFormInventory inventory){ |
| | | public void createInventoryForm(WhFormInventory inventory){ |
| | | String sql = |
| | | "SELECT\n" + |
| | | " b.BASE_GOODS_TEMPLATE_ID,\n" + |
| | | " b.GOODS_TEMPLATE_NAME,\n" + |
| | | " SUM( b.WH_COUNT ) AS WH_COUNT,\n" + |
| | | " b.BASE_GOODS_MODELS_ID,\n" + |
| | | " b.BASE_GOODS_MODELS_NAME,\n" + |
| | | " b.UNIT \n" + |
| | | "FROM\n" + |
| | | " (\n" + |
| | | " SELECT\n" + |
| | | " ID \n" + |
| | | " FROM\n" + |
| | | " BASE_GOODS_MODELS m \n" + |
| | | " WHERE\n" + |
| | | " STATES != 3 \n" + |
| | | " AND EXISTS ( SELECT 1 FROM BASE_GOODS_TEMPLATE t WHERE t.ID = m.GOODS_TEMPLATES_ID AND t.STATES != 3 ) \n" + |
| | | " ) a\n" + |
| | | " LEFT JOIN wh_goods b ON a.ID = b.BASE_GOODS_MODELS_ID \n" + |
| | | "WHERE\n" + |
| | | " b.STATES = 1 \n" + |
| | | " AND b.WAREHOUSE_ID =:WAREHOUSE_ID \n" + |
| | | "GROUP BY\n" + |
| | | " b.BASE_GOODS_TEMPLATE_ID,\n" + |
| | | " b.GOODS_TEMPLATE_NAME,\n" + |
| | | " b.BASE_GOODS_MODELS_ID,\n" + |
| | | " b.BASE_GOODS_MODELS_NAME"; |
| | | |
| | | List<WhGoods> goodsList = select(sql,new SqlParameter().add("WAREHOUSE_ID",inventory.getWarehouseId())); |
| | | List<WhFormInventoryGoods> list = new ArrayList<>(); |
| | | for (WhGoods goods : goodsList) { |
| | | WhFormInventoryGoods inventoryGoods = new WhFormInventoryGoods(); |
| | | inventoryGoods.setId(NumberGenerator.getLongSequenceNumber()); |
| | | inventoryGoods.setWhFormInventoryId(inventory.getId()); |
| | | inventoryGoods.setBaseGoodsTemplateId(goods.getBaseGoodsTemplateId()); |
| | | inventoryGoods.setGoodsTemplateName(goods.getGoodsTemplateName()); |
| | | inventoryGoods.setUnit(goods.getUnit()); |
| | | inventoryGoods.setBaseGoodsModelsId(goods.getBaseGoodsModelsId()); |
| | | inventoryGoods.setBaseGoodsModelsName(goods.getBaseGoodsModelsName()); |
| | | inventoryGoods.setInitCounts(goods.getWhCount()); |
| | | inventoryGoods.setInitCounts(null); |
| | | inventoryGoods.setErrorCounts(null); |
| | | inventoryGoods.setInventoryResult(1); |
| | | list.add(inventoryGoods); |
| | | } |
| | | insertBatch(list); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 盘点出库 |
| | | * @param inventory |
| | | */ |
| | | public void doInventoryOutput(WhFormInventory inventory){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_INVENTORY_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.WH_FORM_INVENTORY_ID = :INVENTORY_ID \n" + |
| | | " AND A.INVENTORY_RESULT =3 "; |
| | | |
| | | List<WhFormInventoryGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("INVENTORY_ID",inventory.getId()),new WhFormInventoryGoods()); |
| | | |
| | | for (WhFormInventoryGoods goods : goodsList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setWarehouseId(inventory.getWarehouseId()); |
| | | param.setCount(goods.getErrorCounts()); |
| | | param.setModelId(goods.getBaseGoodsModelsId()); |
| | | param.setOutput_type(3); |
| | | List<CheckWarehouseResult> results = coreService.unifyCheck(param); |
| | | for (CheckWarehouseResult result : results){ |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setBusinessFormId(inventory.getId()); |
| | | details.setBusinessFormCode(inventory.getBusinessFormCode()); |
| | | details.setBusinessFormName("盘点出单:" + inventory.getBusinessFormCode()); |
| | | |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(2); |
| | | details.setThisCount(result.getInitial_count() - result.getEnd_count()); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(result.getWhGoods().getWarehouseId()); |
| | | details.setWarehouseName(result.getWhGoods().getWarehouseName()); |
| | | details.setClassification(9); |
| | | details.setOperatorId(inventory.getOperatorId()); |
| | | details.setOperatorName(inventory.getOperatorName()); |
| | | details.setDealTime(inventory.getStopTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | |
| | | |
| | | WhFormInventoryModel model = new WhFormInventoryModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setCounts(result.getWhGoods().getWhCount()); |
| | | model.setWhFormInventoryId(inventory.getId()); |
| | | model.setInventoryResult(3); |
| | | model.setWhGoodsDetailsId(details.getId()); |
| | | model.setWhFormInventoryGoodsId(goods.getId()); |
| | | model.setWhGoodsId(result.getWhGoods().getId()); |
| | | insert(model); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 盘点入库 |
| | | * @param inventory |
| | | */ |
| | | public void doInventoryInput(WhFormInventory inventory){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " WH_FORM_INVENTORY_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.WH_FORM_INVENTORY_ID = :INVENTORY_ID \n" + |
| | | " AND A.INVENTORY_RESULT =2 "; |
| | | |
| | | List<WhFormInventoryGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("INVENTORY_ID",inventory.getId()),new WhFormInventoryGoods()); |
| | | |
| | | for (WhFormInventoryGoods goods : goodsList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(true); |
| | | param.setWarehouseId(inventory.getWarehouseId()); |
| | | param.setCount(goods.getErrorCounts()); |
| | | param.setModelId(goods.getBaseGoodsModelsId()); |
| | | param.setFirst_input_type(3); |
| | | CheckWarehouseResult result = coreService.unifyCheck(param).get(0); |
| | | |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setBusinessFormId(inventory.getId()); |
| | | details.setBusinessFormCode(inventory.getBusinessFormCode()); |
| | | details.setBusinessFormName("盘点入库单:" + inventory.getBusinessFormCode()); |
| | | |
| | | details.setInitialCount(result.getInitial_count()); |
| | | details.setThisType(1); |
| | | details.setThisCount(result.getEnd_count()-result.getInitial_count()); |
| | | details.setEndCount(result.getEnd_count()); |
| | | details.setWarehouseId(result.getWhGoods().getWarehouseId()); |
| | | details.setWarehouseName(result.getWhGoods().getWarehouseName()); |
| | | details.setClassification(8); |
| | | details.setOperatorId(inventory.getOperatorId()); |
| | | details.setOperatorName(inventory.getOperatorName()); |
| | | details.setDealTime(inventory.getStopTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | |
| | | |
| | | WhFormInventoryModel model = new WhFormInventoryModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setCounts(result.getWhGoods().getWhCount()); |
| | | model.setWhFormInventoryId(inventory.getId()); |
| | | model.setInventoryResult(3); |
| | | model.setWhGoodsDetailsId(details.getId()); |
| | | model.setWhFormInventoryGoodsId(goods.getId()); |
| | | model.setWhGoodsId(result.getWhGoods().getId()); |
| | | insert(model); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 统一处理库存预警(定时任务调用服务) |
| | | * 计划:每天中午13:00、晚上1:00执行两次 |
| | | */ |
| | | public void insertWarning(){ |
| | | |
| | | String sql = "SELECT\n" + |
| | | " SUM(b.WH_COUNT) AS WH_COUNT,\n" + |
| | | " b.BASE_GOODS_TEMPLATE_ID,\n" + |
| | | " b.GOODS_TEMPLATE_NAME,\n" + |
| | | " b.WAREHOUSE_ID,\n" + |
| | | " a.UPPER_LIMIT,\n" + |
| | | " a.LOWER_LIMIT \n" + |
| | | "FROM\n" + |
| | | " WH_WARNING_CONFIG a\n" + |
| | | " LEFT JOIN wh_goods b ON a.BASE_GOODS_TEMPLATE_ID = b.BASE_GOODS_TEMPLATE_ID \n" + |
| | | "WHERE\n" + |
| | | " a.BASE_WAREHOUSE_ID = b.WAREHOUSE_ID \n" + |
| | | " AND b.STATES = 1 \n" + |
| | | " AND a.GOODS_TYPE=1\n" + |
| | | " AND ( a.UPPER_LIMIT <= WH_COUNT OR a.LOWER_LIMIT >= WH_COUNT ) \n" + |
| | | "GROUP BY\n" + |
| | | " b.BASE_GOODS_TEMPLATE_ID,\n" + |
| | | " b.GOODS_TEMPLATE_NAME,\n" + |
| | | " b.WAREHOUSE_ID,\n" + |
| | | " a.UPPER_LIMIT,\n" + |
| | | " a.LOWER_LIMIT"; |
| | | |
| | | List<Map> goodslist = select(sql,new SqlParameter()); |
| | | |
| | | sql = "SELECT\n" + |
| | | " SUM(b.WH_COUNT) AS WH_COUNT,\n" + |
| | | " b.BASE_GOODS_TEMPLATE_ID,\n" + |
| | | " b.GOODS_TEMPLATE_NAME,\n" + |
| | | " b.BASE_GOODS_MODELS_ID,\n" + |
| | | " b.BASE_GOODS_MODELS_NAME,\n" + |
| | | " b.WAREHOUSE_ID,\n" + |
| | | " a.UPPER_LIMIT,\n" + |
| | | " a.LOWER_LIMIT \n" + |
| | | "FROM\n" + |
| | | " WH_WARNING_CONFIG a\n" + |
| | | " LEFT JOIN wh_goods b ON a.BASE_GOODS_MODELS_ID = b.BASE_GOODS_MODELS_ID \n" + |
| | | "WHERE\n" + |
| | | " a.BASE_WAREHOUSE_ID = b.WAREHOUSE_ID \n" + |
| | | " AND b.STATES = 1 \n" + |
| | | " AND a.GOODS_TYPE=2\n" + |
| | | " AND ( a.UPPER_LIMIT <= WH_COUNT OR a.LOWER_LIMIT >= WH_COUNT ) \n" + |
| | | "GROUP BY\n" + |
| | | " b.BASE_GOODS_TEMPLATE_ID,\n" + |
| | | " b.GOODS_TEMPLATE_NAME,\n" + |
| | | " b.BASE_GOODS_MODELS_ID,\n" + |
| | | " b.BASE_GOODS_MODELS_NAME,\n" + |
| | | " b.WAREHOUSE_ID,\n" + |
| | | " a.UPPER_LIMIT,\n" + |
| | | " a.LOWER_LIMIT"; |
| | | |
| | | List<Map> modeslist = select(sql,new SqlParameter()); |
| | | |
| | | List<Map> list = new ArrayList<>(); |
| | | list.addAll(goodslist); |
| | | list.addAll(modeslist); |
| | | |
| | | List<WhWarning> warningList = new ArrayList<>(); |
| | | for (Map map : list) { |
| | | SuperMap superMap = new SuperMap(map); |
| | | BaseWarehouse warehouse = get(new BaseWarehouse(),"ID=?",new Object[]{superMap.get("WAREHOUSE_ID")}); |
| | | |
| | | WhWarning warning = new WhWarning(); |
| | | warning.setId(NumberGenerator.getLongSequenceNumber()); |
| | | warning.setBaseWarehouseId(warehouse.getId()); |
| | | warning.setBaseWarehouseName(warehouse.getWarehouseName()); |
| | | warning.setBaseGoodsTemplateId(superMap.getLong("BASE_GOODS_TEMPLATE_ID")); |
| | | warning.setBaseGoodsTemplateName(superMap.getString("GOODS_TEMPLATE_NAME")); |
| | | if (superMap.getString("BASE_GOODS_MODELS_ID") == null){ |
| | | warning.setGoodsType(1); |
| | | } else { |
| | | warning.setBaseGoodsModelsId(superMap.getLong("BASE_GOODS_MODELS_ID")); |
| | | warning.setBaseGoodsModelsName(superMap.getString("BASE_GOODS_MODELS_NAME")); |
| | | warning.setGoodsType(2); |
| | | } |
| | | |
| | | int whCount = superMap.getInteger("WH_COUNT"); |
| | | int upCount = superMap.getInteger("UPPER_LIMIT"); |
| | | int lowCount = superMap.getInteger("LOWER_LIMIT"); |
| | | |
| | | if (whCount >= upCount){ |
| | | warning.setWarningType(1); |
| | | } |
| | | if (whCount<=lowCount){ |
| | | warning.setWarningType(2); |
| | | } |
| | | |
| | | warning.setUpperLimit(upCount); |
| | | warning.setLowerLimit(lowCount); |
| | | warning.setWarehouseCount(whCount); |
| | | warning.setStates(1); |
| | | warning.setWarningTime(DateUtil.getCurrentDateFor14()); |
| | | warning.setAgencyId(warehouse.getAgencyId()); |
| | | warning.setAgencyName(warehouse.getAgencyName()); |
| | | |
| | | warningList.add(warning); |
| | | } |
| | | |
| | | insertBatch(warningList); |
| | | } |
| | | |
| | | /** |
| | | * 部门物品分发 |
| | | */ |
| | | public void doDepLending(){ |
| | | |
| | | } |
| | | |