huminmin
15 小时以前 39e8f88af6d3c07c183cda4e7c1d1b1c850209f5
生产报废、废品发货退货后、不合格处理报废的产品都要进到废品库
已修改4个文件
34 ■■■■■ 文件已修改
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/enums/StockInventorySourceEnum.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockUninventoryMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -282,7 +282,7 @@
    }
    private String resolveUninventoryType(String recordType) {
        if (com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(recordType)) {
        if (com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(recordType) || com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(recordType)) {
            return "waste";
        }
        return "unqualified";
src/main/java/com/ruoyi/stock/enums/StockInventorySourceEnum.java
@@ -19,6 +19,7 @@
    OUTSOURCED_RECEIPT("outsourcedReceipt", "外协入库"),
    REPAIR_RECEIPT("repairReceipt", "修复入库"),
    PROD_GENERATED("prodGenerated", "生产产生"),
    DEFECTIVE_SCRAP("defectiveScrap", "不合格处理报废产生"),
    TRANS_GENERATED("transGenerated", "运输产生"),
    CUTTING_GENERATED("cuttingGenerated", "裁剪产生"),
    RETURN_GENERATED("returnGenerated", "销售退货产生"),
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -13,6 +13,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.stock.enums.StockInventorySourceEnum;
import java.time.LocalDateTime;
import com.ruoyi.stock.dto.StockInRecordDto;
@@ -240,6 +241,12 @@
                throw new BaseException("只有待审批状态的记录才能审批,入库批次:" + stockInRecord.getInboundBatches());
            }
            // 兼容历史数据或上游漏传场景,审批时补齐来源,避免废品库存台账来源为空
            String resolvedSource = resolveStockSource(stockInRecord);
            if (StringUtils.isNotEmpty(resolvedSource)) {
                stockInRecord.setSource(resolvedSource);
            }
            // 获取审批时修改的入库数量,如果没有修改则使用原数量
            final BigDecimal finalStockInNum;
            if (item.getStockInNum() != null && item.getStockInNum().compareTo(BigDecimal.ZERO) > 0) {
@@ -293,7 +300,6 @@
                    stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
                    stockUninventoryDto.setSource(stockInRecord.getSource());
                    stockUninventoryDto.setType(uninventoryType);
                    stockUninventoryDto.setSource(stockInRecord.getSource());
                    if (stockUninventory == null) {
                        stockUninventoryMapper.insert(new StockUninventory() {{
                            setProductModelId(stockInRecord.getProductModelId());
@@ -354,6 +360,23 @@
        return stockInventoryDto;
    }
    private String resolveStockSource(StockInRecord stockInRecord) {
        if (stockInRecord == null || StringUtils.isNotEmpty(stockInRecord.getSource())) {
            return stockInRecord == null ? null : stockInRecord.getSource();
        }
        if (StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(stockInRecord.getRecordType())
                || StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(stockInRecord.getRecordType())) {
            if (StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(stockInRecord.getRecordType())) {
                return StockInventorySourceEnum.DEFECTIVE_SCRAP.getCode();
            }
            return StockInventorySourceEnum.PROD_GENERATED.getCode();
        }
        if (StockInQualifiedRecordTypeEnum.RETURN_WASTE_IN.getCode().equals(stockInRecord.getRecordType())) {
            return StockInventorySourceEnum.RETURN_GENERATED.getCode();
        }
        return stockInRecord.getSource();
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchReAudit(List<Long> ids) {
src/main/resources/mapper/stock/StockUninventoryMapper.xml
@@ -103,6 +103,9 @@
            <if test="ew.type != null and ew.type != ''">
                type = #{ew.type},
            </if>
            <if test="ew.source != null and ew.source != ''">
                source = #{ew.source},
            </if>
            update_time = now()
        </set>
        where product_model_id = #{ew.productModelId}
@@ -131,7 +134,8 @@
        (su.qualitity - COALESCE(su.locked_quantity, 0)) as un_locked_quantity,
        pm.model,
        pm.unit,
        p.product_name
        p.product_name,
        su.source
        <include refid="BaseWasteFromClause" />
        <where>
            <if test="ew.type != null and ew.type != ''">