cy
2023-11-27 41dd97a3255d581d4013529730cedfb3f8f8e8ea
consum-base/src/main/java/com/consum/base/service/LWhFormInventoryCoreService.java
@@ -4,27 +4,22 @@
import com.consum.base.core.CodeGeneratorService;
import com.consum.base.core.WhBusinessEnum;
import com.consum.base.core.utils.IdUtil;
import com.consum.model.po.BaseWarehouse;
import com.consum.model.po.FinSysTenantUser;
import com.consum.model.po.LWhFormInventory;
import com.consum.model.po.LWhFormInventoryGoods;
import com.consum.model.po.LWhFormOutput;
import com.consum.model.po.LWhFormProcure;
import com.consum.model.po.LWhFormProcureGoods;
import com.consum.model.po.LWhProcureModel;
import com.consum.model.po.*;
import com.iplatform.model.po.S_user_core;
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.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
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.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.CollectionUtils;
/**
 * @ClassName LWhFormInventoryCoreService
@@ -34,6 +29,7 @@
 **/
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED)
public class LWhFormInventoryCoreService {
    private LWhFormInventoryGoodsServiceImpl lWhFormInventoryGoods;
@@ -51,17 +47,17 @@
    @Autowired
    public LWhFormInventoryCoreService(LWhFormInventoryGoodsServiceImpl lWhFormInventoryGoods,
        LWhFormOutputCoreService lWhFormOutputCoreService,
        CodeGeneratorService codeGeneratorService,
        LWhFormProcureService lWhFormProcureService,
        BaseWarehouseServiceImpl baseWarehouseService,
        LWhFormProcureGoodsService lWhFormProcureGoodsService,
        LWhProcureModelService lWhProcureModelService,
        BaseGoodsTemplateServiceImpl baseGoodsTemplateService,
        LWhGoodsService lWhGoodsService,
        LWhFormInventoryServiceImpl lWhFormInventoryService,
        LWhFormProcureCoreService lWhFormProcureCoreService,
        LWhFormOutputServiceImpl lWhFormOutputService
                                       LWhFormOutputCoreService lWhFormOutputCoreService,
                                       CodeGeneratorService codeGeneratorService,
                                       LWhFormProcureService lWhFormProcureService,
                                       BaseWarehouseServiceImpl baseWarehouseService,
                                       LWhFormProcureGoodsService lWhFormProcureGoodsService,
                                       LWhProcureModelService lWhProcureModelService,
                                       BaseGoodsTemplateServiceImpl baseGoodsTemplateService,
                                       LWhGoodsService lWhGoodsService,
                                       LWhFormInventoryServiceImpl lWhFormInventoryService,
                                       LWhFormProcureCoreService lWhFormProcureCoreService,
                                       LWhFormOutputServiceImpl lWhFormOutputService
    ) {
        this.lWhFormInventoryGoods = lWhFormInventoryGoods;
@@ -104,8 +100,8 @@
            return "没有找到盘点单结果物品";
        }
        Map<Integer, List<LWhFormInventoryGoods>> inventoryGoodsMap = lWhFormInventoryGoods.stream()
            .filter(goods -> goods.getInventoryResult() == 2 || goods.getInventoryResult() == 3)
            .collect(Collectors.groupingBy(LWhFormInventoryGoods::getInventoryResult));
                .filter(goods -> goods.getInventoryResult() == 2 || goods.getInventoryResult() == 3)
                .collect(Collectors.groupingBy(LWhFormInventoryGoods::getInventoryResult));
        if (CollectionUtils.isEmpty(lWhFormInventoryGoods)) {
//            rtnMap.put("status", true);
            return null;
@@ -131,8 +127,8 @@
//                    rtnMap.put("errMsg", "创建入库单失败");
                    return "创建入库单失败";
                }
                Long inFormByInventoryId = (Long) inOutMap.get("inId");
                inOutMap.putAll(rkMap);
                Long inFormByInventoryId = (Long) inOutMap.get("inId");
                String errMsg = lWhFormProcureCoreService.doProcure(inFormByInventoryId, currentUser);
                if (errMsg != null) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -156,7 +152,7 @@
                inOutMap.putAll(ckMap);
                Long lWhFormOutputId = (Long) inOutMap.get("outId");
                //2.根据出库单出库
                Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, WhBusinessEnum.CAIGOU, currentUser, stopTime);
                Long lWarehouseFlowId = lWhFormOutputCoreService.outFormByTransId(lWhFormOutputId, WhBusinessEnum.PANDIAN, currentUser, stopTime);
                if (lWarehouseFlowId == null) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                    throw new RuntimeException("创建出库单失败");
@@ -187,7 +183,7 @@
     * @param currentUser
     */
    private Map<String, Object> createInFormByInventoryId(Long warehouseId, Long procureTime, List<LWhFormInventoryGoods> inventoryGoodsList,
        S_user_core currentUser) {
                                                          S_user_core currentUser) {
        if (CollectionUtils.isEmpty(inventoryGoodsList)) {
            return null;
        }
@@ -268,7 +264,7 @@
     * @param currentUser
     */
    private Map<String, Object> createOutFormByInventoryId(Long warehouseId, Long procureTime, List<LWhFormInventoryGoods> inventoryGoodsList,
        S_user_core currentUser, FinSysTenantUser sysInfo) {
                                                           S_user_core currentUser, FinSysTenantUser sysInfo) {
        if (CollectionUtils.isEmpty(inventoryGoodsList)) {
            return null;
        }
@@ -277,6 +273,7 @@
        //出入库id
        long lWhFormOutputId = IdUtil.generateId();
        lWhFormOutput.setId(lWhFormOutputId);
        lWhFormOutput.setOutWarehouseType(0);
        lWhFormOutput.setWarehouseId(warehouseId);
        //根据仓库id查询仓库
        BaseWarehouse warehouse = this.baseWarehouseService.getById(warehouseId);
@@ -301,6 +298,7 @@
        if (flag1 != 1) {
            return null;
        }
        ArrayList<LWhProcureModel> lWhProcureModels = new ArrayList<>();
        for (LWhFormInventoryGoods inventoryGoods : inventoryGoodsList) {
            Long baseGoodsModelsId = inventoryGoods.getBaseGoodsModelsId();
            Integer counts = inventoryGoods.getErrorCounts();
@@ -312,11 +310,16 @@
            //新增L_WH_PROCURE_MODEL记录
            LWhProcureModel lWhProcureModel = new LWhProcureModel();
            lWhProcureModel.setId(IdUtil.generateId());
            lWhProcureModel.setBusinessType(3);
            lWhProcureModel.setBusinessType(WhBusinessEnum.CHUKU.getValue() + 0);
            lWhProcureModel.setBusinessId(lWhFormOutputId);
            lWhProcureModel.setBaseGoodsModelsId(baseGoodsModelsId);
            lWhProcureModel.setCounts(counts);
            lWhProcureModel.setWorehouseCount(goodsNum);
            lWhProcureModelService.insert(lWhProcureModel);
//            lWhProcureModelService.insert(lWhProcureModel);
            lWhProcureModels.add(lWhProcureModel);
        }
        if (!CollectionUtils.isEmpty(lWhProcureModels)) {
            lWhProcureModelService.insertBatch(lWhProcureModels);
        }
        HashMap<String, Object> rtnMap = new HashMap<>();
        rtnMap.put("outId", lWhFormOutputId);