zelong.shao

dao|task|重新生成email表|打zip包部分

......@@ -20,6 +20,7 @@
<result column="MODIFY_TIME" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="MODIFY_USER_ID" jdbcType="NUMERIC" property="modifyUserId" />
<result column="MODIFY_USER_NAME" jdbcType="VARCHAR" property="modifyUserName" />
<result column="FILE_PATH" jdbcType="VARCHAR" property="filePath" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.fedex.connect.common.model.biz.Email">
<result column="BODY" jdbcType="CLOB" property="body" />
......@@ -85,7 +86,7 @@
<sql id="Base_Column_List">
ID, BIZ_ID, BIZ_CODE, TO_ADDRESS, CC_ADDRESS, SUBJECT, TYPE_CODE, TYPE_NAME, STATUS_CODE,
STATUS_NAME, SEND_NUM, SEND_TIME, CREATE_TIME, CREATE_USER_ID, CREATE_USER_NAME,
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME, FILE_PATH
</sql>
<sql id="Blob_Column_List">
BODY
......@@ -152,14 +153,14 @@
STATUS_NAME, SEND_NUM, SEND_TIME,
CREATE_TIME, CREATE_USER_ID, CREATE_USER_NAME,
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME,
BODY)
FILE_PATH, BODY)
values (#{id,jdbcType=NUMERIC}, #{bizId,jdbcType=NUMERIC}, #{bizCode,jdbcType=VARCHAR},
#{toAddress,jdbcType=VARCHAR}, #{ccAddress,jdbcType=VARCHAR}, #{subject,jdbcType=VARCHAR},
#{typeCode,jdbcType=VARCHAR}, #{typeName,jdbcType=VARCHAR}, #{statusCode,jdbcType=VARCHAR},
#{statusName,jdbcType=VARCHAR}, #{sendNum,jdbcType=NUMERIC}, #{sendTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=NUMERIC}, #{createUserName,jdbcType=VARCHAR},
#{modifyTime,jdbcType=TIMESTAMP}, #{modifyUserId,jdbcType=NUMERIC}, #{modifyUserName,jdbcType=VARCHAR},
#{body,jdbcType=CLOB})
#{filePath,jdbcType=VARCHAR}, #{body,jdbcType=CLOB})
</insert>
<insert id="insertSelective" parameterType="com.fedex.connect.common.model.biz.Email">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
......@@ -219,6 +220,9 @@
<if test="modifyUserName != null">
MODIFY_USER_NAME,
</if>
<if test="filePath != null">
FILE_PATH,
</if>
<if test="body != null">
BODY,
</if>
......@@ -276,6 +280,9 @@
<if test="modifyUserName != null">
#{modifyUserName,jdbcType=VARCHAR},
</if>
<if test="filePath != null">
#{filePath,jdbcType=VARCHAR},
</if>
<if test="body != null">
#{body,jdbcType=CLOB},
</if>
......@@ -344,6 +351,9 @@
<if test="record.modifyUserName != null">
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
</if>
<if test="record.filePath != null">
FILE_PATH = #{record.filePath,jdbcType=VARCHAR},
</if>
<if test="record.body != null">
BODY = #{record.body,jdbcType=CLOB},
</if>
......@@ -372,6 +382,7 @@
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{record.filePath,jdbcType=VARCHAR},
BODY = #{record.body,jdbcType=CLOB}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -396,7 +407,8 @@
CREATE_USER_NAME = #{record.createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR}
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{record.filePath,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -455,6 +467,9 @@
<if test="modifyUserName != null">
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
</if>
<if test="filePath != null">
FILE_PATH = #{filePath,jdbcType=VARCHAR},
</if>
<if test="body != null">
BODY = #{body,jdbcType=CLOB},
</if>
......@@ -480,6 +495,7 @@
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{filePath,jdbcType=VARCHAR},
BODY = #{body,jdbcType=CLOB}
where ID = #{id,jdbcType=NUMERIC}
</update>
......@@ -501,7 +517,8 @@
CREATE_USER_NAME = #{createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR}
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{filePath,jdbcType=VARCHAR}
where ID = #{id,jdbcType=NUMERIC}
</update>
<sql id="OracleDialectPrefix">
......
......@@ -20,6 +20,7 @@
<result column="MODIFY_TIME" jdbcType="TIMESTAMP" property="modifyTime" />
<result column="MODIFY_USER_ID" jdbcType="NUMERIC" property="modifyUserId" />
<result column="MODIFY_USER_NAME" jdbcType="VARCHAR" property="modifyUserName" />
<result column="FILE_PATH" jdbcType="VARCHAR" property="filePath" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.fedex.connect.common.model.log.EmailHistory">
<result column="BODY" jdbcType="CLOB" property="body" />
......@@ -85,7 +86,7 @@
<sql id="Base_Column_List">
ID, BIZ_ID, BIZ_CODE, TO_ADDRESS, CC_ADDRESS, SUBJECT, TYPE_CODE, TYPE_NAME, STATUS_CODE,
STATUS_NAME, SEND_NUM, SEND_TIME, CREATE_TIME, CREATE_USER_ID, CREATE_USER_NAME,
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME, FILE_PATH
</sql>
<sql id="Blob_Column_List">
BODY
......@@ -152,14 +153,14 @@
STATUS_NAME, SEND_NUM, SEND_TIME,
CREATE_TIME, CREATE_USER_ID, CREATE_USER_NAME,
MODIFY_TIME, MODIFY_USER_ID, MODIFY_USER_NAME,
BODY)
FILE_PATH, BODY)
values (#{id,jdbcType=NUMERIC}, #{bizId,jdbcType=NUMERIC}, #{bizCode,jdbcType=VARCHAR},
#{toAddress,jdbcType=VARCHAR}, #{ccAddress,jdbcType=VARCHAR}, #{subject,jdbcType=VARCHAR},
#{typeCode,jdbcType=VARCHAR}, #{typeName,jdbcType=VARCHAR}, #{statusCode,jdbcType=VARCHAR},
#{statusName,jdbcType=VARCHAR}, #{sendNum,jdbcType=NUMERIC}, #{sendTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP}, #{createUserId,jdbcType=NUMERIC}, #{createUserName,jdbcType=VARCHAR},
#{modifyTime,jdbcType=TIMESTAMP}, #{modifyUserId,jdbcType=NUMERIC}, #{modifyUserName,jdbcType=VARCHAR},
#{body,jdbcType=CLOB})
#{filePath,jdbcType=VARCHAR}, #{body,jdbcType=CLOB})
</insert>
<insert id="insertSelective" parameterType="com.fedex.connect.common.model.log.EmailHistory">
<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
......@@ -219,6 +220,9 @@
<if test="modifyUserName != null">
MODIFY_USER_NAME,
</if>
<if test="filePath != null">
FILE_PATH,
</if>
<if test="body != null">
BODY,
</if>
......@@ -276,6 +280,9 @@
<if test="modifyUserName != null">
#{modifyUserName,jdbcType=VARCHAR},
</if>
<if test="filePath != null">
#{filePath,jdbcType=VARCHAR},
</if>
<if test="body != null">
#{body,jdbcType=CLOB},
</if>
......@@ -344,6 +351,9 @@
<if test="record.modifyUserName != null">
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
</if>
<if test="record.filePath != null">
FILE_PATH = #{record.filePath,jdbcType=VARCHAR},
</if>
<if test="record.body != null">
BODY = #{record.body,jdbcType=CLOB},
</if>
......@@ -372,6 +382,7 @@
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{record.filePath,jdbcType=VARCHAR},
BODY = #{record.body,jdbcType=CLOB}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -396,7 +407,8 @@
CREATE_USER_NAME = #{record.createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{record.modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{record.modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR}
MODIFY_USER_NAME = #{record.modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{record.filePath,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -455,6 +467,9 @@
<if test="modifyUserName != null">
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
</if>
<if test="filePath != null">
FILE_PATH = #{filePath,jdbcType=VARCHAR},
</if>
<if test="body != null">
BODY = #{body,jdbcType=CLOB},
</if>
......@@ -480,6 +495,7 @@
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{filePath,jdbcType=VARCHAR},
BODY = #{body,jdbcType=CLOB}
where ID = #{id,jdbcType=NUMERIC}
</update>
......@@ -501,7 +517,8 @@
CREATE_USER_NAME = #{createUserName,jdbcType=VARCHAR},
MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
MODIFY_USER_ID = #{modifyUserId,jdbcType=NUMERIC},
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR}
MODIFY_USER_NAME = #{modifyUserName,jdbcType=VARCHAR},
FILE_PATH = #{filePath,jdbcType=VARCHAR}
where ID = #{id,jdbcType=NUMERIC}
</update>
<sql id="OracleDialectPrefix">
......
......@@ -99,6 +99,11 @@ public class Email implements Serializable {
private String modifyUserName;
/**
* 附件目录
*/
private String filePath;
/**
* 邮件内容
*/
private String body;
......@@ -249,6 +254,14 @@ public class Email implements Serializable {
this.modifyUserName = modifyUserName == null ? null : modifyUserName.trim();
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath == null ? null : filePath.trim();
}
public String getBody() {
return body;
}
......@@ -281,6 +294,7 @@ public class Email implements Serializable {
sb.append(", modifyTime=").append(modifyTime);
sb.append(", modifyUserId=").append(modifyUserId);
sb.append(", modifyUserName=").append(modifyUserName);
sb.append(", filePath=").append(filePath);
sb.append(", body=").append(body);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
......
......@@ -1304,6 +1304,76 @@ public class EmailExample {
addCriterion("MODIFY_USER_NAME not between", value1, value2, "modifyUserName");
return (Criteria) this;
}
public Criteria andFilePathIsNull() {
addCriterion("FILE_PATH is null");
return (Criteria) this;
}
public Criteria andFilePathIsNotNull() {
addCriterion("FILE_PATH is not null");
return (Criteria) this;
}
public Criteria andFilePathEqualTo(String value) {
addCriterion("FILE_PATH =", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotEqualTo(String value) {
addCriterion("FILE_PATH <>", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathGreaterThan(String value) {
addCriterion("FILE_PATH >", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathGreaterThanOrEqualTo(String value) {
addCriterion("FILE_PATH >=", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathLessThan(String value) {
addCriterion("FILE_PATH <", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathLessThanOrEqualTo(String value) {
addCriterion("FILE_PATH <=", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathLike(String value) {
addCriterion("FILE_PATH like", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotLike(String value) {
addCriterion("FILE_PATH not like", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathIn(List<String> values) {
addCriterion("FILE_PATH in", values, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotIn(List<String> values) {
addCriterion("FILE_PATH not in", values, "filePath");
return (Criteria) this;
}
public Criteria andFilePathBetween(String value1, String value2) {
addCriterion("FILE_PATH between", value1, value2, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotBetween(String value1, String value2) {
addCriterion("FILE_PATH not between", value1, value2, "filePath");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
......
......@@ -99,6 +99,11 @@ public class EmailHistory implements Serializable {
private String modifyUserName;
/**
* 附件备份目录
*/
private String filePath;
/**
* 邮件内容
*/
private String body;
......@@ -249,6 +254,14 @@ public class EmailHistory implements Serializable {
this.modifyUserName = modifyUserName == null ? null : modifyUserName.trim();
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath == null ? null : filePath.trim();
}
public String getBody() {
return body;
}
......@@ -281,6 +294,7 @@ public class EmailHistory implements Serializable {
sb.append(", modifyTime=").append(modifyTime);
sb.append(", modifyUserId=").append(modifyUserId);
sb.append(", modifyUserName=").append(modifyUserName);
sb.append(", filePath=").append(filePath);
sb.append(", body=").append(body);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
......
......@@ -1304,6 +1304,76 @@ public class EmailHistoryExample {
addCriterion("MODIFY_USER_NAME not between", value1, value2, "modifyUserName");
return (Criteria) this;
}
public Criteria andFilePathIsNull() {
addCriterion("FILE_PATH is null");
return (Criteria) this;
}
public Criteria andFilePathIsNotNull() {
addCriterion("FILE_PATH is not null");
return (Criteria) this;
}
public Criteria andFilePathEqualTo(String value) {
addCriterion("FILE_PATH =", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotEqualTo(String value) {
addCriterion("FILE_PATH <>", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathGreaterThan(String value) {
addCriterion("FILE_PATH >", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathGreaterThanOrEqualTo(String value) {
addCriterion("FILE_PATH >=", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathLessThan(String value) {
addCriterion("FILE_PATH <", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathLessThanOrEqualTo(String value) {
addCriterion("FILE_PATH <=", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathLike(String value) {
addCriterion("FILE_PATH like", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotLike(String value) {
addCriterion("FILE_PATH not like", value, "filePath");
return (Criteria) this;
}
public Criteria andFilePathIn(List<String> values) {
addCriterion("FILE_PATH in", values, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotIn(List<String> values) {
addCriterion("FILE_PATH not in", values, "filePath");
return (Criteria) this;
}
public Criteria andFilePathBetween(String value1, String value2) {
addCriterion("FILE_PATH between", value1, value2, "filePath");
return (Criteria) this;
}
public Criteria andFilePathNotBetween(String value1, String value2) {
addCriterion("FILE_PATH not between", value1, value2, "filePath");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
......
......@@ -40,7 +40,7 @@
sys:系统 系统相关表,例如kafka表
log: 日志 日志记录表,例如邮件发送日志表
-->
<javaModelGenerator targetPackage="com.fedex.connect.common.model.biz" targetProject="src/main/java">
<javaModelGenerator targetPackage="com.fedex.connect.common.model.log" targetProject="src/main/java">
<!---enableSubPackages:如果true,MBG会根据catalog和schema来生成子包。如果false就会直接用targetPackage属性-->
<property name="enableSubPackages" value="false"/>
<!--该属性只对MyBatis3有效,如果true就会使用构造方法入参,如果false就会使用setter方式。默认为false-->
......@@ -52,13 +52,13 @@
</javaModelGenerator>
<!-- 生成映射文件*.xml的位置-->
<sqlMapGenerator targetPackage="mapper.biz" targetProject="src/main/java/com/fedex/connect/common">
<sqlMapGenerator targetPackage="mapper.log" targetProject="src/main/java/com/fedex/connect/common">
<!--如果true,MBG会根据catalog和schema来生成子包。如果false就会直接用targetPackage属性。默认为false-->
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.fedex.connect.common.dao.biz" targetProject="src/main/java">
<javaClientGenerator type="XMLMAPPER" targetPackage="com.fedex.connect.common.dao.log" targetProject="src/main/java">
<!--如果true,MBG会根据catalog和schema来生成子包。如果false就会直接用targetPackage属性。默认为false-->
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
......@@ -87,24 +87,24 @@
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_LOG_OPERATION.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_LOG_EMAIL_HISTORY" domainObjectName="EmailHistory"-->
<table tableName="T_LOG_EMAIL_HISTORY" domainObjectName="EmailHistory"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
<generatedKey column="ID" sqlStatement="SELECT SEQ_T_LOG_EMAIL_HISTORY.NEXTVAL FROM DUAL" />
</table>
<!-- <table tableName="T_LOG_USER_LOGIN_INFO" domainObjectName="UserLoginInfo"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_LOG_EMAIL_HISTORY.NEXTVAL FROM DUAL" />-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_LOG_USER_LOGIN_INFO.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<!-- <table tableName="T_LOG_USER_LOGIN_INFO" domainObjectName="UserLoginInfo"-->
<!-- <table tableName="T_BIZ_ATTACHMENT" domainObjectName="Attachment"-->
<!-- enableCountByExample="true" enableUpdateByExample="true"-->
<!-- enableDeleteByExample="true" enableSelectByExample="true"-->
<!-- selectByExampleQueryId="true">-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_LOG_USER_LOGIN_INFO.NEXTVAL FROM DUAL" />-->
<!-- <generatedKey column="ID" sqlStatement="SELECT SEQ_T_BIZ_ATTACHMENT.NEXTVAL FROM DUAL" />-->
<!-- </table>-->
<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"-->
......
......@@ -50,4 +50,20 @@ public interface BaseConstants {
//描述
String MSG = "msg";
}
//文件后缀字符串keys
interface FILE_SUFFIX_KEYS{
/**
* json字符串
*/
String JSON = ".json";
/**
* temp临时文件
*/
String TEMP = ".temp";
/**
* zip文件后缀
*/
String ZIP = ".zip";
}
}
\ No newline at end of file
......
package com.fedex.connect.task.data.dto;
import lombok.Data;
@Data
public class PortFileDto {
private String destIataCode;
private String zipPath;
}
package com.fedex.connect.task.data.dto;
import com.fedex.connect.common.model.biz.Attachment;
import lombok.Data;
import java.util.List;
@Data
public class PushZipEmailDto {
private String destIataCode;
private List<Attachment> attachments;
private String filePath;
}
......
package com.fedex.connect.task.repository.dao;
import com.fedex.connect.task.data.dto.PushZipEmailDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface AttachmentExtMapper {
@Select("SELECT c.DEST_IATA_CODE, a.* " +
"FROM T_BIZ_CONSIGNMENT c " +
"JOIN T_BIZ_ATTACHMENT a ON c.ID = a.BIZ_ID " +
"WHERE c.ID = #{conId}")
List<PushZipEmailDto> findAttachmentAndPortByCode(@Param("conId") Long conId);
@Select("SELECT c.DEST_IATA_CODE, a.FILE_PATH " +
"FROM T_BIZ_EMAIL e " +
"JOIN T_BIZ_CONSIGNMENT c ON e.BIZ_ID = c.ID " +
"JOIN T_BIZ_ATTACHMENT a ON a.BIZ_ID = c.ID " +
"WHERE a.STATUS = 1 " +
"AND e.TYPE_CODE = #{typeCode} " +
"AND e.STATUS_CODE = #{statusCode}")
List<PushZipEmailDto> findPathWithPortCode(@Param("typeCode") String typeCode, @Param("statusCode") String statusCode);
}
......
......@@ -5,5 +5,5 @@ import com.fedex.connect.task.data.dto.PushZipEmailDto;
import java.util.List;
public interface IAttachmentExtRepository {
List<PushZipEmailDto> findAttachmentAndPortByCode(Long conId);
List<PushZipEmailDto> findPathWithPortCode(String typeCode,String statusCode);
}
......
......@@ -11,7 +11,7 @@ import java.util.List;
public class AttachmentExtRepositoryImpl extends AbstractDaoRepository implements IAttachmentExtRepository {
@Override
public List<PushZipEmailDto> findAttachmentAndPortByCode(Long conId) {
return attachmentExtMapper.findAttachmentAndPortByCode(conId);
public List<PushZipEmailDto> findPathWithPortCode(String typeCode, String statusCode) {
return attachmentExtMapper.findPathWithPortCode(typeCode,statusCode);
}
}
......
......@@ -3,15 +3,22 @@ package com.fedex.connect.task.service.biz.impl;
import com.fedex.connect.common.dependencies.cache.CacheSystem;
import com.fedex.connect.common.dependencies.enums.biz.EmailStatusEnum;
import com.fedex.connect.common.dependencies.enums.biz.EmailTypeEnum;
import com.fedex.connect.common.dependencies.util.ZipUtils;
import com.fedex.connect.common.model.biz.Email;
import com.fedex.connect.task.data.dto.PortFileDto;
import com.fedex.connect.task.data.dto.PushZipEmailDto;
import com.fedex.connect.task.service.base.BaseService;
import com.fedex.connect.task.service.biz.IPushConsignmentFileService;
import com.fedex.connect.task.utils.sys.ConFileEmailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author Szl
......@@ -19,10 +26,18 @@ import java.util.List;
* @Date 2024/11/7
*/
@Service
@Slf4j
public class PushConsignmentFileServiceImpl extends BaseService implements IPushConsignmentFileService {
@Autowired
private CacheSystem cacheSystem;
@Autowired
private ZipUtils zipUtils;
@Autowired
private ConFileEmailUtil conFileEmailUtil;
/**
* @Author Szl
* @Description 功能说明 推送清关文件
......@@ -32,21 +47,27 @@ public class PushConsignmentFileServiceImpl extends BaseService implements IPush
*/
@Override
public void pushConsignmentFileTask(){
List<Email> emails = new ArrayList<>();
String tempPath = "";
String finalPath = "";
//查询需要发送的数据
List<Email> conPushEmails = iEmailExtRepository.findConPushEmails(cacheSystem.getDicEmailType(EmailTypeEnum.PENDING.getEnMsg()).getId(), cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getId());
//打zip包
if (!CollectionUtils.isEmpty(conPushEmails)){
for (Email conPushEmail : conPushEmails) {
/**
* 获取每个运单的附件
*/
List<PushZipEmailDto> attachmentAndPortByCode = attachmentExtRepository.findAttachmentAndPortByCode(conPushEmail.getBizId());
}
List<PushZipEmailDto> pathWithPortCode = attachmentExtRepository.findPathWithPortCode(cacheSystem.getDicEmailType(EmailTypeEnum.PENDING.getEnMsg()).getCode(),
cacheSystem.getDicEmailStatus(EmailStatusEnum.PENDING.getEnMsg()).getCode());
if (CollectionUtils.isEmpty(pathWithPortCode)){
return;
}
//发送邮件
//更新邮件状态
//根据口岸分类构成map(口岸,filePaths)
Map<String, List<PushZipEmailDto>> portAttachmentsMap = new HashMap<>();
portAttachmentsMap = conFileEmailUtil.getPortAttachmentsMap(portAttachmentsMap,pathWithPortCode);
//根据口岸构成zipPath的map(口岸,zip path)
List<PortFileDto> portFileDtoList = new ArrayList<>();
portFileDtoList = conFileEmailUtil.getPortZipMap(portFileDtoList, portAttachmentsMap, tempPath, finalPath, zipUtils);
//发送邮件
for (PortFileDto portFileDto : portFileDtoList) {
Email email = new Email();
}
}
}
......
package com.fedex.connect.task.utils.sys;
import com.fedex.connect.common.dependencies.contants.BaseConstants;
import com.fedex.connect.common.dependencies.contants.BaseSeparatorConstants;
import com.fedex.connect.common.dependencies.util.DateUtil;
import com.fedex.connect.common.dependencies.util.ZipUtils;
import com.fedex.connect.task.data.dto.PortFileDto;
import com.fedex.connect.task.data.dto.PushZipEmailDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Author Szl
* @Description 类说明 用于推送运单图像邮件
* @Date 2024/11/13
*/
@Slf4j
@Component
public class ConFileEmailUtil {
/**
* @Author Szl
* @Description 功能说明 构建map(口岸,文件目录)
* @Date 2024/11/14
* @param portAttachmentsMap
* @param pathWithPortCode
* @return java.util.Map<java.lang.String,java.util.List<com.fedex.connect.task.data.dto.PushZipEmailDto>>
*/
public Map<String, List<PushZipEmailDto>> getPortAttachmentsMap(Map<String, List<PushZipEmailDto>> portAttachmentsMap,List<PushZipEmailDto> pathWithPortCode){
for (PushZipEmailDto dto : pathWithPortCode) {
String destIataCode = dto.getDestIataCode();
if (destIataCode == null || destIataCode.isEmpty()) {
destIataCode = "null"; // 使用 "null" 代替空口岸
}
portAttachmentsMap.computeIfAbsent(destIataCode, k -> new ArrayList<>()).add(dto);
}
return portAttachmentsMap;
}
/**
* @Author Szl
* @Description 功能说明 根据口岸打包,每个口岸的文件打成一个zip包
* @Date 2024/11/14
* @param portFileDtoList
* @param portAttachmentsMap
* @param tempPath
* @param finalPath
* @param zipUtils
* @return void
*/
public List<PortFileDto> getPortZipMap(List<PortFileDto> portFileDtoList, Map<String, List<PushZipEmailDto>> portAttachmentsMap, String tempPath, String finalPath, ZipUtils zipUtils){
for (Map.Entry<String, List<PushZipEmailDto>> entry : portAttachmentsMap.entrySet()) {
List<File> filesList = new ArrayList<>();
String portCode = entry.getKey();
List<PushZipEmailDto> portAttachments = entry.getValue();
// 打zip包
String date = DateUtil.formatTimeWithoutSlash(new Date());
String fileName = date + BaseSeparatorConstants.SEPARATOR_UNDERLINE + portCode + BaseConstants.FILE_SUFFIX_KEYS.ZIP;
String fileNameTemp = date + BaseSeparatorConstants.SEPARATOR_UNDERLINE + portCode + BaseConstants.FILE_SUFFIX_KEYS.ZIP + BaseConstants.FILE_SUFFIX_KEYS.TEMP;
FileOutputStream fos = null;
for (PushZipEmailDto portAttachment : portAttachments) {
File file = new File(portAttachment.getFilePath());
if (file.exists()) {
filesList.add(file);
}
}
try {
fos = new FileOutputStream(tempPath + fileNameTemp);
zipUtils.toZip(filesList, fos);
File file = new File(tempPath + fileNameTemp);
File finalFile = new File(finalPath + fileName);
// 打包完成后重命名为正式文件
if (!file.renameTo(finalFile)) {
throw new IOException("无法重命名文件 " + file.getAbsolutePath() + " 到 " + finalFile.getAbsolutePath());
}
// 将结果添加到 portFileDtoList
PortFileDto portFileDto = new PortFileDto();
portFileDto.setDestIataCode(portCode);
portFileDto.setZipPath(finalPath + fileName);
portFileDtoList.add(portFileDto);
} catch (Exception e) {
log.error("生成压缩包错误:{}", e.getMessage(), e);
} finally {
try {
if (fos != null) {
fos.close();
fos = null;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
return portFileDtoList;
}
}