From 191b8ae5c768fbb97c7cdea87edde77d0a10e7da Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期五, 09 五月 2025 15:15:41 +0800
Subject: [PATCH] 钣金需求匹配-完善工时计算
---
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml | 3 +--
aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteLineMapper.xml | 3 ++-
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java | 39 +++++++++++++++++++++++----------------
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessRouteLineServiceImpl.java | 9 +++++++--
aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteHeaderMapper.xml | 1 +
5 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java
index e27bd1e..24e079a 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlateStandardRequireServiceImpl.java
+++ b/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));
- /*瀹屾垚鏃堕棿锛宭evel=0 鏃堕粯璁や负宸ュ崟鐨勮鍒掑畬鎴愭棩鏈�*/
- Date completeDate = plan.getPlanEndDay();
+
/*棰勭暀澶╂暟*/
Long reservedDay = getReservedDays();
- if (level > 0) {
+ /*璁剧疆瀹屾垚鏃ユ湡*/
+ if(level==0){
+ /*瀹屾垚鏃堕棿锛宭evel=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 @@
* 鑾峰彇閽i噾璁″垝 棰勭暀澶╂暟
* */
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());
-
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessRouteLineServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessRouteLineServiceImpl.java
index dcb1503..587aa42 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsStandardProcessRouteLineServiceImpl.java
+++ b/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 {
diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
index 7d407f4..623bc32 100644
--- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
+++ b/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>
diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteHeaderMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteHeaderMapper.xml
index 7b152eb..0416d52 100644
--- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteHeaderMapper.xml
+++ b/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">
diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteLineMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteLineMapper.xml
index 9f94cbf..9295d20 100644
--- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsStandardProcessRouteLineMapper.xml
+++ b/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">
--
Gitblit v1.9.3