| | |
| | | package com.consum.base.core; |
| | | |
| | | 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 java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 进出库 业务处 类 |
| | |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setWarehouseId(output.getWarehouseId()); |
| | | param.setModelId(goods.getBaseGoodsModelsId()); |
| | | param.setCount(goods.getCounts()); |
| | | |
| | | List<CheckWarehouseResult> results = coreService.unifyCheck(param); |
| | |
| | | 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 doDepBack(DepFormBack back){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " DEP_FORM_BACK_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.DEP_FORM_BACK_ID = :BACK_ID \n"; |
| | | |
| | | List<DepFormBackGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("BACK_ID",back.getId()),new DepFormBackGoods()); |
| | | |
| | | for (DepFormBackGoods goods : goodsList) { |
| | | CheckUsingParam param = new CheckUsingParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setLending_id(back.getDepFormLendingId()); |
| | | param.setOutputCount(goods.getBackCounts()); |
| | | //型号 |
| | | // param.setModel_id(model.); |
| | | |
| | | //字表设计有问题,需要重新设计,参考报废表。 |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 部门物品分发 |
| | | */ |
| | | public void doDepLending(DepFormLending lending){ |
| | | String sql = "SELECT\n" + |
| | | " * \n" + |
| | | "FROM\n" + |
| | | " DEP_FORM_LENDING_GOODS A \n" + |
| | | "WHERE\n" + |
| | | " A.DEP_FORM_LENDING_ID = :LENDING_ID"; |
| | | |
| | | List<DepFormLendingGoods> goodsList = this.select(sql,new SqlParameter() |
| | | .put("LENDING_ID",lending.getId()),new DepFormLendingGoods()); |
| | | |
| | | for (DepFormLendingGoods goods : goodsList){ |
| | | CheckWarehouseParam param = new CheckWarehouseParam(); |
| | | param.setIsCheckIn(false); |
| | | param.setWarehouseId(lending.getWarehouseId()); |
| | | param.setModelId(goods.getBaseGoodsModelsId()); |
| | | param.setCount(goods.getCounts()); |
| | | |
| | | //首先从机构仓库出库 |
| | | List<CheckWarehouseResult> results = coreService.unifyCheck(param); |
| | | for (CheckWarehouseResult result : results){ |
| | | WhGoodsDetails details = new WhGoodsDetails(); |
| | | details.setId(NumberGenerator.getLongSequenceNumber()); |
| | | details.setBusinessFormId(lending.getId()); |
| | | details.setBusinessFormCode(lending.getBusinessFormCode()); |
| | | details.setBusinessFormName("分发单:" + lending.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(11); |
| | | details.setOperatorId(lending.getOperatorId()); |
| | | details.setOperatorName(lending.getOperatorName()); |
| | | details.setDealTime(lending.getDealTime()); |
| | | details.setWhGoodsId(result.getWhGoods().getId()); |
| | | this.insert(details); |
| | | |
| | | //回填出库流水ID,用于分发时使用 |
| | | result.setWh_goods_detail_id(details.getId()); |
| | | } |
| | | |
| | | CheckUsingParam usingParam = new CheckUsingParam(); |
| | | usingParam.setIsCheckIn(true); |
| | | usingParam.setInput_type(1); |
| | | usingParam.setOutputList(results); |
| | | |
| | | List<CheckUsingResult> usingResults = coreService.unifyUsingCheck(usingParam); |
| | | for (CheckUsingResult usingResult : usingResults) { |
| | | UsingGoodsHis his = new UsingGoodsHis(); |
| | | his.setId(NumberGenerator.getLongSequenceNumber()); |
| | | his.setBusinessFormId(lending.getId()); |
| | | his.setBusinessFormCode(lending.getBusinessFormCode()); |
| | | his.setBusinessFormName("分发单:" + lending.getBusinessFormCode()); |
| | | his.setClassification(1); |
| | | his.setOperatorId(lending.getOperatorId()); |
| | | his.setOperatorName(lending.getOperatorName()); |
| | | his.setDealTime(lending.getDealTime()); |
| | | his.setDepFormLendingModelId(usingResult.getLendingModel().getId()); |
| | | his.setDepFormLendingGoodsId(usingResult.getLendingModel().getDepFormLendingGoodsId()); |
| | | his.setDepFormLendingId(lending.getId()); |
| | | his.setWhGoodsId(usingResult.getLendingModel().getWhGoodsId()); |
| | | his.setInitialCount(usingResult.getInitial_count()); |
| | | his.setEndCount(usingResult.getEnd_count()); |
| | | his.setWarehouseId(lending.getWarehouseId()); |
| | | his.setWarehouseName(lending.getWarehouseName()); |
| | | his.setDepartmentId(lending.getDepartmentId()); |
| | | his.setDepartmentName(lending.getDepartmentName()); |
| | | insert(his); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |