tao.mo

task-schedule | 修改 | save跟savelAll方法调整名称为saveOrUpdate

mt
2024年11月20日11:47:05
Showing 15 changed files with 199 additions and 64 deletions
package com.fedex.connect.common.dependencies.contants;
/**
* @Author mt
* @Description 系统配置参数keys
* @Date 2024/11/20
*/
public interface ParamConfigConstants {
/**
* @Author mt
* @Description FCL参数相关
* @Date 2024/11/20
*/
interface FCL_PARAM_KEYS{
//FCL登陆地址
String FCL_LOGIN_URL = "fcl_login_url";
}
/**
* @Author mt
* @Description 定时任务参数相关
* @Date 2024/11/20
*/
interface TASK_PARAM_KEYS{
}
}
package com.fedex.connect.common.dependencies.enums.sys;
public enum ParamConfigEnum {
FCL_LOGIN_URL(0L,"fcl_login_url","FCL登陆地址"),
;
private Long code;
private String enMsg;
private String msg;
ParamConfigEnum(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;
}
}
......@@ -4,12 +4,13 @@ import java.lang.annotation.*;
/**
* @Author mt
* @Description 输出执行时间日志
* @Description 输出执行时间日志,并且控制任务执行间隔
* @Date 2024/5/23
*/
@Target({ ElementType.PARAMETER, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ProcessingTime {
public @interface ProcessingInterval {
//参数编码
String paramCode() default "";
}
\ No newline at end of file
......
package com.fedex.connect.task.aspect;
import com.fedex.connect.task.annotation.ProcessingInterval;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
......@@ -24,7 +25,7 @@ import java.lang.reflect.Method;
public class ExecuteAspect {
private Logger log = LoggerFactory.getLogger(ExecuteAspect.class);
@Pointcut("@annotation(com.fedex.connect.task.annotation.ProcessingTime)")
@Pointcut("@annotation(com.fedex.connect.task.annotation.ProcessingInterval)")
public void executePointCut()
{
}
......@@ -35,7 +36,7 @@ public class ExecuteAspect {
* @return
*/
@Around(value = "executePointCut()")
public Object executeAround(ProceedingJoinPoint pjp){
public Object executeAround(ProceedingJoinPoint pjp, ProcessingInterval processingTime){
Object obj = null;
try {
Signature signature = pjp.getSignature();
......
package com.fedex.connect.task.job;
import com.fedex.connect.task.annotation.ProcessingTime;
import com.fedex.connect.task.annotation.ProcessingInterval;
import com.fedex.connect.task.service.sys.IRedisSlabExtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -20,7 +20,7 @@ public class BaseJob {
/**
* 30秒一次作废失效token
*/
@ProcessingTime
@ProcessingInterval
@Scheduled(cron="0/30 * * * * ?")
public void validRedisMsgJob(){
redisUtilService.validRedisMsg();
......
package com.fedex.connect.task.job;
import com.fedex.connect.task.annotation.ProcessingTime;
import com.fedex.connect.task.annotation.ProcessingInterval;
import com.fedex.connect.task.service.biz.IPushObService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -20,16 +20,17 @@ public class Imp001Job {
/**
* 推送Imp001数据给到进口组
*/
@ProcessingTime
@ProcessingInterval
@Scheduled(cron = "${export.task.allocation.sendOb}")
public void sendObTask() {
sendObService.sendOb();
}
/**
* 推送OB数据错误重试
*/
@ProcessingTime
@ProcessingInterval
@Scheduled(cron = "${export.task.allocation.sendObRetry}")
public void sendObRetryTask() {
sendObService.sendObRetry();
......
package com.fedex.connect.task.job;
import com.fedex.connect.task.annotation.ProcessingTime;
import com.fedex.connect.task.annotation.ProcessingInterval;
import com.fedex.connect.task.service.sys.IKafkaDmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -20,7 +20,7 @@ public class KafkaJob {
/**
* kafka补偿定时任务
*/
@ProcessingTime
@ProcessingInterval
@Scheduled(cron = "${export.task.allocation.kafkaRetry}")
public void kafkaRetryTask() {
kafkaDmService.scanKafkaTemporaryStorage();
......
package com.fedex.connect.task.job;
import com.fedex.connect.task.annotation.ProcessingTime;
import com.fedex.connect.task.annotation.ProcessingInterval;
import com.fedex.connect.task.service.biz.IPushConsignmentFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -17,7 +17,7 @@ public class PushConsignmentFileEmailJob {
@Autowired
private IPushConsignmentFileService pushConsignmentFileService;
@ProcessingTime
@ProcessingInterval
@Scheduled(cron = "${export.task.allocation.pushConFile}")
public void pushConsignmentFileTask() {
pushConsignmentFileService.pushConsignmentFileTask();
......
package com.fedex.connect.task.repository.base;
import com.fedex.connect.common.dao.biz.EmailMapper;
import com.fedex.connect.common.dao.biz.PushObMapper;
import com.fedex.connect.common.dao.log.EmailHistoryMapper;
import com.fedex.connect.common.dao.sys.KafkaStorageHistoryMapper;
import com.fedex.connect.common.dao.sys.KafkaTemporaryStorageMapper;
......@@ -9,12 +10,18 @@ import org.springframework.beans.factory.annotation.Autowired;
public class AbstractDaoRepository {
@Autowired
protected KafkaTemporaryStorageMapperExt kafkaTemporaryStorageMapperExt;
protected EmailMapper emailMapper;
@Autowired
protected EmailHistoryMapper emailHistoryMapper;
@Autowired
protected KafkaTemporaryStorageMapper kafkaTemporaryStorageMapper;
@Autowired
protected KafkaStorageHistoryMapper kafkaStorageHistoryMapper;
@Autowired
protected PushObMapper pushObMapper;
@Autowired
protected KafkaTemporaryStorageMapperExt kafkaTemporaryStorageMapperExt;
@Autowired
protected RedisSlabMapperExt redisSlabMapperExt;
@Autowired
protected EmailExtMapper emailExtMapper;
......@@ -23,7 +30,5 @@ public class AbstractDaoRepository {
@Autowired
protected PortclearEmailMappingExtMapper portclearEmailMappingExtMapper;
@Autowired
protected EmailMapper emailMapper;
@Autowired
protected EmailHistoryMapper emailHistoryMapper;
protected PushObMapperExt pushObMapperExt;
}
\ No newline at end of file
......
package com.fedex.connect.task.repository.dao;
import com.fedex.connect.common.model.biz.PushOb;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface PushObMapperExt {
@Select( "<script>" +
"SELECT * FROM T_PUSH_OB_LOG WHERE PUSH_STATUS = #{pushStatus,jdbcType=NUMERIC} AND ROWNUM &lt;= 500" +
"</script>")
List<PushOb> findPushObByStatus(@Param("pushStatus") Long pushStatus);
@Select( "<script>" +
"SELECT * FROM T_PUSH_OB_LOG WHERE PUSH_NUM &lt; #{pushNum,jdbcType=NUMERIC} AND PUSH_STATUS = #{pushStatus,jdbcType=NUMERIC} AND ROWNUM &lt;= 500" +
"</script>")
List<PushOb> findPushObByStatusAndNum(@Param("pushNum") Long pushNum, @Param("pushStatus") Long pushStatus);
@Select( "<script>" +
"SELECT count(*) FROM T_PUSH_OB_LOG WHERE PUSH_NUM &gt;= #{pushNum,jdbcType=NUMERIC} AND PUSH_STATUS = #{pushStatus,jdbcType=NUMERIC} " +
"AND TRUNC(CREATE_TIME) = TRUNC(TO_DATE(#{date,jdbcType=VARCHAR}, 'YYYY-MM-DD'))" +
"</script>")
Integer findErrPushForEmail(@Param("pushNum") Long pushNum, @Param("pushStatus") Long pushStatus, @Param("date") String date);
}
package com.fedex.connect.task.repository.repo.biz;
import com.fedex.connect.common.model.biz.PushOb;
import java.util.List;
public interface IPushObRepository {
/**
* @Author mt
* @Description 保存pushObLog数据
* @Date 2024/11/20
* @param pushOb
* @return int
*/
int save(PushOb pushOb);
/**
* @Author mt
* @Description 根据主键id更新
* @Date 2024/11/20
* @param pushOb
* @return void
*/
void updateById(PushOb pushOb);
/**
* @Author mt
* @Description 根据推送次数,推送状态查找需要推送记录
* @Date 2024/11/20
* @param pushStatus
* @return java.util.List<com.fedex.connect.common.model.biz.PushOb>
*/
List<PushOb> findPushOb(Long pushStatus);
/**
* @Author mt
* @Description 根据推送次数,推送状态查找需要推送记录
* @Date 2024/11/20
* @param pushNum
* @param pushStatus
* @return java.util.List<com.fedex.connect.common.model.biz.PushOb>
*/
List<PushOb> findErrPushOb(Long pushNum,Long pushStatus);
Integer findErrPushForEmail(Long pushNum,Long pushStatus,String date);
}
package com.fedex.connect.task.repository.repo.biz.impl;
import com.fedex.connect.common.model.biz.PushOb;
import com.fedex.connect.task.repository.base.AbstractDaoRepository;
import com.fedex.connect.task.repository.repo.biz.IPushObRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class PushObRepositoryImpl extends AbstractDaoRepository implements IPushObRepository {
/**
* @Author mt
* @Description 保存PushOb数据
* @Date 2024/8/2
* @param PushOb
* @return int
*/
public int save(PushOb PushOb){
return pushObMapper.insertSelective(PushOb);
}
/**
* @Author mt
* @Description 根据主键id更新
* @Date 2024/5/30
* @param PushOb
* @return void
*/
@Override
public void updateById(PushOb PushOb){
pushObMapper.updateByPrimaryKey(PushOb);
}
/**
* @Author mt
* @Description 根据推送次数,推送状态查找需要推送记录
* @Date 2024/5/24
* @param pushStatus
* @return java.util.List<com.fedex.export.repository.entity.PushOb>
*/
@Override
public List<PushOb> findPushOb(Long pushStatus) {
return pushObMapperExt.findPushObByStatus(pushStatus);
}
/**
* @Author mt
* @Description 根据推送次数,推送状态查找需要推送记录
* @Date 2024/5/24
* @param pushNum
* @param pushStatus
* @return java.util.List<com.fedex.export.repository.entity.PushOb>
*/
@Override
public List<PushOb> findErrPushOb(Long pushNum, Long pushStatus) {
return pushObMapperExt.findPushObByStatusAndNum(pushNum,pushStatus);
}
@Override
public Integer findErrPushForEmail(Long pushNum, Long pushStatus, String date) {
return pushObMapperExt.findErrPushForEmail(pushNum,pushStatus,date);
}
}
......@@ -3,6 +3,7 @@ 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.IAttachmentRepository;
import com.fedex.connect.task.repository.repo.biz.IEmailRepository;
import com.fedex.connect.task.repository.repo.biz.IPushObRepository;
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;
......@@ -26,4 +27,6 @@ public class BaseService {
protected IEmailRepository iEmailExtRepository;
@Autowired
protected IAttachmentRepository attachmentExtRepository;
@Autowired
protected IPushObRepository pushObRepository;
}
\ No newline at end of file
......
......@@ -27,7 +27,8 @@ public class PushObServiceImpl extends BaseService implements IPushObService {
*/
@Override
public void sendOb() {
//获取需要处理的记录
// List<PushObLog> pushObLogList = pushObLogRepository.findPushObLog(Constant.SEND_TW001_KEYS.PUSH_OB_STATUS_WAIT);
}
/**
......
......@@ -279,14 +279,14 @@ public class ConFileEmailUtil {
if (result){
//成功后需要将业务表数据删除,保存至历史表
emailRepository.deleteById(conPushEmail.getId());
emailHistoryRepository.save(emailHistory);
emailHistoryRepository.saveOrUpdate(emailHistory);
}else {
//失败则根据是否第三次,如果是第三次失败则删除,保存到历史表
if (conPushEmail.getSendNum() == 3){
emailRepository.deleteById(conPushEmail.getId());
emailHistoryRepository.save(emailHistory);
emailHistoryRepository.saveOrUpdate(emailHistory);
}else {
emailRepository.save(conPushEmail);
emailRepository.saveOrUpdate(conPushEmail);
}
}
......