Showing
23 changed files
with
348 additions
and
30 deletions
| ... | @@ -20,4 +20,6 @@ public class BaseDao { | ... | @@ -20,4 +20,6 @@ public class BaseDao { |
| 20 | protected ConsignmentExtMapper consignmentExtMapper; | 20 | protected ConsignmentExtMapper consignmentExtMapper; |
| 21 | @Autowired | 21 | @Autowired |
| 22 | protected AttachmentExtMapper attachmentExtMapper; | 22 | protected AttachmentExtMapper attachmentExtMapper; |
| 23 | + @Autowired | ||
| 24 | + protected EmailMapper emailMapper; | ||
| 23 | } | 25 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | +package com.fedex.connect.customer.repository.repo.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.model.biz.Email; | ||
| 4 | +import com.fedex.connect.customer.repository.base.BaseDao; | ||
| 5 | +import com.fedex.connect.customer.repository.repo.IEmailRepository; | ||
| 6 | +import org.springframework.stereotype.Repository; | ||
| 7 | + | ||
| 8 | +@Repository | ||
| 9 | +public class EmailRepositoryImpl extends BaseDao implements IEmailRepository { | ||
| 10 | + | ||
| 11 | + public void save(Email entity){ | ||
| 12 | + if(entity != null) { | ||
| 13 | + if (entity.getId() == null || entity.getId() <= 0) { | ||
| 14 | + emailMapper.insertSelective(entity); | ||
| 15 | + } else if (entity.getId() != null && entity.getId() > 0){ | ||
| 16 | + emailMapper.updateByPrimaryKeySelective(entity); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | +} |
| ... | @@ -16,5 +16,7 @@ public class BaseService { | ... | @@ -16,5 +16,7 @@ public class BaseService { |
| 16 | @Autowired | 16 | @Autowired |
| 17 | protected IUserConsignmentMappingRepository userConsignmentMappingRepository; | 17 | protected IUserConsignmentMappingRepository userConsignmentMappingRepository; |
| 18 | @Autowired | 18 | @Autowired |
| 19 | + protected IEmailRepository emailRepository; | ||
| 20 | + @Autowired | ||
| 19 | protected IPushObRepository pushObRepository; | 21 | protected IPushObRepository pushObRepository; |
| 20 | } | 22 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | package com.fedex.connect.customer.service.biz.impl; | 1 | package com.fedex.connect.customer.service.biz.impl; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.common.dependencies.date.vo.ResponseVo; | 3 | import com.fedex.connect.common.dependencies.date.vo.ResponseVo; |
| 4 | -import com.fedex.connect.common.dependencies.enums.base.StatusEnum; | ||
| 5 | -import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils; | ||
| 6 | -import com.fedex.connect.common.dependencies.util.ResponseUtils; | ||
| 7 | import com.fedex.connect.common.model.biz.*; | 4 | import com.fedex.connect.common.model.biz.*; |
| 8 | import com.fedex.connect.common.model.sys.User; | 5 | import com.fedex.connect.common.model.sys.User; |
| 9 | import com.fedex.connect.customer.data.bo.AddBo; | 6 | import com.fedex.connect.customer.data.bo.AddBo; |
| ... | @@ -12,6 +9,7 @@ import com.fedex.connect.customer.enums.ResponseCode; | ... | @@ -12,6 +9,7 @@ import com.fedex.connect.customer.enums.ResponseCode; |
| 12 | import com.fedex.connect.customer.service.base.BaseService; | 9 | import com.fedex.connect.customer.service.base.BaseService; |
| 13 | import com.fedex.connect.customer.service.biz.IAttachmentService; | 10 | import com.fedex.connect.customer.service.biz.IAttachmentService; |
| 14 | import com.fedex.connect.customer.service.biz.IConsignmentService; | 11 | import com.fedex.connect.customer.service.biz.IConsignmentService; |
| 12 | +import com.fedex.connect.customer.service.biz.IEmailService; | ||
| 15 | import com.fedex.connect.customer.util.service.biz.ConsignmentUtil; | 13 | import com.fedex.connect.customer.util.service.biz.ConsignmentUtil; |
| 16 | import com.fedex.connect.customer.util.service.biz.PushObUtil; | 14 | import com.fedex.connect.customer.util.service.biz.PushObUtil; |
| 17 | import com.fedex.connect.customer.util.service.biz.UploadRecordUtil; | 15 | import com.fedex.connect.customer.util.service.biz.UploadRecordUtil; |
| ... | @@ -22,7 +20,6 @@ import org.springframework.stereotype.Service; | ... | @@ -22,7 +20,6 @@ import org.springframework.stereotype.Service; |
| 22 | import org.springframework.transaction.annotation.Transactional; | 20 | import org.springframework.transaction.annotation.Transactional; |
| 23 | import org.springframework.web.multipart.MultipartFile; | 21 | import org.springframework.web.multipart.MultipartFile; |
| 24 | 22 | ||
| 25 | -import java.io.File; | ||
| 26 | import java.time.LocalDate; | 23 | import java.time.LocalDate; |
| 27 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
| 28 | import java.util.List; | 25 | import java.util.List; |
| ... | @@ -46,6 +43,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS | ... | @@ -46,6 +43,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS |
| 46 | private PushObUtil pushObUtil; | 43 | private PushObUtil pushObUtil; |
| 47 | @Autowired | 44 | @Autowired |
| 48 | private IAttachmentService attachmentService; | 45 | private IAttachmentService attachmentService; |
| 46 | + @Autowired | ||
| 47 | + private IEmailService emailService; | ||
| 49 | 48 | ||
| 50 | /** | 49 | /** |
| 51 | * @Author Szl | 50 | * @Author Szl |
| ... | @@ -154,13 +153,13 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS | ... | @@ -154,13 +153,13 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS |
| 154 | /** | 153 | /** |
| 155 | * 保存或更新运单表 | 154 | * 保存或更新运单表 |
| 156 | */ | 155 | */ |
| 157 | - consignmentRepository.save(consignment); | 156 | + consignmentRepository.saveOrUpdate(consignment); |
| 158 | //设置上传记录表运单ID | 157 | //设置上传记录表运单ID |
| 159 | uploadRecord.setConsignmentId(consignment.getId()); | 158 | uploadRecord.setConsignmentId(consignment.getId()); |
| 160 | /** | 159 | /** |
| 161 | * 保存上传记录表 | 160 | * 保存上传记录表 |
| 162 | */ | 161 | */ |
| 163 | - uploadRecordRepository.save(uploadRecord); | 162 | + uploadRecordRepository.saveOrUpdate(uploadRecord); |
| 164 | //设置附件表运单id,上传记录表id | 163 | //设置附件表运单id,上传记录表id |
| 165 | Optional.ofNullable(attachmentList).orElse(new ArrayList<>()).stream().filter(Objects::nonNull).forEach(p->{ | 164 | Optional.ofNullable(attachmentList).orElse(new ArrayList<>()).stream().filter(Objects::nonNull).forEach(p->{ |
| 166 | p.setBizId(consignment.getId()); | 165 | p.setBizId(consignment.getId()); |
| ... | @@ -169,7 +168,7 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS | ... | @@ -169,7 +168,7 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS |
| 169 | /** | 168 | /** |
| 170 | * 保存附件表信息 | 169 | * 保存附件表信息 |
| 171 | */ | 170 | */ |
| 172 | - attachmentRepository.saveAll(attachmentList); | 171 | + attachmentRepository.saveOrUpdateAll(attachmentList); |
| 173 | //用户uuid与运单uuid不一致,则需要添加用户运单中间表信息 | 172 | //用户uuid与运单uuid不一致,则需要添加用户运单中间表信息 |
| 174 | if(!user.getUserUuid().equals(consignment.getUserUuid())){ | 173 | if(!user.getUserUuid().equals(consignment.getUserUuid())){ |
| 175 | /** | 174 | /** |
| ... | @@ -184,7 +183,7 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS | ... | @@ -184,7 +183,7 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS |
| 184 | /** | 183 | /** |
| 185 | * 初始化插入预清关文件推送任务日志 | 184 | * 初始化插入预清关文件推送任务日志 |
| 186 | */ | 185 | */ |
| 187 | - userConsignmentMappingRepository.save(userConsignmentMapping); | 186 | + userConsignmentMappingRepository.saveOrUpdate(userConsignmentMapping); |
| 188 | } | 187 | } |
| 189 | } | 188 | } |
| 190 | /** | 189 | /** |
| ... | @@ -196,8 +195,12 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS | ... | @@ -196,8 +195,12 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS |
| 196 | */ | 195 | */ |
| 197 | PushOb pushOb = pushObUtil.initPushOb(consignment,user); | 196 | PushOb pushOb = pushObUtil.initPushOb(consignment,user); |
| 198 | /** | 197 | /** |
| 198 | + * 初始化插入提醒发件人邮件日志 | ||
| 199 | + */ | ||
| 200 | + emailService.saveNotificationEmail(consignment,user); | ||
| 201 | + /** | ||
| 199 | * 推送进口文件主表 | 202 | * 推送进口文件主表 |
| 200 | */ | 203 | */ |
| 201 | - pushObRepository.save(pushOb); | 204 | + pushObRepository.saveOrUpdate(pushOb); |
| 202 | } | 205 | } |
| 203 | } | 206 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
server/biz-customer/src/main/java/com/fedex/connect/customer/service/biz/impl/EmailServiceImpl.java
0 → 100644
| 1 | +package com.fedex.connect.customer.service.biz.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.model.biz.Consignment; | ||
| 4 | +import com.fedex.connect.common.model.biz.Email; | ||
| 5 | +import com.fedex.connect.common.model.sys.User; | ||
| 6 | +import com.fedex.connect.customer.service.base.BaseService; | ||
| 7 | +import com.fedex.connect.customer.service.biz.IEmailService; | ||
| 8 | +import com.fedex.connect.customer.util.service.biz.EmailUtil; | ||
| 9 | +import org.apache.commons.lang3.StringUtils; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.stereotype.Service; | ||
| 12 | + | ||
| 13 | +@Service | ||
| 14 | +public class EmailServiceImpl extends BaseService implements IEmailService { | ||
| 15 | + | ||
| 16 | + @Autowired | ||
| 17 | + private EmailUtil emailUtil; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * @Author Szl | ||
| 21 | + * @Description 功能说明 如果新建运单不是该账号UUID下的运单,则发邮件通知到该运单所属用户,告知运单已被其他用户创建上传。 | ||
| 22 | + * @Date 2024/11/20 | ||
| 23 | + * @param consignment | ||
| 24 | + * @param user | ||
| 25 | + * @return void | ||
| 26 | + */ | ||
| 27 | + @Override | ||
| 28 | + public void saveNotificationEmail(Consignment consignment, User user) throws Exception { | ||
| 29 | + if (!StringUtils.isEmpty(consignment.getUserUuid()) && consignment.getUserUuid().equals(user.getUserUuid())){ | ||
| 30 | + return; | ||
| 31 | + } | ||
| 32 | + /** | ||
| 33 | + * 初始化Email对象 | ||
| 34 | + */ | ||
| 35 | + Email email = new Email(); | ||
| 36 | + emailUtil.initNotificationEmail(email,consignment); | ||
| 37 | + /** | ||
| 38 | + * 保存入库 | ||
| 39 | + */ | ||
| 40 | + emailRepository.save(email); | ||
| 41 | + } | ||
| 42 | +} |
server/biz-customer/src/main/java/com/fedex/connect/customer/util/service/biz/EmailUtil.java
0 → 100644
| 1 | +package com.fedex.connect.customer.util.service.biz; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.enums.biz.EmailStatusEnum; | ||
| 4 | +import com.fedex.connect.common.dependencies.enums.biz.EmailTypeEnum; | ||
| 5 | +import com.fedex.connect.common.dependencies.util.AssignmentFieldUtils; | ||
| 6 | +import com.fedex.connect.common.model.biz.Consignment; | ||
| 7 | +import com.fedex.connect.common.model.biz.Email; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | +@Component | ||
| 11 | +public class EmailUtil { | ||
| 12 | + public void initNotificationEmail(Email email, Consignment consignment) throws Exception{ | ||
| 13 | + email.setBizId(consignment.getId()); | ||
| 14 | + email.setBizCode(consignment.getConsignmentCode()); | ||
| 15 | + email.setToAddress(consignment.getShipperEmail()); | ||
| 16 | + email.setSubject(""); | ||
| 17 | + email.setSubject(""); | ||
| 18 | + email.setTypeName(EmailTypeEnum.NOTIFICATION_SENDER.getMsg()); | ||
| 19 | + email.setTypeCode(EmailTypeEnum.NOTIFICATION_SENDER.getCode()); | ||
| 20 | + email.setStatusName(EmailStatusEnum.PENDING.getMsg()); | ||
| 21 | + email.setStatusCode(EmailStatusEnum.PENDING.getCode()); | ||
| 22 | + AssignmentFieldUtils.assignmentTableBaseField(email); | ||
| 23 | + } | ||
| 24 | +} |
| ... | @@ -6,26 +6,27 @@ package com.fedex.connect.common.dependencies.enums.biz; | ... | @@ -6,26 +6,27 @@ package com.fedex.connect.common.dependencies.enums.biz; |
| 6 | * @Date 2024/11/19 | 6 | * @Date 2024/11/19 |
| 7 | */ | 7 | */ |
| 8 | public enum EmailStatusEnum { | 8 | public enum EmailStatusEnum { |
| 9 | - PENDING(0L,"pending","待发送"), | 9 | + PENDING("emailStatus_01","pending","待发送"), |
| 10 | - SUCCESS(1L,"success","发送成功"), | 10 | + SUCCESS("emailStatus_02","success","发送成功"), |
| 11 | - FAILED(2L,"failed","发送失败"), | 11 | + FAILED("emailStatus_03","failed","发送失败"), |
| 12 | + | ||
| 12 | ; | 13 | ; |
| 13 | 14 | ||
| 14 | - private Long code; | 15 | + private String code; |
| 15 | private String enMsg; | 16 | private String enMsg; |
| 16 | private String msg; | 17 | private String msg; |
| 17 | 18 | ||
| 18 | - EmailStatusEnum(Long code, String enMsg,String msg) { | 19 | + EmailStatusEnum(String code, String enMsg,String msg) { |
| 19 | this.code = code; | 20 | this.code = code; |
| 20 | this.enMsg = enMsg; | 21 | this.enMsg = enMsg; |
| 21 | this.msg = msg; | 22 | this.msg = msg; |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | - public Long getCode() { | 25 | + public String getCode() { |
| 25 | return code; | 26 | return code; |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | - public void setCode(Long code) { | 29 | + public void setCode(String code) { |
| 29 | this.code = code; | 30 | this.code = code; |
| 30 | } | 31 | } |
| 31 | 32 | ... | ... |
| ... | @@ -6,24 +6,26 @@ package com.fedex.connect.common.dependencies.enums.biz; | ... | @@ -6,24 +6,26 @@ package com.fedex.connect.common.dependencies.enums.biz; |
| 6 | * @Date 2024/11/19 | 6 | * @Date 2024/11/19 |
| 7 | */ | 7 | */ |
| 8 | public enum EmailTypeEnum { | 8 | public enum EmailTypeEnum { |
| 9 | - PUSH_CON_FILE(0L,"pushConFile","推送预清关文件"), | 9 | + PUSH_CON_FILE("emailType_01","pushConFile","推送预清关文件"), |
| 10 | + NOTIFICATION_SENDER("emailType_02","notificationSender","提醒发件人"), | ||
| 11 | + | ||
| 10 | ; | 12 | ; |
| 11 | 13 | ||
| 12 | - private Long code; | 14 | + private String code; |
| 13 | private String enMsg; | 15 | private String enMsg; |
| 14 | private String msg; | 16 | private String msg; |
| 15 | 17 | ||
| 16 | - EmailTypeEnum(Long code, String enMsg,String msg) { | 18 | + EmailTypeEnum(String code, String enMsg,String msg) { |
| 17 | this.code = code; | 19 | this.code = code; |
| 18 | this.enMsg = enMsg; | 20 | this.enMsg = enMsg; |
| 19 | this.msg = msg; | 21 | this.msg = msg; |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | - public Long getCode() { | 24 | + public String getCode() { |
| 23 | return code; | 25 | return code; |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | - public void setCode(Long code) { | 28 | + public void setCode(String code) { |
| 27 | this.code = code; | 29 | this.code = code; |
| 28 | } | 30 | } |
| 29 | 31 | ... | ... |
| ... | @@ -50,7 +50,7 @@ url: | ... | @@ -50,7 +50,7 @@ url: |
| 50 | fcl: | 50 | fcl: |
| 51 | login: | 51 | login: |
| 52 | url: http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnLogin | 52 | url: http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnLogin |
| 53 | - redjrectLogin: http://localhost:8080/ImpPer/#/redjrectLogin | 53 | + redjrectLogin: http://192.168.1.251/time.html |
| 54 | twidx: | 54 | twidx: |
| 55 | url: http://exportdeclarationuat-tw.apac.fedex.com | 55 | url: http://exportdeclarationuat-tw.apac.fedex.com |
| 56 | interface: | 56 | interface: | ... | ... |
server/task-schedule/src/main/java/com/fedex/connect/task/job/DuplicateConsignmentEmailJob.java
0 → 100644
| 1 | +package com.fedex.connect.task.job; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.task.annotation.ProcessingInterval; | ||
| 4 | +import com.fedex.connect.task.service.biz.IDuplicateConsignmentEmailService; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 7 | +import org.springframework.stereotype.Component; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @Author Szl | ||
| 11 | + * @Description 类说明 发邮件通知到该运单所属用户,告知运单已被其他用户创建上传 | ||
| 12 | + * @Date 2024/11/20 | ||
| 13 | + */ | ||
| 14 | +@Component | ||
| 15 | +public class DuplicateConsignmentEmailJob { | ||
| 16 | + | ||
| 17 | + @Autowired | ||
| 18 | + private IDuplicateConsignmentEmailService duplicateConsignmentEmailService; | ||
| 19 | + | ||
| 20 | + @ProcessingInterval | ||
| 21 | + @Scheduled(cron = "${export.task.allocation.pushConFile}") | ||
| 22 | + public void pushConsignmentFileTask() { | ||
| 23 | + duplicateConsignmentEmailService.duplicateConsignmentEmail(); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | +} |
| ... | @@ -9,7 +9,7 @@ import java.util.List; | ... | @@ -9,7 +9,7 @@ import java.util.List; |
| 9 | 9 | ||
| 10 | @Mapper | 10 | @Mapper |
| 11 | public interface EmailExtMapper { | 11 | public interface EmailExtMapper { |
| 12 | - List<Email> findConPushEmails(String typeCode,String statusCode); | 12 | + List<Email> findEmailsByDic(String typeCode,String statusCode); |
| 13 | 13 | ||
| 14 | @Delete("DELETE FROM T_BIZ_EMAIL WHERE ID = #{id}") | 14 | @Delete("DELETE FROM T_BIZ_EMAIL WHERE ID = #{id}") |
| 15 | void deleteById(@Param("id") Long id); | 15 | void deleteById(@Param("id") Long id); | ... | ... |
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | <mapper namespace="com.fedex.connect.task.repository.dao.EmailExtMapper"> | 3 | <mapper namespace="com.fedex.connect.task.repository.dao.EmailExtMapper"> |
| 4 | -<select id="findConPushEmails" resultType="com.fedex.connect.common.model.biz.Email"> | 4 | +<select id="findEmailsByDic" resultType="com.fedex.connect.common.model.biz.Email"> |
| 5 | SELECT * | 5 | SELECT * |
| 6 | FROM ( | 6 | FROM ( |
| 7 | SELECT * | 7 | SELECT * | ... | ... |
| ... | @@ -5,7 +5,7 @@ import com.fedex.connect.common.model.biz.Email; | ... | @@ -5,7 +5,7 @@ import com.fedex.connect.common.model.biz.Email; |
| 5 | import java.util.List; | 5 | import java.util.List; |
| 6 | 6 | ||
| 7 | public interface IEmailRepository { | 7 | public interface IEmailRepository { |
| 8 | - List<Email> findConPushEmails(String typeCode,String statusCode); | 8 | + List<Email> findEmailsByDic(String typeCode,String statusCode); |
| 9 | 9 | ||
| 10 | void deleteById(Long id); | 10 | void deleteById(Long id); |
| 11 | 11 | ... | ... |
| ... | @@ -9,8 +9,8 @@ import java.util.List; | ... | @@ -9,8 +9,8 @@ import java.util.List; |
| 9 | 9 | ||
| 10 | @Repository | 10 | @Repository |
| 11 | public class EmailRepositoryImpl extends AbstractDaoRepository implements IEmailRepository { | 11 | public class EmailRepositoryImpl extends AbstractDaoRepository implements IEmailRepository { |
| 12 | - public List<Email> findConPushEmails(String typeCode,String statusCode){ | 12 | + public List<Email> findEmailsByDic(String typeCode,String statusCode){ |
| 13 | - return emailExtMapper.findConPushEmails(typeCode,statusCode); | 13 | + return emailExtMapper.findEmailsByDic(typeCode,statusCode); |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | @Override | 16 | @Override | ... | ... |
| 1 | package com.fedex.connect.task.repository.repo.log.impl; | 1 | package com.fedex.connect.task.repository.repo.log.impl; |
| 2 | 2 | ||
| 3 | +import com.fedex.connect.common.model.biz.Email; | ||
| 3 | import com.fedex.connect.common.model.log.EmailHistory; | 4 | import com.fedex.connect.common.model.log.EmailHistory; |
| 4 | import com.fedex.connect.task.repository.base.AbstractDaoRepository; | 5 | import com.fedex.connect.task.repository.base.AbstractDaoRepository; |
| 5 | import com.fedex.connect.task.repository.repo.log.IEmailHistoryRepository; | 6 | import com.fedex.connect.task.repository.repo.log.IEmailHistoryRepository; |
| 6 | import org.springframework.stereotype.Repository; | 7 | import org.springframework.stereotype.Repository; |
| 7 | 8 | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 8 | @Repository | 11 | @Repository |
| 9 | public class EmailHistoryRepositoryImpl extends AbstractDaoRepository implements IEmailHistoryRepository { | 12 | public class EmailHistoryRepositoryImpl extends AbstractDaoRepository implements IEmailHistoryRepository { |
| 10 | 13 | ... | ... |
| 1 | +package com.fedex.connect.task.service.biz.impl; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.cache.CacheSystem; | ||
| 4 | +import com.fedex.connect.common.dependencies.enums.biz.EmailStatusEnum; | ||
| 5 | +import com.fedex.connect.common.dependencies.enums.biz.EmailTypeEnum; | ||
| 6 | +import com.fedex.connect.common.model.biz.Email; | ||
| 7 | +import com.fedex.connect.task.data.dto.MailConfigDto; | ||
| 8 | +import com.fedex.connect.task.service.base.BaseService; | ||
| 9 | +import com.fedex.connect.task.service.biz.IDuplicateConsignmentEmailService; | ||
| 10 | +import com.fedex.connect.task.utils.sys.DuplicateEmailUtil; | ||
| 11 | +import com.fedex.connect.task.utils.sys.EmailUtil; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | + | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * @Author Szl | ||
| 19 | + * @Description 类说明 发送邮件通知用户 | ||
| 20 | + * @Date 2024/11/20 | ||
| 21 | + */ | ||
| 22 | +@Service | ||
| 23 | +public class DuplicateConsignmentEmailServiceImpl extends BaseService implements IDuplicateConsignmentEmailService { | ||
| 24 | + | ||
| 25 | + @Autowired | ||
| 26 | + private CacheSystem cacheSystem; | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + private EmailUtil emailUtil; | ||
| 30 | + | ||
| 31 | + @Autowired | ||
| 32 | + private DuplicateEmailUtil duplicateEmailUtil; | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public void duplicateConsignmentEmail(){ | ||
| 36 | + /** | ||
| 37 | + * 查询邮件发送日志表中状态为待推送且类型为“提醒发件人”的数据 | ||
| 38 | + */ | ||
| 39 | + List<Email> emails = iEmailExtRepository.findEmailsByDic(cacheSystem.getDicEmailType(EmailTypeEnum.NOTIFICATION_SENDER.getEnMsg()).getCode(), | ||
| 40 | + cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode()); | ||
| 41 | + /** | ||
| 42 | + * 发送邮件 | ||
| 43 | + */ | ||
| 44 | + for (Email email : emails) { | ||
| 45 | + /** | ||
| 46 | + * 构造邮件dto | ||
| 47 | + */ | ||
| 48 | + MailConfigDto mailConfigDto = new MailConfigDto(); | ||
| 49 | + duplicateEmailUtil.createMailConfigDto(mailConfigDto); | ||
| 50 | + /** | ||
| 51 | + * 发送邮件 | ||
| 52 | + */ | ||
| 53 | + boolean result = emailUtil.sendMail(mailConfigDto); | ||
| 54 | + /** | ||
| 55 | + * 更新邮件实体 | ||
| 56 | + */ | ||
| 57 | + duplicateEmailUtil.updateEmail(result,email,cacheSystem); | ||
| 58 | + /** | ||
| 59 | + * 更新数据库 | ||
| 60 | + */ | ||
| 61 | + duplicateEmailUtil.saveEmail(email); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | +} |
| ... | @@ -55,7 +55,7 @@ public class PushConsignmentFileServiceImpl extends BaseService implements IPush | ... | @@ -55,7 +55,7 @@ public class PushConsignmentFileServiceImpl extends BaseService implements IPush |
| 55 | String tempPath = ""; | 55 | String tempPath = ""; |
| 56 | String finalPath = ""; | 56 | String finalPath = ""; |
| 57 | //查询需要发送的数据 | 57 | //查询需要发送的数据 |
| 58 | - List<Email> conPushEmails = iEmailExtRepository.findConPushEmails(cacheSystem.getDicEmailType(EmailTypeEnum.PUSH_CON_FILE.getEnMsg()).getCode(), | 58 | + List<Email> conPushEmails = iEmailExtRepository.findEmailsByDic(cacheSystem.getDicEmailType(EmailTypeEnum.PUSH_CON_FILE.getEnMsg()).getCode(), |
| 59 | cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode()); | 59 | cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode()); |
| 60 | 60 | ||
| 61 | for (Email conPushEmail : conPushEmails) { | 61 | for (Email conPushEmail : conPushEmails) { | ... | ... |
| ... | @@ -29,7 +29,6 @@ import java.io.File; | ... | @@ -29,7 +29,6 @@ import java.io.File; |
| 29 | import java.io.FileOutputStream; | 29 | import java.io.FileOutputStream; |
| 30 | import java.io.IOException; | 30 | import java.io.IOException; |
| 31 | import java.nio.file.Paths; | 31 | import java.nio.file.Paths; |
| 32 | -import java.text.SimpleDateFormat; | ||
| 33 | import java.util.ArrayList; | 32 | import java.util.ArrayList; |
| 34 | import java.util.Date; | 33 | import java.util.Date; |
| 35 | import java.util.List; | 34 | import java.util.List; |
| ... | @@ -244,7 +243,7 @@ public class ConFileEmailUtil { | ... | @@ -244,7 +243,7 @@ public class ConFileEmailUtil { |
| 244 | String fileName = String.format("%s%s%s%s", | 243 | String fileName = String.format("%s%s%s%s", |
| 245 | "", | 244 | "", |
| 246 | "", | 245 | "", |
| 247 | - new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()), | 246 | + DateUtil.yyyyMMddHHmmss(new Date()), |
| 248 | extension | 247 | extension |
| 249 | ); | 248 | ); |
| 250 | String basePath = ""; | 249 | String basePath = ""; | ... | ... |
server/task-schedule/src/main/java/com/fedex/connect/task/utils/sys/DuplicateEmailUtil.java
0 → 100644
| 1 | +package com.fedex.connect.task.utils.sys; | ||
| 2 | + | ||
| 3 | +import com.fedex.connect.common.dependencies.cache.CacheSystem; | ||
| 4 | +import com.fedex.connect.common.dependencies.enums.biz.EmailStatusEnum; | ||
| 5 | +import com.fedex.connect.common.model.bi.DictionaryEntries; | ||
| 6 | +import com.fedex.connect.common.model.biz.Email; | ||
| 7 | +import com.fedex.connect.common.model.log.EmailHistory; | ||
| 8 | +import com.fedex.connect.task.data.dto.MailConfigDto; | ||
| 9 | +import com.fedex.connect.task.repository.repo.biz.IEmailRepository; | ||
| 10 | +import com.fedex.connect.task.repository.repo.log.IEmailHistoryRepository; | ||
| 11 | +import org.springframework.beans.BeanUtils; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.stereotype.Component; | ||
| 14 | +import org.springframework.transaction.annotation.Transactional; | ||
| 15 | + | ||
| 16 | +import java.util.Date; | ||
| 17 | + | ||
| 18 | +@Component | ||
| 19 | +public class DuplicateEmailUtil { | ||
| 20 | + | ||
| 21 | + @Autowired | ||
| 22 | + private IEmailRepository emailRepository; | ||
| 23 | + | ||
| 24 | + @Autowired | ||
| 25 | + private IEmailHistoryRepository emailHistoryRepository; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * @Author Szl | ||
| 29 | + * @Description 功能说明 初始化邮件dto | ||
| 30 | + * @Date 2024/11/20 | ||
| 31 | + * @param mailConfigDto | ||
| 32 | + * @return com.fedex.connect.task.data.dto.MailConfigDto | ||
| 33 | + */ | ||
| 34 | + public MailConfigDto createMailConfigDto(MailConfigDto mailConfigDto){ | ||
| 35 | + mailConfigDto.setHost(""); | ||
| 36 | + mailConfigDto.setPort(""); | ||
| 37 | + mailConfigDto.setAuth(""); | ||
| 38 | + //设置代理 | ||
| 39 | + mailConfigDto.setProxyStartFlag(""); | ||
| 40 | + mailConfigDto.setProxyHost(""); | ||
| 41 | + mailConfigDto.setProxyPort(""); | ||
| 42 | + //发件人 | ||
| 43 | + mailConfigDto.setFrom(""); | ||
| 44 | + //发件人密码 | ||
| 45 | + mailConfigDto.setPassword(""); | ||
| 46 | + //ce接收人 | ||
| 47 | + mailConfigDto.setTo(""); | ||
| 48 | + //设置邮件标题 | ||
| 49 | + mailConfigDto.setSubject(""); | ||
| 50 | + //设置邮件内容 | ||
| 51 | + mailConfigDto.setContent(""); | ||
| 52 | + return mailConfigDto; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * @Author Szl | ||
| 57 | + * @Description 功能说明 更新Email状态 | ||
| 58 | + * @Date 2024/11/20 | ||
| 59 | + * @param result | ||
| 60 | + * @param email | ||
| 61 | + * @param cacheSystem | ||
| 62 | + * @return com.fedex.connect.common.model.biz.Email | ||
| 63 | + */ | ||
| 64 | + public void updateEmail(boolean result, Email email, CacheSystem cacheSystem){ | ||
| 65 | + DictionaryEntries pending = cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()); | ||
| 66 | + DictionaryEntries success = cacheSystem.getDicEmailStatus(EmailStatusEnum.SUCCESS.getEnMsg()); | ||
| 67 | + DictionaryEntries failed = cacheSystem.getDicEmailStatus(EmailStatusEnum.FAILED.getEnMsg()); | ||
| 68 | + email.setSendTime(new Date()); | ||
| 69 | + if (result){ | ||
| 70 | + email.setTypeCode(success.getCode()); | ||
| 71 | + email.setTypeName(success.getEnglishName()); | ||
| 72 | + }else { | ||
| 73 | + if (email.getSendNum()<3){ | ||
| 74 | + email.setTypeCode(pending.getCode()); | ||
| 75 | + email.setTypeName(pending.getEnglishName()); | ||
| 76 | + email.setSendNum(email.getSendNum()+1); | ||
| 77 | + }else { | ||
| 78 | + email.setTypeCode(failed.getCode()); | ||
| 79 | + email.setTypeName(failed.getEnglishName()); | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * @Author Szl | ||
| 86 | + * @Description 功能说明 保存email信息入库 | ||
| 87 | + * @Date 2024/11/20 | ||
| 88 | + * @param email | ||
| 89 | + * @return void | ||
| 90 | + */ | ||
| 91 | + @Transactional | ||
| 92 | + public void saveEmail(Email email){ | ||
| 93 | + if (EmailStatusEnum.PENDING.getCode().equals(email.getTypeCode())){ | ||
| 94 | + emailRepository.save(email); | ||
| 95 | + }else { | ||
| 96 | + EmailHistory emailHistory = new EmailHistory(); | ||
| 97 | + BeanUtils.copyProperties(email, emailHistory); | ||
| 98 | + emailRepository.deleteById(email.getId()); | ||
| 99 | + emailHistoryRepository.save(emailHistory); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | +} |
| ... | @@ -18,6 +18,13 @@ import java.util.Properties; | ... | @@ -18,6 +18,13 @@ import java.util.Properties; |
| 18 | @Slf4j | 18 | @Slf4j |
| 19 | @Component | 19 | @Component |
| 20 | public class EmailUtil { | 20 | public class EmailUtil { |
| 21 | + /** | ||
| 22 | + * @Author Szl | ||
| 23 | + * @Description 功能说明 发送邮件 | ||
| 24 | + * @Date 2024/11/20 | ||
| 25 | + * @param mailConfig | ||
| 26 | + * @return boolean | ||
| 27 | + */ | ||
| 21 | public static boolean sendMail(MailConfigDto mailConfig) { | 28 | public static boolean sendMail(MailConfigDto mailConfig) { |
| 22 | System.setProperty("mail.mime.splitlongparameters","false"); | 29 | System.setProperty("mail.mime.splitlongparameters","false"); |
| 23 | try { | 30 | try { | ... | ... |
-
Please register or login to post a comment