| | |
| | | package com.consum.base.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | 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.service.LWhWarningCoreServiceImpl; |
| | | import com.consum.base.core.type.InAndOutPutType; |
| | | import com.consum.base.core.type.OutPutStatesType; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.core.utils.LockManage; |
| | | import com.consum.base.service.BaseGoodsTemplateService; |
| | |
| | | private LWhGoodsRecordService lWhGoodsRecordServiceImpl; |
| | | |
| | | @Autowired |
| | | public LWhFormOutputCoreService(BaseGoodsTemplateService baseGoodsTemplateService, |
| | | LWhGoodsService lWhGoodsService, |
| | | CodeGeneratorService codeGeneratorService, |
| | | LWhProcureModelService lWhProcureModelService, |
| | | LWhFormOutputService lWhFormOutputService, |
| | | LWarehouseFlowService lWarehouseFlowService, |
| | | LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, |
| | | LWhGoodsRecordService lWhGoodsRecordServiceImpl, |
| | | public LWhFormOutputCoreService(BaseGoodsTemplateService baseGoodsTemplateService, LWhGoodsService lWhGoodsService, |
| | | CodeGeneratorService codeGeneratorService, LWhProcureModelService lWhProcureModelService, |
| | | LWhFormOutputService lWhFormOutputService, LWarehouseFlowService lWarehouseFlowService, |
| | | LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, LWhGoodsRecordService lWhGoodsRecordServiceImpl, |
| | | LWhWarningCoreServiceImpl lWhWarningCoreService) { |
| | | this.baseGoodsTemplateService = baseGoodsTemplateService; |
| | | this.lWhGoodsService = lWhGoodsService; |
| | |
| | | this.lWhWarningCoreService = lWhWarningCoreService; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据 调拨单 生成 出库单 |
| | | * |
| | |
| | | * @return 出库单Id |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createOutFormByTransId(Long whFormTransferId, WhBusinessEnum businessEnum, S_user_core currentUser, Long dealTime) { |
| | | public Long createOutFormByTransId(Long whFormTransferId, WhBusinessEnum businessEnum, S_user_core currentUser, |
| | | Long dealTime) { |
| | | if (whFormTransferId == null) { |
| | | return null; |
| | | } |
| | |
| | | whFormOutput.setId(outWarehouseFormId); |
| | | // 此时并没有出库 |
| | | whFormOutput.setWarehouseFlowId(null); |
| | | whFormOutput.setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.OutPut_Warehouse)); |
| | | whFormOutput |
| | | .setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.OutPut_Warehouse)); |
| | | //进出库流水总表 入库单ID |
| | | whFormOutput.setInWarehouseFlowId(null); |
| | | // 调拨单ID(调拨时需要) |
| | | whFormOutput.setTransBusinessId(whFormTransferId); |
| | | whFormOutput.setOutputCode(BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() + ""); |
| | | whFormOutput.setOutputCode(InAndOutPutType.Transfer_Output.getValue() + ""); |
| | | whFormOutput.setOutputName("调拨出库"); |
| | | whFormOutput.setWarehouseId(outWarehouseId); |
| | | whFormOutput.setWarehouseName(outWarehouseName); |
| | |
| | | return outWarehouseFormId; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据 出库单 出库 |
| | | * |
| | |
| | | * @return 流水记录总表ID |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long outFormByTransId(Long outWarehouseFormId, WhBusinessEnum businessType, S_user_core currentUser, Long dealTime, Long whFormTransferId) { |
| | | public Long outFormByTransId(Long outWarehouseFormId, WhBusinessEnum businessType, S_user_core currentUser, |
| | | Long dealTime, Long whFormTransferId) { |
| | | if (outWarehouseFormId == null) { |
| | | return null; |
| | | } |
| | |
| | | return null; |
| | | } |
| | | //申请调拨的物品 |
| | | List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(WhBusinessEnum.CHUKU, outWarehouseFormId); |
| | | List<LWhProcureModel> goodsModelNumList = |
| | | lWhProcureModelService.getModelByForm(WhBusinessEnum.CHUKU, outWarehouseFormId); |
| | | if (CollectionUtils.isEmpty(goodsModelNumList)) { |
| | | log.error("没有要出库的物品"); |
| | | return null; |
| | |
| | | Integer buyTypeT = null; |
| | | Integer modGoodsTransferingStatusT = null; |
| | | short businessTypeValue = businessType.getValue(); |
| | | if (BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() == businessTypeValue) { |
| | | if (InAndOutPutType.Transfer_Output.getValue() == businessTypeValue) { |
| | | //调拨出库 |
| | | queryModelStatusT = 1; |
| | | buyTypeT = 1; |
| | | lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId(); |
| | | modGoodsTransferingStatusT = 0; |
| | | } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Dept_Lending_Out.getValue() == businessTypeValue) { |
| | | } else if (InAndOutPutType.Dept_Lending_Out.getValue() == businessTypeValue) { |
| | | // 部门仓库 分发出库 |
| | | // queryModelStatusT = 2; |
| | | lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId(); |
| | | } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Fragmentary_Output.getValue() == businessTypeValue) { |
| | | } else if (InAndOutPutType.Fragmentary_Output.getValue() == businessTypeValue) { |
| | | // 零星出库 |
| | | queryModelStatusT = 1; |
| | | buyTypeT = null; |
| | | modGoodsTransferingStatusT = 4; |
| | | } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Inventory_Output.getValue() == businessTypeValue) { |
| | | } else if (InAndOutPutType.Inventory_Output.getValue() == businessTypeValue) { |
| | | // 盘点出库 |
| | | queryModelStatusT = 1; |
| | | buyTypeT = null; |
| | |
| | | List<Long> outGoodsId = null; |
| | | synchronized (warehouseModelLockObj) { |
| | | // 获得锁后查询该型号的期初数量 |
| | | int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType); |
| | | List<Long> warehouseIds = new ArrayList<>(Arrays.asList(outWarehouseId)); |
| | | int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, warehouseIds, |
| | | baseGoodsModelsId, queryModelStatus, buyType); |
| | | if (goodsModelNum < counts) { |
| | | log.error("出库失败!型号{} 的数量不足,需要调拨{}个,仓库中现存{}个", baseGoodsModelsId, counts, goodsModelNum); |
| | | // 手动回滚 |
| | |
| | | whGoodsRecord.setEndCount(goodsModelNum - counts); |
| | | |
| | | //出库时候,按 先入库的先出库,同时入库的,按价格高的先出库 |
| | | outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType, |
| | | counts); |
| | | lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName, modGoodsTransferingStatus); |
| | | outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId, |
| | | queryModelStatus, buyType, counts); |
| | | lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName, |
| | | modGoodsTransferingStatus); |
| | | // 批量插入 进出库流水明细[L_WH_GOODS_RECORD_DETAILS] |
| | | lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short) 0); |
| | | } |
| | |
| | | } |
| | | // 向出库单 插入 进出库流水总表ID |
| | | lWhFormOutput = new LWhFormOutput(outWarehouseFormId); |
| | | lWhFormOutput.setStates(2); |
| | | lWhFormOutput.setStates(OutPutStatesType.OUT_SUCCESS.getValue()); |
| | | lWhFormOutput.setWarehouseFlowId(lWarehouseFlowId); |
| | | lWhFormOutputService.update(lWhFormOutput); |
| | | |
| | | //当库存变动时调用该方法 |
| | | if (outWarehouseType == 0) { |
| | | lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short) 0), outWarehouseId, allChangModelList, null, dealTime); |
| | | lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short)0), outWarehouseId, |
| | | allChangModelList, null, dealTime); |
| | | } |
| | | return lWarehouseFlowId; |
| | | } |
| | | |
| | | |
| | | } |