From 12b37691692364c8cb3f76fdc7f3ffddc89eb891 Mon Sep 17 00:00:00 2001 From: futian.liu <liufutianyoo@163.com> Date: 星期一, 18 十二月 2023 17:05:42 +0800 Subject: [PATCH] 调拨出库回显时间 --- consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java | 158 +++++++++++++++++++++++----------------------------- 1 files changed, 69 insertions(+), 89 deletions(-) diff --git a/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java b/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java index 624d04b..7f53a70 100644 --- a/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java +++ b/consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java @@ -1,6 +1,7 @@ package com.consum.base.service.impl; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -13,8 +14,9 @@ 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; @@ -57,15 +59,11 @@ private LWhGoodsRecordService lWhGoodsRecordServiceImpl; @Autowired - public LWhFormOutputCoreService(BaseGoodsTemplateService baseGoodsTemplateService, - LWhGoodsService lWhGoodsService, - CodeGeneratorService codeGeneratorService, - LWhProcureModelService lWhProcureModelService, - LWhFormOutputService lWhFormOutputService, - LWarehouseFlowService lWarehouseFlowService, - LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, - LWhGoodsRecordService lWhGoodsRecordServiceImpl, - LWhWarningCoreServiceImpl lWhWarningCoreService) { + 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.codeGeneratorService = codeGeneratorService; @@ -77,7 +75,6 @@ this.lWhWarningCoreService = lWhWarningCoreService; } - /** * 鏍规嵁 璋冩嫧鍗� 鐢熸垚 鍑哄簱鍗� * @@ -85,7 +82,8 @@ * @return 鍑哄簱鍗旾d */ @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; } @@ -96,27 +94,24 @@ return null; } // 鏌ヨ璇ヨ皟鎷ㄥ崟鏄惁宸茬粡鐢熸垚浜嗗嚭搴撳崟 - Long outWarehouseFormIdT = lWhFormOutputService.queyrIdByTransferId(whFormTransferId); - if (outWarehouseFormIdT != null) { - return outWarehouseFormIdT; + Long outWarehouseFormId = lWhFormOutputService.queyrIdByTransferId(whFormTransferId); + if (outWarehouseFormId != null) { + return outWarehouseFormId; } + // 鍑哄簱鍗旾D + outWarehouseFormId = NumberGenerator.getLongSequenceNumberNano(); - //鐢宠璋冩嫧鐨勭墿鍝� + // 鐢宠璋冩嫧鐨勭墿鍝� List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(businessEnum, whFormTransferId); if (CollectionUtils.isEmpty(goodsModelNumList)) { log.error("娌℃湁瑕佸叆搴撶殑鐗╁搧"); throw new RuntimeException("娌℃湁瑕佸叆搴撶殑鐗╁搧"); -// return null; } Long outWarehouseId = lWhFormTransfer.getOutWarehouseId(); String outWarehouseName = lWhFormTransfer.getOutWarehouseName(); - // 鍑哄簱鍗旾D - outWarehouseFormIdT = NumberGenerator.getLongSequenceNumberNano(); - Long outWarehouseFormId = outWarehouseFormIdT; - // 璋冩嫧鍗曠墿鍝� 宸茬粡鎸夊瀷鍙峰垎濂戒簡 - goodsModelNumList.forEach(itemModelInfo -> { + for (LWhProcureModel itemModelInfo : goodsModelNumList) { // 澶嶇敤瀵硅薄 itemModelInfo.setId(IdUtil.generateId()); itemModelInfo.setFromProcureGoodsId(null); @@ -124,21 +119,21 @@ itemModelInfo.setBusinessId(outWarehouseFormId); itemModelInfo.setPrice(null); itemModelInfo.setSupplier(null); - }); + } lWhProcureModelService.insertBatch(goodsModelNumList); // //鍒涘缓鍑哄簱鍗� LWhFormOutput whFormOutput = new LWhFormOutput(); - whFormOutput.setId(outWarehouseFormId); // 姝ゆ椂骞舵病鏈夊嚭搴� whFormOutput.setWarehouseFlowId(null); - whFormOutput.setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.OutPut_Warehouse)); - //杩涘嚭搴撴祦姘存�昏〃 鍏ュ簱鍗旾D + whFormOutput + .setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.OutPut_Warehouse)); + // 杩涘嚭搴撴祦姘存�昏〃 鍏ュ簱鍗旾D whFormOutput.setInWarehouseFlowId(null); -// 璋冩嫧鍗旾D(璋冩嫧鏃堕渶瑕�) + // 璋冩嫧鍗旾D(璋冩嫧鏃堕渶瑕�) 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); @@ -149,7 +144,7 @@ whFormOutput.setOperatorName(currentUser.getNick_name()); whFormOutput.setDealTime(dealTime); - whFormOutput.setStates(1); + whFormOutput.setStates(OutPutStatesType.OUT_PENDING.getValue()); int insert = lWhFormOutputService.insert(whFormOutput); if (insert == 0) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @@ -159,7 +154,6 @@ return outWarehouseFormId; } - /** * 鏍规嵁 鍑哄簱鍗� 鍑哄簱 * @@ -167,7 +161,8 @@ * @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; } @@ -177,8 +172,9 @@ log.error("鍑哄簱澶辫触锛佽妫�鏌ュ嚭搴撳崟鐘舵��"); 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; @@ -196,65 +192,46 @@ // 娴佹按璁板綍鎬昏〃ID long lWarehouseFlowId = NumberGenerator.getLongSequenceNumberNano(); - // 娴佹按璁板綍鎬昏〃涓� 涓氬姟ID 銆傝皟鎷ㄥ崟鏃� 淇濆瓨璋冩嫧鍗昳d 鍑哄簱鍗曟椂 淇濆瓨鍑哄簱鍗昳d long lWarehouseFlowBusinessId = outWarehouseFormId; + Integer queryModelStatus = 1; + Integer buyType = null; + Integer modGoodsTransferStatus = null; - // 鐗╁搧鐘舵�侊紙0=鍦ㄩ�旇皟鎷紱1=鍏ュ簱鏈垎鍙戯紱2=宸蹭笅鍙戯紱3=鎶ュ簾锛� - Integer queryModelStatusT = 1; - //閲囪喘鏂瑰紡锛�1锛氶泦閲囷紱2=鑷噰锛� - Integer buyTypeT = null; - Integer modGoodsTransferingStatusT = null; - short businessTypeValue = businessType.getValue(); - if (BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() == businessTypeValue) { - //璋冩嫧鍑哄簱 - queryModelStatusT = 1; - buyTypeT = 1; + Integer businessTypeValue = businessType.getValue(); + if (businessTypeValue == InAndOutPutType.Transfer_Output.getValue()) { + // 璋冩嫧鍑哄簱 + queryModelStatus = 0; + buyType = 1; lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId(); - modGoodsTransferingStatusT = 0; - } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Dept_Lending_Out.getValue() == businessTypeValue) { - // 閮ㄩ棬浠撳簱 鍒嗗彂鍑哄簱 -// queryModelStatusT = 2; + modGoodsTransferStatus = 0; + } else if (businessTypeValue == InAndOutPutType.Dept_Lending_Out.getValue()) { + // 閮ㄩ棬浠撳簱 鍒嗗彂鍑哄簱 lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId(); - } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Fragmentary_Output.getValue() == businessTypeValue) { - // 闆舵槦鍑哄簱 - queryModelStatusT = 1; - buyTypeT = null; - modGoodsTransferingStatusT = 4; - } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Inventory_Output.getValue() == businessTypeValue) { - // 鐩樼偣鍑哄簱 - queryModelStatusT = 1; - buyTypeT = null; - modGoodsTransferingStatusT = 4; + } else if (businessTypeValue == InAndOutPutType.Fragmentary_Output.getValue() + || businessTypeValue == InAndOutPutType.Inventory_Output.getValue()) { + // 闆舵槦鍑哄簱 鎴� 鐩樼偣鍑哄簱 + queryModelStatus = 1; + modGoodsTransferStatus = 4; } - Integer queryModelStatus = queryModelStatusT; - Integer buyType = buyTypeT; - Integer modGoodsTransferingStatus = modGoodsTransferingStatusT; ArrayList<Long> allChangModelList = new ArrayList<>(); - goodsModelNumList.forEach(itemModelInfo -> { + for (LWhProcureModel itemModelInfo : goodsModelNumList) { // 闇�瑕佽皟鎷ㄧ殑鐗╁搧鐨勬煇涓瀷鍙� Long baseGoodsModelsId = itemModelInfo.getBaseGoodsModelsId(); - //TODO 涓虹┖鏃朵笉鍔犲叆鏇存柊鍒楄〃 + // TODO 涓虹┖鏃朵笉鍔犲叆鏇存柊鍒楄〃 if (baseGoodsModelsId != null) { allChangModelList.add(baseGoodsModelsId); } // 闇�瑕佽皟鎷ㄧ殑鐗╁搧鏌愪釜鍨嬪彿鐨勬暟閲� Integer counts = itemModelInfo.getCounts(); - //鏌ヨ鍨嬪彿淇℃伅 + // 鏌ヨ鍨嬪彿淇℃伅 Map<String, Object> tempGoodsInfo = baseGoodsTemplateService.queryGoodsInfoByModelId(baseGoodsModelsId); - //浠峰�肩被鍨� - String classificationObj = (String) tempGoodsInfo.get("classification"); - Short classificationT = 3; - if (classificationObj != null) { - classificationT = (short) ((classificationObj).charAt(0) - 64); - } - short classification = classificationT; - Long tempGoodsId = (Long) tempGoodsInfo.get("goodsid"); - String goodsName = (String) tempGoodsInfo.get("goodsname"); - String modelName = (String) tempGoodsInfo.get("modelname"); - String goodsUnit = (String) tempGoodsInfo.get("unit"); + + Long tempGoodsId = (Long)tempGoodsInfo.get("goodsid"); + String goodsName = (String)tempGoodsInfo.get("goodsname"); + String modelName = (String)tempGoodsInfo.get("modelname"); // 鎻掑叆 鍚勮鏍肩墿鍝佺殑杩涘嚭搴撹褰� L_WH_GOODS_RECORD long whGoodsRecordId = NumberGenerator.getLongSequenceNumberNano(); @@ -267,16 +244,18 @@ whGoodsRecord.setBaseGoodsModelsId(baseGoodsModelsId); whGoodsRecord.setBaseGoodsModelsName(modelName); whGoodsRecord.setDealTime(dealTime); - //鏈璋冩暣绫诲瀷 1=璋冨锛�2=璋冨噺 + // 鏈璋冩暣绫诲瀷 1=璋冨锛�2=璋冨噺 whGoodsRecord.setThisType(2); whGoodsRecord.setThisCount(counts); - //閫氳繃LockManage鑾峰緱閿� + // 閫氳繃LockManage鑾峰緱閿� Object warehouseModelLockObj = LockManage.acquireLock(outWarehouseType, outWarehouseId, baseGoodsModelsId); 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); // 鎵嬪姩鍥炴粴 @@ -286,12 +265,13 @@ whGoodsRecord.setInitialCount(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, + modGoodsTransferStatus); // 鎵归噺鎻掑叆 杩涘嚭搴撴祦姘存槑缁哰L_WH_GOODS_RECORD_DETAILS] - lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short) 0); + lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short)0); } long totalAmount = lWhGoodsService.queryGoodsPriceById(outGoodsId); LWhProcureModel lWhProcureModel = new LWhProcureModel(itemModelInfo.getId()); @@ -299,13 +279,13 @@ lWhGoodsRecordServiceImpl.insert(whGoodsRecord); lWhProcureModel.setTotalAmount(totalAmount); lWhProcureModelService.update(lWhProcureModel); - }); + } LWarehouseFlow warehouseFlow = new LWarehouseFlow(); warehouseFlow.setId(lWarehouseFlowId); warehouseFlow.setWarehouseId(outWarehouseId); warehouseFlow.setWarehouseName(warehouseName); warehouseFlow.setThisType(2); - warehouseFlow.setBusinessType(businessType.getValue() + 0); + warehouseFlow.setBusinessType(businessType.getValue()); warehouseFlow.setBusinessFormId(whFormTransferId == null ? lWarehouseFlowBusinessId : whFormTransferId); warehouseFlow.setOperatorId(userId); @@ -318,16 +298,16 @@ } // 鍚戝嚭搴撳崟 鎻掑叆 杩涘嚭搴撴祦姘存�昏〃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; } - } -- Gitblit v1.9.1