From 53813b862f027c97c967415bb7773ffbf6b6ea3d Mon Sep 17 00:00:00 2001 From: cy <1664593601@qq.com> Date: 星期五, 01 十二月 2023 14:51:49 +0800 Subject: [PATCH] feat: 部门报废 --- consum-base/src/main/java/com/consum/base/service/LWhFormOutputCoreService.java | 74 ++++++++++++++++++++++++++----------- 1 files changed, 52 insertions(+), 22 deletions(-) diff --git a/consum-base/src/main/java/com/consum/base/service/LWhFormOutputCoreService.java b/consum-base/src/main/java/com/consum/base/service/LWhFormOutputCoreService.java index 4a4a7e9..37cba45 100644 --- a/consum-base/src/main/java/com/consum/base/service/LWhFormOutputCoreService.java +++ b/consum-base/src/main/java/com/consum/base/service/LWhFormOutputCoreService.java @@ -1,10 +1,12 @@ package com.consum.base.service; +import cn.hutool.core.convert.Convert; 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.util.LockManage; +import com.consum.base.core.service.LWhWarningCoreServiceImpl; +import com.consum.base.core.utils.LockManage; import com.consum.model.po.*; import com.iplatform.model.po.S_user_core; import com.walker.infrastructure.utils.CollectionUtils; @@ -12,22 +14,23 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import java.util.ArrayList; import java.util.List; import java.util.Map; /** * @ClassName WhFormOutputCoreService - * @Date 2023/10/26 * @Description * @Version 1.0 **/ @Slf4j @Service -@Transactional(rollbackFor = Exception.class) +@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public class LWhFormOutputCoreService { private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; @@ -35,6 +38,7 @@ private CodeGeneratorService codeGeneratorService; private LWhProcureModelService lWhProcureModelService; private LWhFormOutputService lWhFormOutputService; + private LWhWarningCoreServiceImpl lWhWarningCoreService; private LWarehouseFlowService lWarehouseFlowService; private LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService; private LWhGoodsRecordService lWhGoodsRecordService; @@ -47,7 +51,8 @@ LWhFormOutputService lWhFormOutputService, LWarehouseFlowService lWarehouseFlowService, LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, - LWhGoodsRecordService lWhGoodsRecordService) { + LWhGoodsRecordService lWhGoodsRecordService, + LWhWarningCoreServiceImpl lWhWarningCoreService) { this.baseGoodsTemplateService = baseGoodsTemplateService; this.lWhGoodsService = lWhGoodsService; this.codeGeneratorService = codeGeneratorService; @@ -56,6 +61,7 @@ this.lWarehouseFlowService = lWarehouseFlowService; this.lWhGoodsRecordDetailsService = lWhGoodsRecordDetailsService; this.lWhGoodsRecordService = lWhGoodsRecordService; + this.lWhWarningCoreService = lWhWarningCoreService; } @@ -66,7 +72,7 @@ * @return 鍑哄簱鍗旾d */ @Transactional(rollbackFor = Exception.class) - public Long createOutFormByTransId(Long whFormTransferId, S_user_core currentUser, Long dealTime) { + public Long createOutFormByTransId(Long whFormTransferId, WhBusinessEnum businessEnum, S_user_core currentUser, Long dealTime) { if (whFormTransferId == null) { return null; } @@ -83,10 +89,11 @@ } //鐢宠璋冩嫧鐨勭墿鍝� - List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(WhBusinessEnum.DIAOBO, whFormTransferId); + List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(businessEnum, whFormTransferId); if (CollectionUtils.isEmpty(goodsModelNumList)) { log.error("娌℃湁瑕佸叆搴撶殑鐗╁搧"); - return null; + throw new RuntimeException("娌℃湁瑕佸叆搴撶殑鐗╁搧"); +// return null; } Long outWarehouseId = lWhFormTransfer.getOutWarehouseId(); String outWarehouseName = lWhFormTransfer.getOutWarehouseName(); @@ -122,6 +129,7 @@ whFormOutput.setOutputName("璋冩嫧鍑哄簱"); whFormOutput.setWarehouseId(outWarehouseId); whFormOutput.setWarehouseName(outWarehouseName); + // 杩欐牱灏辨煡璇笉鍒拌鏉¤褰� whFormOutput.setAgencyId(null); whFormOutput.setAgencyName(null); whFormOutput.setOperatorId(currentUser.getId()); @@ -146,7 +154,7 @@ * @return 娴佹按璁板綍鎬昏〃ID */ @Transactional(rollbackFor = Exception.class) - public Long outFormByTransId(Long outWarehouseFormId, S_user_core currentUser, Long dealTime) { + public Long outFormByTransId(Long outWarehouseFormId, WhBusinessEnum businessType, S_user_core currentUser, Long dealTime) { if (outWarehouseFormId == null) { return null; } @@ -166,6 +174,9 @@ Integer outWarehouseType = lWhFormOutput.getOutWarehouseType(); Long outWarehouseId = lWhFormOutput.getWarehouseId(); String warehouseName = lWhFormOutput.getWarehouseName(); + Integer inWarehouseType = lWhFormOutput.getInWarehouseType(); + Long inWarehouseId = lWhFormOutput.getInWarehouseId(); + String inWarehouseName = lWhFormOutput.getInWarehouseName(); Long userId = currentUser.getId(); String nickName = currentUser.getNick_name(); @@ -176,33 +187,41 @@ long lWarehouseFlowBusinessId = outWarehouseFormId; // 鐗╁搧鐘舵�侊紙0=鍦ㄩ�旇皟鎷紱1=鍏ュ簱鏈垎鍙戯紱2=宸蹭笅鍙戯紱3=鎶ュ簾锛� - short queryModelStatusT = 1; + Integer queryModelStatusT = 1; //閲囪喘鏂瑰紡锛�1锛氶泦閲囷紱2=鑷噰锛� - Short buyTypeT = null; - Short modGoodsTransferingStatusT = null; - String outputCode = lWhFormOutput.getOutputCode(); - if ((BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() + "").equals(outputCode)) { + Integer buyTypeT = null; + Integer modGoodsTransferingStatusT = null; + short businessTypeValue = businessType.getValue(); + if (BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() == businessTypeValue) { //璋冩嫧鍑哄簱 queryModelStatusT = 1; buyTypeT = 1; lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId(); modGoodsTransferingStatusT = 0; - } else if ((BaseWarehouseParam1.In_OutPutTypeEnum.Dept_Lending_Out.getValue() + "").equals(outputCode)) { + } else if (BaseWarehouseParam1.In_OutPutTypeEnum.Dept_Lending_Out.getValue() == businessTypeValue) { // 閮ㄩ棬浠撳簱 鍒嗗彂鍑哄簱 // queryModelStatusT = 2; - } else if ((BaseWarehouseParam1.In_OutPutTypeEnum.Fragmentary_Output.getValue() + "").equals(outputCode)) { + 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; } - short queryModelStatus = queryModelStatusT; - Short buyType = buyTypeT; - Short modGoodsTransferingStatus = modGoodsTransferingStatusT; + Integer queryModelStatus = queryModelStatusT; + Integer buyType = buyTypeT; + Integer modGoodsTransferingStatus = modGoodsTransferingStatusT; + ArrayList<Long> allChangModelList = new ArrayList<>(); goodsModelNumList.forEach(itemModelInfo -> { // 闇�瑕佽皟鎷ㄧ殑鐗╁搧鐨勬煇涓瀷鍙� Long baseGoodsModelsId = itemModelInfo.getBaseGoodsModelsId(); + allChangModelList.add(baseGoodsModelsId); // 闇�瑕佽皟鎷ㄧ殑鐗╁搧鏌愪釜鍨嬪彿鐨勬暟閲� Integer counts = itemModelInfo.getCounts(); @@ -237,6 +256,7 @@ //閫氳繃LockManage鑾峰緱閿� Object warehouseModelLockObj = LockManage.acquireLock(outWarehouseType, outWarehouseId, baseGoodsModelsId); + List<Long> outGoodsId = null; synchronized (warehouseModelLockObj) { // 鑾峰緱閿佸悗鏌ヨ璇ュ瀷鍙风殑鏈熷垵鏁伴噺 int goodsModelNum = lWhGoodsService.queryGoodsModelNum(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType); @@ -250,19 +270,25 @@ whGoodsRecord.setEndCount(goodsModelNum - counts); //鍑哄簱鏃跺�欙紝鎸� 鍏堝叆搴撶殑鍏堝嚭搴擄紝鍚屾椂鍏ュ簱鐨勶紝鎸変环鏍奸珮鐨勫厛鍑哄簱 - List<Long> outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId, queryModelStatus, buyType, goodsModelNum); - lWhGoodsService.modGoodsTransfering(outGoodsId, null, null, null, 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); - lWhGoodsRecordService.insert(whGoodsRecord); } + long totalAmount = lWhGoodsService.queryGoodsPriceById(outGoodsId); + LWhProcureModel lWhProcureModel = new LWhProcureModel(itemModelInfo.getId()); + whGoodsRecord.setTotalPrice(totalAmount); + lWhGoodsRecordService.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(WhBusinessEnum.DIAOBO.getValue() + 0); + warehouseFlow.setBusinessType(businessType.getValue() + 0); warehouseFlow.setBusinessFormId(lWarehouseFlowBusinessId); warehouseFlow.setOperatorId(userId); @@ -279,6 +305,10 @@ lWhFormOutput.setWarehouseFlowId(lWarehouseFlowId); lWhFormOutputService.update(lWhFormOutput); + //褰撳簱瀛樺彉鍔ㄦ椂璋冪敤璇ユ柟娉� + if (outWarehouseType == 0){ + lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short) 0), outWarehouseId, allChangModelList, null, dealTime); + } return lWarehouseFlowId; } -- Gitblit v1.9.1