From 52bc59241a15cb24f4dcb3c52894457f203368a5 Mon Sep 17 00:00:00 2001 From: "yunpeng.zhang" Date: Fri, 5 Jan 2024 17:33:41 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E8=AE=BE=E5=A4=87=E8=80=97=E6=9D=90?= =?UTF-8?q?=E5=88=B0=E6=9C=9F=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/consumableDueEmailTemp.ftl | 57 +++++++++++++++++++ common/pom.xml | 5 ++ .../impl/EquipmentConsumablesServiceImpl.java | 14 ++++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 admin/src/main/resources/template/consumableDueEmailTemp.ftl diff --git a/admin/src/main/resources/template/consumableDueEmailTemp.ftl b/admin/src/main/resources/template/consumableDueEmailTemp.ftl new file mode 100644 index 0000000..4891644 --- /dev/null +++ b/admin/src/main/resources/template/consumableDueEmailTemp.ftl @@ -0,0 +1,57 @@ + + + + + www.lingdaima.com(零代码excel转HTML) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
设备设备序列号所在科室所在位置耗材名称耗材编号开始使用时间到期时间
减压沸腾式清洗机16811000131-2020-11供应室门密封圈(洁区)RN-80CSW L=2360 S=602023/12/162024/6/16
门密封圈(污区)RN-80CSW L=2360 S=602023/7/152024/1/15
+ + diff --git a/common/pom.xml b/common/pom.xml index 85e234b..b0b70ae 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -29,6 +29,11 @@ spring-web + + org.springframework.boot + spring-boot-starter-freemarker + + cn.dev33 diff --git a/system/src/main/java/com/eqc/system/service/impl/EquipmentConsumablesServiceImpl.java b/system/src/main/java/com/eqc/system/service/impl/EquipmentConsumablesServiceImpl.java index cc95630..8882015 100644 --- a/system/src/main/java/com/eqc/system/service/impl/EquipmentConsumablesServiceImpl.java +++ b/system/src/main/java/com/eqc/system/service/impl/EquipmentConsumablesServiceImpl.java @@ -12,7 +12,9 @@ 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.system.domain.dto.ConsumableNoticeDto; +import freemarker.template.Configuration; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.eqc.system.domain.bo.EquipmentConsumablesBo; import com.eqc.system.domain.vo.EquipmentConsumablesVo; @@ -35,6 +37,9 @@ public class EquipmentConsumablesServiceImpl implements IEquipmentConsumablesSer private final EquipmentConsumablesMapper baseMapper; + // 自动注入FreeMarker配置类,用户获取模板 + private final Configuration configuration; + /** * 查询设备耗材 */ @@ -159,6 +164,13 @@ public class EquipmentConsumablesServiceImpl implements IEquipmentConsumablesSer Date date = DateUtils.addDays(DateUtils.beginOfDay(DateUtils.getNowDate()), 7); List consumableNotices = baseMapper.selectNoticeList(date); Map> 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 + // 自动注入FreeMarker配置类,用户获取模板 + MailUtils.sendHtml(email, subject, ""); + }); } }