tao.mo

biz-customer、kafka-cndc-server | 修改 |

推送的DM501报文内缺失UUID和联邦计费账号:推送后还是进入了运单表和CE表,与
=预期不一致修复
mt
2025年1月16日14:56:38
...@@ -17,6 +17,7 @@ import com.fedex.connect.customer.service.biz.IAttachmentService; ...@@ -17,6 +17,7 @@ import com.fedex.connect.customer.service.biz.IAttachmentService;
17 import com.fedex.connect.customer.service.biz.IConsignmentService; 17 import com.fedex.connect.customer.service.biz.IConsignmentService;
18 import com.fedex.connect.customer.util.service.biz.ConsignmentUtil; 18 import com.fedex.connect.customer.util.service.biz.ConsignmentUtil;
19 import com.fedex.connect.customer.util.service.biz.UploadRecordUtil; 19 import com.fedex.connect.customer.util.service.biz.UploadRecordUtil;
20 +import com.fedex.connect.customer.validate.controller.biz.AttachmentValidate;
20 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
21 import org.apache.commons.lang3.StringUtils; 22 import org.apache.commons.lang3.StringUtils;
22 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
...@@ -41,6 +42,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS ...@@ -41,6 +42,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
41 private UploadRecordUtil uploadRecordUtil; 42 private UploadRecordUtil uploadRecordUtil;
42 @Autowired 43 @Autowired
43 private IAttachmentService attachmentService; 44 private IAttachmentService attachmentService;
45 + @Autowired
46 + private AttachmentValidate attachmentValidate;
44 47
45 /** 48 /**
46 * @Author Szl 49 * @Author Szl
...@@ -94,8 +97,6 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS ...@@ -94,8 +97,6 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
94 }else if (byUserIdAndConsignmentCode.getCeFlag() != null){ 97 }else if (byUserIdAndConsignmentCode.getCeFlag() != null){
95 ceFlag = byUserIdAndConsignmentCode.getCeFlag(); 98 ceFlag = byUserIdAndConsignmentCode.getCeFlag();
96 } 99 }
97 -
98 -
99 /** 100 /**
100 * 根据是否是DM501返回不同的提示 101 * 根据是否是DM501返回不同的提示
101 */ 102 */
...@@ -135,6 +136,11 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS ...@@ -135,6 +136,11 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
135 consignmentBo.getAttachmentBizTypeList(), 136 consignmentBo.getAttachmentBizTypeList(),
136 user, 137 user,
137 consignmentBo.getConsignmentCode()); 138 consignmentBo.getConsignmentCode());
139 +
140 + /**
141 + * 拷贝附件后,需要再次进行附件信息验证
142 + */
143 + attachmentValidate.validateAttachment(attachmentList);
138 /** 144 /**
139 * 初始化运单信息 145 * 初始化运单信息
140 */ 146 */
......
1 package com.fedex.connect.customer.validate.controller.biz; 1 package com.fedex.connect.customer.validate.controller.biz;
2 2
3 -import com.fedex.connect.common.dependencies.contants.DigitConstants;
4 import com.fedex.connect.common.dependencies.util.ResponseUtils; 3 import com.fedex.connect.common.dependencies.util.ResponseUtils;
5 import com.fedex.connect.common.dependencies.util.Utils; 4 import com.fedex.connect.common.dependencies.util.Utils;
5 +import com.fedex.connect.common.model.biz.Attachment;
6 import com.fedex.connect.customer.constants.CustomerConstant; 6 import com.fedex.connect.customer.constants.CustomerConstant;
7 import com.fedex.connect.customer.data.bo.ConsignmentBo; 7 import com.fedex.connect.customer.data.bo.ConsignmentBo;
8 import com.fedex.connect.customer.enums.ResponseCode; 8 import com.fedex.connect.customer.enums.ResponseCode;
...@@ -57,4 +57,36 @@ public class AttachmentValidate { ...@@ -57,4 +57,36 @@ public class AttachmentValidate {
57 responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE); 57 responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE);
58 } 58 }
59 } 59 }
60 +
61 + /**
62 + * @Author mt
63 + * @Description 附件信息校验
64 + * @Date 2024/11/12
65 + * @param files
66 + * @return void
67 + */
68 + public void validateAttachment(List<Attachment> files){
69 + //文件为空
70 + if(Objects.isNull(files)){
71 + return;
72 + }
73 + //上传最大文件个数限制
74 + if(Objects.nonNull(files) && files.size() > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL){
75 + responseUtils.fail(ResponseCode.MESSAGE_CODE_30007,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL);
76 + }
77 + //上传总文件大小限制
78 + List<Long> fileSizeList = new ArrayList<>();
79 + if(Objects.nonNull(files)) {
80 + for (Attachment file : files) {
81 + fileSizeList.add(file.getFileSize());
82 + }
83 + }
84 + //总文件大小
85 + Long totalSize = Utils.listOf(fileSizeList).stream().filter(Objects::nonNull)
86 + .mapToLong(f -> Optional.ofNullable(f).orElse(0L)).sum();
87 + //最大上传总文件大小超过95M
88 + if(totalSize > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE){
89 + responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE);
90 + }
91 + }
60 } 92 }
......
...@@ -53,14 +53,17 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service { ...@@ -53,14 +53,17 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service {
53 processResults.setConsignmentCode(consignment501.getTrackingNumber()); 53 processResults.setConsignmentCode(consignment501.getTrackingNumber());
54 //该运单号不存在创建时间为1个月内CE数据 54 //该运单号不存在创建时间为1个月内CE数据
55 if (Objects.isNull(bizCeInfo)) { 55 if (Objects.isNull(bizCeInfo)) {
56 - CeInfo ceInfo = dm501Util.generateCeInfo(consignment501,kafKaTemporaryStorage.getSendTime()); 56 + CeInfo ceInfo = dm501Util.generateCeInfo(consignment501,kafKaTemporaryStorage.getSendTime(),processResults);
57 - //ce数据解析正常,进行后续操作 57 + //ce信息为空,则不记录运单表
58 - Email email = new Email(); 58 + if(Objects.nonNull(ceInfo)){
59 - Consignment consignment = dm501Util.generateConsignment(ceInfo,email); 59 + //ce数据解析正常,进行后续操作
60 - /** 60 + Email email = new Email();
61 - * 保存ce信息、以及运单表信息 61 + Consignment consignment = dm501Util.generateConsignment(ceInfo,email);
62 - */ 62 + /**
63 - dm501Util.saveCeInfoAndConsignment(ceInfo,consignment,email); 63 + * 保存ce信息、以及运单表信息
64 + */
65 + dm501Util.saveCeInfoAndConsignment(ceInfo,consignment,email);
66 + }
64 } 67 }
65 }catch(Exception ex){ 68 }catch(Exception ex){
66 log.error("DM501消息处理异常:{}", ex.getMessage(),ex); 69 log.error("DM501消息处理异常:{}", ex.getMessage(),ex);
......
...@@ -123,6 +123,8 @@ public class KafkaDmServiceImpl extends BaseService implements ApplicationContex ...@@ -123,6 +123,8 @@ public class KafkaDmServiceImpl extends BaseService implements ApplicationContex
123 kafkaStorageHistory.setStatusName(KafkaStatusEnum.PROCESSED.getName()); 123 kafkaStorageHistory.setStatusName(KafkaStatusEnum.PROCESSED.getName());
124 //设置运单号 124 //设置运单号
125 kafkaStorageHistory.setConsignmentCode(processResults.getConsignmentCode()); 125 kafkaStorageHistory.setConsignmentCode(processResults.getConsignmentCode());
126 + //记录报文处理备注
127 + kafkaStorageHistory.setRemark(processResults.getResult());
126 //保存至kafka历史表 128 //保存至kafka历史表
127 this.saveKafkaStorageHistory(kafkaStorageHistory); 129 this.saveKafkaStorageHistory(kafkaStorageHistory);
128 }else{ 130 }else{
......
...@@ -11,6 +11,7 @@ import com.fedex.connect.common.model.biz.Consignment; ...@@ -11,6 +11,7 @@ import com.fedex.connect.common.model.biz.Consignment;
11 import com.fedex.connect.common.model.biz.Email; 11 import com.fedex.connect.common.model.biz.Email;
12 import com.fedex.connect.common.model.sys.User; 12 import com.fedex.connect.common.model.sys.User;
13 import com.fedex.connect.kafka.constants.Constant; 13 import com.fedex.connect.kafka.constants.Constant;
14 +import com.fedex.connect.kafka.data.dto.DmProcessResults;
14 import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501ConAddresses; 15 import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501ConAddresses;
15 import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Consignments; 16 import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Consignments;
16 import com.fedex.connect.kafka.repository.repo.*; 17 import com.fedex.connect.kafka.repository.repo.*;
...@@ -49,12 +50,13 @@ public class Dm501Util { ...@@ -49,12 +50,13 @@ public class Dm501Util {
49 * @param dm501Consignment 50 * @param dm501Consignment
50 * @return com.fedex.connect.common.model.biz.CeInfo 51 * @return com.fedex.connect.common.model.biz.CeInfo
51 */ 52 */
52 - public CeInfo generateCeInfo(Dm501Consignments dm501Consignment,Date sendTime) throws Exception{ 53 + public CeInfo generateCeInfo(Dm501Consignments dm501Consignment, Date sendTime, DmProcessResults processResults) throws Exception{
53 CeInfo ceInfo = new CeInfo(); 54 CeInfo ceInfo = new CeInfo();
54 //地址信息 55 //地址信息
55 List<Dm501ConAddresses> addressList = dm501Consignment.getAddresses(); 56 List<Dm501ConAddresses> addressList = dm501Consignment.getAddresses();
56 //没有地址信息,不需要处理,不进CE业务表 57 //没有地址信息,不需要处理,不进CE业务表
57 if(addressList == null){ 58 if(addressList == null){
59 + processResults.setResult("缺失address信息");
58 return null; 60 return null;
59 } 61 }
60 //发件人 62 //发件人
...@@ -63,6 +65,7 @@ public class Dm501Util { ...@@ -63,6 +65,7 @@ public class Dm501Util {
63 Dm501ConAddresses recipientAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.RECIPIENT); 65 Dm501ConAddresses recipientAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.RECIPIENT);
64 //没有收发件人地址信息,不需要处理,不进CE业务表 66 //没有收发件人地址信息,不需要处理,不进CE业务表
65 if(shipperAddress == null || recipientAddress == null){ 67 if(shipperAddress == null || recipientAddress == null){
68 + processResults.setResult("缺失收发件人address信息");
66 return null; 69 return null;
67 } 70 }
68 71
...@@ -70,6 +73,12 @@ public class Dm501Util { ...@@ -70,6 +73,12 @@ public class Dm501Util {
70 String recipientCountry = recipientAddress.getCountry(); 73 String recipientCountry = recipientAddress.getCountry();
71 //收件人国家不为CN,不需要处理,不进CE业务表 74 //收件人国家不为CN,不需要处理,不进CE业务表
72 if(StringUtils.isEmpty(recipientCountry) || !recipientCountry.trim().equals(Constant.CE_INFO_KEYS.CN)){ 75 if(StringUtils.isEmpty(recipientCountry) || !recipientCountry.trim().equals(Constant.CE_INFO_KEYS.CN)){
76 + processResults.setResult("收件人国家不为CN");
77 + return null;
78 + }
79 + //uuid与shipperAccount都为空,则不进行才做
80 + if(StringUtils.isEmpty(dm501Consignment.getUserId()) && StringUtils.isEmpty(shipperAddress.getAccount())){
81 + processResults.setResult("uuid与shipperAccount都为空");
73 return null; 82 return null;
74 } 83 }
75 /** 84 /**
......