futian.liu
2023-12-18 3884e330379c96e7576ada6b7a988a84e8757886
consum-base/src/main/java/com/consum/base/service/impl/LWhFormOutputCoreService.java
@@ -94,27 +94,24 @@
            return null;
        }
        // 查询该调拨单是否已经生成了出库单
        Long outWarehouseFormIdT = lWhFormOutputService.queyrIdByTransferId(whFormTransferId);
        if (outWarehouseFormIdT != null) {
            return outWarehouseFormIdT;
        Long outWarehouseFormId = lWhFormOutputService.queyrIdByTransferId(whFormTransferId);
        if (outWarehouseFormId != null) {
            return outWarehouseFormId;
        }
        // 出库单ID
        outWarehouseFormId = NumberGenerator.getLongSequenceNumberNano();
        // 申请调拨的物品
        List<LWhProcureModel> goodsModelNumList = lWhProcureModelService.getModelByForm(businessEnum, whFormTransferId);
        if (CollectionUtils.isEmpty(goodsModelNumList)) {
            log.error("没有要入库的物品");
            throw new RuntimeException("没有要入库的物品");
            // return null;
        }
        Long outWarehouseId = lWhFormTransfer.getOutWarehouseId();
        String outWarehouseName = lWhFormTransfer.getOutWarehouseName();
        // 出库单ID
        outWarehouseFormIdT = NumberGenerator.getLongSequenceNumberNano();
        Long outWarehouseFormId = outWarehouseFormIdT;
        // 调拨单物品 已经按型号分好了
        goodsModelNumList.forEach(itemModelInfo -> {
        for (LWhProcureModel itemModelInfo : goodsModelNumList) {
            // 复用对象
            itemModelInfo.setId(IdUtil.generateId());
            itemModelInfo.setFromProcureGoodsId(null);
@@ -122,12 +119,11 @@
            itemModelInfo.setBusinessId(outWarehouseFormId);
            itemModelInfo.setPrice(null);
            itemModelInfo.setSupplier(null);
        });
        }
        lWhProcureModelService.insertBatch(goodsModelNumList);
        // //创建出库单
        LWhFormOutput whFormOutput = new LWhFormOutput();
        whFormOutput.setId(outWarehouseFormId);
        // 此时并没有出库
        whFormOutput.setWarehouseFlowId(null);
@@ -148,7 +144,7 @@
        whFormOutput.setOperatorName(currentUser.getNick_name());
        whFormOutput.setDealTime(dealTime);
        whFormOutput.setStates(1);
        whFormOutput.setStates(OutPutStatesType.OUT_PENDING.getValue());
        int insert = lWhFormOutputService.insert(whFormOutput);
        if (insert == 0) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -196,42 +192,30 @@
        // 流水记录总表ID
        long lWarehouseFlowId = NumberGenerator.getLongSequenceNumberNano();
        // 流水记录总表中 业务ID 。调拨单时 保存调拨单id 出库单时 保存出库单id
        long lWarehouseFlowBusinessId = outWarehouseFormId;
        Integer queryModelStatus = 1;
        Integer buyType = null;
        Integer modGoodsTransferStatus = null;
        // 物品状态(0=在途调拨;1=入库未分发;2=已下发;3=报废)
        Integer queryModelStatusT = 1;
        // 采购方式(1:集采;2=自采)
        Integer buyTypeT = null;
        Integer modGoodsTransferingStatusT = null;
        short businessTypeValue = businessType.getValue();
        if (InAndOutPutType.Transfer_Output.getValue() == businessTypeValue) {
        Integer businessTypeValue = businessType.getValue();
        if (businessTypeValue == InAndOutPutType.Transfer_Output.getValue()) {
            // 调拨出库
            queryModelStatusT = 1;
            buyTypeT = 1;
            queryModelStatus = 0;
            buyType = 1;
            lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId();
            modGoodsTransferingStatusT = 0;
        } else if (InAndOutPutType.Dept_Lending_Out.getValue() == businessTypeValue) {
            modGoodsTransferStatus = 0;
        } else if (businessTypeValue == InAndOutPutType.Dept_Lending_Out.getValue()) {
            // 部门仓库 分发出库
            // queryModelStatusT = 2;
            lWarehouseFlowBusinessId = lWhFormOutput.getTransBusinessId();
        } else if (InAndOutPutType.Fragmentary_Output.getValue() == businessTypeValue) {
            // 零星出库
            queryModelStatusT = 1;
            buyTypeT = null;
            modGoodsTransferingStatusT = 4;
        } else if (InAndOutPutType.Inventory_Output.getValue() == businessTypeValue) {
            // 盘点出库
            queryModelStatusT = 1;
            buyTypeT = null;
            modGoodsTransferingStatusT = 4;
        } else if (businessTypeValue == InAndOutPutType.Fragmentary_Output.getValue()
            || businessTypeValue == InAndOutPutType.Inventory_Output.getValue()) {
            // 零星出库 或 盘点出库
            queryModelStatus = 1;
            modGoodsTransferStatus = 4;
        }
        Integer queryModelStatus = queryModelStatusT;
        Integer buyType = buyTypeT;
        Integer modGoodsTransferingStatus = modGoodsTransferingStatusT;
        ArrayList<Long> allChangModelList = new ArrayList<>();
        goodsModelNumList.forEach(itemModelInfo -> {
        for (LWhProcureModel itemModelInfo : goodsModelNumList) {
            // 需要调拨的物品的某个型号
            Long baseGoodsModelsId = itemModelInfo.getBaseGoodsModelsId();
@@ -244,17 +228,10 @@
            // 查询型号信息
            Map<String, Object> tempGoodsInfo = baseGoodsTemplateService.queryGoodsInfoByModelId(baseGoodsModelsId);
            // 价值类型
            String classificationObj = (String)tempGoodsInfo.get("classification");
            Short classificationT = 3;
            if (classificationObj != null) {
                classificationT = (short)((classificationObj).charAt(0) - 64);
            }
            short classification = classificationT;
            Long tempGoodsId = (Long)tempGoodsInfo.get("goodsid");
            String goodsName = (String)tempGoodsInfo.get("goodsname");
            String modelName = (String)tempGoodsInfo.get("modelname");
            String goodsUnit = (String)tempGoodsInfo.get("unit");
            // 插入 各规格物品的进出库记录 L_WH_GOODS_RECORD
            long whGoodsRecordId = NumberGenerator.getLongSequenceNumberNano();
@@ -292,7 +269,7 @@
                outGoodsId = lWhGoodsService.queryOutGoodsId(outWarehouseType, outWarehouseId, baseGoodsModelsId,
                    queryModelStatus, buyType, counts);
                lWhGoodsService.modGoodsTransfering(outGoodsId, inWarehouseType, inWarehouseId, inWarehouseName,
                    modGoodsTransferingStatus);
                    modGoodsTransferStatus);
                // 批量插入 进出库流水明细[L_WH_GOODS_RECORD_DETAILS]
                lWhGoodsRecordDetailsService.sameGoodsInsertMore(outGoodsId, whGoodsRecordId, (short)0);
            }
@@ -302,13 +279,13 @@
            lWhGoodsRecordServiceImpl.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(businessType.getValue() + 0);
        warehouseFlow.setBusinessType(businessType.getValue());
        warehouseFlow.setBusinessFormId(whFormTransferId == null ? lWarehouseFlowBusinessId : whFormTransferId);
        warehouseFlow.setOperatorId(userId);