tao.mo

biz-customer | 修改 | 运单提交、附件上传、DM501解析

mt
2024年11月14日17:42:11
Showing 26 changed files with 646 additions and 194 deletions
package com.fedex.connect.customer.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
public class PropertiesConfig {
@Value("${spring.profiles.env}")
private String env;
@Value("${upload.path.attachment}")
private String attachmentPath;
}
......@@ -29,5 +29,5 @@ public class ConsignmentBo {
private String destinationCountry;
//文件业务类型AWB,INV,PKL,OTH(分运单,发票,箱单和其它这四种类型)
@BaseNotBlank(describe = "business_field_31008")
private List<String> fileBizType;
private List<String> attachmentBizTypeList;
}
......
package com.fedex.connect.customer.service.biz;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.common.model.sys.User;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
public interface IAttachmentService {
List<Attachment> uploadAttachments(MultipartFile[] files,List<String> fileBizTypeList, User user);
}
......
package com.fedex.connect.customer.service.biz.impl;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.service.base.BaseService;
import com.fedex.connect.customer.service.biz.IAttachmentService;
import com.fedex.connect.customer.util.service.biz.AttachmentUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List;
/**
* @Author Szl
......@@ -12,4 +20,27 @@ import org.springframework.stereotype.Service;
@Service
public class AttachmentServiceImpl extends BaseService implements IAttachmentService {
@Autowired
AttachmentUtil attachmentUtil;
/**
* @Author mt
* @Description 文件上传到服务器,并且生成附件实体返回
* 除运单ID、运单号、用户上传记录表ID,其他参数会返回
* @Date 2024/11/12
* @param files
* @param attachmentBizTypeList
* @param user
* @return void
*/
public List<Attachment> uploadAttachments(MultipartFile[] files,List<String> attachmentBizTypeList,User user){
List<Attachment> attachmentList = new ArrayList<>();
for (int i = 0; i < files.length; i++) {
MultipartFile file = files[i];
String bizType = attachmentBizTypeList.get(i);
Attachment attachment = attachmentUtil.uploadFile(file,bizType,user);
attachmentList.add(attachment);
}
return attachmentList;
}
}
......
......@@ -2,18 +2,23 @@ package com.fedex.connect.customer.service.biz.impl;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.common.model.biz.Consignment;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.data.bo.AddBo;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.service.base.BaseService;
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 net.bytebuddy.asm.Advice;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Objects;
/**
......@@ -26,9 +31,8 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
@Autowired
private ConsignmentUtil consignmentUtil;
@Autowired
private ResponseUtils responseUtils;
private IAttachmentService attachmentService;
/**
* @Author Szl
......@@ -87,6 +91,10 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
* @return com.fedex.connect.common.dependencies.date.vo.ResponseVo
*/
public ResponseVo submitConsignment(MultipartFile[] files,ConsignmentBo consignmentBo,User user){
/**
* 上传附件
*/
List<Attachment> attachmentList = attachmentService.uploadAttachments(files,consignmentBo.getAttachmentBizTypeList(),user);
return null;
}
......
package com.fedex.connect.customer.util.service.biz;
import com.fedex.connect.common.dependencies.cache.CacheSystem;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.enums.base.StatusEnum;
import com.fedex.connect.common.dependencies.util.NIOFileUtils;
import com.fedex.connect.common.model.biz.Attachment;
import com.fedex.connect.common.model.sys.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
......@@ -11,15 +17,28 @@ import org.springframework.web.multipart.MultipartFile;
*/
@Component
public class AttachmentUtil {
@Autowired
CacheSystem cacheSystem;
@Autowired
NIOFileUtils nioFileUtils;
/**
* @Author mt
* @Description 文件上传
* @Date 2024/11/12
* @param files
* @Description 文件上传到服务器,并且生成附件实体返回
* 除运单ID、运单号、用户上传记录表ID,其他参数会返回
* @Date 2024/11/14
* @param file
* @param bizType
* @param user
* @return void
* @return com.fedex.connect.common.model.biz.Attachment
*/
public void uploadFile(MultipartFile[] files, User user){
public Attachment uploadFile(MultipartFile file,String bizType, User user){
Attachment attachment = new Attachment();
// attachment.setBizTypeCode();
// attachment.setBizTypeName();
attachment.setStatus(StatusEnum.YES.getCode());
return attachment;
}
}
......
package com.fedex.connect.customer.validate.controller.biz;
import com.fedex.connect.common.dependencies.contants.DigitConstants;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.common.dependencies.enums.biz.AttachmentBizTypeEnum;
import com.fedex.connect.common.dependencies.util.ResponseUtils;
import com.fedex.connect.common.dependencies.util.Utils;
import com.fedex.connect.customer.constants.CustomerConstant;
import com.fedex.connect.customer.data.bo.ConsignmentBo;
import com.fedex.connect.customer.enums.FileBizTypeEnum;
import com.fedex.connect.customer.enums.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -39,7 +38,7 @@ public class AttachmentValidate {
if(Objects.isNull(files)
|| files.length == DigitConstants.DIGIT_MINUS_ONE
|| Objects.isNull(consignmentBo)
|| Objects.isNull(consignmentBo.getFileBizType())){
|| Objects.isNull(consignmentBo.getAttachmentBizTypeList())){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30006);
}
//上传最大文件个数限制
......@@ -58,15 +57,15 @@ public class AttachmentValidate {
if(totalSize > CustomerConstant.VALIDATE_KEYS.UPLOAD_FILE_MAX_SIZE){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30008);
}
List<String> fileBizTypeList = consignmentBo.getFileBizType();
List<String> fileBizTypeList = consignmentBo.getAttachmentBizTypeList();
//运单或发票未上传
if(!fileBizTypeList.contains(FileBizTypeEnum.AWB.getName()) ||
!fileBizTypeList.contains(FileBizTypeEnum.INV.getName())){
if(!fileBizTypeList.contains(AttachmentBizTypeEnum.AWB.getExt1()) ||
!fileBizTypeList.contains(AttachmentBizTypeEnum.INV.getExt1())){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30009);
}
//文件类型不在范围内
fileBizTypeList.stream().forEach(p -> {
if(Objects.isNull(FileBizTypeEnum.valueOf(p))){
if(Objects.isNull(AttachmentBizTypeEnum.valueOf(p))){
responseUtils.fail(ResponseCode.MESSAGE_CODE_30010);
};
});
......
......@@ -32,12 +32,9 @@ export:
needauth: true
proxy:
startFlag: false
host: sin-proxy.apac.fedex.com
host: proxy-cn.g.fedex.com
port: 3128
mailAccountFlag: true
mailgroup:
declare: { from: 'kexin.zhou@erry.com',password: 'Zhou1234',to: 'kexin.zhou@erry.com',cc: 'kexin.zhou@erry.com' }
resetpwd: { from: 'tao.mo@erry.com',password: 'xiaozhen!1'}
# propertyPath:
# redis: /opt/fedex/exporttw/redis/export-redis.properties
language: en_US
......@@ -45,32 +42,4 @@ export:
upload:
path:
declare: E:/var/fedex/exportTw/upload/declareFile
image: E:/var/fedex/exportTw/upload/brandImage
url:
loginIndex: http://47.103.140.98:8086/icleartw
twIdx: http://47.103.140.98/IcTw/
twIdxImg: https://declarationuat.fedex.com.cn/Exp/manager-server/
#fcl
fcl:
login:
url: http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnLogin
redjrectLogin: https://exportdeclarationuat-tw.dmz.apac.fedex.com/IcTw/#/redjrectLogin
twidx:
url: http://exportdeclarationuat-tw.apac.fedex.com
interface:
logurl: https://www.fedex.com/secure-login/zh-tw/#/login-credentials?redirectUrl=http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnForward
fedex_api_address: https://api.fedex.com
proxy_url: cn2-proxy.apac.fedex.com:3128
token:
url: /auth/oauth/v2/token
grant_type : client_credentials
client_id: l7c13f958213e04d1280f807789bd783a3
client_secret: 3d43932198b6467a8e20d024bfa82e1c
scope: oob
account:
url: /user/v2/accounts
userinfo:
url: /user/v2/users/userinfo
\ No newline at end of file
attachment: D:/var/share/iclearConnect/upload/attachment
\ No newline at end of file
......
......@@ -28,42 +28,14 @@ export:
needauth: true
proxy:
startFlag: false
host: sg2-proxy.apac.fedex.com
host: proxy-cn.g.fedex.com
port: 3128
mailAccountFlag: false
# propertyPath:
# redis: /opt/fedex/exporttw/redis/export-redis.properties
language: zh_TW
language: en_US
emailActiveTime: 60
upload:
path:
declare: /var/share/icleartw/upload/declareFile
image: /var/share/icleartw/upload/brandImage
url:
loginIndex: https://exportdeclaration-tw.apac.fedex.com/IcTw/
twIdx: https://exportdeclaration-tw.apac.fedex.com/IcTw/
twIdxImg: https://declaration.fedex.com.cn/Exp/manager-server/
#fcl
fcl:
login:
url: https://exportdeclaration-tw.apac.fedex.com/icleartw/auth/wlgnLogin
redjrectLogin: https://exportdeclaration-tw.apac.fedex.com/IcTw/#/redjrectLogin
twidx:
url: https://exportdeclaration-tw.apac.fedex.com
interface:
logurl: https://www.fedex.com/secure-login/zh-tw/#/login-credentials?redirectUrl=https://exportdeclaration-tw.apac.fedex.com/icleartw/auth/wlgnForward
fedex_api_address: https://api.fedex.com
proxy_url: cn2-proxy.apac.fedex.com:3128
token:
url: /auth/oauth/v2/token
grant_type : client_credentials
client_id: l7c13f958213e04d1280f807789bd783a3
client_secret: 3d43932198b6467a8e20d024bfa82e1c
scope: oob
account:
url: /user/v2/accounts
userinfo:
url: /user/v2/users/userinfo
\ No newline at end of file
attachment: /app/Oracle/Middleware/user_projects/domains/base_domain/iclearConnect/upload/attachment
\ No newline at end of file
......
......@@ -28,42 +28,14 @@ export:
needauth: true
proxy:
startFlag: false
host: sin-proxy.apac.fedex.com
host: proxy-cn.g.fedex.com
port: 3128
mailAccountFlag: true
# propertyPath:
# redis: /opt/fedex/exporttw/redis/export-redis.properties
language: zh_TW
language: en_US
emailActiveTime: 60
upload:
path:
declare: /app/Oracle/Middleware/user_projects/domains/base_domain/exportTw/upload/declareFile
image: /app/Oracle/Middleware/user_projects/domains/base_domain/exportTw/upload/brandImage
url:
loginIndex: http://47.103.140.98:8086/icleartw
twIdx: http://47.103.140.98/IcTw/
twIdxImg: https://declarationuat.fedex.com.cn/Exp/manager-server/
#fcl
fcl:
login:
url: http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnLogin
redjrectLogin: https://exportdeclarationuat-tw.dmz.apac.fedex.com/IcTw/#/redjrectLogin
twidx:
url: http://exportdeclarationuat-tw.apac.fedex.com
interface:
logurl: https://www.fedex.com/secure-login/zh-tw/#/login-credentials?redirectUrl=http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnForward
fedex_api_address: https://api.fedex.com
proxy_url: cn2-proxy.apac.fedex.com:3128
token:
url: /auth/oauth/v2/token
grant_type : client_credentials
client_id: l7c13f958213e04d1280f807789bd783a3
client_secret: 3d43932198b6467a8e20d024bfa82e1c
scope: oob
account:
url: /user/v2/accounts
userinfo:
url: /user/v2/users/userinfo
\ No newline at end of file
attachment: /app/Oracle/Middleware/user_projects/domains/base_domain/iclearConnect/upload/attachment
\ No newline at end of file
......
......@@ -28,7 +28,7 @@ export:
needauth: true
proxy:
startFlag: false
host: sg2-proxy.apac.fedex.com
host: proxy-cn.g.fedex.com
port: 3128
mailAccountFlag: false
# propertyPath:
......@@ -38,31 +38,4 @@ export:
upload:
path:
declare: /var/share/icleartw/upload/declareFile
image: /var/share/icleartw/upload/brandImage
url:
loginIndex: http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw
twIdx: http://exportdeclarationuat-tw.apac.fedex.com/IcTw/
twIdxImg: https://declarationuat.fedex.com.cn/Exp/manager-server/
fcl:
login:
url: http://exportdeclarationuat-tw.apac.fedex.com/icleartw/auth/wlgnLogin
redjrectLogin: https://exportdeclarationuat-tw.dmz.apac.fedex.com/IcTw/#/redjrectLogin
twidx:
url: http://exportdeclarationuat-tw.apac.fedex.com
interface:
logurl: https://www.fedex.com/secure-login/zh-tw/#/login-credentials?redirectUrl=http://exportdeclarationuat-tw.dmz.apac.fedex.com/icleartw/auth/wlgnForward
fedex_api_address: https://api.fedex.com
proxy_url: cn2-proxy.apac.fedex.com:3128
token:
url: /auth/oauth/v2/token
grant_type : client_credentials
client_id: l7c13f958213e04d1280f807789bd783a3
client_secret: 3d43932198b6467a8e20d024bfa82e1c
scope: oob
account:
url: /user/v2/accounts
userinfo:
url: /user/v2/users/userinfo
\ No newline at end of file
attachment: /var/share/iclearConnect/upload/attachment
\ No newline at end of file
......
......@@ -33,7 +33,7 @@ business_exception_30002=单次最多可查询1000个运单号码
business_exception_30003=${0}不正确,请重新输入
business_exception_30004=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30005=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30006=附件未上传
business_exception_30006=附件上传不符合标准
business_exception_30007=所有上传文件数量不超过50个文件
business_exception_30008=所有上传文件总大小不超过50M
business_exception_30009=运单或发票未上传
......
......@@ -33,7 +33,7 @@ business_exception_30002=单次最多可查询1000个运单号码
business_exception_30003=${0}不正确,请重新输入
business_exception_30004=The waybill you entered is generated by another user, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30005=The waybill you entered is generated by another account, whether continue uploading? Confirm, Cancel. No more prompts in the future for the same situation.
business_exception_30006=附件未上传
business_exception_30006=附件上传不符合标准
business_exception_30007=所有上传文件数量不超过50个文件
business_exception_30008=所有上传文件总大小不超过50M
business_exception_30009=运单或发票未上传
......
......@@ -20,6 +20,7 @@
<result column="MODIFY_USER_NAME" jdbcType="VARCHAR" property="modifyUserName" />
<result column="UPLOAD_RECORD_ID" jdbcType="NUMERIC" property="uploadRecordId" />
<result column="FILE_SIZE" jdbcType="NUMERIC" property="fileSize" />
<result column="CONSIGNMENT_CODE" jdbcType="VARCHAR" property="consignmentCode" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
......@@ -82,7 +83,7 @@
<sql id="Base_Column_List">
ID, BIZ_ID, BIZ_TYPE_CODE, BIZ_TYPE_NAME, SOURCE_FILE_NAME, FILE_NAME, FILE_PATH,
FILE_TYPE_CODE, FILE_TYPE_NAME, STATUS, CREATE_TIME, CREATE_USER_ID, CREATE_USER_NAME,
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME, UPLOAD_RECORD_ID, FILE_SIZE
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME, UPLOAD_RECORD_ID, FILE_SIZE, CONSIGNMENT_CODE
</sql>
<select id="selectByExample" parameterType="com.fedex.connect.common.model.biz.AttachmentExample" resultMap="BaseResultMap">
<include refid="OracleDialectPrefix" />
......@@ -126,15 +127,15 @@
FILE_PATH, FILE_TYPE_CODE, FILE_TYPE_NAME,
STATUS, CREATE_TIME, CREATE_USER_ID,
CREATE_USER_NAME, MODIFY_TIME, MODIFY_USER_ID,
MODIFY_USER_NAME, UPLOAD_RECORD_ID, FILE_SIZE
)
MODIFY_USER_NAME, UPLOAD_RECORD_ID, FILE_SIZE,
CONSIGNMENT_CODE)
values (#{id,jdbcType=NUMERIC}, #{bizId,jdbcType=NUMERIC}, #{bizTypeCode,jdbcType=VARCHAR},
#{bizTypeName,jdbcType=VARCHAR}, #{sourceFileName,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR},
#{filePath,jdbcType=VARCHAR}, #{fileTypeCode,jdbcType=VARCHAR}, #{fileTypeName,jdbcType=VARCHAR},
#{status,jdbcType=NUMERIC}, #{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=NUMERIC},
#{createUserName,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}, #{modifyUserId,jdbcType=NUMERIC},
#{modifyUserName,jdbcType=VARCHAR}, #{uploadRecordId,jdbcType=NUMERIC}, #{fileSize,jdbcType=NUMERIC}
)
#{modifyUserName,jdbcType=VARCHAR}, #{uploadRecordId,jdbcType=NUMERIC}, #{fileSize,jdbcType=NUMERIC},
#{consignmentCode,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.fedex.connect.common.model.biz.Attachment">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
......@@ -194,6 +195,9 @@
<if test="fileSize != null">
FILE_SIZE,
</if>
<if test="consignmentCode != null">
CONSIGNMENT_CODE,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id,jdbcType=NUMERIC},
......@@ -248,6 +252,9 @@
<if test="fileSize != null">
#{fileSize,jdbcType=NUMERIC},
</if>
<if test="consignmentCode != null">
#{consignmentCode,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.fedex.connect.common.model.biz.AttachmentExample" resultType="java.lang.Long">
......@@ -313,6 +320,9 @@
<if test="record.fileSize != null">
FILE_SIZE = #{record.fileSize,jdbcType=NUMERIC},
</if>
<if test="record.consignmentCode != null">
CONSIGNMENT_CODE = #{record.consignmentCode,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -337,7 +347,8 @@
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
UPLOAD_RECORD_ID = #{record.uploadRecordId,jdbcType=NUMERIC},
FILE_SIZE = #{record.fileSize,jdbcType=NUMERIC}
FILE_SIZE = #{record.fileSize,jdbcType=NUMERIC},
CONSIGNMENT_CODE = #{record.consignmentCode,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -396,6 +407,9 @@
<if test="fileSize != null">
FILE_SIZE = #{fileSize,jdbcType=NUMERIC},
</if>
<if test="consignmentCode != null">
CONSIGNMENT_CODE = #{consignmentCode,jdbcType=VARCHAR},
</if>
</set>
where ID = #{id,jdbcType=NUMERIC}
</update>
......@@ -417,7 +431,8 @@
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
UPLOAD_RECORD_ID = #{uploadRecordId,jdbcType=NUMERIC},
FILE_SIZE = #{fileSize,jdbcType=NUMERIC}
FILE_SIZE = #{fileSize,jdbcType=NUMERIC},
CONSIGNMENT_CODE = #{consignmentCode,jdbcType=VARCHAR}
where ID = #{id,jdbcType=NUMERIC}
</update>
<sql id="OracleDialectPrefix">
......
......@@ -19,13 +19,13 @@ public class Attachment implements Serializable {
private Long bizId;
/**
* 业务类型CODE。
* 附件业务类型CODE。
关联数据字典表。指定字典目录CODE:ATTACHMENT_BIZ_TYPE
*/
private String bizTypeCode;
/**
* 业务类型名称(用户上传、系统生成)
* 附件业务类型名称(运单、发票、箱单、其他)
*/
private String bizTypeName;
......@@ -45,12 +45,12 @@ public class Attachment implements Serializable {
private String filePath;
/**
* 文件类型CODE。关联数据字典表。指定字典目录CODE:ATTACHMENT_FILE_TYPE
* 附件文件类型CODE。关联数据字典表。指定字典目录CODE:ATTACHMENT_FILE_TYPE
*/
private String fileTypeCode;
/**
* 文件类型名称(压缩包、PDF)
* 附件文件类型(压缩包、文件)
*/
private String fileTypeName;
......@@ -99,6 +99,11 @@ public class Attachment implements Serializable {
*/
private Long fileSize;
/**
* 运单号
*/
private String consignmentCode;
private static final long serialVersionUID = 1L;
public Long getId() {
......@@ -245,6 +250,14 @@ public class Attachment implements Serializable {
this.fileSize = fileSize;
}
public String getConsignmentCode() {
return consignmentCode;
}
public void setConsignmentCode(String consignmentCode) {
this.consignmentCode = consignmentCode == null ? null : consignmentCode.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
......@@ -269,6 +282,7 @@ public class Attachment implements Serializable {
sb.append(", modifyUserName=").append(modifyUserName);
sb.append(", uploadRecordId=").append(uploadRecordId);
sb.append(", fileSize=").append(fileSize);
sb.append(", consignmentCode=").append(consignmentCode);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
......
......@@ -1294,6 +1294,76 @@ public class AttachmentExample {
addCriterion("FILE_SIZE not between", value1, value2, "fileSize");
return (Criteria) this;
}
public Criteria andConsignmentCodeIsNull() {
addCriterion("CONSIGNMENT_CODE is null");
return (Criteria) this;
}
public Criteria andConsignmentCodeIsNotNull() {
addCriterion("CONSIGNMENT_CODE is not null");
return (Criteria) this;
}
public Criteria andConsignmentCodeEqualTo(String value) {
addCriterion("CONSIGNMENT_CODE =", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeNotEqualTo(String value) {
addCriterion("CONSIGNMENT_CODE <>", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeGreaterThan(String value) {
addCriterion("CONSIGNMENT_CODE >", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeGreaterThanOrEqualTo(String value) {
addCriterion("CONSIGNMENT_CODE >=", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeLessThan(String value) {
addCriterion("CONSIGNMENT_CODE <", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeLessThanOrEqualTo(String value) {
addCriterion("CONSIGNMENT_CODE <=", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeLike(String value) {
addCriterion("CONSIGNMENT_CODE like", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeNotLike(String value) {
addCriterion("CONSIGNMENT_CODE not like", value, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeIn(List<String> values) {
addCriterion("CONSIGNMENT_CODE in", values, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeNotIn(List<String> values) {
addCriterion("CONSIGNMENT_CODE not in", values, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeBetween(String value1, String value2) {
addCriterion("CONSIGNMENT_CODE between", value1, value2, "consignmentCode");
return (Criteria) this;
}
public Criteria andConsignmentCodeNotBetween(String value1, String value2) {
addCriterion("CONSIGNMENT_CODE not between", value1, value2, "consignmentCode");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
......
......@@ -99,30 +99,30 @@
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_LOG_USER_LOGIN_INFO.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_BIZ_ATTACHMENT" domainObjectName="Attachment"-->
<table tableName="T_BIZ_ATTACHMENT" domainObjectName="Attachment"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_ATTACHMENT.NEXTVAL FROM DUAL" />
</table>
<!-- <table tableName="T_BIZ_UPLOAD_RECORD" domainObjectName="UploadRecord"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_ATTACHMENT.NEXTVAL FROM DUAL" />-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_UPLOAD_RECORD.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_BIZ_UPLOAD_RECORD" domainObjectName="UploadRecord"-->
<!-- <table schema="ICLEARIMP" tableName="T_BIZ_CE_INFO" domainObjectName="CeInfo"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_UPLOAD_RECORD.NEXTVAL FROM DUAL" />-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_CE_INFO.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_BIZ_CONSIGNMENT" domainObjectName="Consignment"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_CONSIGNMENT.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<table schema="ICLEARIMP" tableName="T_BIZ_CE_INFO" domainObjectName="CeInfo"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_CE_INFO.NEXTVAL FROM DUAL" />
</table>
<table tableName="T_BIZ_CONSIGNMENT" domainObjectName="Consignment"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_CONSIGNMENT.NEXTVAL FROM DUAL" />
</table>
<!-- <table tableName="T_BIZ_EMAIL" domainObjectName="Email"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
......
......@@ -18,4 +18,8 @@ public interface DictionaryConstants {
String EMAIL_TYPE = "EMAIL_TYPE";
//邮件状态
String EMAIL_STATUS = "EMAIL_STATUS";
//附件业务类型
String ATTACHMENT_BIZ_TYPE = "ATTACHMENT_BIZ_TYPE";
//附件文件类型
String ATTACHMENT_FILE_TYPE = "ATTACHMENT_FILE_TYPE";
}
......
package com.fedex.connect.customer.enums;
package com.fedex.connect.common.dependencies.enums.base;
/**
* @Author mt
* @Description 文件类型
* @Date 2024/11/12
* @Description 表记录状态
* @Date 2024/11/14
*/
public enum FileBizTypeEnum {
AWB("AWB","运单"),
INV("INV","发票"),
PKL("PKL","箱单"),
OTH("OTH","其他"),
public enum StatusEnum {
YES(1L,"有效"),
NO(0L,"无效"),
;
private String code;
private Long code;
private String name;
FileBizTypeEnum(String code, String name) {
StatusEnum(Long code,String name) {
this.code = code;
this.name = name;
}
public String getCode() {
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......
package com.fedex.connect.common.dependencies.enums.biz;
/**
* @Author mt
* @Description 附件业务类型
* @Date 2024/11/14
*/
public enum AttachmentBizTypeEnum {
AWB("attachmentBizType_01","waybill","运单","AWB"),
INV("attachmentBizType_02","invoice","发票","INV"),
PKL("attachmentBizType_03","packing","箱单","PKL"),
OTH("attachmentBizType_04","other","其他","OTH"),
;
private String code;
private String enMsg;
private String msg;
private String ext1;
AttachmentBizTypeEnum(String code, String enMsg, String msg,String ext1) {
this.code = code;
this.enMsg = enMsg;
this.msg = msg;
this.ext1 = ext1;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getEnMsg() {
return enMsg;
}
public void setEnMsg(String enMsg) {
this.enMsg = enMsg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
}
package com.fedex.connect.common.dependencies.enums.biz;
/**
* @Author mt
* @Description 附件文件类型
* @Date 2024/11/14
*/
public enum AttachmentFileTypeEnum {
ZIP("attachmentFileType_01","zip","压缩包"),
FILE("attachmentFileType_02","file","文件"),
;
private String code;
private String enMsg;
private String msg;
AttachmentFileTypeEnum(String code, String enMsg, String msg) {
this.code = code;
this.enMsg = enMsg;
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getEnMsg() {
return enMsg;
}
public void setEnMsg(String enMsg) {
this.enMsg = enMsg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
......@@ -6,23 +6,41 @@ package com.fedex.connect.common.dependencies.enums.biz;
* @Date 2024/11/4
*/
public enum ConsignmentStatusEnum {
CONSIGNMENT_STATUS_01("consignmentStatus_01", "待上传"),
CONSIGNMENT_STATUS_02("consignmentStatus_02", "已上传"),
CONSIGNMENT_STATUS_03("consignmentStatus_03", "已发送");
CONSIGNMENT_STATUS_01("consignmentStatus_01", "success", "上传成功"),
CONSIGNMENT_STATUS_02("consignmentStatus_02", "fail","上传失败");
private String code;
private String name;
private String enMsg;
private String msg;
ConsignmentStatusEnum(String code, String name) {
ConsignmentStatusEnum(String code, String enMsg,String msg) {
this.code = code;
this.name = name;
this.enMsg = enMsg;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getName() {
return name;
public void setCode(String code) {
this.code = code;
}
public String getEnMsg() {
return enMsg;
}
public void setEnMsg(String enMsg) {
this.enMsg = enMsg;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
......
package com.fedex.connect.common.dependencies.util;
import org.slf4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* @Author mt
* @Description 非阻塞式文件操作工具
* @Date 2024/11/14
*/
@Component
public class NIOFileUtils {
public void copyFile(InputStream is,Path targetPath) throws IOException{
if(is != null) {
try {
Files.copy(is, targetPath, StandardCopyOption.REPLACE_EXISTING);
}finally {
is.close();
is = null;
}
}
}
public void deleteFile(String filePath) throws IOException{
Files.delete(Paths.get(filePath));
}
public void copyFile(InputStream is,String targetPath) throws IOException{
copyFile(is,Paths.get(targetPath));
}
public void copyFileByParent(InputStream is, String targetPath) throws IOException {
if (is != null) {
Path target = Paths.get(targetPath);
Files.createDirectories(target.getParent());
this.copyFile(is,targetPath);
}
}
/**
* @Author mt
* @Description 非阻塞式文件复制
* @Date 2024/11/14
* @param sFilePath
* @param tFilePath
* @return void
*/
public void copyFile(String sFilePath, String tFilePath) throws IOException {
this.copyFile(new File(sFilePath), tFilePath);
}
/**
* @Author mt
* @Description 非阻塞式文件复制
* @Date 2024/11/14
* @param sFilePath
* @param tFilePath
* @return void
*/
public void copyFile(File sFilePath, String tFilePath) throws IOException {
this.copyFile(new FileInputStream(sFilePath),tFilePath);
}
/**
* @Author mt
* @Description 创建临时文件
* @Date 2024/11/14
* @param null
* @return
*/
/**
* @Author mt
* @Description 删除临时文件
* @Date 2024/11/14
* @param path
* @return void
*/
public void deleteTempFile(Path path) throws IOException{
deleteIfExists(path);
}
/**
* @Author mt
* @Description 删除文件夹及其文件
* @Date 2024/11/14
* @param logger
* @param dirPath
* @param isDeleteChildDir
* @return void
*/
public void deleteDir(Logger logger,String dirPath,boolean isDeleteChildDir){
Path directoryToBeDeleted = Paths.get(dirPath);
List<Path> subList = new ArrayList<>();
try {
Files.walkFileTree(directoryToBeDeleted, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if(isDeleteChildDir
|| (!isDeleteChildDir && directoryToBeDeleted.equals(file.getParent()))) {
Files.deleteIfExists(file);
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
if(isDeleteChildDir
|| (!isDeleteChildDir
&& directoryToBeDeleted.equals(dir))) {
if(subList == null || subList.isEmpty()) {
Files.deleteIfExists(dir);
}
}else if(!isDeleteChildDir
&& !directoryToBeDeleted.equals(dir)){
subList.add(dir);
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
if(logger != null) {
logger.error("NIO 删除文件夹及其文件 发生异常 | {} | 具体原因为:", e.getMessage(), e);
}
}
}
/**
* @Author mt
* @Description 删除已存在的文件
* @Date 2024/11/14
* @param filePath
* @return void
*/
public void deleteIfExists(String filePath) throws IOException{
deleteIfExists(Paths.get(filePath));
}
/**
* @Author mt
* @Description 删除已存在文件
* @Date 2024/11/14
* @param path
* @return void
*/
public void deleteIfExists(Path path) throws IOException{
Files.deleteIfExists(path);
}
// 复制文件到目标文件夹
public void copyFile(String sourceFilePath, Path targetFolderPath) throws IOException {
Path sourcePath = Paths.get(sourceFilePath);
Path targetFilePath = targetFolderPath.resolve(sourcePath.getFileName());
Files.copy(sourcePath, targetFilePath, StandardCopyOption.REPLACE_EXISTING);
}
// 压缩文件夹
public void zipFolder(String sourceFolderPath, String zipFilePath) throws IOException {
Path sourcePath = Paths.get(sourceFolderPath);
try (FileOutputStream fos = new FileOutputStream(zipFilePath);
ZipOutputStream zos = new ZipOutputStream(fos)) {
// 遍历文件夹并添加到压缩包
Files.walkFileTree(sourcePath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// 获取文件在源文件夹中的相对路径
Path relativePath = sourcePath.relativize(file);
zos.putNextEntry(new ZipEntry(relativePath.toString()));
// 将文件内容复制到压缩流中
Files.copy(file, zos);
zos.closeEntry();
return FileVisitResult.CONTINUE;
}
});
}
}
// 删除文件夹及其内容
public void deleteFolder(Path folderPath) throws IOException {
Files.walk(folderPath)
.sorted(java.util.Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
public File[] findFolder(Path folderPath,List<String> childDirs) throws IOException {
List<File> files = new ArrayList<>();
Files.walk(folderPath)
.sorted(java.util.Comparator.reverseOrder())
.map(Path::toFile)
.forEach(p->{
if(p.isFile()){
if(CollectionUtils.isEmpty(childDirs)){
files.add(p);
}else {
long total = childDirs.stream().filter(c -> p.getName().toUpperCase().contains(c.toUpperCase())).count();
if (total > 0) {
files.add(p);
}
}
}
});
if(!CollectionUtils.isEmpty(files)){
return files.toArray(new File[files.size()]);
}
return null;
}
/**
* @Author mt
* @Description 移动文件
* @Date 2024/11/14
* @param logger
* @param sourceFilePath
* @param targetDir
* @return void
*/
public void moveFile(Logger logger,String sourceFilePath,String targetDir) throws IOException{
File dir = new File(targetDir);
if (!dir.exists()) {
dir.mkdirs();
}
Path sPath = Paths.get(sourceFilePath);
Path tPath = Paths.get(targetDir + File.separator + sPath.getFileName());
// 移动文件
Files.move(sPath, tPath, StandardCopyOption.REPLACE_EXISTING);
}
}
......@@ -40,7 +40,7 @@ public class ConsignmentRepositoryImpl extends BaseRepository implements IConsig
/**
* @Author mt
* @Description 根据运单号查找30天之运单
* @Description 根据运单号查找30天之运单
* @Date 2024/11/4
* @param consignmentCode
* @return com.fedex.connect.common.model.biz.Consignment
......
......@@ -55,11 +55,9 @@ public class Dm501ServiceImpl extends BaseService implements IDm501Service {
if (Objects.isNull(bizCeInfo)) {
CeInfo ceInfo = dm501Util.generateCeInfo(consignment501,kafKaTemporaryStorage.getSendTime());
//ce数据解析正常,进行后续操作
if(Objects.nonNull(ceInfo)){
Consignment consignment = dm501Util.generateConsignment(ceInfo);
this.saveCeInfoAndConsignment(ceInfo,consignment);
}
}
}catch(Exception ex){
log.error("DM501消息处理异常:{}", ex.getMessage(),ex);
}
......
......@@ -190,7 +190,7 @@ public class Dm501Util {
public Consignment generateConsignment(CeInfo ceInfo) throws Exception{
Consignment rsConsignment;
/**
* 根据运单号查找30天之运单
* 根据运单号查找30天之运单
*/
Consignment consignment = consignmentRepository.findThirtyDaysAgoConByCode(ceInfo.getConsignmentCode());
if(Objects.isNull(consignment)){
......@@ -201,6 +201,10 @@ public class Dm501Util {
resultConsignment.setStatusCode(consignmentDicEntries.getCode());
resultConsignment.setStatusName(consignmentDicEntries.getDescription());
/**
* 初始化运单表原产国、目的国
*/
this.initOriginCountryDestinationCountry(ceInfo,consignment);
/**
* 初始化表基础字段
*/
AssignmentFieldUtils.assignmentTableBaseField(resultConsignment);
......@@ -210,6 +214,24 @@ public class Dm501Util {
String[] ignoreProperties = Constant.CE_CONSIGNMENT_COPY_IGNORE_PROP_KEYS.IGNORE_PROPERTIES;
//字段拷贝
BeanUtils.copyProperties(ceInfo,consignment,ignoreProperties);
/**
* 初始化运单表原产国、目的国
*/
this.initOriginCountryDestinationCountry(ceInfo,consignment);
rsConsignment = consignment;
}
return rsConsignment;
}
/**
* @Author mt
* @Description 初始化运单表原产国、目的国
* @Date 2024/11/13
* @param ceInfo
* @param consignment
* @return void
*/
private void initOriginCountryDestinationCountry(CeInfo ceInfo,Consignment consignment){
//根据发件人国家二字码获取字典
DictionaryEntries shipperCountryEntries = cacheSystem.getDicCountryByExt1(ceInfo.getShipperCountry());
//根据二字码能获取到二字码则赋值始发国全称
......@@ -228,9 +250,6 @@ public class Dm501Util {
//目的国全称
consignment.setDestinationCountry(countryEntries.getEnglishName());
}
rsConsignment = consignment;
}
return rsConsignment;
}
/**
......