zelong.shao

task|发送预清关文件邮件

Showing 24 changed files with 323 additions and 21 deletions
package com.fedex.connect.customer.controller.biz.impl;
import com.fedex.connect.common.dependencies.annotation.OperationMethodLog;
import com.fedex.connect.common.dependencies.date.model.LogShowModel;
import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
import com.fedex.connect.common.dependencies.enums.BaseResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.base.BaseController;
import com.fedex.connect.customer.controller.biz.IConsignmentController;
......@@ -38,16 +35,7 @@ public class ConsignmentController extends BaseController implements IConsignmen
if (responseResultVo != null){
return responseResultVo;
}
User user = null;
try {
user = CurrentUserInfo.getUser();
} catch (Exception e) {
logger.error(LogShowModel.showException("Exception", e));
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
}
if (user == null) {
return ResponseVo.fail(localeMessageUtil.getMessage(BaseResponseCode.OVERDUE_TOKEN_CODE.getMsg()));
}
User user = getUserInfo(localeMessageUtil);
return consignmentService.add(bo,user);
}
}
......
......@@ -18,7 +18,7 @@ public interface ConsignmentExtMapper {
@Select("SELECT * FROM ( " +
"SELECT * FROM T_BIZ_CONSIGNMENT " +
"WHERE CONSIGNMENT_CODE = #{consignmentCode} " +
"AND CREATE_TIME >= SYSDATE - 30 " +
"AND CREATE_TIME >= SYSDATE - 30 " +
"ORDER BY CREATE_TIME DESC" +
") WHERE ROWNUM = 1")
Consignment findByConsignmentCode(@Param("consignmentCode") String consignmentCode);
......
......@@ -4,6 +4,6 @@ import com.fedex.connect.customer.data.dto.AttachmentHistoryDto;
import java.util.List;
public interface IAttachmentRepository {
public interface IAttachmentExtRepository {
List<AttachmentHistoryDto> findHistory(Long bizId);
}
\ No newline at end of file
......
......@@ -2,13 +2,13 @@ package com.fedex.connect.customer.repository.repo.impl;
import com.fedex.connect.customer.data.dto.AttachmentHistoryDto;
import com.fedex.connect.customer.repository.base.BaseDao;
import com.fedex.connect.customer.repository.repo.IAttachmentRepository;
import com.fedex.connect.customer.repository.repo.IAttachmentExtRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class AttachmentExtRepositoryImpl extends BaseDao implements IAttachmentRepository {
public class AttachmentExtRepositoryImpl extends BaseDao implements IAttachmentExtRepository {
@Override
public List<AttachmentHistoryDto> findHistory(Long bizId) {
return attachmentExtMapper.findHistory(bizId);
......
......@@ -2,7 +2,7 @@ package com.fedex.connect.customer.service.base;
import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil;
import com.fedex.connect.customer.repository.repo.IAttachmentRepository;
import com.fedex.connect.customer.repository.repo.IAttachmentExtRepository;
import com.fedex.connect.customer.repository.repo.IConsignmentExtRepository;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,7 +17,7 @@ public class BaseService {
protected IConsignmentExtRepository consignmentExtRepository;
@Autowired
protected IAttachmentRepository attachmentRepository;
protected IAttachmentExtRepository attachmentRepository;
/**
* repository
......
......@@ -111,8 +111,39 @@ public class CacheSystem implements CommandLineRunner {
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
}
/**
* @Author Szl
* @Description 功能说明 根据code获取用户类型指定字典项
* @Date 2024/11/7
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicUserLoginType(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.USER_LOGIN_TYPE).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
}
/**
* @Author Szl
* @Description 功能说明 根据code获取邮件类型指定字典项
* @Date 2024/11/7
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicEmailType(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.EMAIL_TYPE).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
}
/**
* @Author Szl
* @Description 功能说明 根据code获取邮件状态指定字典项
* @Date 2024/11/7
* @param code
* @return com.fedex.connect.common.model.bi.DictionaryEntries
*/
public DictionaryEntries getDicEmailStatus(String code){
List<DictionaryEntries> filter = dictionaryMap.get(DictionaryConstants.EMAIL_STATUS).stream().filter(p -> code.equals(p.getCode())).collect(Collectors.toList());
return filter.isEmpty() ? null : filter.get(DigitConstants.DIGIT_ZERO);
}
}
\ No newline at end of file
......
......@@ -14,4 +14,8 @@ public interface DictionaryConstants {
String COUNTRY = "COUNTRY";
//用户操作类型
String USER_LOGIN_TYPE = "USER_LOGIN_TYPE";
//邮件类型
String EMAIL_TYPE = "EMAIL_TYPE";
//邮件状态
String EMAIL_STATUS = "EMAIL_STATUS";
}
......
package com.fedex.connect.common.dependencies.enums.biz;
public enum EmailStatusEnum {
PENDING(0L,"pending","待发送"),
SUCCESS(1L,"success","发送成功"),
FAILED(2L,"failed","发送失败"),
;
private Long code;
private String enMsg;
private String msg;
EmailStatusEnum(Long code, String enMsg,String msg) {
this.code = code;
this.enMsg = enMsg;
this.msg = msg;
}
public Long getCode() {
return code;
}
public void setCode(Long 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.enums.biz;
public enum EmailTypeEnum {
PENDING(0L,"pushConFile","推送预清关文件"),
;
private Long code;
private String enMsg;
private String msg;
EmailTypeEnum(Long code, String enMsg,String msg) {
this.code = code;
this.enMsg = enMsg;
this.msg = msg;
}
public Long getCode() {
return code;
}
public void setCode(Long 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.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* @Author mt
* @Description zip压缩工具类
* @Date 2024/5/30
*/
@Component
public class ZipUtils {
//缓冲区
private static final int BUFFER_SIZE = 2 * 1024;
/**
* 压缩成ZIP 方法2
* @param srcFiles 需要压缩的文件列表
* @param out 压缩文件输出流
* @throws Exception 压缩失败会抛出运行时异常
*/
public void toZip(List<File> srcFiles , OutputStream out) throws Exception {
ZipOutputStream zos = null ;
try {
zos = new ZipOutputStream(out);
for (File srcFile : srcFiles) {
byte[] buf = new byte[BUFFER_SIZE];
zos.putNextEntry(new ZipEntry(srcFile.getName()));
int len;
FileInputStream in = new FileInputStream(srcFile);
while ((len = in.read(buf)) != -1){
zos.write(buf, 0, len);
}
zos.closeEntry();
in.close();
}
} catch (Exception e) {
throw e;
}finally{
if(zos != null){
try {
zos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
package com.fedex.connect.task.job;
import com.fedex.connect.task.annotation.ProcessingTime;
import com.fedex.connect.task.service.biz.IPushConsignmentFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @Author Szl
* @Description 类说明 异步任务发送邮件到预清关组
* @Date 2024/11/7
*/
@Component
public class PushConsignmentFileEmailJob {
@Autowired
private IPushConsignmentFileService pushConsignmentFileService;
@ProcessingTime
@Scheduled(cron = "${export.task.allocation.pushConFile}")
public void pushConsignmentFileTask() {
pushConsignmentFileService.pushConsignmentFileTask();
}
}
......@@ -2,10 +2,9 @@ package com.fedex.connect.task.repository.base;
import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper;
import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper;
import com.fedex.connect.task.repository.dao.EmailExtMapper;
import com.fedex.connect.task.repository.dao.KafkaTemporaryStorageMapperExt;
import com.fedex.connect.task.repository.dao.RedisSlabMapperExt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class AbstractDaoRepository {
......@@ -17,4 +16,6 @@ public class AbstractDaoRepository {
protected KafkaStorageHistoryMapper kafkaStorageHistoryMapper;
@Autowired
protected RedisSlabMapperExt redisSlabMapperExt;
@Autowired
protected EmailExtMapper emailExtMapper;
}
\ No newline at end of file
......
package com.fedex.connect.task.repository.dao;
import com.fedex.connect.common.model.biz.Email;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface EmailExtMapper {
List<Email> findConPushEmails(Long typeId,Long statusId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fedex.connect.task.repository.dao.EmailExtMapper">
<select id="findConPushEmails" resultType="com.fedex.connect.common.model.biz.Email">
SELECT *
FROM T_BIZ_EMAIL
WHERE TYPE_ID = #{typeId}
AND STATUS_ID = #{statusId}
</select>
</mapper>
\ No newline at end of file
package com.fedex.connect.task.repository.repo.biz;
import com.fedex.connect.common.model.biz.Email;
import java.util.List;
public interface IEmailExtRepository {
List<Email> findConPushEmails(Long typeId, Long statusId);
}
package com.fedex.connect.task.repository.repo.biz.impl;
import com.fedex.connect.common.model.biz.Email;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.biz.IEmailExtRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class EmailRepositoryExtImpl extends AbstractDaoRepository implements IEmailExtRepository {
public List<Email> findConPushEmails(Long typeId,Long statusId){
return emailExtMapper.findConPushEmails(typeId,statusId);
}
}
package com.fedex.connect.task.repository.repo.sys;
import com.fedex.connect.common.model.sys.RedisSlab;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
@Repository
public interface IRedisSlabExtRepository {
List<RedisSlab> findValidRedisMsgList(Date curDate);
}
\ No newline at end of file
......
package com.fedex.connect.task.service.base;
import com.fedex.connect.common.dependencies.repository.repo.sys.IRedisSlabRepository;
import com.fedex.connect.task.repository.repo.biz.IEmailExtRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaStorageHistoryRepository;
import com.fedex.connect.task.repository.repo.sys.IKafkaTemporaryStorageRepository;
import com.fedex.connect.task.repository.repo.sys.IRedisSlabExtRepository;
......@@ -20,4 +21,6 @@ public class BaseService {
protected IRedisSlabRepository redisSlabRepository;
@Autowired
protected IRedisSlabExtRepository redisRepository;
@Autowired
protected IEmailExtRepository iEmailExtRepository;
}
\ No newline at end of file
......
package com.fedex.connect.task.service.biz;
public interface IPushConsignmentFileService {
void pushConsignmentFileTask();
}
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.model.biz.Email;
import com.fedex.connect.task.service.base.BaseService;
import com.fedex.connect.task.service.biz.IPushConsignmentFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* @Author Szl
* @Description 类说明 推送清关文件任务
* @Date 2024/11/7
*/
@Service
public class PushConsignmentFileServiceImpl extends BaseService implements IPushConsignmentFileService {
@Autowired
private CacheSystem cacheSystem;
/**
* @Author Szl
* @Description 功能说明 推送清关文件
* @Date 2024/11/7
* @param
* @return void
*/
@Override
public void pushConsignmentFileTask(){
//查询需要发送的数据
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) {
}
}
//发送邮件
//更新邮件状态
}
}
......@@ -18,6 +18,8 @@ export:
sendOb: 0 0/1 * * * ?
#推送ob文件异常重试任务
sendObRetry: 0 0/1 * * * ?
#发送邮件到预清关组
pushConFile: 0 0/1 * * * ?
rpc:
url:
......
......@@ -14,6 +14,8 @@ export:
sendOb: 0 0/1 * * * ?
#推送ob zip包文件异常重试任务
sendObRetry: 0 0/3 * * * ?
#发送邮件到预清关组
pushConFile: 0 0/5 * * * ?
rpc:
url:
rpcKafkaReceive1: https://pjea0179.prod.apac.fedex.com:9002/icleartwkafka/rpcKafka/rpcKafkaReceive
......
......@@ -14,6 +14,8 @@ export:
sendOb: 0 0/1 * * * ?
#推送ob zip包文件异常重试任务
sendObRetry: 0 0/1 * * * ?
#发送邮件到预清关组
pushConFile: 0 0/1 * * * ?
rpc:
url:
rpcKafkaReceive1: http://47.103.140.98:7010/icleartwkafka/rpcKafka/rpcKafkaReceive
......
......@@ -14,6 +14,8 @@ export:
sendOb: 0 0/1 * * * ?
#推送ob zip包文件异常重试任务
sendObRetry: 0 0/3 * * * ?
#发送邮件到预清关组
pushConFile: 0 0/5 * * * ?
rpc:
url:
rpcKafkaReceive1: http://ujea0145.nonprod.apac.fedex.com:9001/icleartwkafka/rpcKafka/rpcKafkaReceive
......