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;
import com.fedex.connect.customer.service.biz.IConsignmentService;
import com.fedex.connect.customer.util.service.biz.ConsignmentUtil;
import com.fedex.connect.customer.util.service.biz.UploadRecordUtil;
import com.fedex.connect.customer.validate.controller.biz.AttachmentValidate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -41,6 +42,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
private UploadRecordUtil uploadRecordUtil;
@Autowired
private IAttachmentService attachmentService;
@Autowired
private AttachmentValidate attachmentValidate;
/**
* @Author Szl
......@@ -94,8 +97,6 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
}else if (byUserIdAndConsignmentCode.getCeFlag() != null){
ceFlag = byUserIdAndConsignmentCode.getCeFlag();
}
/**
* 根据是否是DM501返回不同的提示
*/
......@@ -135,6 +136,11 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
consignmentBo.getAttachmentBizTypeList(),
user,
consignmentBo.getConsignmentCode());
/**
* 拷贝附件后,需要再次进行附件信息验证
*/
attachmentValidate.validateAttachment(attachmentList);
/**
* 初始化运单信息
*/
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.customer.constants.CustomerConstant;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.enums.ResponseCode;
......@@ -57,4 +57,36 @@ public class AttachmentValidate {
responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE);
}
}
/**
* @Author mt
* @Description 附件信息校验
* @Date 2024/11/12
* @param files
* @return void
*/
public void validateAttachment(List<Attachment> files){
//文件为空
if(Objects.isNull(files)){
return;
}
//上传最大文件个数限制
if(Objects.nonNull(files) && files.size() > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30007,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_TOTAL);
}
//上传总文件大小限制
List<Long> fileSizeList = new ArrayList<>();
if(Objects.nonNull(files)) {
for (Attachment file : files) {
fileSizeList.add(file.getFileSize());
}
}
//总文件大小
Long totalSize = Utils.listOf(fileSizeList).stream().filter(Objects::nonNull)
.mapToLong(f -> Optional.ofNullable(f).orElse(0L)).sum();
//最大上传总文件大小超过95M
if(totalSize > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30008,CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE);
}
}
}
......
......@@ -53,7 +53,9 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service {
processResults.setConsignmentCode(consignment501.getTrackingNumber());
//该运单号不存在创建时间为1个月内CE数据
if (Objects.isNull(bizCeInfo)) {
CeInfo ceInfo = dm501Util.generateCeInfo(consignment501,kafKaTemporaryStorage.getSendTime());
CeInfo ceInfo = dm501Util.generateCeInfo(consignment501,kafKaTemporaryStorage.getSendTime(),processResults);
//ce信息为空,则不记录运单表
if(Objects.nonNull(ceInfo)){
//ce数据解析正常,进行后续操作
Email email = new Email();
Consignment consignment = dm501Util.generateConsignment(ceInfo,email);
......@@ -62,6 +64,7 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service {
*/
dm501Util.saveCeInfoAndConsignment(ceInfo,consignment,email);
}
}
}catch(Exception ex){
log.error("DM501消息处理异常:{}", ex.getMessage(),ex);
}
......
......@@ -123,6 +123,8 @@ public class KafkaDmServiceImpl extends BaseService implements ApplicationContex
kafkaStorageHistory.setStatusName(KafkaStatusEnum.PROCESSED.getName());
//设置运单号
kafkaStorageHistory.setConsignmentCode(processResults.getConsignmentCode());
//记录报文处理备注
kafkaStorageHistory.setRemark(processResults.getResult());
//保存至kafka历史表
this.saveKafkaStorageHistory(kafkaStorageHistory);
}else{
......
......@@ -11,6 +11,7 @@ import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.model.biz.Email;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.kafka.constants.Constant;
import com.fedex.connect.kafka.data.dto.DmProcessResults;
import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501ConAddresses;
import com.fedex.connect.kafka.data.dto.dm.dm501.Dm501Consignments;
import com.fedex.connect.kafka.repository.repo.*;
......@@ -49,12 +50,13 @@ public class Dm501Util {
* @param dm501Consignment
* @return com.fedex.connect.common.model.biz.CeInfo
*/
public CeInfo generateCeInfo(Dm501Consignments dm501Consignment,Date sendTime) throws Exception{
public CeInfo generateCeInfo(Dm501Consignments dm501Consignment, Date sendTime, DmProcessResults processResults) throws Exception{
CeInfo ceInfo = new CeInfo();
//地址信息
List<Dm501ConAddresses> addressList = dm501Consignment.getAddresses();
//没有地址信息,不需要处理,不进CE业务表
if(addressList == null){
processResults.setResult("缺失address信息");
return null;
}
//发件人
......@@ -63,6 +65,7 @@ public class Dm501Util {
Dm501ConAddresses recipientAddress = this.queryDM501Addresses(addressList, Constant.CE_INFO_ADDRESS_KEYS.RECIPIENT);
//没有收发件人地址信息,不需要处理,不进CE业务表
if(shipperAddress == null || recipientAddress == null){
processResults.setResult("缺失收发件人address信息");
return null;
}
......@@ -70,6 +73,12 @@ public class Dm501Util {
String recipientCountry = recipientAddress.getCountry();
//收件人国家不为CN,不需要处理,不进CE业务表
if(StringUtils.isEmpty(recipientCountry) || !recipientCountry.trim().equals(Constant.CE_INFO_KEYS.CN)){
processResults.setResult("收件人国家不为CN");
return null;
}
//uuid与shipperAccount都为空,则不进行才做
if(StringUtils.isEmpty(dm501Consignment.getUserId()) && StringUtils.isEmpty(shipperAddress.getAccount())){
processResults.setResult("uuid与shipperAccount都为空");
return null;
}
/**
......