[feat]设备耗材到期提醒
This commit is contained in:
parent
52bc59241a
commit
ff67d4606d
@ -1,57 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>www.lingdaima.com(零代码excel转HTML)</title>
|
||||
<style>
|
||||
table{border-top:1px solid #333;border-left:1px solid #333;border-spacing:0;background-color:#fff;width:100%}
|
||||
table td{border-bottom:1px solid #333;border-right:1px solid #333;font-size:13px;padding:5px}
|
||||
.font5{color:windowtext;}
|
||||
.xl69{text-align:left;background:red;}
|
||||
.xl66{text-align:left ;}
|
||||
.xl68{background:red;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table style="width:833pt"> <!--StartFragment-->
|
||||
<colgroup>
|
||||
<col width="162" style="mso-width-source:userset;mso-width-alt:5774;width:122pt">
|
||||
<col width="206" style="mso-width-source:userset;mso-width-alt:7338;width:155pt">
|
||||
<col width="114" style="mso-width-source:userset;mso-width-alt:4067;width:86pt">
|
||||
<col width="78" style="mso-width-source:userset;mso-width-alt:2787;width:59pt">
|
||||
<col width="159" style="mso-width-source:userset;mso-width-alt:5660;width:119pt">
|
||||
<col width="178" style="mso-width-source:userset;mso-width-alt:6314;width:133pt">
|
||||
<col width="106" style="mso-width-source:userset;mso-width-alt:3754;width:79pt">
|
||||
<col width="106" style="mso-width-source:userset;mso-width-alt:3783;width:80pt">
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr height="18">
|
||||
<td class>设备</td>
|
||||
<td class>设备序列号</td>
|
||||
<td class>所在科室</td>
|
||||
<td class>所在位置</td>
|
||||
<td class>耗材名称</td>
|
||||
<td class>耗材编号</td>
|
||||
<td class>开始使用时间</td>
|
||||
<td class="xl68">到期时间</td>
|
||||
</tr>
|
||||
<tr height="18">
|
||||
<td rowspan="2" class="xl66">减压沸腾式清洗机</td>
|
||||
<td rowspan="2" class="xl66">16811000131-2020-11</td>
|
||||
<td rowspan="2" class="xl66">供应室</td>
|
||||
<td rowspan="2" class="xl66"></td>
|
||||
<td class="xl66">门密封圈(洁区)</td>
|
||||
<td class="xl66">RN-80CSW L=2360 S=60</td>
|
||||
<td class="xl66">2023/12/16</td>
|
||||
<td class="xl69">2024/6/16</td>
|
||||
</tr>
|
||||
<tr height="18">
|
||||
<td class="xl66">门密封圈(污区)</td>
|
||||
<td class="xl66">RN-80CSW L=2360 S=60</td>
|
||||
<td class="xl66">2023/7/15</td>
|
||||
<td class="xl69">2024/1/15</td>
|
||||
</tr> <!--EndFragment-->
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
<style>
|
||||
table {
|
||||
border-top: 1px solid #333;
|
||||
border-left: 1px solid #333;
|
||||
border-spacing: 0;
|
||||
background-color: #fff;
|
||||
width: 100%
|
||||
}
|
||||
table tr td, th {
|
||||
border-bottom: 1px solid #333;
|
||||
border-right: 1px solid #333;
|
||||
font-size: 13px;
|
||||
padding: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
table tr {
|
||||
height: 18px
|
||||
}
|
||||
.xl69 {
|
||||
background: #e74c3c
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="padding: 10px;">
|
||||
Dear ${nickName} :
|
||||
<p style="padding-left: 30px;">以下设备耗材即将到达使用效期,请及时处理!</p>
|
||||
<table style="width:833pt">
|
||||
<thead>
|
||||
<tr style="background:#3498db;">
|
||||
<th>耗材编号</th>
|
||||
<th>耗材名称</th>
|
||||
<th>所属设备</th>
|
||||
<th>所属设备序列号</th>
|
||||
<th>设备所属科室</th>
|
||||
<th>设备所在位置</th>
|
||||
<th>开始使用时间</th>
|
||||
<th>到期时间</th>
|
||||
</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>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr>
|
||||
<p style="font-size: 13px;"><i>该邮件为系统自动发送,请勿回复</i></p>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,8 +1,13 @@
|
||||
package com.eqc.test;
|
||||
|
||||
import com.eqc.system.service.IEquipmentConsumablesService;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 断言单元测试案例
|
||||
@ -10,6 +15,7 @@ import org.junit.jupiter.api.Test;
|
||||
* @author Lion Li
|
||||
*/
|
||||
@DisplayName("断言单元测试案例")
|
||||
@SpringBootTest
|
||||
public class AssertUnitTest {
|
||||
|
||||
@DisplayName("测试 assertEquals 方法")
|
||||
@ -42,4 +48,12 @@ public class AssertUnitTest {
|
||||
Assertions.assertNotNull(null);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private IEquipmentConsumablesService consumablesService;
|
||||
|
||||
@Test
|
||||
public void testDueConsumables() {
|
||||
consumablesService.dueNotice();
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,7 +13,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.eqc.common.utils.email.MailUtils;
|
||||
import com.eqc.system.domain.dto.ConsumableNoticeDto;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.eqc.system.domain.bo.EquipmentConsumablesBo;
|
||||
@ -21,7 +24,9 @@ import com.eqc.system.domain.vo.EquipmentConsumablesVo;
|
||||
import com.eqc.system.domain.EquipmentConsumables;
|
||||
import com.eqc.system.mapper.EquipmentConsumablesMapper;
|
||||
import com.eqc.system.service.IEquipmentConsumablesService;
|
||||
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
@ -31,13 +36,16 @@ import java.util.*;
|
||||
* @author yunpeng.zhang
|
||||
* @date 2023-12-29
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class EquipmentConsumablesServiceImpl implements IEquipmentConsumablesService {
|
||||
|
||||
private final EquipmentConsumablesMapper baseMapper;
|
||||
|
||||
// 自动注入FreeMarker配置类,用户获取模板
|
||||
/**
|
||||
* 自动注入FreeMarker配置类,用户获取模板
|
||||
*/
|
||||
private final Configuration configuration;
|
||||
|
||||
/**
|
||||
@ -163,14 +171,37 @@ public class EquipmentConsumablesServiceImpl implements IEquipmentConsumablesSer
|
||||
String subject = "设备耗材即将到期提醒";
|
||||
Date date = DateUtils.addDays(DateUtils.beginOfDay(DateUtils.getNowDate()), 7);
|
||||
List<ConsumableNoticeDto> consumableNotices = baseMapper.selectNoticeList(date);
|
||||
if (consumableNotices.isEmpty()){
|
||||
log.warn("当前没有即将到期的耗材");
|
||||
return;
|
||||
}
|
||||
Map<Long, List<ConsumableNoticeDto>> userNoticeMap = StreamUtils.groupByKey(consumableNotices, ConsumableNoticeDto::getChargeUser);
|
||||
userNoticeMap.forEach((userId, notices) -> {
|
||||
ConsumableNoticeDto notice = notices.get(0);
|
||||
String email = notice.getChargeUserEmail();
|
||||
String chargeNickName = notice.getChargeNickName();
|
||||
//TODO 构建html
|
||||
//构建html
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
root.put("nickName", chargeNickName);
|
||||
root.put("dueConsumables", notices);
|
||||
String content = buildMailContent(root, "consumableDueEmailTemp.ftl");
|
||||
if (StringUtils.isEmpty(content)){
|
||||
log.error("邮件内容构建失败,邮件未发送");
|
||||
return;
|
||||
}
|
||||
// 自动注入FreeMarker配置类,用户获取模板
|
||||
MailUtils.sendHtml(email, subject, "");
|
||||
MailUtils.sendHtml(email, subject, content);
|
||||
});
|
||||
}
|
||||
|
||||
private String buildMailContent(Map<String, Object> root, String temp){
|
||||
String content = null;
|
||||
try {
|
||||
Template template = configuration.getTemplate(temp);
|
||||
content = FreeMarkerTemplateUtils.processTemplateIntoString(template, root);
|
||||
} catch (IOException | TemplateException e) {
|
||||
log.error("构建邮件内容报错",e);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ 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 <= #{date}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user