cy
2023-11-27 41dd97a3255d581d4013529730cedfb3f8f8e8ea
consum-base/src/main/java/com/consum/base/service/LWhFormOutputCoreService.java
@@ -1,9 +1,11 @@
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.service.LWhWarningCoreServiceImpl;
import com.consum.base.core.utils.LockManage;
import com.consum.model.po.*;
import com.iplatform.model.po.S_user_core;
@@ -12,9 +14,11 @@
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;
@@ -26,7 +30,7 @@
 **/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class LWhFormOutputCoreService {
    private BaseGoodsTemplateServiceImpl baseGoodsTemplateService;
@@ -34,6 +38,7 @@
    private CodeGeneratorService codeGeneratorService;
    private LWhProcureModelService lWhProcureModelService;
    private LWhFormOutputService lWhFormOutputService;
    private LWhWarningCoreServiceImpl lWhWarningCoreService;
    private LWarehouseFlowService lWarehouseFlowService;
    private LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService;
    private LWhGoodsRecordService lWhGoodsRecordService;
@@ -46,7 +51,8 @@
                                    LWhFormOutputService lWhFormOutputService,
                                    LWarehouseFlowService lWarehouseFlowService,
                                    LWhGoodsRecordDetailsService lWhGoodsRecordDetailsService,
                                    LWhGoodsRecordService lWhGoodsRecordService) {
                                    LWhGoodsRecordService lWhGoodsRecordService,
                                    LWhWarningCoreServiceImpl lWhWarningCoreService) {
        this.baseGoodsTemplateService = baseGoodsTemplateService;
        this.lWhGoodsService = lWhGoodsService;
        this.codeGeneratorService = codeGeneratorService;
@@ -55,6 +61,7 @@
        this.lWarehouseFlowService = lWarehouseFlowService;
        this.lWhGoodsRecordDetailsService = lWhGoodsRecordDetailsService;
        this.lWhGoodsRecordService = lWhGoodsRecordService;
        this.lWhWarningCoreService = lWhWarningCoreService;
    }
@@ -121,6 +128,7 @@
        whFormOutput.setOutputName("调拨出库");
        whFormOutput.setWarehouseId(outWarehouseId);
        whFormOutput.setWarehouseName(outWarehouseName);
        // 这样就查询不到该条记录
        whFormOutput.setAgencyId(null);
        whFormOutput.setAgencyName(null);
        whFormOutput.setOperatorId(currentUser.getId());
@@ -145,7 +153,7 @@
     * @return 流水记录总表ID
     */
    @Transactional(rollbackFor = Exception.class)
    public Long outFormByTransId(Long outWarehouseFormId,WhBusinessEnum businessType, S_user_core currentUser, Long dealTime) {
    public Long outFormByTransId(Long outWarehouseFormId, WhBusinessEnum businessType, S_user_core currentUser, Long dealTime) {
        if (outWarehouseFormId == null) {
            return null;
        }
@@ -178,33 +186,40 @@
        long lWarehouseFlowBusinessId = outWarehouseFormId;
        // 物品状态(0=在途调拨;1=入库未分发;2=已下发;3=报废)
        short queryModelStatusT = 1;
        Integer queryModelStatusT = 1;
        //采购方式(1:集采;2=自采)
        Short buyTypeT = null;
        Integer buyTypeT = null;
        Integer modGoodsTransferingStatusT = null;
        String outputCode = lWhFormOutput.getOutputCode();
        if ((BaseWarehouseParam1.In_OutPutTypeEnum.Transfer_Output.getValue() + "").equals(outputCode)) {
        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)) {
        } 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;
        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();
@@ -288,6 +303,8 @@
        lWhFormOutput.setWarehouseFlowId(lWarehouseFlowId);
        lWhFormOutputService.update(lWhFormOutput);
        //当库存变动时调用该方法
        lWhWarningCoreService.updateKuCun(Convert.toShort(outWarehouseType, (short) 0), outWarehouseId, allChangModelList, null, dealTime);
        return lWarehouseFlowId;
    }