REQ-2135: 更新日志
This commit is contained in:
parent
ee444b5898
commit
7a678c612a
@ -43,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -456,14 +457,19 @@ public class TodoManager {
|
||||
List<Todo> todos = builder.getQuery().list();
|
||||
// 通过日志反应状态推进失败的原因, 用于排查问题
|
||||
Runnable advanceFailLogger = () -> {
|
||||
ctx.addLogContent("stateAdvanced", false);
|
||||
List<Todo> noStateTodos = builder.getNoStateQuery()
|
||||
.orderByDesc(Todo::getId)
|
||||
.list();
|
||||
if (!noStateTodos.isEmpty())
|
||||
todoLogger.logTodosUpdated(ctx, noStateTodos);
|
||||
Todo currentStateSample = noStateTodos.isEmpty() ? null : noStateTodos.get(0);
|
||||
String reason = currentStateSample == null ? "没有找到对应的待办" : "起初状态不匹配";
|
||||
ctx.addLogContent("stateAdvanced", false);
|
||||
if (!noStateTodos.isEmpty()) {
|
||||
HashMap<String, Object> fail = new HashMap<>();
|
||||
fail.put("failReason", reason);
|
||||
fail.put("currentStateSample", currentStateSample);
|
||||
ctx.addLogContent("stateAdvanceFail", fail);
|
||||
todoLogger.logTodosUpdated(ctx, noStateTodos);
|
||||
}
|
||||
// throw an error? dunno
|
||||
log.warn("尝试推进待办状态, 但是 {}. ctx={}, query={}, currentStateSample={}",
|
||||
reason, ctx, QueryFormatter.format(builder.getQuery()), currentStateSample);
|
||||
@ -483,7 +489,7 @@ public class TodoManager {
|
||||
// rerun no state query in case of race condition
|
||||
if (updated)
|
||||
ctx.addLogContent("stateAdvanced", true);
|
||||
else
|
||||
else
|
||||
advanceFailLogger.run();
|
||||
Todo sample = todos.get(0);
|
||||
TodoBusiness business = todoBusinessDao.getById(sample.getTodoBusinessId());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user