From f7f1a85441ccbfc8721863c4e4ca2a3c2516b07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 31 Aug 2023 10:34:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E9=87=8F=E4=B8=8D=E8=B6=B3=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WEB-INF/prop/hrmSalaryCustom.properties | 1 + .../TaxDeclarationApiFlowWarnServiceImpl.java | 56 ++++++++++++++----- 2 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 resource/WEB-INF/prop/hrmSalaryCustom.properties diff --git a/resource/WEB-INF/prop/hrmSalaryCustom.properties b/resource/WEB-INF/prop/hrmSalaryCustom.properties new file mode 100644 index 000000000..a4f1cdeaa --- /dev/null +++ b/resource/WEB-INF/prop/hrmSalaryCustom.properties @@ -0,0 +1 @@ +flowNoticeMessageType=2022060951 \ No newline at end of file diff --git a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java index 13717760d..0dd420668 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationApiFlowWarnServiceImpl.java @@ -35,7 +35,9 @@ import dm.jdbc.util.IdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.transaction.annotation.Transactional; +import weaver.common.MessageUtil; import weaver.email.EmailWorkRunnable; +import weaver.general.BaseBean; import weaver.hrm.User; import java.io.IOException; @@ -248,22 +250,16 @@ public class TaxDeclarationApiFlowWarnServiceImpl extends Service implements Tax String context = String.format(SalaryI18nUtil.getI18nLabel(111, "智能算薪流量已不足%s,请及时采购续费,避免次月无法使用。"), warnConfig.getThreshold()); warnReceiverList.forEach(e -> { Long receiver = e.getEmployeeId(); - sendEmail(receiver, title, context); sendMsg(receiver, title, context, warnConfig.getBusinessId()); + sendEmail(e.getEmail(), title, context); + sendSMS(e.getMobile(), context); } ); } - /** - * 发送邮件 - * - * @param receiver - * @param title - * @param context - */ - private void sendEmail(Long receiver, String title, String context) { - EmailWorkRunnable.threadModeReminder(receiver.toString(), title, context); - } + //提醒的消息类型 + BaseBean bb = new BaseBean(); + private final String flowNoticeMessageType = bb.getPropValue("hrmSalaryCustom", "flowNoticeMessageType"); /** * 发送Em消息 @@ -273,18 +269,48 @@ public class TaxDeclarationApiFlowWarnServiceImpl extends Service implements Tax * @param context * @param businessId */ - public static void sendMsg(Long receiver, String title, String context, Long businessId) { - MessageType messageType = MessageType.newInstance(499); // 消息来源(见文档第四点补充 必填) - Set userIdList = new HashSet<>(); // 接收人id 必填 + public void sendMsg(Long receiver, String title, String context, Long businessId) { + if (StringUtils.isBlank(flowNoticeMessageType)) { + return; + } + MessageType messageType = MessageType.newInstance(Integer.parseInt(flowNoticeMessageType)); + Set userIdList = new HashSet<>(); userIdList.add(receiver.toString()); try { MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, "", ""); messageBean.setCreater(1);// 创建人id messageBean.setBizState("0");// 需要修改消息为已处理等状态时传入,表示消息最初状态为待处理 - messageBean.setTargetId("499|" + businessId); //消息来源code +“|”+业务id需要修改消息为已处理等状态时传入 + messageBean.setTargetId(flowNoticeMessageType + "|" + businessId); //消息来源code +“|”+业务id需要修改消息为已处理等状态时传入 Util_Message.store(messageBean); } catch (IOException e) { e.printStackTrace(); } } + + /** + * 发送邮件 + * + * @param email + * @param title + * @param context + */ + private void sendEmail(String email, String title, String context) { + if (MessageUtil.checkSendEmail()) { + EmailWorkRunnable.threadModeReminder(email, title, context); + } + } + + /** + * 发送短信 + * + * @param mobile + * @param context + */ + private void sendSMS(String mobile, String context) { + if (MessageUtil.checkSendSMS()) { + MessageUtil.sendSMS(mobile, context); + } + } + + }