【修复】修复派工单定时任务状态判断逻辑
This commit is contained in:
parent
fe74fa3c56
commit
235ef24e4b
|
|
@ -1,9 +1,12 @@
|
|||
package com.nflg.mobilebroken.gongfu.task;
|
||||
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.util.DateTimeUtil;
|
||||
import com.nflg.mobilebroken.common.util.IdUtil;
|
||||
import com.nflg.mobilebroken.repository.entity.GongfuDispatch;
|
||||
import com.nflg.mobilebroken.repository.service.IGongfuDispatchService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -24,17 +27,24 @@ public class DispatchScheduledTasks {
|
|||
*/
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void setState() {
|
||||
List<GongfuDispatch> datas = dispatchService.lambdaQuery().eq(GongfuDispatch::getState, 0).list();
|
||||
log.info("共{}条记录", datas.size());
|
||||
String now = DateTimeUtil.format(LocalDate.now(), "yyyy-MM-dd");
|
||||
datas.forEach(data -> {
|
||||
log.info("开始处理{}:{}", data.getId(), data.getTitle());
|
||||
if (data.getPlanStartDate().compareTo(now) >= 0) {
|
||||
log.info("设置为处理中");
|
||||
data.setState(1);
|
||||
dispatchService.updateById(data);
|
||||
}
|
||||
log.info("处理完成");
|
||||
});
|
||||
try {
|
||||
MDC.put(Constant.TRACE_ID, IdUtil.getIdStr());
|
||||
List<GongfuDispatch> datas = dispatchService.lambdaQuery().eq(GongfuDispatch::getState, 0).list();
|
||||
log.info("共{}条记录", datas.size());
|
||||
String now = DateTimeUtil.format(LocalDate.now(), "yyyy-MM-dd");
|
||||
datas.forEach(data -> {
|
||||
log.info("开始处理{}:{}", data.getId(), data.getTitle());
|
||||
if (now.compareTo(data.getPlanStartDate()) >= 0) {
|
||||
log.info("设置为处理中");
|
||||
data.setState(1);
|
||||
dispatchService.updateById(data);
|
||||
}
|
||||
log.info("处理完成");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
log.error("设置状态失败", e);
|
||||
} finally {
|
||||
MDC.remove(Constant.TRACE_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue