tao.mo

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

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