Showing
19 changed files
with
279 additions
and
39 deletions
| ... | @@ -29,13 +29,15 @@ public interface ParamConfigConstants { | ... | @@ -29,13 +29,15 @@ public interface ParamConfigConstants { |
| 29 | String PUSH_IMP001_RETRY_NUMBER = "push_imp001_retry_number"; | 29 | String PUSH_IMP001_RETRY_NUMBER = "push_imp001_retry_number"; |
| 30 | //推送进口文件定时任务处理数量 | 30 | //推送进口文件定时任务处理数量 |
| 31 | String PUSH_CON_NUMBER = "push_con_number"; | 31 | String PUSH_CON_NUMBER = "push_con_number"; |
| 32 | - //通知发件人定时任务处理数量 | ||
| 33 | - String NOTIFICATION_SENDER_NUMBER = "notification_sender_number"; | ||
| 34 | //通知发件人邮件定时任务处理数量 | 32 | //通知发件人邮件定时任务处理数量 |
| 35 | String NOTIFICATION_SENDER_EMAIL_NUMBER = "notification_sender_email_number"; | 33 | String NOTIFICATION_SENDER_EMAIL_NUMBER = "notification_sender_email_number"; |
| 36 | //邮件发送进口文件时间间隔key | 34 | //邮件发送进口文件时间间隔key |
| 37 | String PUSH_CON_EMAIL_INTERVAL = "push_con_email_interval"; | 35 | String PUSH_CON_EMAIL_INTERVAL = "push_con_email_interval"; |
| 38 | //通知发件人时间间隔 | 36 | //通知发件人时间间隔 |
| 39 | String NOTIFICATION_SENDER_EMAIL_INTERVAL = "notification_sender_email_interval"; | 37 | String NOTIFICATION_SENDER_EMAIL_INTERVAL = "notification_sender_email_interval"; |
| 38 | + //预警邮件任务时间间隔 | ||
| 39 | + String SEND_FAIL_ALERT_INTERVAL = "send_fail_alert_interval"; | ||
| 40 | + //错误邮件预警任务显示运单数量 | ||
| 41 | + String FAILED_EMAIL_CON_NUMBER = "failed_email_con_number"; | ||
| 40 | } | 42 | } |
| 41 | } | 43 | } | ... | ... |
| 1 | package com.fedex.connect.common.dependencies.enums.biz; | 1 | package com.fedex.connect.common.dependencies.enums.biz; |
| 2 | 2 | ||
| 3 | +import java.util.Arrays; | ||
| 4 | +import java.util.List; | ||
| 5 | + | ||
| 3 | /** | 6 | /** |
| 4 | * @Author mt | 7 | * @Author mt |
| 5 | * @Description 邮件推送类型 | 8 | * @Description 邮件推送类型 |
| 6 | * @Date 2024/11/19 | 9 | * @Date 2024/11/19 |
| 7 | */ | 10 | */ |
| 8 | public enum EmailTypeEnum { | 11 | public enum EmailTypeEnum { |
| 9 | - PUSH_CON_FILE("emailType_01","pushConFile","推送预清关文件"), | 12 | + PUSH_CON_FILE("emailType_01","Push Pre-Customs Clearance Files","推送预清关文件"), |
| 10 | NOTIFICATION_SENDER("emailType_02","notificationSender","提醒发件人"), | 13 | NOTIFICATION_SENDER("emailType_02","notificationSender","提醒发件人"), |
| 14 | + SEND_FAILED_EMAIL("emailType_03","sendFailedEmail","错误邮件预警"), | ||
| 11 | 15 | ||
| 12 | ; | 16 | ; |
| 13 | 17 | ||
| ... | @@ -21,6 +25,21 @@ public enum EmailTypeEnum { | ... | @@ -21,6 +25,21 @@ public enum EmailTypeEnum { |
| 21 | this.msg = msg; | 25 | this.msg = msg; |
| 22 | } | 26 | } |
| 23 | 27 | ||
| 28 | + // 获取所有需要错误预警的code | ||
| 29 | + public static List<String> getFailedAlertCodes() { | ||
| 30 | + return Arrays.asList(PUSH_CON_FILE.getCode(),NOTIFICATION_SENDER.getCode()); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + // 获取 enMsg 根据 code | ||
| 34 | + public static String getEnMsgByCode(String code) { | ||
| 35 | + for (EmailTypeEnum emailType : EmailTypeEnum.values()) { | ||
| 36 | + if (emailType.code.equals(code)) { | ||
| 37 | + return emailType.enMsg; | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | + return null; // 如果找不到对应的 code,返回 null | ||
| 41 | + } | ||
| 42 | + | ||
| 24 | public String getCode() { | 43 | public String getCode() { |
| 25 | return code; | 44 | return code; |
| 26 | } | 45 | } | ... | ... |
| ... | @@ -13,7 +13,13 @@ public class ClearanceEmailTemplate implements EmailTemplate { | ... | @@ -13,7 +13,13 @@ public class ClearanceEmailTemplate implements EmailTemplate { |
| 13 | public String getTitle(Object ... arguments) { | 13 | public String getTitle(Object ... arguments) { |
| 14 | return MessageFormat.format(CLEARANCE_TITLE.TITLE,arguments); | 14 | return MessageFormat.format(CLEARANCE_TITLE.TITLE,arguments); |
| 15 | } | 15 | } |
| 16 | - | 16 | + /** |
| 17 | + * 邮件说明 | ||
| 18 | + */ | ||
| 19 | + @Override | ||
| 20 | + public String getDescription(Object... arguments) { | ||
| 21 | + return null; | ||
| 22 | + } | ||
| 17 | /** | 23 | /** |
| 18 | * 模板内容 | 24 | * 模板内容 |
| 19 | */ | 25 | */ | ... | ... |
| ... | @@ -3,4 +3,5 @@ package com.fedex.connect.common.dependencies.template.clearanceEmail; | ... | @@ -3,4 +3,5 @@ package com.fedex.connect.common.dependencies.template.clearanceEmail; |
| 3 | public interface EmailTemplate { | 3 | public interface EmailTemplate { |
| 4 | String getTitle(Object ... arguments); | 4 | String getTitle(Object ... arguments); |
| 5 | String getBody(Object ... arguments); | 5 | String getBody(Object ... arguments); |
| 6 | + String getDescription(Object... arguments); | ||
| 6 | } | 7 | } | ... | ... |
| 1 | +package com.fedex.connect.common.dependencies.template.clearanceEmail; | ||
| 2 | + | ||
| 3 | +import org.springframework.stereotype.Component; | ||
| 4 | + | ||
| 5 | +import java.text.MessageFormat; | ||
| 6 | + | ||
| 7 | +@Component | ||
| 8 | +public class SendFailedEmailTemplate implements EmailTemplate { | ||
| 9 | + /** | ||
| 10 | + * 模板标题格式化返回内容 | ||
| 11 | + */ | ||
| 12 | + @Override | ||
| 13 | + public String getTitle(Object ... arguments) { | ||
| 14 | + return MessageFormat.format(FAILED_EMAIL_TITLE.TITLE,arguments); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 模板内容 | ||
| 19 | + */ | ||
| 20 | + @Override | ||
| 21 | + public String getBody(Object ... arguments) { | ||
| 22 | + return FAILED_EMAIL_BODY.TABLE; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 邮件说明 | ||
| 27 | + */ | ||
| 28 | + @Override | ||
| 29 | + public String getDescription(Object... arguments) { | ||
| 30 | + return MessageFormat.format(FAILED_EMAIL_BODY.DESCRIPTION,arguments); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + interface FAILED_EMAIL_TITLE{ | ||
| 35 | + String TITLE = "失败预警"; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + interface FAILED_EMAIL_BODY{ | ||
| 39 | + String DESCRIPTION = "<p>1.【文件推送】任务,系统启动后每{0}分钟轮巡一次。</p>\n" + | ||
| 40 | + " <p>2.【推送预清关文件】任务,系统启动后每{1}分钟轮巡一次。</p>\n" + | ||
| 41 | + " <p>3.【提醒发件人】任务,系统启动后每{2}分钟轮巡一次。</p>\n" + | ||
| 42 | + " <p>备注:邮件发送机制:</p>\n" + | ||
| 43 | + " <p>该预警邮件任务,系统启动后每{3}分钟执行一次,当日上述3个定时任务,有任何一个任务的最终判定为失败的记录数量大于{4},则自动发送邮件通知FedEX IT,每个接口显示最新{5}条失败运单号、当日调用总次数、当日调用失败总次数。</p>\n" + | ||
| 44 | + " <p style=\"font-size:10px;\">(注:所有任务相关的数字均可以在系统配置界面调整)</p>"; | ||
| 45 | + | ||
| 46 | + String TABLE = "<table style=\"width: 100%;table-layout: fixed;padding: 20px;width: 100%;border-collapse: collapse;\">\n" + | ||
| 47 | + "<tr>\n" + | ||
| 48 | + "<td style=\"border: 0px;text-align: left;padding: 8px;\">\n" + | ||
| 49 | + "<div style=\"margin: auto;padding: 20px;\">\n" + | ||
| 50 | + "<h2 style=\"text-align: center;\">接口调用失败详情</h2>\n" + | ||
| 51 | + "<table style=\"width: 100%;border-collapse: collapse;\">\n" + | ||
| 52 | + "<tr>\n" + | ||
| 53 | + "<th style=\"border: 1px solid #dddddd;text-align: left;padding: 8px;background-color: #593BB7;color: white;\">任务名称</th>\n" + | ||
| 54 | + "<th style=\"border: 1px solid #dddddd;text-align: left;padding: 8px;background-color: #593BB7;color: white;\">失败的运单号</th>\n" + | ||
| 55 | + "<th style=\"border: 1px solid #dddddd;text-align: left;padding: 8px;background-color: #593BB7;color: white;\">总数</th>\n" + | ||
| 56 | + "<th style=\"border: 1px solid #dddddd;text-align: left;padding: 8px;background-color: #593BB7;color: white;\">失败数量</th>\n" + | ||
| 57 | + "</tr>\n" + | ||
| 58 | + "{0}\n" + | ||
| 59 | + "</table>\n" + | ||
| 60 | + "<div style=\"color:#808080;font-style:Arial;font-size:14px;margin: auto;margin-bottom: 5px;\">\n" + | ||
| 61 | + "{1}\n" + | ||
| 62 | + "</div>\n" + | ||
| 63 | + "</div>\n" + | ||
| 64 | + "</td>\n" + | ||
| 65 | + "</tr>\n" + | ||
| 66 | + "</table>"; | ||
| 67 | + } | ||
| 68 | +} |
server/task-schedule/src/main/java/com/fedex/connect/task/data/dto/SendFailedEmailDto.java
0 → 100644
| 1 | +package com.fedex.connect.task.data.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | +/** | ||
| 7 | + * @Author Szl | ||
| 8 | + * @Description 类说明 发送预警邮件dto | ||
| 9 | + * @Date 2024/11/21 | ||
| 10 | + */ | ||
| 11 | +@Data | ||
| 12 | +public class SendFailedEmailDto { | ||
| 13 | + private String typeCode; | ||
| 14 | + private long statusCodeCount; | ||
| 15 | + private List<String> bizCodes; | ||
| 16 | + private long totalCount; | ||
| 17 | + | ||
| 18 | + public SendFailedEmailDto(String typeCode, long statusCodeCount, List<String> latestBizCodes, long totalCount) { | ||
| 19 | + this.typeCode = typeCode; | ||
| 20 | + this.statusCodeCount = statusCodeCount; | ||
| 21 | + this.bizCodes = latestBizCodes; | ||
| 22 | + this.totalCount = totalCount; | ||
| 23 | + } | ||
| 24 | +} |
| ... | @@ -3,25 +3,55 @@ package com.fedex.connect.task.job; | ... | @@ -3,25 +3,55 @@ package com.fedex.connect.task.job; |
| 3 | import com.fedex.connect.common.dependencies.contants.ParamConfigConstants; | 3 | import com.fedex.connect.common.dependencies.contants.ParamConfigConstants; |
| 4 | import com.fedex.connect.task.annotation.ProcessingInterval; | 4 | import com.fedex.connect.task.annotation.ProcessingInterval; |
| 5 | import com.fedex.connect.task.service.biz.IDuplicateConsignmentEmailService; | 5 | import com.fedex.connect.task.service.biz.IDuplicateConsignmentEmailService; |
| 6 | +import com.fedex.connect.task.service.biz.IPushConsignmentFileService; | ||
| 7 | +import com.fedex.connect.task.service.sys.ISendFailedEmailAlertService; | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.scheduling.annotation.Scheduled; | 9 | import org.springframework.scheduling.annotation.Scheduled; |
| 8 | import org.springframework.stereotype.Component; | 10 | import org.springframework.stereotype.Component; |
| 9 | 11 | ||
| 10 | -/** | ||
| 11 | - * @Author Szl | ||
| 12 | - * @Description 类说明 发邮件通知到该运单所属用户,告知运单已被其他用户创建上传 | ||
| 13 | - * @Date 2024/11/20 | ||
| 14 | - */ | ||
| 15 | @Component | 12 | @Component |
| 16 | -public class DuplicateConsignmentEmailJob { | 13 | +public class EmailJob { |
| 17 | - | ||
| 18 | @Autowired | 14 | @Autowired |
| 19 | private IDuplicateConsignmentEmailService duplicateConsignmentEmailService; | 15 | private IDuplicateConsignmentEmailService duplicateConsignmentEmailService; |
| 16 | + @Autowired | ||
| 17 | + private IPushConsignmentFileService pushConsignmentFileService; | ||
| 18 | + @Autowired | ||
| 19 | + private ISendFailedEmailAlertService sendWarningEmail; | ||
| 20 | 20 | ||
| 21 | + /** | ||
| 22 | + * @Author Szl | ||
| 23 | + * @Description 功能说明 提醒发件人 | ||
| 24 | + * @Date 2024/11/21 | ||
| 25 | + * @param | ||
| 26 | + * @return void | ||
| 27 | + */ | ||
| 21 | @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_INTERVAL) | 28 | @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_INTERVAL) |
| 22 | @Scheduled(cron = "${export.task.allocation.sendOb}") | 29 | @Scheduled(cron = "${export.task.allocation.sendOb}") |
| 23 | - public void pushConsignmentFileTask() { | 30 | + public void notificationSenderTask() { |
| 24 | duplicateConsignmentEmailService.duplicateConsignmentEmail(); | 31 | duplicateConsignmentEmailService.duplicateConsignmentEmail(); |
| 25 | } | 32 | } |
| 26 | 33 | ||
| 34 | + /** | ||
| 35 | + * @Author Szl | ||
| 36 | + * @Description 功能说明 推送清关文件 | ||
| 37 | + * @Date 2024/11/21 | ||
| 38 | + * @param | ||
| 39 | + * @return void | ||
| 40 | + */ | ||
| 41 | + @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.PUSH_CON_EMAIL_INTERVAL) | ||
| 42 | + @Scheduled(cron = "${export.task.allocation.sendOb}") | ||
| 43 | + public void pushConsignmentFileTask() { | ||
| 44 | + pushConsignmentFileService.pushConsignmentFileTask(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 发送失败邮件提醒 | ||
| 49 | + */ | ||
| 50 | + @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.SEND_FAIL_ALERT_INTERVAL) | ||
| 51 | + @Scheduled(cron = "${export.task.allocation.warningEmail}") | ||
| 52 | + public void sendingFailedEmailAlert() { | ||
| 53 | + sendWarningEmail.sendFailedEmail(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + | ||
| 27 | } | 57 | } | ... | ... |
| 1 | -package com.fedex.connect.task.job; | ||
| 2 | - | ||
| 3 | -import com.fedex.connect.common.dependencies.contants.ParamConfigConstants; | ||
| 4 | -import com.fedex.connect.task.annotation.ProcessingInterval; | ||
| 5 | -import com.fedex.connect.task.service.biz.IPushConsignmentFileService; | ||
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | -import org.springframework.scheduling.annotation.Scheduled; | ||
| 8 | -import org.springframework.stereotype.Component; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @Author Szl | ||
| 12 | - * @Description 类说明 异步任务发送邮件到预清关组 | ||
| 13 | - * @Date 2024/11/7 | ||
| 14 | - */ | ||
| 15 | -@Component | ||
| 16 | -public class PushConsignmentFileEmailJob { | ||
| 17 | - | ||
| 18 | - @Autowired | ||
| 19 | - private IPushConsignmentFileService pushConsignmentFileService; | ||
| 20 | - | ||
| 21 | - @ProcessingInterval(paramCode = ParamConfigConstants.TASK_PARAM_KEYS.PUSH_CON_EMAIL_INTERVAL) | ||
| 22 | - @Scheduled(cron = "${export.task.allocation.sendOb}") | ||
| 23 | - public void pushConsignmentFileTask() { | ||
| 24 | - pushConsignmentFileService.pushConsignmentFileTask(); | ||
| 25 | - } | ||
| 26 | -} |
server/task-schedule/src/main/java/com/fedex/connect/task/repository/base/AbstractDaoRepository.java
| ... | @@ -36,5 +36,7 @@ public class AbstractDaoRepository { | ... | @@ -36,5 +36,7 @@ public class AbstractDaoRepository { |
| 36 | @Autowired | 36 | @Autowired |
| 37 | protected ParamConfigMapper paramConfigMapper; | 37 | protected ParamConfigMapper paramConfigMapper; |
| 38 | @Autowired | 38 | @Autowired |
| 39 | + protected ParamConfigExtMapper paramConfigExtMapper; | ||
| 40 | + @Autowired | ||
| 39 | protected ConsignmentMapper consignmentMapper; | 41 | protected ConsignmentMapper consignmentMapper; |
| 40 | } | 42 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -4,6 +4,7 @@ import com.fedex.connect.common.model.biz.Email; | ... | @@ -4,6 +4,7 @@ import com.fedex.connect.common.model.biz.Email; |
| 4 | import org.apache.ibatis.annotations.Delete; | 4 | import org.apache.ibatis.annotations.Delete; |
| 5 | import org.apache.ibatis.annotations.Mapper; | 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | import org.apache.ibatis.annotations.Param; | 6 | import org.apache.ibatis.annotations.Param; |
| 7 | +import org.apache.ibatis.annotations.Select; | ||
| 7 | 8 | ||
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | 10 | ||
| ... | @@ -13,4 +14,12 @@ public interface EmailExtMapper { | ... | @@ -13,4 +14,12 @@ public interface EmailExtMapper { |
| 13 | 14 | ||
| 14 | @Delete("DELETE FROM T_BIZ_EMAIL WHERE ID = #{id}") | 15 | @Delete("DELETE FROM T_BIZ_EMAIL WHERE ID = #{id}") |
| 15 | void deleteById(@Param("id") Long id); | 16 | void deleteById(@Param("id") Long id); |
| 17 | + | ||
| 18 | + @Select("<script>" + | ||
| 19 | + "SELECT * " + | ||
| 20 | + "FROM T_BIZ_EMAIL " + | ||
| 21 | + "WHERE MODIFY_TIME >= #{modifyTime}" + | ||
| 22 | + "</script>") | ||
| 23 | + List<Email> findEmailsByModifyTime(@Param("modifyTime") String modifyTime); | ||
| 24 | + | ||
| 16 | } | 25 | } | ... | ... |
| ... | @@ -25,4 +25,11 @@ public interface PushObMapperExt { | ... | @@ -25,4 +25,11 @@ public interface PushObMapperExt { |
| 25 | "AND TRUNC(CREATE_TIME) = TRUNC(TO_DATE(#{date,jdbcType=VARCHAR}, 'YYYY-MM-DD'))" + | 25 | "AND TRUNC(CREATE_TIME) = TRUNC(TO_DATE(#{date,jdbcType=VARCHAR}, 'YYYY-MM-DD'))" + |
| 26 | "</script>") | 26 | "</script>") |
| 27 | Integer findErrPushForEmail(@Param("pushNum") Long pushNum, @Param("statusCode") String statusCode, @Param("date") String date); | 27 | Integer findErrPushForEmail(@Param("pushNum") Long pushNum, @Param("statusCode") String statusCode, @Param("date") String date); |
| 28 | + | ||
| 29 | + @Select("<script>" + | ||
| 30 | + "SELECT * " + | ||
| 31 | + "FROM T_BIZ_EMAIL " + | ||
| 32 | + "WHERE MODIFY_TIME >= #{modifyTime}" + | ||
| 33 | + "</script>") | ||
| 34 | + List<PushOb> findPushObByModifyTime(@Param("modifyTime") String modifyTime); | ||
| 28 | } | 35 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -10,4 +10,6 @@ public interface IEmailRepository { | ... | @@ -10,4 +10,6 @@ public interface IEmailRepository { |
| 10 | void deleteById(Long id); | 10 | void deleteById(Long id); |
| 11 | 11 | ||
| 12 | void saveOrUpdate(Email entity); | 12 | void saveOrUpdate(Email entity); |
| 13 | + | ||
| 14 | + List<Email> findEmailsByModifyTime(String modifyTime); | ||
| 13 | } | 15 | } | ... | ... |
server/task-schedule/src/main/java/com/fedex/connect/task/repository/repo/biz/IPushObRepository.java
| 1 | package com.fedex.connect.task.repository.repo.biz; | 1 | package com.fedex.connect.task.repository.repo.biz; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.common.model.biz.PushOb; | 3 | import com.fedex.connect.common.model.biz.PushOb; |
| 4 | + | ||
| 4 | import java.util.List; | 5 | import java.util.List; |
| 5 | 6 | ||
| 6 | public interface IPushObRepository { | 7 | public interface IPushObRepository { |
| ... | @@ -45,4 +46,6 @@ public interface IPushObRepository { | ... | @@ -45,4 +46,6 @@ public interface IPushObRepository { |
| 45 | List<PushOb> findErrPushOb(Long pushNum,String statusCode,Long rownum); | 46 | List<PushOb> findErrPushOb(Long pushNum,String statusCode,Long rownum); |
| 46 | 47 | ||
| 47 | Integer findErrPushForEmail(Long pushNum,String statusCode,String date); | 48 | Integer findErrPushForEmail(Long pushNum,String statusCode,String date); |
| 49 | + | ||
| 50 | + List<PushOb> findPushObByModifyTime(String modifyTime); | ||
| 48 | } | 51 | } | ... | ... |
| ... | @@ -34,4 +34,9 @@ public class EmailRepositoryImpl extends AbstractDaoRepository implements IEmail | ... | @@ -34,4 +34,9 @@ public class EmailRepositoryImpl extends AbstractDaoRepository implements IEmail |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | + @Override | ||
| 38 | + public List<Email> findEmailsByModifyTime(String modifyTime) { | ||
| 39 | + return emailExtMapper.findEmailsByModifyTime(modifyTime); | ||
| 40 | + } | ||
| 41 | + | ||
| 37 | } | 42 | } | ... | ... |
| ... | @@ -62,4 +62,9 @@ public class PushObRepositoryImpl extends AbstractDaoRepository implements IPush | ... | @@ -62,4 +62,9 @@ public class PushObRepositoryImpl extends AbstractDaoRepository implements IPush |
| 62 | public Integer findErrPushForEmail(Long pushNum, String statusCode, String date) { | 62 | public Integer findErrPushForEmail(Long pushNum, String statusCode, String date) { |
| 63 | return pushObMapperExt.findErrPushForEmail(pushNum,statusCode,date); | 63 | return pushObMapperExt.findErrPushForEmail(pushNum,statusCode,date); |
| 64 | } | 64 | } |
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public List<PushOb> findPushObByModifyTime(String modifyTime) { | ||
| 68 | + return pushObMapperExt.findPushObByModifyTime(modifyTime); | ||
| 69 | + } | ||
| 65 | } | 70 | } | ... | ... |
| ... | @@ -37,7 +37,7 @@ public class DuplicateConsignmentEmailServiceImpl extends BaseService implements | ... | @@ -37,7 +37,7 @@ public class DuplicateConsignmentEmailServiceImpl extends BaseService implements |
| 37 | /** | 37 | /** |
| 38 | * 查询邮件发送日志表中状态为待推送且类型为“提醒发件人”的数据 | 38 | * 查询邮件发送日志表中状态为待推送且类型为“提醒发件人”的数据 |
| 39 | */ | 39 | */ |
| 40 | - List<Email> emails = iEmailExtRepository.findEmailsByDic(cacheSystem.getDicEmailType(EmailTypeEnum.NOTIFICATION_SENDER.getEnMsg()).getCode(), | 40 | + List<Email> emails = iEmailExtRepository.findEmailsByDic(cacheSystem.getDicEmailType(EmailTypeEnum.NOTIFICATION_SENDER.getCode()).getCode(), |
| 41 | cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode(), ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_NUMBER); | 41 | cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode(), ParamConfigConstants.TASK_PARAM_KEYS.NOTIFICATION_SENDER_EMAIL_NUMBER); |
| 42 | /** | 42 | /** |
| 43 | * 发送邮件 | 43 | * 发送邮件 | ... | ... |
| 1 | +package com.fedex.connect.task.service.sys.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.util.DateUtil; | ||
| 4 | +import com.fedex.connect.common.model.biz.Email; | ||
| 5 | +import com.fedex.connect.common.model.biz.PushOb; | ||
| 6 | +import com.fedex.connect.common.model.sys.ParamConfig; | ||
| 7 | +import com.fedex.connect.task.data.dto.MailConfigDto; | ||
| 8 | +import com.fedex.connect.task.data.dto.SendFailedEmailDto; | ||
| 9 | +import com.fedex.connect.task.service.base.BaseService; | ||
| 10 | +import com.fedex.connect.task.service.sys.ISendFailedEmailAlertService; | ||
| 11 | +import com.fedex.connect.task.utils.sys.EmailUtil; | ||
| 12 | +import com.fedex.connect.task.utils.sys.SendFailedEmailUtil; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | + | ||
| 17 | +import java.util.Date; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Map; | ||
| 20 | + | ||
| 21 | +@Service | ||
| 22 | +@Slf4j | ||
| 23 | +public class SendFailedEmailAlertServiceImpl extends BaseService implements ISendFailedEmailAlertService { | ||
| 24 | + | ||
| 25 | + @Autowired | ||
| 26 | + private SendFailedEmailUtil sendFailedEmailUtil; | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + private EmailUtil emailUtil; | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @Author Szl | ||
| 33 | + * @Description 功能说明 推送错误预警邮件 | ||
| 34 | + * @Date 2024/11/21 | ||
| 35 | + * @param | ||
| 36 | + * @return void | ||
| 37 | + */ | ||
| 38 | + @Override | ||
| 39 | + public void sendFailedEmail() { | ||
| 40 | + /** | ||
| 41 | + * 获取配置信息 | ||
| 42 | + */ | ||
| 43 | + Map<String, ParamConfig> paramConfigMap = sendFailedEmailUtil.getParam(); | ||
| 44 | + /** | ||
| 45 | + * 查询需要发送邮件的记录 | ||
| 46 | + */ | ||
| 47 | + String date = DateUtil.format(new Date()); | ||
| 48 | + List<Email> emails = sendFailedEmailUtil.getEmails(date); | ||
| 49 | + /** | ||
| 50 | + * 查询推送文件集合 | ||
| 51 | + */ | ||
| 52 | + List<PushOb> obs= sendFailedEmailUtil.getOb(date); | ||
| 53 | + /** | ||
| 54 | + * 处理邮件集合,过滤需要发送邮件的数据 | ||
| 55 | + */ | ||
| 56 | + List<SendFailedEmailDto> sendFailedEmailDto = sendFailedEmailUtil.createSendFailedEmailDto(emails,obs,paramConfigMap); | ||
| 57 | + /** | ||
| 58 | + * 构建邮件内容 | ||
| 59 | + */ | ||
| 60 | + String emailBody = sendFailedEmailUtil.createEmailBody(sendFailedEmailDto,paramConfigMap); | ||
| 61 | + /** | ||
| 62 | + * 构建发送邮件dto | ||
| 63 | + */ | ||
| 64 | + MailConfigDto mailConfigDto = sendFailedEmailUtil.createMailConfigDto(emailBody); | ||
| 65 | + /** | ||
| 66 | + * 发送邮件 | ||
| 67 | + */ | ||
| 68 | + boolean result = emailUtil.sendMail(mailConfigDto); | ||
| 69 | + try { | ||
| 70 | + /** | ||
| 71 | + * 保存邮件记录 | ||
| 72 | + */ | ||
| 73 | + sendFailedEmailUtil.saveEmail(result,mailConfigDto); | ||
| 74 | + }catch (Exception e){ | ||
| 75 | + log.error("保存邮件记录失败",e); | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | +} |
server/task-schedule/src/main/java/com/fedex/connect/task/utils/sys/SendFailedEmailUtil.java
0 → 100644
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment