huangjiayang
2025-05-09 77b9b1492b8578b280bd61e15896de5bdc8e5213
Merge remote-tracking branch 'origin/dev' into dev
已修改8个文件
60 ■■■■■ 文件已修改
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateStandardRequire.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanOrderManagerMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlateStandardRequireMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlan.java
@@ -26,7 +26,7 @@
    private static final long serialVersionUID = 1L;
    /** 主键id */
    private String id;
    private Long id;
    /** 主计划员 */
    @Excel(name = "主计划")
aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlateStandardRequire.java
@@ -31,7 +31,8 @@
    private String requireTrackId;
    /**单号*/
    private String docNum;
    /**上级物料编码*/
    private String bomHeaderCode;
    /** bom_line_id */
//    @Excel(name = "bom_line_id")
    private String bomLineId;
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java
@@ -77,7 +77,7 @@
    /**
     * 获取未匹配的子计划
     * */
    ApsPlatePlan selectUnMatchPlateSubPlan(String plant);
    ApsPlatePlan selectUnMatchPlateSubPlan(String plant,String itemNumber);
    /**
     * 更新子计划未匹配数量
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
@@ -1,5 +1,6 @@
package com.aps.core.service.impl;
import cn.hutool.core.util.IdUtil;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.DictUtils;
@@ -68,7 +69,7 @@
    @Override
    public int insertApsPlatePlan(ApsPlatePlan apsPlatePlan)
    {
        apsPlatePlan.setId(IdUtils.fastUUID());
        apsPlatePlan.setId(IdUtil.getSnowflakeNextId());
        apsPlatePlan.setCreateTime(DateUtils.getNowDate());
        return apsPlatePlanMapper.insertApsPlatePlan(apsPlatePlan);
    }
@@ -122,7 +123,7 @@
            ids[i]=apsPartPlanTemps.get(i).getId();
            ApsPlatePlan platePlan=new ApsPlatePlan();
            BeanUtils.copyProperties(apsPartPlanTemps.get(i), platePlan);
            platePlan.setId(IdUtils.fastUUID());
            platePlan.setId(IdUtil.getSnowflakeNextId());
            platePlan.setCreateTime(DateUtils.getNowDate());
            //插入正式表,并记录
            apsPlatePlanMapper.insertApsPlatePlan(platePlan);
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java
@@ -178,7 +178,7 @@
            List<ApsPlateStandardRequire> requiresList=new ArrayList<>();
            getBomRequires(plantCode, "0",itemNumber,BigDecimal.ONE, batchNum, null, mainPlan, requiresList, 0L);
            getBomRequires(plantCode, "0","0",itemNumber,BigDecimal.ONE, batchNum, null, mainPlan, requiresList, 0L);
            // 批量插入以提高性能
            if (!requiresList.isEmpty()) {
@@ -196,6 +196,7 @@
     * 构建需求信息
     *
     * @param plant 工厂代码
     * @param bomHeaderCode BOM上级物料编码
     * @param bomLineId BOM行ID
     * @param itemCode 物料代码
     * @param itemNum 物料数量
@@ -205,14 +206,15 @@
     * @param allRequires 所有需求的列表
     * @param level 层级
     */
    private void getBomRequires(String plant,  String bomLineId,String itemCode,BigDecimal itemNum, String batchNum, Date upLevelStartDate, ApsPlatePlan plan, List<ApsPlateStandardRequire> allRequires, Long level) {
    private void getBomRequires(String plant, String bomHeaderCode, String bomLineId,String itemCode,BigDecimal itemNum, String batchNum, Date upLevelStartDate, ApsPlatePlan plan, List<ApsPlateStandardRequire> allRequires, Long level) {
        /*构建需求信息*/
        ApsPlateStandardRequire require = new ApsPlateStandardRequire();
        require.setId(IdUtil.getSnowflakeNextId());
        require.setRequireTrackId(plan.getId());
        require.setRequireTrackId(plan.getId() + "");
        require.setBatchNumber(batchNum);
        require.setDocNum(plan.getDocumentNumber());
        require.setOrgCode(plant);
        require.setBomHeaderCode(bomHeaderCode);
        require.setBomLineId(bomLineId);
        require.setBomLineCode(itemCode);
        require.setBomLineLevel(level);
@@ -259,6 +261,8 @@
                bomStockDetailService.saveStorageAndDetail(storage, plan, bomLineId,itemCode, batchNum, deductionAmount, afterStockAmount,require.getId());
            }
        }
        /*未匹配数量,默认为净需求*/
        require.setUnmatchedDemandAmount(require.getNetRequirement());
        /*工艺路线总需求*/
        ApsStandardProcessRouteLine routeHeader = routeLineService.getRouteLineTotalTime(require);
        String routeId = routeHeader.getRouteId();
@@ -310,7 +314,7 @@
            List<ApsBom> bomLineList = bomLineService.selectApsBomLineList(plant, itemCode);
            if (!bomLineList.isEmpty()) {
                bomLineList.forEach(line -> {
                    getBomRequires(plant, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum, require.getStartDate(), plan, allRequires, nextLevel);
                    getBomRequires(plant, itemCode, line.getBomLineId(),line.getItemCode() ,line.getNum() , batchNum, require.getStartDate(), plan, allRequires, nextLevel);
                });
            }
        }
