| | |
| | | package com.consum.base.service; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.core.util.LockManage; |
| | | import com.consum.model.po.*; |
| | | 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; |
| | | import com.consum.model.po.LWhFormScrappedGoods; |
| | | 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 lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | 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; |
| | | |
| | | /** |
| | | * @ClassName LWhFormScrappedCoreService |
| | |
| | | **/ |
| | | @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, |
| | | BaseGoodsTemplateService baseGoodsTemplateService, |
| | | LWhGoodsService lWhGoodsService, |
| | | LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService, |
| | | LWhGoodsRecordService lWhGoodsRecordService, |
| | | LWarehouseFlowService lWarehouseFlowService) { |
| | | LWarehouseFlowService lWarehouseFlowService, |
| | | LWhWarningCoreServiceImpl lWhWarningCoreService) { |
| | | // this.lWhFormScrappedService = lWhFormScrappedService; |
| | | this.lWhFormScrappedGoodsService = lWhFormScrappedGoodsService; |
| | | this.baseGoodsTemplateService = baseGoodsTemplateService; |
| | |
| | | this.lWhGoodsRecordService = lWhGoodsRecordService; |
| | | this.lWarehouseFlowService = lWarehouseFlowService; |
| | | this.goodsBaseService = goodsBaseService; |
| | | this.lWhWarningCoreService = lWhWarningCoreService; |
| | | } |
| | | |
| | | |
| | |
| | | Long warehouseId = lWhFormScrapped.getWarehouseId(); |
| | | String warehouseName = lWhFormScrapped.getWarehouseName(); |
| | | // 流水记录总表ID |
| | | long lWarehouseFlowId = NumberGenerator.getLongSequenceNumberNano(); |
| | | long lWarehouseFlowId = IdUtil.generateId(); |
| | | |
| | | //要报废的物品 |
| | | LWhFormScrappedGoods goods = new LWhFormScrappedGoods(); |
| | |
| | | } |
| | | |
| | | // 按型号分组 |
| | | Map<Long, List<LWhFormScrappedGoods>> modelGroup = formScrappedGoods.stream().collect(Collectors.groupingBy(LWhFormScrappedGoods::getBaseGoodsModelsId)); |
| | | ArrayList<Long> allChangModelList = new ArrayList<>(); |
| | | |
| | | Map<Long, List<LWhFormScrappedGoods>> modelGroup = formScrappedGoods.stream() |
| | | .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(); |
| | | //查询型号信息 |
| | |
| | | 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); |
| | |
| | | //使用人员名称 |
| | | String userName = formScrappedGood.getUserName(); |
| | | // 根据分发单、规格型号编号、使用人员名称,进行报废 |
| | | srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(warehouseType, warehouseId, transBusinessId, userName, baseGoodsModelsId, (short) 2, counts); |
| | | srappedGoodsIds = lWhGoodsService.queryScrappedGoodsIds(warehouseType, warehouseId, transBusinessId, userName, baseGoodsModelsId, |
| | | (short) 2, counts); |
| | | } |
| | | if (CollectionUtils.isEmpty(srappedGoodsIds) || srappedGoodsIds.size() < counts) { |
| | | log.error("要报废的物品数量不足!"); |
| | |
| | | whGoodsRecord.setEndCount(goodsModelNum - counts); |
| | | |
| | | // 设置物品为报废状态 |
| | | lWhGoodsService.modGoodsTransfering(srappedGoodsIds, null, null, null, (short) 3); |
| | | lWhGoodsService.modGoodsTransfering(srappedGoodsIds, null, null, null, 3); |
| | | // 批量插入 进出库流水明细[L_WH_GOODS_RECORD_DETAILS] |
| | | lWhGoodsRecordDetailsService.sameGoodsInsertMore(srappedGoodsIds, whGoodsRecordId, (short) 2); |
| | | } |
| | |
| | | } |
| | | // 更新报废单 |
| | | 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; |
| | | } |
| | | |