zelong.shao

customer|add|校验规则调整

Showing 23 changed files with 198 additions and 126 deletions
...@@ -28,7 +28,7 @@ public enum ResponseCode { ...@@ -28,7 +28,7 @@ public enum ResponseCode {
28 MESSAGE_CODE_30008(30008,"business_exception_30008"), 28 MESSAGE_CODE_30008(30008,"business_exception_30008"),
29 MESSAGE_CODE_30009(30009,"business_exception_30009"), 29 MESSAGE_CODE_30009(30009,"business_exception_30009"),
30 MESSAGE_CODE_30010(30010,"business_exception_30010"), 30 MESSAGE_CODE_30010(30010,"business_exception_30010"),
31 - MESSAGE_CODE_30011(30011,"business_exception_30010"), 31 + MESSAGE_CODE_30011(30011,"business_exception_30011"),
32 MESSAGE_CODE_30012(30012,"business_exception_30012"), 32 MESSAGE_CODE_30012(30012,"business_exception_30012"),
33 33
34 /******打个样,编写样例*****/ 34 /******打个样,编写样例*****/
......
...@@ -2,12 +2,13 @@ package com.fedex.connect.customer.repository.dao; ...@@ -2,12 +2,13 @@ package com.fedex.connect.customer.repository.dao;
2 2
3 import com.fedex.connect.common.model.biz.Consignment; 3 import com.fedex.connect.common.model.biz.Consignment;
4 import com.fedex.connect.customer.data.dto.FindConsignmentsDto; 4 import com.fedex.connect.customer.data.dto.FindConsignmentsDto;
5 -import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
6 import com.fedex.connect.customer.data.query.ConsignmentQuery; 5 import com.fedex.connect.customer.data.query.ConsignmentQuery;
6 +import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
7 import org.apache.ibatis.annotations.Mapper; 7 import org.apache.ibatis.annotations.Mapper;
8 import org.apache.ibatis.annotations.Param; 8 import org.apache.ibatis.annotations.Param;
9 import org.apache.ibatis.annotations.Select; 9 import org.apache.ibatis.annotations.Select;
10 10
11 +import java.time.LocalDate;
11 import java.util.List; 12 import java.util.List;
12 13
13 @Mapper 14 @Mapper
...@@ -19,10 +20,10 @@ public interface ConsignmentExtMapper { ...@@ -19,10 +20,10 @@ public interface ConsignmentExtMapper {
19 @Select("SELECT * FROM ( " + 20 @Select("SELECT * FROM ( " +
20 "SELECT t.* FROM T_BIZ_CONSIGNMENT t " + 21 "SELECT t.* FROM T_BIZ_CONSIGNMENT t " +
21 "WHERE t.CONSIGNMENT_CODE = #{consignmentCode} " + 22 "WHERE t.CONSIGNMENT_CODE = #{consignmentCode} " +
22 - "AND t.CREATE_TIME >= SYSDATE - 30 " + 23 + "AND t.CREATE_TIME >= #{dateParam} " +
23 "ORDER BY t.CREATE_TIME DESC" + 24 "ORDER BY t.CREATE_TIME DESC" +
24 ") WHERE ROWNUM = 1") 25 ") WHERE ROWNUM = 1")
25 - Consignment findByConsignmentCode(@Param("consignmentCode") String consignmentCode); 26 + Consignment findByConsignmentCode(@Param("consignmentCode") String consignmentCode, @Param("dateParam") LocalDate dateParam);
26 27
27 @Select("SELECT BC.* FROM T_BIZ_CONSIGNMENT BC INNER JOIN T_BIZ_USER_CONSIGNMENT_MAPPING BUCM ON(BC.ID = BUCM.CONSIGNMENT_ID) " + 28 @Select("SELECT BC.* FROM T_BIZ_CONSIGNMENT BC INNER JOIN T_BIZ_USER_CONSIGNMENT_MAPPING BUCM ON(BC.ID = BUCM.CONSIGNMENT_ID) " +
28 "WHERE BC.ID = #{query.consignmentId} AND (BC.USER_UUID = #{query.userUuid} AND BUCM.USER_ID = #{query.userId})") 29 "WHERE BC.ID = #{query.consignmentId} AND (BC.USER_UUID = #{query.userUuid} AND BUCM.USER_ID = #{query.userId})")
......
...@@ -3,9 +3,10 @@ package com.fedex.connect.customer.repository.repo; ...@@ -3,9 +3,10 @@ package com.fedex.connect.customer.repository.repo;
3 import com.fedex.connect.common.model.biz.Consignment; 3 import com.fedex.connect.common.model.biz.Consignment;
4 import com.fedex.connect.common.model.sys.User; 4 import com.fedex.connect.common.model.sys.User;
5 import com.fedex.connect.customer.data.dto.FindConsignmentsDto; 5 import com.fedex.connect.customer.data.dto.FindConsignmentsDto;
6 -import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
7 import com.fedex.connect.customer.data.query.ConsignmentQuery; 6 import com.fedex.connect.customer.data.query.ConsignmentQuery;
7 +import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
8 8
9 +import java.time.LocalDate;
9 import java.util.List; 10 import java.util.List;
10 11
11 public interface IConsignmentRepository { 12 public interface IConsignmentRepository {
...@@ -13,7 +14,7 @@ public interface IConsignmentRepository { ...@@ -13,7 +14,7 @@ public interface IConsignmentRepository {
13 14
14 Long findAllCount(ConsignmentQuery query); 15 Long findAllCount(ConsignmentQuery query);
15 16
16 - Consignment findByConsignmentCode(String consignmentCode); 17 + Consignment findByConsignmentCode(String consignmentCode,LocalDate dateParam);
17 18
18 Consignment findConsignmentInfo(UserConsignmentInfoQuery consignmentInfoQuery); 19 Consignment findConsignmentInfo(UserConsignmentInfoQuery consignmentInfoQuery);
19 } 20 }
......
1 package com.fedex.connect.customer.repository.repo.impl; 1 package com.fedex.connect.customer.repository.repo.impl;
2 2
3 +import com.fedex.connect.common.dependencies.contants.SystemDefaultUserConstants;
3 import com.fedex.connect.common.model.biz.Consignment; 4 import com.fedex.connect.common.model.biz.Consignment;
4 import com.fedex.connect.common.model.sys.User; 5 import com.fedex.connect.common.model.sys.User;
5 import com.fedex.connect.customer.data.dto.FindConsignmentsDto; 6 import com.fedex.connect.customer.data.dto.FindConsignmentsDto;
...@@ -7,9 +8,9 @@ import com.fedex.connect.customer.data.query.ConsignmentQuery; ...@@ -7,9 +8,9 @@ import com.fedex.connect.customer.data.query.ConsignmentQuery;
7 import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery; 8 import com.fedex.connect.customer.data.query.UserConsignmentInfoQuery;
8 import com.fedex.connect.customer.repository.base.BaseDao; 9 import com.fedex.connect.customer.repository.base.BaseDao;
9 import com.fedex.connect.customer.repository.repo.IConsignmentRepository; 10 import com.fedex.connect.customer.repository.repo.IConsignmentRepository;
10 -import org.apache.commons.lang3.StringUtils;
11 import org.springframework.stereotype.Repository; 11 import org.springframework.stereotype.Repository;
12 12
13 +import java.time.LocalDate;
13 import java.util.Collections; 14 import java.util.Collections;
14 import java.util.List; 15 import java.util.List;
15 16
...@@ -31,7 +32,7 @@ public class ConsignmentRepositoryImpl extends BaseDao implements IConsignmentRe ...@@ -31,7 +32,7 @@ public class ConsignmentRepositoryImpl extends BaseDao implements IConsignmentRe
31 return Collections.emptyList(); 32 return Collections.emptyList();
32 } 33 }
33 consignments.forEach(consignment -> { 34 consignments.forEach(consignment -> {
34 - if (StringUtils.isBlank(consignment.getCreateUserName())) { 35 + if (SystemDefaultUserConstants.SYSTEM_USER_KEYS.USER_NAME.equals(consignment.getCreateUserName())){
35 consignment.setCreateUserName(user.getUserName()); 36 consignment.setCreateUserName(user.getUserName());
36 } 37 }
37 }); 38 });
...@@ -44,8 +45,8 @@ public class ConsignmentRepositoryImpl extends BaseDao implements IConsignmentRe ...@@ -44,8 +45,8 @@ public class ConsignmentRepositoryImpl extends BaseDao implements IConsignmentRe
44 } 45 }
45 46
46 @Override 47 @Override
47 - public Consignment findByConsignmentCode(String consignmentCode) { 48 + public Consignment findByConsignmentCode(String consignmentCode, LocalDate dateParam) {
48 - return consignmentExtMapper.findByConsignmentCode(consignmentCode); 49 + return consignmentExtMapper.findByConsignmentCode(consignmentCode,dateParam);
49 } 50 }
50 51
51 public Consignment findConsignmentInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){ 52 public Consignment findConsignmentInfo(UserConsignmentInfoQuery userConsignmentInfoQuery){
......
...@@ -11,14 +11,13 @@ import com.fedex.connect.customer.service.base.BaseService; ...@@ -11,14 +11,13 @@ import com.fedex.connect.customer.service.base.BaseService;
11 import com.fedex.connect.customer.service.biz.IAttachmentService; 11 import com.fedex.connect.customer.service.biz.IAttachmentService;
12 import com.fedex.connect.customer.service.biz.IConsignmentService; 12 import com.fedex.connect.customer.service.biz.IConsignmentService;
13 import com.fedex.connect.customer.util.service.biz.ConsignmentUtil; 13 import com.fedex.connect.customer.util.service.biz.ConsignmentUtil;
14 -import net.bytebuddy.asm.Advice;
15 import org.apache.commons.lang3.StringUtils; 14 import org.apache.commons.lang3.StringUtils;
16 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.stereotype.Service; 16 import org.springframework.stereotype.Service;
18 import org.springframework.web.multipart.MultipartFile; 17 import org.springframework.web.multipart.MultipartFile;
19 18
19 +import java.time.LocalDate;
20 import java.util.List; 20 import java.util.List;
21 -
22 import java.util.Objects; 21 import java.util.Objects;
23 22
24 /** 23 /**
...@@ -44,7 +43,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS ...@@ -44,7 +43,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
44 */ 43 */
45 public ResponseVo add(AddBo bo, User user){ 44 public ResponseVo add(AddBo bo, User user){
46 //查询运单表是否存在已提交的运单 45 //查询运单表是否存在已提交的运单
47 - Consignment consignment = consignmentRepository.findByConsignmentCode(bo.getConsignmentCode()); 46 + LocalDate thirtyDaysAgo = LocalDate.now().minusDays(30);
47 + Consignment consignment = consignmentRepository.findByConsignmentCode(bo.getConsignmentCode(),thirtyDaysAgo);
48 /** 48 /**
49 * 不存在则直接返回 49 * 不存在则直接返回
50 */ 50 */
......
...@@ -70,14 +70,6 @@ public class ConsignmentUtil { ...@@ -70,14 +70,6 @@ public class ConsignmentUtil {
70 } 70 }
71 71
72 /** 72 /**
73 - * uuid不一致且未填写shipperAccount
74 - */
75 - if (StringUtils.hasText(bo.getShipperAccount())){
76 - consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO);
77 - return responseUtils.success(ResponseCode.MESSAGE_CODE_30012);
78 - }
79 -
80 - /**
81 * 运单的shipperAccount和用户的shipperAccount一致,则返回提示语+运单信息 73 * 运单的shipperAccount和用户的shipperAccount一致,则返回提示语+运单信息
82 */ 74 */
83 if (isShipperAccountMatch(user.getAccountNo(), consignment.getShipperAccount())) { 75 if (isShipperAccountMatch(user.getAccountNo(), consignment.getShipperAccount())) {
...@@ -86,11 +78,29 @@ public class ConsignmentUtil { ...@@ -86,11 +78,29 @@ public class ConsignmentUtil {
86 } 78 }
87 79
88 /** 80 /**
81 + * uuid不一致且未填写shipperAccount
82 + */
83 + if (!StringUtils.hasText(bo.getShipperAccount())){
84 + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO);
85 + return responseUtils.success(ResponseCode.MESSAGE_CODE_30012);
86 + }
87 +
88 + /**
89 * 录入的shipperAccount和运单的shipperAccount一致,则返回提示语+运单信息 89 * 录入的shipperAccount和运单的shipperAccount一致,则返回提示语+运单信息
90 */ 90 */
91 if (isShipperAccountMatch(bo.getShipperAccount(), consignment.getShipperAccount())) { 91 if (isShipperAccountMatch(bo.getShipperAccount(), consignment.getShipperAccount())) {
92 consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE); 92 consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE);
93 - return responseUtils.success(ResponseCode.MESSAGE_CODE_30005, consignmentAddDto); 93 + return responseUtils.success(consignmentAddDto);
94 + }
95 +
96 + // 如果存在DM501,但是一个用户没有使用这条DM501并且提交了这个运单号,另一个用户再次提交这个运单号的时候,则判断录入的shipperAccount和运单中用户手动输入的shipperAccount,如果一致,则返回;如果不一致,则提示重单
97 + if (!StringUtils.isEmpty(consignment.getUserInputShipperAccount())){
98 + if (isShipperAccountMatch(bo.getShipperAccount(),consignment.getUserInputShipperAccount())){
99 + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE);
100 + return responseUtils.success(consignmentAddDto);
101 + }else {
102 + return responseUtils.success(ResponseCode.MESSAGE_CODE_30011);
103 + }
94 } 104 }
95 105
96 /** 106 /**
......
...@@ -41,6 +41,8 @@ public interface BaseConstants { ...@@ -41,6 +41,8 @@ public interface BaseConstants {
41 String USER_INPUT_ORIGIN_COUNTRY_CODE = "userInputOriginCountryCode"; 41 String USER_INPUT_ORIGIN_COUNTRY_CODE = "userInputOriginCountryCode";
42 //用户录入原产国全称 42 //用户录入原产国全称
43 String USER_INPUT_ORIGIN_COUNTRY = "userInputOriginCountry"; 43 String USER_INPUT_ORIGIN_COUNTRY = "userInputOriginCountry";
44 + //口岸
45 + String DEST_IATA_CODE = "destTataCode";
44 } 46 }
45 47
46 //异常枚举字段 48 //异常枚举字段
......
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 ClearanceEmailTemplate implements EmailTemplate {
9 + /**
10 + * 模板标题格式化返回内容
11 + */
12 + @Override
13 + public String getTitle(Object ... arguments) {
14 + return MessageFormat.format(CE_EMAIL_TITLE.TITLE,arguments);
15 + }
16 +
17 + /**
18 + * 模板内容
19 + */
20 + @Override
21 + public String getBody(Object ... arguments) {
22 + return CE_EMAIL_BODY.BODY;
23 + }
24 +}
1 +package com.fedex.connect.common.dependencies.template.clearanceEmail;
2 +
3 +public interface EmailTemplate {
4 + String getTitle(Object ... arguments);
5 + String getBody(Object ... arguments);
6 +}
...@@ -2,10 +2,7 @@ package com.fedex.connect.task.repository.base; ...@@ -2,10 +2,7 @@ package com.fedex.connect.task.repository.base;
2 2
3 import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper; 3 import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper;
4 import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper; 4 import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper;
5 -import com.fedex.connect.task.repository.dao.AttachmentExtMapper; 5 +import com.fedex.connect.task.repository.dao.*;
6 -import com.fedex.connect.task.repository.dao.EmailExtMapper;
7 -import com.fedex.connect.task.repository.dao.KafkaTemporaryStorageMapperExt;
8 -import com.fedex.connect.task.repository.dao.RedisSlabMapperExt;
9 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
10 7
11 public class AbstractDaoRepository { 8 public class AbstractDaoRepository {
...@@ -21,4 +18,6 @@ public class AbstractDaoRepository { ...@@ -21,4 +18,6 @@ public class AbstractDaoRepository {
21 protected EmailExtMapper emailExtMapper; 18 protected EmailExtMapper emailExtMapper;
22 @Autowired 19 @Autowired
23 protected AttachmentExtMapper attachmentExtMapper; 20 protected AttachmentExtMapper attachmentExtMapper;
21 + @Autowired
22 + protected PortclearEmailMappingExtMapper portclearEmailMappingExtMapper;
24 } 23 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -8,12 +8,10 @@ import java.util.List; ...@@ -8,12 +8,10 @@ import java.util.List;
8 @Mapper 8 @Mapper
9 public interface AttachmentExtMapper { 9 public interface AttachmentExtMapper {
10 10
11 - @Select("SELECT c.DEST_IATA_CODE, a.FILE_PATH " + 11 + @Select("SELECT a.FILE_PATH, c.DEST_IATA_CODE, c.CONSIGNMENT_CODE " +
12 - "FROM T_BIZ_EMAIL e " + 12 + "FROM T_BIZ_ATTACHMENT a " +
13 - "JOIN T_BIZ_CONSIGNMENT c ON e.BIZ_ID = c.ID " + 13 + "JOIN T_BIZ_CONSIGNMENT c ON a.BIZ_ID = c.ID " +
14 - "JOIN T_BIZ_ATTACHMENT a ON a.BIZ_ID = c.ID " + 14 + "WHERE a.BIZ_ID = #{bizId}")
15 - "WHERE a.STATUS = 1 " + 15 + List<PushZipEmailDto> findAttachmentDetailsByBizId(@Param("bizId") Long bizId);
16 - "AND e.TYPE_CODE = #{typeCode} " + 16 +
17 - "AND e.STATUS_CODE = #{statusCode}")
18 - List<PushZipEmailDto> findPathWithPortCode(@Param("typeCode") String typeCode, @Param("statusCode") String statusCode);
19 } 17 }
......
...@@ -7,5 +7,5 @@ import java.util.List; ...@@ -7,5 +7,5 @@ import java.util.List;
7 7
8 @Mapper 8 @Mapper
9 public interface EmailExtMapper { 9 public interface EmailExtMapper {
10 - List<Email> findConPushEmails(Long typeId,Long statusId); 10 + List<Email> findConPushEmails(String typeCode,String statusCode);
11 } 11 }
......
1 +package com.fedex.connect.task.repository.dao;
2 +
3 +import org.apache.ibatis.annotations.Mapper;
4 +import org.apache.ibatis.annotations.Param;
5 +import org.apache.ibatis.annotations.Select;
6 +
7 +@Mapper
8 +public interface PortclearEmailMappingExtMapper {
9 +
10 + @Select("SELECT EMAIL FROM T_BI_PORTCLEAR_EMAIL_MAPPING WHERE PORT_CODE = #{portCode}")
11 + String findEmailByPortCode(@Param("portCode") String portCode);
12 +
13 +}
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="findConPushEmails" resultType="com.fedex.connect.common.model.biz.Email">
5 SELECT * 5 SELECT *
6 FROM ( 6 FROM (
7 SELECT * 7 SELECT *
8 FROM T_BIZ_EMAIL 8 FROM T_BIZ_EMAIL
9 - WHERE TYPE_ID = #{typeId} 9 + WHERE TYPE_CODE = #{typeCode}
10 - AND STATUS_ID = #{statusId} 10 + AND STATUS_CODE = #{statusCode}
11 ORDER BY CREATED_DATE DESC 11 ORDER BY CREATED_DATE DESC
12 ) 12 )
13 WHERE ROWNUM &lt; 500 13 WHERE ROWNUM &lt; 500
......
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">
3 +<mapper namespace="com.fedex.connect.task.repository.dao.PortclearEmailMappingExtMapper">
4 +
5 +</mapper>
...\ No newline at end of file ...\ No newline at end of file
1 +package com.fedex.connect.task.repository.repo.bi;
2 +
3 +import org.apache.ibatis.annotations.Param;
4 +
5 +public interface IPortclearEmailMappingExtRepository {
6 + String findEmailByPortCode(@Param("portCode") String portCode);
7 +}
1 +package com.fedex.connect.task.repository.repo.bi.impl;
2 +
3 +import com.fedex.connect.task.repository.base.AbstractDaoRepository;
4 +import com.fedex.connect.task.repository.repo.bi.IPortclearEmailMappingExtRepository;
5 +import org.springframework.stereotype.Repository;
6 +
7 +@Repository
8 +public class PortclearEmailMappingExtRepositoryImpl extends AbstractDaoRepository implements IPortclearEmailMappingExtRepository {
9 +
10 + @Override
11 + public String findEmailByPortCode(String portCode) {
12 + return portclearEmailMappingExtMapper.findEmailByPortCode(portCode);
13 + }
14 +}
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.task.data.dto.PushZipEmailDto; 3 import com.fedex.connect.task.data.dto.PushZipEmailDto;
4 +import org.apache.ibatis.annotations.Param;
4 5
5 import java.util.List; 6 import java.util.List;
6 7
7 public interface IAttachmentExtRepository { 8 public interface IAttachmentExtRepository {
8 - List<PushZipEmailDto> findPathWithPortCode(String typeCode,String statusCode); 9 +
10 + List<PushZipEmailDto> findAttachmentDetailsByBizId(@Param("bizId") Long bizId);
9 } 11 }
......
...@@ -5,5 +5,5 @@ import com.fedex.connect.common.model.biz.Email; ...@@ -5,5 +5,5 @@ import com.fedex.connect.common.model.biz.Email;
5 import java.util.List; 5 import java.util.List;
6 6
7 public interface IEmailExtRepository { 7 public interface IEmailExtRepository {
8 - List<Email> findConPushEmails(Long typeId, Long statusId); 8 + List<Email> findConPushEmails(String typeCode,String statusCode);
9 } 9 }
......
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
11 public class AttachmentExtRepositoryImpl extends AbstractDaoRepository implements IAttachmentExtRepository { 11 public class AttachmentExtRepositoryImpl extends AbstractDaoRepository implements IAttachmentExtRepository {
12 12
13 @Override 13 @Override
14 - public List<PushZipEmailDto> findPathWithPortCode(String typeCode, String statusCode) { 14 + public List<PushZipEmailDto> findAttachmentDetailsByBizId(Long bizId) {
15 - return attachmentExtMapper.findPathWithPortCode(typeCode,statusCode); 15 + return attachmentExtMapper.findAttachmentDetailsByBizId(bizId);
16 } 16 }
17 } 17 }
......
...@@ -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 EmailExtRepositoryImpl extends AbstractDaoRepository implements IEmailExtRepository { 11 public class EmailExtRepositoryImpl extends AbstractDaoRepository implements IEmailExtRepository {
12 - public List<Email> findConPushEmails(Long typeId,Long statusId){ 12 + public List<Email> findConPushEmails(String typeCode,String statusCode){
13 - return emailExtMapper.findConPushEmails(typeId,statusId); 13 + return emailExtMapper.findConPushEmails(typeCode,statusCode);
14 } 14 }
15 15
16 } 16 }
......
...@@ -13,12 +13,8 @@ import com.fedex.connect.task.utils.sys.ConFileEmailUtil; ...@@ -13,12 +13,8 @@ import com.fedex.connect.task.utils.sys.ConFileEmailUtil;
13 import lombok.extern.slf4j.Slf4j; 13 import lombok.extern.slf4j.Slf4j;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
16 -import org.springframework.util.CollectionUtils;
17 16
18 -import java.util.ArrayList;
19 -import java.util.HashMap;
20 import java.util.List; 17 import java.util.List;
21 -import java.util.Map;
22 18
23 /** 19 /**
24 * @Author Szl 20 * @Author Szl
...@@ -47,27 +43,22 @@ public class PushConsignmentFileServiceImpl extends BaseService implements IPush ...@@ -47,27 +43,22 @@ public class PushConsignmentFileServiceImpl extends BaseService implements IPush
47 */ 43 */
48 @Override 44 @Override
49 public void pushConsignmentFileTask(){ 45 public void pushConsignmentFileTask(){
50 - List<Email> emails = new ArrayList<>();
51 String tempPath = ""; 46 String tempPath = "";
52 String finalPath = ""; 47 String finalPath = "";
53 //查询需要发送的数据 48 //查询需要发送的数据
54 - List<PushZipEmailDto> pathWithPortCode = attachmentExtRepository.findPathWithPortCode(cacheSystem.getDicEmailType(EmailTypeEnum.PENDING.getEnMsg()).getCode(), 49 + List<Email> conPushEmails = iEmailExtRepository.findConPushEmails(cacheSystem.getDicEmailType(EmailTypeEnum.PENDING.getEnMsg()).getCode(),
55 cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode()); 50 cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode());
56 - if (CollectionUtils.isEmpty(pathWithPortCode)){
57 - return;
58 - }
59 51
60 - //根据口岸分类构成map(口岸,filePaths) 52 + for (Email conPushEmail : conPushEmails) {
61 - Map<String, List<PushZipEmailDto>> portAttachmentsMap = new HashMap<>(); 53 + //获取待发送的文件并打zip包
62 - portAttachmentsMap = conFileEmailUtil.getPortAttachmentsMap(portAttachmentsMap,pathWithPortCode); 54 + List<PushZipEmailDto> attachmentDetailsByBizId = attachmentExtRepository.findAttachmentDetailsByBizId(conPushEmail.getBizId());
55 + PortFileDto portFileDto = new PortFileDto();
56 + portFileDto = conFileEmailUtil.getPortZipMap(portFileDto, attachmentDetailsByBizId, tempPath, finalPath, zipUtils);
57 +
58 + //记录到发送邮件表中
63 59
64 - //根据口岸构成zipPath的map(口岸,zip path)
65 - List<PortFileDto> portFileDtoList = new ArrayList<>();
66 - portFileDtoList = conFileEmailUtil.getPortZipMap(portFileDtoList, portAttachmentsMap, tempPath, finalPath, zipUtils);
67 60
68 - //发送邮件
69 - for (PortFileDto portFileDto : portFileDtoList) {
70 - Email email = new Email();
71 } 61 }
62 +
72 } 63 }
73 } 64 }
......
...@@ -2,11 +2,16 @@ package com.fedex.connect.task.utils.sys; ...@@ -2,11 +2,16 @@ package com.fedex.connect.task.utils.sys;
2 2
3 import com.fedex.connect.common.dependencies.contants.BaseConstants; 3 import com.fedex.connect.common.dependencies.contants.BaseConstants;
4 import com.fedex.connect.common.dependencies.contants.BaseSeparatorConstants; 4 import com.fedex.connect.common.dependencies.contants.BaseSeparatorConstants;
5 +import com.fedex.connect.common.dependencies.enums.biz.AttachmentBizTypeEnum;
5 import com.fedex.connect.common.dependencies.util.DateUtil; 6 import com.fedex.connect.common.dependencies.util.DateUtil;
6 import com.fedex.connect.common.dependencies.util.ZipUtils; 7 import com.fedex.connect.common.dependencies.util.ZipUtils;
8 +import com.fedex.connect.common.model.biz.Email;
7 import com.fedex.connect.task.data.dto.PortFileDto; 9 import com.fedex.connect.task.data.dto.PortFileDto;
8 import com.fedex.connect.task.data.dto.PushZipEmailDto; 10 import com.fedex.connect.task.data.dto.PushZipEmailDto;
11 +import com.fedex.connect.task.repository.repo.bi.IPortclearEmailMappingExtRepository;
9 import lombok.extern.slf4j.Slf4j; 12 import lombok.extern.slf4j.Slf4j;
13 +import org.apache.commons.lang3.StringUtils;
14 +import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
11 16
12 import java.io.File; 17 import java.io.File;
...@@ -15,7 +20,6 @@ import java.io.IOException; ...@@ -15,7 +20,6 @@ import java.io.IOException;
15 import java.util.ArrayList; 20 import java.util.ArrayList;
16 import java.util.Date; 21 import java.util.Date;
17 import java.util.List; 22 import java.util.List;
18 -import java.util.Map;
19 23
20 /** 24 /**
21 * @Author Szl 25 * @Author Szl
...@@ -26,87 +30,81 @@ import java.util.Map; ...@@ -26,87 +30,81 @@ import java.util.Map;
26 @Component 30 @Component
27 public class ConFileEmailUtil { 31 public class ConFileEmailUtil {
28 32
29 - /** 33 + @Autowired
30 - * @Author Szl 34 + private IPortclearEmailMappingExtRepository portclearEmailMappingExtRepository;
31 - * @Description 功能说明 构建map(口岸,文件目录)
32 - * @Date 2024/11/14
33 - * @param portAttachmentsMap
34 - * @param pathWithPortCode
35 - * @return java.util.Map<java.lang.String,java.util.List<com.fedex.connect.task.data.dto.PushZipEmailDto>>
36 - */
37 - public Map<String, List<PushZipEmailDto>> getPortAttachmentsMap(Map<String, List<PushZipEmailDto>> portAttachmentsMap,List<PushZipEmailDto> pathWithPortCode){
38 - for (PushZipEmailDto dto : pathWithPortCode) {
39 - String destIataCode = dto.getDestIataCode();
40 - if (destIataCode == null || destIataCode.isEmpty()) {
41 - destIataCode = "null"; // 使用 "null" 代替空口岸
42 - }
43 - portAttachmentsMap.computeIfAbsent(destIataCode, k -> new ArrayList<>()).add(dto);
44 - }
45 - return portAttachmentsMap;
46 - }
47 35
48 /** 36 /**
49 * @Author Szl 37 * @Author Szl
50 * @Description 功能说明 根据口岸打包,每个口岸的文件打成一个zip包 38 * @Description 功能说明 根据口岸打包,每个口岸的文件打成一个zip包
51 * @Date 2024/11/14 39 * @Date 2024/11/14
52 - * @param portFileDtoList
53 - * @param portAttachmentsMap
54 * @param tempPath 40 * @param tempPath
55 * @param finalPath 41 * @param finalPath
56 * @param zipUtils 42 * @param zipUtils
57 * @return void 43 * @return void
58 */ 44 */
59 - public List<PortFileDto> getPortZipMap(List<PortFileDto> portFileDtoList, Map<String, List<PushZipEmailDto>> portAttachmentsMap, String tempPath, String finalPath, ZipUtils zipUtils){ 45 + public PortFileDto getPortZipMap(PortFileDto portFileDto, List<PushZipEmailDto> attachmentDetailsByBizId, String tempPath, String finalPath, ZipUtils zipUtils){
60 - for (Map.Entry<String, List<PushZipEmailDto>> entry : portAttachmentsMap.entrySet()) { 46 + List<File> filesList = new ArrayList<>();
61 - List<File> filesList = new ArrayList<>(); 47 + String portCode = null;
62 - String portCode = entry.getKey(); 48 + for (PushZipEmailDto pushZipEmailDto : attachmentDetailsByBizId) {
63 - List<PushZipEmailDto> portAttachments = entry.getValue(); 49 + portCode = pushZipEmailDto.getDestIataCode();
64 - 50 + if (pushZipEmailDto.getDestIataCode() == null || pushZipEmailDto.getDestIataCode().isEmpty()) {
65 - // 打zip包 51 + portCode = BaseConstants.CONSIGNMENT_TABLE_COLUMN_KEYS.DEST_IATA_CODE; // 使用 "destTataCode" 代替空口岸
66 - String date = DateUtil.formatTimeWithoutSlash(new Date());
67 - String fileName = date + BaseSeparatorConstants.SEPARATOR_UNDERLINE + portCode + BaseConstants.FILE_SUFFIX_KEYS.ZIP;
68 - String fileNameTemp = date + BaseSeparatorConstants.SEPARATOR_UNDERLINE + portCode + BaseConstants.FILE_SUFFIX_KEYS.ZIP + BaseConstants.FILE_SUFFIX_KEYS.TEMP;
69 - FileOutputStream fos = null;
70 -
71 - for (PushZipEmailDto portAttachment : portAttachments) {
72 - File file = new File(portAttachment.getFilePath());
73 - if (file.exists()) {
74 - filesList.add(file);
75 - }
76 } 52 }
53 + File file = new File(pushZipEmailDto.getFilePath());
54 + if (file.exists()) {
55 + filesList.add(file);
56 + }
57 + }
58 + String date = DateUtil.formatTimeWithoutSlash(new Date());
59 + String fileName = date + BaseSeparatorConstants.SEPARATOR_UNDERLINE + portCode + BaseConstants.FILE_SUFFIX_KEYS.ZIP;
60 + String fileNameTemp = date + BaseSeparatorConstants.SEPARATOR_UNDERLINE + portCode + BaseConstants.FILE_SUFFIX_KEYS.ZIP + BaseConstants.FILE_SUFFIX_KEYS.TEMP;
61 + FileOutputStream fos = null;
77 62
78 - try { 63 + try {
79 - fos = new FileOutputStream(tempPath + fileNameTemp); 64 + fos = new FileOutputStream(tempPath + fileNameTemp);
80 - zipUtils.toZip(filesList, fos); 65 + zipUtils.toZip(filesList, fos);
81 66
82 - File file = new File(tempPath + fileNameTemp); 67 + File file = new File(tempPath + fileNameTemp);
83 - File finalFile = new File(finalPath + fileName); 68 + File finalFile = new File(finalPath + fileName);
84 69
85 - // 打包完成后重命名为正式文件 70 + // 打包完成后重命名为正式文件
86 - if (!file.renameTo(finalFile)) { 71 + if (!file.renameTo(finalFile)) {
87 - throw new IOException("无法重命名文件 " + file.getAbsolutePath() + " 到 " + finalFile.getAbsolutePath()); 72 + throw new IOException("无法重命名文件 " + file.getAbsolutePath() + " 到 " + finalFile.getAbsolutePath());
88 - } 73 + }
89 74
90 - // 将结果添加到 portFileDtoList 75 + portFileDto.setDestIataCode(portCode);
91 - PortFileDto portFileDto = new PortFileDto(); 76 + portFileDto.setZipPath(finalPath + fileName);
92 - portFileDto.setDestIataCode(portCode);
93 - portFileDto.setZipPath(finalPath + fileName);
94 - portFileDtoList.add(portFileDto);
95 77
96 - } catch (Exception e) { 78 + } catch (Exception e) {
97 - log.error("生成压缩包错误:{}", e.getMessage(), e); 79 + log.error("生成压缩包错误:{}", e.getMessage(), e);
98 - } finally { 80 + } finally {
99 - try { 81 + try {
100 - if (fos != null) { 82 + if (fos != null) {
101 - fos.close(); 83 + fos.close();
102 - fos = null; 84 + fos = null;
103 - }
104 - } catch (Exception e) {
105 - log.error(e.getMessage(), e);
106 } 85 }
86 + } catch (Exception e) {
87 + log.error(e.getMessage(), e);
107 } 88 }
108 } 89 }
109 - return portFileDtoList; 90 + return portFileDto;
91 + }
92 +
93 +
94 + public void saveEmail(Email conPushEmail,PortFileDto portFileDto){
95 + //获取邮箱地址
96 + if (BaseConstants.CONSIGNMENT_TABLE_COLUMN_KEYS.DEST_IATA_CODE.equals(portFileDto.getDestIataCode())){
97 + portFileDto.setDestIataCode(AttachmentBizTypeEnum.OTH.getEnMsg());
98 + }
99 + String emailByPortCode = portclearEmailMappingExtRepository.findEmailByPortCode(portFileDto.getDestIataCode());
100 + if (StringUtils.isEmpty(emailByPortCode)){
101 +
102 + }
103 + conPushEmail.setToAddress(emailByPortCode);
104 + conPushEmail.setSubject();
105 + conPushEmail.setBody();
106 + conPushEmail.setFilePath(portFileDto.getZipPath());
107 +
110 } 108 }
111 109
112 } 110 }
......