|
|
|
@ -1,14 +1,18 @@
|
|
|
|
|
package com.glxp.api.task.mq;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.glxp.api.config.rabbit.TopicRabbitConfig;
|
|
|
|
|
import com.glxp.api.entity.trace.MqTaskDelayMessage;
|
|
|
|
|
import com.glxp.api.entity.trace.MqTraceMessage;
|
|
|
|
|
import com.glxp.api.entity.trace.TraceTaskHistoryEntity;
|
|
|
|
|
import com.glxp.api.entity.trace.TraceTaskNoticeEntity;
|
|
|
|
|
import com.glxp.api.service.trace.TraceTaskHistoryService;
|
|
|
|
|
import com.glxp.api.service.trace.TraceTaskNoticeService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -20,12 +24,15 @@ public class TraceSearchReceiver {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
TraceTaskNoticeService taskNoticeService;
|
|
|
|
|
@Resource
|
|
|
|
|
TraceTaskHistoryService traceTaskHistoryService;
|
|
|
|
|
|
|
|
|
|
public void traceReceiver(String mqTraceMessage) {
|
|
|
|
|
System.out.println("xxxx.xxxx.xxxx收到的消息内容为:\n" + mqTraceMessage);
|
|
|
|
|
//todo 测试用
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
@RabbitListener(queues = TopicRabbitConfig.delaytrace)
|
|
|
|
|
public void traceDeleyReceiver(MqTaskDelayMessage mqTaskDelayMessage) {
|
|
|
|
|
|
|
|
|
@ -36,7 +43,11 @@ public class TraceSearchReceiver {
|
|
|
|
|
taskNoticeEntity.setUpdateTime(new Date());
|
|
|
|
|
taskNoticeService.updateById(taskNoticeEntity);
|
|
|
|
|
} else if (mqTaskDelayMessage.getTaskStatus() == 3) {
|
|
|
|
|
log.info(mqTaskDelayMessage.getTaskId() + ":任务已完成,过期删除");
|
|
|
|
|
log.info(mqTaskDelayMessage.getTaskId() + ":任务已完成,过期删除,并存到备份表");
|
|
|
|
|
TraceTaskNoticeEntity taskNoticeEntity = taskNoticeService.getById(mqTaskDelayMessage.getTaskId());
|
|
|
|
|
TraceTaskHistoryEntity traceTaskHistoryEntity = new TraceTaskHistoryEntity();
|
|
|
|
|
BeanUtil.copyProperties(taskNoticeEntity, traceTaskHistoryEntity);
|
|
|
|
|
traceTaskHistoryService.saveOrUpdate(traceTaskHistoryEntity);
|
|
|
|
|
taskNoticeService.removeById(mqTaskDelayMessage.getTaskId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|