zhanghl
2025-05-09 191b8ae5c768fbb97c7cdea87edde77d0a10e7da
钣金需求匹配-完善工时计算
已修改5个文件
55 ■■■■■ 文件已修改
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessRouteLineServiceImpl.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteHeaderMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteLineMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java
@@ -272,21 +272,27 @@
        require.setProcessRouteId(routeId);
        require.setProcessRouteHours(String.valueOf(totalRouteTime));
        /*完成时间,level=0 时默认为工单的计划完成日期*/
        Date completeDate = plan.getPlanEndDay();
        /*预留天数*/
        Long reservedDay = getReservedDays();
        if (level > 0) {
        /*设置完成日期*/
        if(level==0){
            /*完成时间,level=0 时默认为工单的计划完成日期*/
            require.setCompleteDate(plan.getPlanEndDay());
            require.setDemandDate(plan.getPlanEndDay());
        } else  {
            /* 当前需求完成日期为上阶层需求的开始时间 - 预留天数(转换为毫秒)*/
            long reservedMillisecond = reservedDay * 24 * millisecond;
            Date completeDate = new Date();
            completeDate.setTime(upLevelStartDate.getTime() - reservedMillisecond);
            require.setCompleteDate(completeDate);
            require.setDemandDate(completeDate);
        }
        /*设置完成日期*/
        require.setCompleteDate(completeDate);
        require.setDemandDate(completeDate);
        /*设置开始时间*/
        Date startDay = new Date();
        startDay.setTime(completeDate.getTime() - totalRouteMillisecond);
        startDay.setTime(require.getCompleteDate().getTime() - totalRouteMillisecond);
        require.setStartDate(startDay);
        /*计算是否有风险*/
@@ -334,10 +340,10 @@
     * 获取钣金计划 预留天数
     * */
    private Long getReservedDays(){
        Long days=0L;
        List<SysDictData> dictDataList = DictUtils.getDictCache("aps_is_suspended");
        if (dictDataList != null) {
            Long.getLong(dictDataList.get(0).getDictValue());
        long days=0L;
        List<SysDictData> dictDataList = DictUtils.getDictCache("plate_plan_param");
        if (dictDataList != null && !dictDataList.isEmpty()) {
            days = Long.parseLong(dictDataList.get(0).getDictValue());
        }
        return days;
    }
@@ -349,6 +355,9 @@
    private void matchRequireAndSubPlan(ApsPlateStandardRequire require) {
        BigDecimal netRequirement = require.getNetRequirement();
        require.setMatchMode("工单匹配");
        if(require.getBomLineCode().equals("W0202-100028")){
            System.out.println("W0202-100028");
        }
        if (netRequirement.compareTo(BigDecimal.ZERO) > 0) {
            ApsPlatePlan platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(),  require.getBomLineCode());
            /*子件工单的未匹配数量 作为当前的库存*/
@@ -361,7 +370,7 @@
                    bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement);
                    netRequirement = BigDecimal.ZERO;
                    require.setMatchState("已匹配");
                    require.setUnmatchedDemandAmount(netRequirement);
                    require.setUnmatchedDemandAmount(BigDecimal.ZERO);
                    /*净需求已经被满足,不需要继续匹配*/
                } else if (netRequirement.compareTo(stock) == 0) {
@@ -371,7 +380,7 @@
                    bomOrderDetailService.savePlastPlanAndBomOrderDetail(require, platePlan, subtract, stock, netRequirement);
                    netRequirement = BigDecimal.ZERO;
                    require.setMatchState("已匹配");
                    require.setUnmatchedDemandAmount(netRequirement);
                    require.setUnmatchedDemandAmount(BigDecimal.ZERO);
                    /*净需求已经被满足,不需要继续匹配*/
                }
                if (netRequirement.compareTo(stock) > 0) {
@@ -385,12 +394,10 @@
                    platePlan = apsPlatePlanMapper.selectUnMatchPlateSubPlan(require.getOrgCode(),  require.getBomLineCode());
                    /*剩余净需求*/
                    netRequirement = rest;
                    require.setUnmatchedDemandAmount(netRequirement);
                    require.setUnmatchedDemandAmount(rest);
                }
            }
        }
        require.setUnmatchedDemandAmount(require.getNetRequirement());
    }
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessRouteLineServiceImpl.java
@@ -4,6 +4,7 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import cn.hutool.core.util.IdUtil;
import com.aps.common.core.utils.DateUtils;
@@ -151,10 +152,14 @@
                    if (line.getProductivityModel().equals(productivityModel_monopolize)) {
                        line.setRouteTime(line.getDesignCapacity().multiply(require.getNetRequirement()));
                    }
                    // 累加路线时间到总工时中
                    totalRouteTime.add(line.getRouteTime());
                });
                // 累加路线时间到总工时中
               totalRouteTime = apsStandardProcessRouteLines.stream()
                        .map(ApsStandardProcessRouteLine::getRouteTime)
                        .reduce(BigDecimal.ZERO, BigDecimal::add);
            }
            ret.setRouteTime(totalRouteTime);
            ret.setRouteId(routeHeader.getRouteId());
        }else {
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
@@ -271,8 +271,7 @@
    <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,
        (case   when custom_time is null then plan_end_day else custom_time end ) as plan_end_day
        unmatched_quantity,version, production_base,plan_end_day
        from aps_plate_plan
        <where>
            <if test="plant != null "> and plant = #{plant}</if>
aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteHeaderMapper.xml
@@ -39,6 +39,7 @@
            <if test="orgCode != null  and orgCode != ''"> and org_code = #{orgCode}</if>
            and del_flag = '0'
        </where>
        ORDER BY version desc
    </select>
    
    <select id="selectApsStandardProcessRouteHeaderById" parameterType="Long" resultMap="ApsStandardProcessRouteHeaderResult">
aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteLineMapper.xml
@@ -31,7 +31,7 @@
    <select id="selectApsStandardProcessRouteLineList" parameterType="ApsStandardProcessRouteLine" resultMap="ApsStandardProcessRouteLineResult">
        <include refid="selectApsStandardProcessRouteLineVo"/>
        <where>
        <where>
            <if test="routeId != null  and routeId != ''"> and route_id = #{routeId}</if>
            <if test="routeNum != null  and routeNum != ''"> and route_num = #{routeNum}</if>
            <if test="routeName != null  and routeName != ''"> and route_name = #{routeName}</if>
@@ -43,6 +43,7 @@
            <if test="designCapacity != null  and designCapacity != ''"> and design_capacity = #{designCapacity}</if>
            and del_flag = '0'
        </where>
    </select>
    
    <select id="selectApsStandardProcessRouteLineById" parameterType="Long" resultMap="ApsStandardProcessRouteLineResult">