From 07ef5e332c8184c4fc6e6c02343eb1b49cbc07e3 Mon Sep 17 00:00:00 2001 From: cy <1664593601@qq.com> Date: 星期六, 02 十二月 2023 20:59:50 +0800 Subject: [PATCH] feat: 物品报废 --- consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java | 43 ++++++++++++++++++++++++++----------------- 1 files changed, 26 insertions(+), 17 deletions(-) diff --git a/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java b/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java index 06a2a59..28040ff 100644 --- a/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java +++ b/consum-base/src/main/java/com/consum/base/service/LWhFormScrappedCoreService.java @@ -1,6 +1,9 @@ package com.consum.base.service; +import cn.hutool.core.convert.Convert; import com.consum.base.core.WhBusinessEnum; +import com.consum.base.core.service.LWhWarningCoreServiceImpl; +import com.consum.base.core.utils.IdUtil; import com.consum.base.core.utils.LockManage; import com.consum.model.po.LWarehouseFlow; import com.consum.model.po.LWhFormScrapped; @@ -8,13 +11,14 @@ import com.consum.model.po.LWhGoodsRecord; import com.iplatform.model.po.S_user_core; import com.walker.infrastructure.utils.CollectionUtils; -import com.walker.infrastructure.utils.NumberGenerator; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; 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; @@ -26,24 +30,27 @@ **/ @Service @Slf4j +@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public class LWhFormScrappedCoreService { private GoodsBaseServiceImpl goodsBaseService; private LWhFormScrappedGoodsService lWhFormScrappedGoodsService; - private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; + private BaseGoodsTemplateService baseGoodsTemplateService; private LWhGoodsService lWhGoodsService; private LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService; private LWhGoodsRecordService lWhGoodsRecordService; private LWarehouseFlowService lWarehouseFlowService; + private LWhWarningCoreServiceImpl lWhWarningCoreService; @Autowired public LWhFormScrappedCoreService(GoodsBaseServiceImpl goodsBaseService, - LWhFormScrappedGoodsService lWhFormScrappedGoodsService, - BaseGoodsTemplateServiceImpl baseGoodsTemplateService, - LWhGoodsService lWhGoodsService, - LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, - LWhGoodsRecordService lWhGoodsRecordService, - LWarehouseFlowService lWarehouseFlowService) { + LWhFormScrappedGoodsService lWhFormScrappedGoodsService, + BaseGoodsTemplateService baseGoodsTemplateService, + LWhGoodsService lWhGoodsService, + LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, + LWhGoodsRecordService lWhGoodsRecordService, + LWarehouseFlowService lWarehouseFlowService, + LWhWarningCoreServiceImpl lWhWarningCoreService) { // this.lWhFormScrappedService = lWhFormScrappedService; this.lWhFormScrappedGoodsService = lWhFormScrappedGoodsService; this.baseGoodsTemplateService = baseGoodsTemplateService; @@ -52,6 +59,7 @@ this.lWhGoodsRecordService = lWhGoodsRecordService; this.lWarehouseFlowService = lWarehouseFlowService; this.goodsBaseService = goodsBaseService; + this.lWhWarningCoreService = lWhWarningCoreService; } @@ -80,7 +88,7 @@ Long warehouseId = lWhFormScrapped.getWarehouseId(); String warehouseName = lWhFormScrapped.getWarehouseName(); // 娴佹按璁板綍鎬昏〃ID - long lWarehouseFlowId = NumberGenerator.getLongSequenceNumberNano(); + long lWarehouseFlowId = IdUtil.generateId(); //瑕佹姤搴熺殑鐗╁搧 LWhFormScrappedGoods goods = new LWhFormScrappedGoods(); @@ -92,11 +100,14 @@ } // 鎸夊瀷鍙峰垎缁� + ArrayList<Long> allChangModelList = new ArrayList<>(); + Map<Long, List<LWhFormScrappedGoods>> modelGroup = formScrappedGoods.stream() - .collect(Collectors.groupingBy(LWhFormScrappedGoods::getBaseGoodsModelsId)); + .collect(Collectors.groupingBy(LWhFormScrappedGoods::getBaseGoodsModelsId)); for (Map.Entry<Long, List<LWhFormScrappedGoods>> entry : modelGroup.entrySet()) { //瑙勬牸鍨嬪彿缂栧彿 Long baseGoodsModelsId = entry.getKey(); + allChangModelList.add(baseGoodsModelsId); //瀵规瘡缁勪腑瑕佹姤搴熺殑鏁伴噺姹傚拰 List<LWhFormScrappedGoods> modelGoodsList = entry.getValue(); //鏌ヨ鍨嬪彿淇℃伅 @@ -107,7 +118,7 @@ String goodsName = (String) tempGoodsInfo.get("goodsname"); String modelName = (String) tempGoodsInfo.get("modelname"); // 鎻掑叆 鍚勮鏍肩墿鍝佺殑杩涘嚭搴撹褰� L_WH_GOODS_RECORD - long whGoodsRecordId = NumberGenerator.getLongSequenceNumberNano(); + long whGoodsRecordId = IdUtil.generateId(); LWhGoodsRecord whGoodsRecord = new LWhGoodsRecord(); whGoodsRecord.setId(whGoodsRecordId); whGoodsRecord.setWarehouseType(warehouseType); @@ -140,7 +151,7 @@ String userName = formScrappedGood.getUserName(); // 鏍规嵁鍒嗗彂鍗曘�佽鏍煎瀷鍙风紪鍙枫�佷娇鐢ㄤ汉鍛樺悕绉帮紝杩涜鎶ュ簾 srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(warehouseType, warehouseId, transBusinessId, userName, baseGoodsModelsId, - (short) 2, counts); + (short) 2, counts); } if (CollectionUtils.isEmpty(srappedGoodsIds) || srappedGoodsIds.size() < counts) { log.error("瑕佹姤搴熺殑鐗╁搧鏁伴噺涓嶈冻锛�"); @@ -180,17 +191,15 @@ } // 鏇存柊鎶ュ簾鍗� lWhFormScrapped = new LWhFormScrapped(formScrappedId); - lWhFormScrapped = goodsBaseService.get(lWhFormScrapped); - if (lWhFormScrapped != null && lWhFormScrapped.getStates() != 0) { - log.error("鎶ュ簾澶辫触锛佽妫�鏌ユ姤搴熷崟鐘舵��"); - return null; - } lWhFormScrapped.setLWarehouseFlowId(lWarehouseFlowId); lWhFormScrapped.setStates(1); lWhFormScrapped.setOperatorId(userId); lWhFormScrapped.setOperatorName(nickName); lWhFormScrapped.setDealTime(dealTime); goodsBaseService.update(lWhFormScrapped); + + //褰撳簱瀛樺彉鍔ㄦ椂璋冪敤璇ユ柟娉� + lWhWarningCoreService.updateKuCun(Convert.toShort(warehouseType,(short) 0), warehouseId, allChangModelList, null, dealTime); return lWarehouseFlowId; } -- Gitblit v1.9.1