Browse Source

2026-07-28

RoHS:
1、【更新失效日期】操作里加一个“状态”属性
2、刷新RoHS即将失效标识的定时任务,只有 单据状态=已完成 且 RoHS状态=Active 才参与“即将失效”判断;
3、筛选条件变动;
master
fengyuan_yang 14 hours ago
parent
commit
995a562f4e
  1. 16
      src/main/java/com/spring/modules/rohs/service/impl/RohsServiceImpl.java
  2. 35
      src/main/resources/mapper/rohs/RohsMapper.xml

16
src/main/java/com/spring/modules/rohs/service/impl/RohsServiceImpl.java

@ -87,6 +87,8 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
params.put("ifsPartNo", trimToNull((String) params.get("ifsPartNo"))); params.put("ifsPartNo", trimToNull((String) params.get("ifsPartNo")));
params.put("materialDesc", trimToNull((String) params.get("materialDesc"))); params.put("materialDesc", trimToNull((String) params.get("materialDesc")));
params.put("isExpiring", trimToNull((String) params.get("isExpiring"))); params.put("isExpiring", trimToNull((String) params.get("isExpiring")));
params.put("expiryStartDate", trimToNull((String) params.get("expiryStartDate")));
params.put("expiryEndDate", trimToNull((String) params.get("expiryEndDate")));
long currPage = parseLong(params.get(Constant.PAGE), 1L); long currPage = parseLong(params.get(Constant.PAGE), 1L);
long pageSize = parseLong(params.get(Constant.LIMIT), 10L); long pageSize = parseLong(params.get(Constant.LIMIT), 10L);
@ -518,6 +520,13 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
if (StringUtils.isBlank(validUntil)) { if (StringUtils.isBlank(validUntil)) {
throw new RuntimeException("有效期单位不能为空"); throw new RuntimeException("有效期单位不能为空");
} }
String rohsStatus = StringUtils.trimToEmpty(rohs.getRohsStatus());
if (StringUtils.isBlank(rohsStatus)) {
rohsStatus = StringUtils.trimToEmpty(exists.getRohsStatus());
}
if (StringUtils.isBlank(rohsStatus)) {
rohsStatus = "Active";
}
Date expiryDate = calculateExpiryDateFromRule(rohs.getExpiredDate(), validUntilValue, validUntil); Date expiryDate = calculateExpiryDateFromRule(rohs.getExpiredDate(), validUntilValue, validUntil);
if (expiryDate == null) { if (expiryDate == null) {
@ -528,8 +537,9 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
updateEntity.setExpiredDate(rohs.getExpiredDate()); updateEntity.setExpiredDate(rohs.getExpiredDate());
updateEntity.setValidUntilValue(validUntilValue); updateEntity.setValidUntilValue(validUntilValue);
updateEntity.setValidUntil(validUntil); updateEntity.setValidUntil(validUntil);
updateEntity.setRohsStatus(rohsStatus);
updateEntity.setExpiryDate(expiryDate); updateEntity.setExpiryDate(expiryDate);
updateEntity.setIsExpiring(isAboutToExpire(expiryDate) ? "Y" : "N");
updateEntity.setIsExpiring(isActiveRohsStatus(rohsStatus) && isAboutToExpire(expiryDate) ? "Y" : "N");
updateEntity.setUpdateDate(new Date()); updateEntity.setUpdateDate(new Date());
updateEntity.setUpdateBy(StringUtils.isNotBlank(userName) ? userName : exists.getUpdateBy()); updateEntity.setUpdateBy(StringUtils.isNotBlank(userName) ? userName : exists.getUpdateBy());
@ -857,6 +867,10 @@ public class RohsServiceImpl extends ServiceImpl<RohsMapper, RohsEntity> impleme
return ""; return "";
} }
private boolean isActiveRohsStatus(String rohsStatus) {
return "Active".equalsIgnoreCase(StringUtils.trimToEmpty(rohsStatus));
}
private boolean isAboutToExpire(Date expiryDate) { private boolean isAboutToExpire(Date expiryDate) {
LocalDate expiryLocalDate = toLocalDate(expiryDate); LocalDate expiryLocalDate = toLocalDate(expiryDate);
if (expiryLocalDate == null) { if (expiryLocalDate == null) {

35
src/main/resources/mapper/rohs/RohsMapper.xml

@ -228,12 +228,17 @@
<if test="params.status != null and params.status != ''"> <if test="params.status != null and params.status != ''">
and a.status = #{params.status} and a.status = #{params.status}
</if> </if>
<if test="params.rohsStatus != null and params.rohsStatus != ''">
and a.rohs_status = #{params.rohsStatus}
</if>
<if test="params.isExpiring != null and params.isExpiring != ''"> <if test="params.isExpiring != null and params.isExpiring != ''">
and isnull(a.is_expiring, 'N') = #{params.isExpiring} and isnull(a.is_expiring, 'N') = #{params.isExpiring}
</if> </if>
<if test="params.expiryStartDate != null and params.expiryStartDate != ''">
and a.expiry_date is not null
and cast(a.expiry_date as date) <![CDATA[ >= ]]> cast(#{params.expiryStartDate} as date)
</if>
<if test="params.expiryEndDate != null and params.expiryEndDate != ''">
and a.expiry_date is not null
and cast(a.expiry_date as date) <![CDATA[ <= ]]> cast(#{params.expiryEndDate} as date)
</if>
<if test="params.nodeId != null and params.nodeId != ''"> <if test="params.nodeId != null and params.nodeId != ''">
and d.node_id = #{params.nodeId} and d.node_id = #{params.nodeId}
</if> </if>
@ -306,12 +311,17 @@
<if test="params.status != null and params.status != ''"> <if test="params.status != null and params.status != ''">
and a.status = #{params.status} and a.status = #{params.status}
</if> </if>
<if test="params.rohsStatus != null and params.rohsStatus != ''">
and a.rohs_status = #{params.rohsStatus}
</if>
<if test="params.isExpiring != null and params.isExpiring != ''"> <if test="params.isExpiring != null and params.isExpiring != ''">
and isnull(a.is_expiring, 'N') = #{params.isExpiring} and isnull(a.is_expiring, 'N') = #{params.isExpiring}
</if> </if>
<if test="params.expiryStartDate != null and params.expiryStartDate != ''">
and a.expiry_date is not null
and cast(a.expiry_date as date) <![CDATA[ >= ]]> cast(#{params.expiryStartDate} as date)
</if>
<if test="params.expiryEndDate != null and params.expiryEndDate != ''">
and a.expiry_date is not null
and cast(a.expiry_date as date) <![CDATA[ <= ]]> cast(#{params.expiryEndDate} as date)
</if>
<if test="params.nodeId != null and params.nodeId != ''"> <if test="params.nodeId != null and params.nodeId != ''">
and d.node_id = #{params.nodeId} and d.node_id = #{params.nodeId}
</if> </if>
@ -455,12 +465,17 @@
<if test="params.status != null and params.status != ''"> <if test="params.status != null and params.status != ''">
and a.status = #{params.status} and a.status = #{params.status}
</if> </if>
<if test="params.rohsStatus != null and params.rohsStatus != ''">
and a.rohs_status = #{params.rohsStatus}
</if>
<if test="params.isExpiring != null and params.isExpiring != ''"> <if test="params.isExpiring != null and params.isExpiring != ''">
and isnull(a.is_expiring, 'N') = #{params.isExpiring} and isnull(a.is_expiring, 'N') = #{params.isExpiring}
</if> </if>
<if test="params.expiryStartDate != null and params.expiryStartDate != ''">
and a.expiry_date is not null
and cast(a.expiry_date as date) <![CDATA[ >= ]]> cast(#{params.expiryStartDate} as date)
</if>
<if test="params.expiryEndDate != null and params.expiryEndDate != ''">
and a.expiry_date is not null
and cast(a.expiry_date as date) <![CDATA[ <= ]]> cast(#{params.expiryEndDate} as date)
</if>
<if test="params.nodeId != null and params.nodeId != ''"> <if test="params.nodeId != null and params.nodeId != ''">
and d.node_id = #{params.nodeId} and d.node_id = #{params.nodeId}
</if> </if>
@ -706,6 +721,7 @@
set is_expiring = set is_expiring =
case case
when status = '已完成' when status = '已完成'
and upper(isnull(rohs_status, '')) = 'ACTIVE'
and expiry_date is not null and expiry_date is not null
and cast(expiry_date as date) <![CDATA[ <= ]]> dateadd(month, 1, cast(getdate() as date)) and cast(expiry_date as date) <![CDATA[ <= ]]> dateadd(month, 1, cast(getdate() as date))
then 'Y' then 'Y'
@ -714,6 +730,7 @@
where isnull(is_expiring, 'N') <![CDATA[ <> ]]> where isnull(is_expiring, 'N') <![CDATA[ <> ]]>
case case
when status = '已完成' when status = '已完成'
and upper(isnull(rohs_status, '')) = 'ACTIVE'
and expiry_date is not null and expiry_date is not null
and cast(expiry_date as date) <![CDATA[ <= ]]> dateadd(month, 1, cast(getdate() as date)) and cast(expiry_date as date) <![CDATA[ <= ]]> dateadd(month, 1, cast(getdate() as date))
then 'Y' then 'Y'

Loading…
Cancel
Save