[fix]调整到期提醒策略,新增已过期的设备可以关闭提醒的功能
This commit is contained in:
parent
934dae7c4c
commit
26a28178bb
@ -28,7 +28,8 @@
|
||||
</head>
|
||||
<body style="padding: 10px;">
|
||||
Dear ${nickName} :
|
||||
<p style="padding-left: 30px;">以下设备耗材即将到达使用效期,请及时处理!</p>
|
||||
<div style="padding-left: 20px;">
|
||||
<p><strong>以下设备耗材即将到达使用效期或已过使用效期,请及时处理!</strong></p>
|
||||
<table style="width:833pt">
|
||||
<thead>
|
||||
<tr style="background:#3498db;">
|
||||
@ -43,22 +44,43 @@ Dear ${nickName} :
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#if dueConsumables ?? && (dueConsumables ?size > 0) >
|
||||
<#list dueConsumables as consumable >
|
||||
<tr>
|
||||
<td>${consumable.consumableNo}</td>
|
||||
<td>${consumable.consumableName}</td>
|
||||
<td>${consumable.equipmentName}</td>
|
||||
<td>${consumable.equipmentNo}</td>
|
||||
<td>${consumable.equipmentDept}</td>
|
||||
<td>${consumable.equipmentLocation}</td>
|
||||
<td>${consumable.activationTime?string("yyyy-MM-dd")}</td>
|
||||
<td style="background: #e74c3c">${consumable.dueTime?string("yyyy-MM-dd")}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
<#if overDueNotices ?? && (overDueNotices ?size > 0) >
|
||||
<tr>
|
||||
<th colspan="8" style="background:#f56c6c;text-align: center;">已过期</th>
|
||||
</tr>
|
||||
<#list overDueNotices as consumable >
|
||||
<tr>
|
||||
<td>${consumable.consumableNo}</td>
|
||||
<td>${consumable.consumableName}</td>
|
||||
<td>${consumable.equipmentName}</td>
|
||||
<td>${consumable.equipmentNo}</td>
|
||||
<td>${consumable.equipmentDept}</td>
|
||||
<td>${consumable.equipmentLocation}</td>
|
||||
<td>${consumable.activationTime?string("yyyy-MM-dd")}</td>
|
||||
<td style="background: #e74c3c">${consumable.dueTime?string("yyyy-MM-dd")}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
<#if dueNotices ?? && (dueNotices ?size > 0) >
|
||||
<tr>
|
||||
<th colspan="8" style="background:#e6a23c;text-align: center;">即将到期</th>
|
||||
</tr>
|
||||
<#list dueNotices as consumable >
|
||||
<tr>
|
||||
<td>${consumable.consumableNo}</td>
|
||||
<td>${consumable.consumableName}</td>
|
||||
<td>${consumable.equipmentName}</td>
|
||||
<td>${consumable.equipmentNo}</td>
|
||||
<td>${consumable.equipmentDept}</td>
|
||||
<td>${consumable.equipmentLocation}</td>
|
||||
<td>${consumable.activationTime?string("yyyy-MM-dd")}</td>
|
||||
<td style="background: #ebb768">${consumable.dueTime?string("yyyy-MM-dd")}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
</#if>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
<p style="font-size: 13px;"><i>该邮件为系统自动发送,请勿回复</i></p>
|
||||
</body>
|
||||
|
||||
@ -18,10 +18,11 @@ import java.util.List;
|
||||
public interface EquipmentConsumablesMapper extends BaseMapperPlus<EquipmentConsumablesMapper, EquipmentConsumables, EquipmentConsumablesVo> {
|
||||
|
||||
/**
|
||||
* 获取即将到期需要提醒的耗材
|
||||
* @param date 与到期时间相比较,查询出距离到期时间还有一段时间的耗材
|
||||
* 获取即将到期需要提醒的耗材 到期时间处于 beginDate 和 endDate 之间的耗材
|
||||
* @param beginDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<ConsumableNoticeDto> selectNoticeList(@Param("date") Date date);
|
||||
List<ConsumableNoticeDto> selectNoticeList(@Param("beginDate") Date beginDate,@Param("endDate") Date endDate);
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.eqc.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.eqc.common.utils.DateUtils;
|
||||
import com.eqc.common.utils.StreamUtils;
|
||||
@ -11,7 +12,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.eqc.common.utils.email.MailUtils;
|
||||
import com.eqc.common.utils.spring.SpringUtils;
|
||||
import com.eqc.system.domain.dto.ConsumableNoticeDto;
|
||||
import com.eqc.system.service.ISysConfigService;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
@ -163,14 +166,17 @@ public class EquipmentConsumablesServiceImpl implements IEquipmentConsumablesSer
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备到期提醒 提前七天开始提醒
|
||||
* 设备即将到期提醒 提前七天开始提醒,已过期的不再提醒
|
||||
*/
|
||||
@Override
|
||||
public void dueNotice() {
|
||||
//获取到期的耗材是否继续提醒
|
||||
boolean isOverDueNotice = Convert.toBool(SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.consumable.overDueNotices"));
|
||||
//当前时间+7天
|
||||
String subject = "设备耗材即将到期提醒";
|
||||
Date date = DateUtils.addDays(DateUtils.beginOfDay(DateUtils.getNowDate()), 7);
|
||||
List<ConsumableNoticeDto> consumableNotices = baseMapper.selectNoticeList(date);
|
||||
Date today = DateUtils.beginOfDay(DateUtils.getNowDate());
|
||||
Date afterSevenDays = DateUtils.addDays(today, 7);
|
||||
List<ConsumableNoticeDto> consumableNotices = baseMapper.selectNoticeList(isOverDueNotice ? null : today, afterSevenDays);
|
||||
if (consumableNotices.isEmpty()){
|
||||
log.warn("当前没有即将到期的耗材");
|
||||
return;
|
||||
@ -180,10 +186,16 @@ public class EquipmentConsumablesServiceImpl implements IEquipmentConsumablesSer
|
||||
ConsumableNoticeDto notice = notices.get(0);
|
||||
String email = notice.getChargeUserEmail();
|
||||
String chargeNickName = notice.getChargeNickName();
|
||||
//拆分即将过期和已过期的
|
||||
//已过期的
|
||||
List<ConsumableNoticeDto> overDueNotices = StreamUtils.filter(notices, (n -> n.getDueTime().before(today)));
|
||||
//即将过期的
|
||||
List<ConsumableNoticeDto> dueNotices = StreamUtils.filter(notices, (n -> n.getDueTime().after(today)));
|
||||
//构建html
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
root.put("nickName", chargeNickName);
|
||||
root.put("dueConsumables", notices);
|
||||
root.put("overDueNotices", overDueNotices);
|
||||
root.put("dueNotices", dueNotices);
|
||||
String content = buildMailContent(root, "consumableDueEmailTemp.ftl");
|
||||
if (StringUtils.isEmpty(content)){
|
||||
log.error("邮件内容构建失败,邮件未发送");
|
||||
|
||||
@ -45,7 +45,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join sys_user u on u.user_id = c.charge_user
|
||||
left join sys_dept dept on e.department = dept.dept_id
|
||||
where u.del_flag = '0' and dept.del_flag = '0'
|
||||
and c.status = '0' and c.due_time <= #{date}
|
||||
and c.status = '0' and c.due_time <= #{endDate}
|
||||
<if test="beginDate != null">
|
||||
and c.due_time >= #{beginDate}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user