| | |
| | | |
| | | import com.consum.base.core.CodeGeneratorEnum; |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.core.param.BaseWarehouseParam1; |
| | | import com.consum.base.core.utils.CurrencyUtil; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.pojo.LWFormsOutputGoodsInfoParam; |
| | | import com.consum.base.pojo.LWFormsOutputGoodsModelParam; |
| | | import com.consum.base.pojo.LWFormsOutputGoodsParam; |
| | | import com.consum.base.pojo.LWhFormOutputInsertParam; |
| | | import com.consum.base.pojo.LWhFormOutputParam; |
| | | import com.consum.base.pojo.excel.OutputExcelTemplate; |
| | | import com.consum.base.pojo.query.LWhFormOutputQry; |
| | | import com.consum.model.po.BaseGoodsModels; |
| | | import com.consum.model.po.BaseWarehouse; |
| | |
| | | import com.consum.model.po.LWhProcureModel; |
| | | import com.iplatform.model.po.S_user_core; |
| | | 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 java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | |
| | | @Autowired |
| | | private CodeGeneratorService codeGeneratorService; |
| | | @Autowired |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | private BaseWarehouseService baseWarehouseService; |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private LWhFormOutputCoreService lWhFormOutputCoreService; |
| | | @Autowired |
| | | private BaseGoodsModelsServiceImpl baseGoodsModelsService; |
| | | private BaseGoodsModelsService baseGoodsModelsService; |
| | | |
| | | private static String QUERY_FORM_OUTPUT_LIST = "SELECT * FROM l_wh_form_output WHERE 1 = 1"; |
| | | |
| | | // /** |
| | | // * @Description 新增出库单 |
| | | // * @Author 卢庆阳 |
| | | // * @Date 2023/10/27 |
| | | // */ |
| | | // public int add(LWhFormOutputParam param, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | | // //1.新增出库单记录 |
| | | // LWhFormOutput lWhFormOutput = new LWhFormOutput(); |
| | | // //出入库id |
| | | // long lWhFormOutputId = IdUtil.generateId(); |
| | | // lWhFormOutput.setId(lWhFormOutputId); |
| | | // Long warehouseId = param.getWarehouseId(); |
| | | // lWhFormOutput.setWarehouseId(warehouseId); |
| | | // //根据仓库id查询仓库 |
| | | // BaseWarehouse warehouse = this.baseWarehouseService.getById(warehouseId); |
| | | // if (warehouse == null) { |
| | | // log.error("仓库id不存在"); |
| | | // return 0; |
| | | // } |
| | | // lWhFormOutput.setWarehouseName(warehouse.getWarehouseName()); |
| | | // lWhFormOutput.setOutputCode(BaseWarehouseParam1.In_OutPutTypeEnum.Fragmentary_Output.getValue()+""); |
| | | // lWhFormOutput.setOutputName("零星出库"); |
| | | // lWhFormOutput.setAgencyId(Long.valueOf(sysInfo.getTenantId())); |
| | | // lWhFormOutput.setAgencyName(sysInfo.getTenantName()); |
| | | // lWhFormOutput.setOperatorId(sysInfo.getId()); |
| | | // lWhFormOutput.setOperatorName(sysInfo.getUserName()); |
| | | // long dateTimeNumber = DateUtils.getDateTimeNumber(System.currentTimeMillis()); |
| | | // lWhFormOutput.setDealTime(dateTimeNumber); |
| | | // lWhFormOutput.setStates(1); |
| | | // int flag1 = this.insert(lWhFormOutput); |
| | | // |
| | | // //2.根据出库单出库 |
| | | // Long lWarehouseFlowId = this.lWhFormOutputCoreService.outFormByTransId(lWhFormOutput.getId(), currentUser, dateTimeNumber); |
| | | // //3.向出库单 插入 进出库流水总表ID |
| | | // int flag3 = 0; |
| | | // if (flag1 > 0) { |
| | | // LWhFormOutput lWhFormOutput1 = new LWhFormOutput(lWhFormOutputId); |
| | | // lWhFormOutput1.setWarehouseFlowId(lWarehouseFlowId); |
| | | // flag3 = this.update(lWhFormOutput1); |
| | | // } |
| | | // |
| | | // //4.新增l_wh_goods_record记录 |
| | | // List<LWhGoodsRecord> recordList = param.getList(); |
| | | // if (CollectionUtils.isEmpty(recordList)) { |
| | | // log.error("规格型号为空"); |
| | | // return 0; |
| | | // } |
| | | // int flag5 = 0; |
| | | // int number = -1; //出库后,物品剩余数量 |
| | | // for (LWhGoodsRecord record : recordList) { |
| | | // //物品id和物品名称 |
| | | // record.setBaseGoodsTemplateId(param.getBaseGoodsTemplateId()); |
| | | // record.setGoodsTemplateName(param.getGoodsTemplateName()); |
| | | // |
| | | // record.setId(IdUtil.generateId()); |
| | | // record.setWarehouseId(warehouseId); |
| | | // //根据物品型号查询物品库存 |
| | | // int goodsNum = this.lWhGoodsService.queryGoodsModelNum(warehouseId, record.getBaseGoodsModelsId(), (short) 1, null); |
| | | // record.setInitialCount(goodsNum); |
| | | // record.setThisType(2); |
| | | // |
| | | // //判断出库数量是否小于库存 |
| | | // number = goodsNum - record.getThisCount(); |
| | | // if (number < 0) { |
| | | // log.error("库存不足"); |
| | | // break; |
| | | // } |
| | | // record.setEndCount(number); |
| | | // record.setDealTime(dateTimeNumber); |
| | | // record.setWarehouseFlowId(lWarehouseFlowId); |
| | | // |
| | | // //5.新增L_WH_PROCURE_MODEL记录 |
| | | // LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | // lWhProcureModel.setId(IdUtil.generateId()); |
| | | // lWhProcureModel.setBusinessType(3); |
| | | // lWhProcureModel.setBaseGoodsModelsId(record.getBaseGoodsModelsId()); |
| | | // lWhProcureModel.setCounts(record.getThisCount()); |
| | | // lWhProcureModel.setWorehouseCount(goodsNum); |
| | | // int res = this.lWhProcureModelService.insert(lWhProcureModel); |
| | | // flag5 += res; |
| | | // } |
| | | // //如果出库后,剩余库存大于0,新增l_wh_goods_record记录 |
| | | // int flag4 = 0; |
| | | // if (number >= 0){ |
| | | // flag4 = this.lWhGoodsService.insert(recordList); |
| | | // } |
| | | // |
| | | // //如果有一条记录新增失败,则回滚 |
| | | // if (flag1 == 0 || flag3 == 0 || flag4 != recordList.size() || flag5 != recordList.size() || number < 0) { |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | // return 0; |
| | | // } |
| | | // |
| | | // return 1; |
| | | // } |
| | | |
| | | /** |
| | | * @Description 新增出库单 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/27 |
| | | */ |
| | | public int add(LWhFormOutputInsertParam param, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | | public int add(LWhFormOutputParam param, S_user_core currentUser, FinSysTenantUser sysInfo) { |
| | | //1.新增出库单记录 |
| | | LWhFormOutput lWhFormOutput = new LWhFormOutput(); |
| | | //出入库id |
| | |
| | | return 0; |
| | | } |
| | | //2.新增物品型号记录 |
| | | List<LWFormsOutputGoodsParam> goodsList = param.getGoods(); |
| | | List<LWFormsOutputGoodsInfoParam> goodsList = param.getGoods(); |
| | | List<LWhProcureModel> modelList = new ArrayList<>(); |
| | | for (LWFormsOutputGoodsParam goods : goodsList) { |
| | | for (LWFormsOutputGoodsInfoParam goods : goodsList) { |
| | | List<LWFormsOutputGoodsModelParam> models = goods.getModels(); |
| | | for (LWFormsOutputGoodsModelParam model : models) { |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | |
| | | } |
| | | lWhProcureModel.setCounts(model.getCounts()); |
| | | //根据物品型号查询物品库存 |
| | | int goodsNum = this.lWhGoodsService.queryGoodsModelNum(0, warehouseId, model.getBaseGoodsModelsId(), (short) 1, null); |
| | | int goodsNum = this.lWhGoodsService.queryGoodsModelNum(0, warehouseId, model.getBaseGoodsModelsId(), 1, null); |
| | | lWhProcureModel.setWorehouseCount(goodsNum); |
| | | modelList.add(lWhProcureModel); |
| | | } |
| | |
| | | } |
| | | |
| | | //3.根据出库单出库 |
| | | Long lWarehouseFlowId = this.lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, currentUser, param.getDealTime()); |
| | | Long lWarehouseFlowId = this.lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, WhBusinessEnum.CHUKU, currentUser, param.getDealTime(), null); |
| | | if (lWarehouseFlowId == null) { |
| | | log.error("根据出库单出库失败"); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | |
| | | //出库单号 |
| | | if (!StringUtils.isEmpty(param.getBusinessFormCode())) { |
| | | sql.append(" and BUSINESS_FORM_CODE = :businessFormCode "); |
| | | paramts.put("businessFormCode", StringUtils.CHAR_PERCENT + param.getBusinessFormCode() + StringUtils.CHAR_PERCENT); |
| | | paramts.put("businessFormCode", param.getBusinessFormCode()); |
| | | } |
| | | //物品名称 |
| | | if (!StringUtils.isEmpty(param.getGoodsTemplateName())) { |
| | | if (!StringUtils.isEmpty(param.getGoodsName())) { |
| | | sql.append( |
| | | " AND id IN (SELECT BUSINESS_ID FROM L_WH_PROCURE_MODEL procureModel LEFT JOIN BASE_GOODS_MODELS baseModel ON procureModel.BASE_GOODS_MODELS_ID=baseModel.ID LEFT JOIN BASE_GOODS_TEMPLATE baseTemp ON baseModel.GOODS_TEMPLATES_ID=baseTemp.id WHERE procureModel.BUSINESS_TYPE=1 AND baseTemp.GOODS_NAME LIKE :goodsTemplateName)"); |
| | | paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT); |
| | | " AND id IN (SELECT BUSINESS_ID FROM L_WH_PROCURE_MODEL procureModel LEFT JOIN BASE_GOODS_MODELS baseModel ON procureModel.BASE_GOODS_MODELS_ID=baseModel.ID LEFT JOIN BASE_GOODS_TEMPLATE baseTemp ON baseModel.GOODS_TEMPLATES_ID=baseTemp.id WHERE procureModel.BUSINESS_TYPE=3 AND baseTemp.GOODS_NAME LIKE :goodsTemplateName)"); |
| | | paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //机构 |
| | | if (param.getAgencyId() != null) { |
| | |
| | | GenericPager genericPager = selectSplit(sql.toString(), paramts, new LWhFormOutput()); |
| | | return genericPager; |
| | | } |
| | | |
| | | public GenericPager<Map<String, Object>> queryFormOutputDetailList(LWhFormOutputQry param) { |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | StringBuilder sql = new StringBuilder("SELECT pm.id,fp.BUSINESS_FORM_CODE,fpg.GOODS_TEMPLATE_NAME,pm.PRICE,pm.COUNTS, " |
| | | + "( pm.PRICE * pm.COUNTS ) amount,fp.AGENCY_NAME,fp.BUYER_NAME,fp.PROCURE_TIME,pm.BUSINESS_ID,pm.BASE_GOODS_MODELS_NAME FROM l_wh_procure_model pm " |
| | | + "LEFT JOIN l_wh_form_procure fp ON pm.BUSINESS_ID = fp.id " |
| | | + "LEFT JOIN l_wh_form_procure_goods fpg ON fp.id = fpg.WH_FORM_PROCURE_ID WHERE pm.BUSINESS_TYPE = 1 "); |
| | | //入库单号 |
| | | if (!StringUtils.isEmpty(param.getBusinessFormCode())) { |
| | | sql.append("and BUSINESS_FORM_CODE = :businessFormCode "); |
| | | paramts.put("businessFormCode", param.getBusinessFormCode()); |
| | | } |
| | | //物品名称 |
| | | if (!StringUtils.isEmpty(param.getGoodsName())) { |
| | | sql.append("and fpg.GOODS_TEMPLATE_NAME like :goodsTemplateName "); |
| | | paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | if (param.getAgencyId() != null) { |
| | | sql.append("and AGENCY_ID like :agencyId "); |
| | | paramts.put("agencyId", param.getAgencyId() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //创建人 |
| | | if (!StringUtils.isEmpty(param.getCreateName())) { |
| | | sql.append("and buyer_Name =:buyerName "); |
| | | paramts.put("buyerName", param.getCreateName()); |
| | | } |
| | | //入库开始时间 |
| | | if (param.getStartTime() != null) { |
| | | sql.append("and INCOME_TIME >=:incomeTimeStart "); |
| | | paramts.put("incomeTimeStart", param.getStartTime() * 1000000); |
| | | } |
| | | //入库结束时间 |
| | | if (param.getEndTime() != null) { |
| | | sql.append("and INCOME_TIME <:incomeTimeEnd "); |
| | | paramts.put("incomeTimeEnd", param.getEndTime() * 1000000 + 240000); |
| | | } |
| | | //规格型号 |
| | | if (param.getBaseGoodsModelsId() != null) { |
| | | sql.append("and pm.BASE_GOODS_MODELS_ID =:baseGoodsModelsId "); |
| | | paramts.put("baseGoodsModelsId", param.getBaseGoodsModelsId()); |
| | | } |
| | | |
| | | sql.append("ORDER BY PROCURE_TIME DESC"); |
| | | GenericPager genericPager = selectSplit(sql.toString(), paramts, param.getPageNum(), param.getPageSize(), new MapperUtil()); |
| | | return genericPager; |
| | | |
| | | } |
| | | |
| | | public List<OutputExcelTemplate> getExportList(Long id) { |
| | | String sql = "SELECT\n" |
| | | + "\tfo.BUSINESS_FORM_CODE,\n" |
| | | + "\tfo.AGENCY_NAME tenantName,\n" |
| | | + "\tGOODS_NAME templateName,\n" |
| | | + "\tpm.BASE_GOODS_MODELS_NAME baseModelName,\n" |
| | | + "\tcounts num,\n" |
| | | + "\ttotal_amount totalAmount,\n" |
| | | + "\tfo.DEAL_TIME createTime,\n" |
| | | + "\tfo.OPERATOR_NAME,\n" |
| | | + "\tBEIZ remark\n" |
| | | + "FROM\n" |
| | | + "\tl_wh_procure_model pm\n" |
| | | + "\tLEFT JOIN base_goods_models bgm ON pm.BASE_GOODS_MODELS_ID = bgm.id\n" |
| | | + "\tLEFT JOIN base_goods_template bgt ON bgm.GOODS_TEMPLATES_ID = bgt.id\n" |
| | | + "\tLEFT JOIN l_wh_form_output fo ON fo.ID = pm.BUSINESS_ID\n" |
| | | + "WHERE\n" |
| | | + "\tpm.BUSINESS_ID = :id"; |
| | | |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("id", id); |
| | | List<Map<String, Object>> select = this.select(sql, param, new MapperUtil()); |
| | | if (CollectionUtils.isEmpty(select)) { |
| | | return null; |
| | | } |
| | | List<OutputExcelTemplate> list = Lists.newArrayList(); |
| | | select.forEach(item -> { |
| | | OutputExcelTemplate templateExcelExport = MapUtils.convertMapToObj(item, OutputExcelTemplate.class); |
| | | templateExcelExport.setTotalAmount(CurrencyUtil.convertFenToYuan(templateExcelExport.getTotalAmount())); |
| | | list.add(templateExcelExport); |
| | | }); |
| | | return list; |
| | | |
| | | } |
| | | |
| | | } |