@@ -344,39 +348,44 @@
    private void matchRequireAndSubPlan(ApsPlateStandardRequire require) {
        BigDecimal netRequirement = require.getNetRequirement();
        require.setMatchMode("工单匹配");
        if (netRequirement.compareTo(BigDecimal.ZERO) > 0) {
            ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode());
            ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(),  require.getBomLineCode());
            /*子件工单的未匹配数量 作为当前的库存*/
            while (platePlan != null && netRequirement.compareTo(BigDecimal.ZERO) > 0) {
                BigDecimal stock = platePlan.getUnmatchedQuantity();
                if (netRequirement.compareTo(stock) < 0) {
                    /* 库存数量 大于 净需求数量*/
                    /* 净需求数量=0 ,子件工单未匹配数量= 库存-净需求*/
                    netRequirement = BigDecimal.ZERO;
                    require.setNetRequirement(netRequirement);
                    BigDecimal subtract = stock.subtract(netRequirement);
                    bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement);
                    netRequirement = BigDecimal.ZERO;
                    require.setMatchState("已匹配");
                    require.setUnmatchedDemandAmount(netRequirement);
                    /*净需求已经被满足,不需要继续匹配*/
                } else if (netRequirement.compareTo(stock) == 0) {
                    /*净需求数量 == 库存数量*/
                    netRequirement = BigDecimal.ZERO;
                    require.setNetRequirement(netRequirement);
                    BigDecimal subtract = BigDecimal.ZERO;
                    bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement);
                    netRequirement = BigDecimal.ZERO;
                    require.setMatchState("已匹配");
                    require.setUnmatchedDemandAmount(netRequirement);
                    /*净需求已经被满足,不需要继续匹配*/
                }
                if (netRequirement.compareTo(stock) > 0) {
                    /*需求大于库存*/
                    /*净需求 被部分满足 */
                    BigDecimal rest = netRequirement.subtract(stock);
                    require.setNetRequirement(rest);
                    require.setMatchState("匹配中");
                    /*工单 未匹配数量为0 全部用于匹配需求*/
                    bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, BigDecimal.ZERO, stock, netRequirement);
                    /*净需求未被满足,需要继续匹配*/
                    platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode());
                    platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(),  require.getBomLineCode());
                    /*剩余净需求*/
                    netRequirement = rest;
                    require.setUnmatchedDemandAmount(netRequirement);
                }
            }
        }
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
@@ -271,8 +271,9 @@
    <select id="selectPlatePlanByPlantMajor" parameterType="ApsPlatePlan" resultMap="ApsPlatePlanResult">
        select  id,document_number,main_part_number,item_number,plant,professional_affiliation,production_quantity,require_id,
        unmatched_quantity,version, production_base
        unmatched_quantity,version, production_base,
        (case   when custom_time is null then plan_end_day else custom_time end ) as plan_end_day
        from aps_plate_plan
        <where>
            <if test="plant != null "> and plant = #{plant}</if>
            <if test="professionalAffiliation != null "> and professional_affiliation = #{professionalAffiliation}</if>
@@ -286,7 +287,8 @@
             unmatched_quantity,version
        from aps_plate_plan
        where  del_flag='0' and professional_affiliation !='0' and unmatched_quantity > 0
        <if test="plant != null  and plan !='' "> and plant = #{plant}</if>
        <if test="plant != null  and plant !='' "> and plant = #{plant}</if>
        <if test="itemNumber != null  and itemNumber !='' "> and item_number = #{itemNumber}</if>
        order by document_number asc,id asc
        limit 1
    </select>
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanOrderManagerMapper.xml
@@ -150,11 +150,11 @@
    <update id="updatePlanDateByBatch" parameterType="ApsPlateOrderPlanRequireDate">
        update aps_plate_plan set
          plan_start_day = #{planRequireDate.start},
          plan_end_day = #{planRequireDate.end},
          update_by = #{planRequireDate.updateBy},
          plan_start_day = #{start},
          plan_end_day = #{end},
          update_by = #{updateBy},
          update_time = now()
        where id =  #{planRequireDate.id}
        where id =  #{id}
    </update>
    <update id="updatePlanDateByCustom" parameterType="ApsPlateOrderPlanDate">
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlateStandardRequireMapper.xml
@@ -187,7 +187,7 @@
    <insert id="batchInsert" parameterType="java.util.List">
        insert into aps_plate_standard_require
        (id, require_track_id,doc_num,batch_number, org_code, bom_line_id, bom_line_code, bom_line_level, bom_use_amount, process_route_id,
        (id, require_track_id,doc_num,batch_number, org_code, bom_header_code,bom_line_id, bom_line_code, bom_line_level, bom_use_amount, process_route_id,
         process_route_hours, require_amount, net_requirement, start_date, complete_date, demand_date,
         production_base, match_state, match_mode, unmatched_demand_amount, suggested_completion_date,
         has_delay_risk, del_flag, create_time, create_by)
@@ -199,6 +199,7 @@
            #{item.docNum},
            #{item.batchNumber},
            #{item.orgCode},
            #{item.bomHeaderCode},
            #{item.bomLineId},
            #{item.bomLineCode},
            #{item.bomLineLevel},