REQ-2453: fix set processing issue

This commit is contained in:
yanglin 2024-06-24 17:59:04 +08:00
parent 6c6d9e0346
commit 0fc83d0ed9
2 changed files with 21 additions and 8 deletions

View File

@ -20,7 +20,6 @@ import cn.axzo.msg.center.message.service.MessageTemplateNewService;
import cn.axzo.msg.center.message.service.todo.manage.broadcast.TodoBroadcaster; import cn.axzo.msg.center.message.service.todo.manage.broadcast.TodoBroadcaster;
import cn.axzo.msg.center.message.service.todo.manage.broadcast.TodoMqBroadcaster; import cn.axzo.msg.center.message.service.todo.manage.broadcast.TodoMqBroadcaster;
import cn.axzo.msg.center.message.service.todo.manage.event.HandoverEvent; import cn.axzo.msg.center.message.service.todo.manage.event.HandoverEvent;
import cn.axzo.msg.center.message.service.todo.manage.broadcast.TodoBroadcaster;
import cn.axzo.msg.center.message.service.todo.manage.event.NewTodoEvent; import cn.axzo.msg.center.message.service.todo.manage.event.NewTodoEvent;
import cn.axzo.msg.center.mq.MqMessageRecord; import cn.axzo.msg.center.mq.MqMessageRecord;
import cn.axzo.msg.center.mq.MqMessageType; import cn.axzo.msg.center.mq.MqMessageType;
@ -45,7 +44,6 @@ import cn.axzo.msg.center.service.util.JSONUtils;
import cn.axzo.msg.center.utils.DateFormatUtil; import cn.axzo.msg.center.utils.DateFormatUtil;
import cn.axzo.msg.center.utils.QueryFormatter; import cn.axzo.msg.center.utils.QueryFormatter;
import cn.axzo.msg.center.utils.UUIDUtil; import cn.axzo.msg.center.utils.UUIDUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -68,7 +66,6 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
@ -465,14 +462,19 @@ public class TodoManager {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean batchSetProcessing(List<String> identityCodes, List<String> subBizCodes) { public Boolean batchSetProcessing(List<String> identityCodes, List<String> subBizCodes) {
log.info("batch set processing...,request:{}", JSONUtil.toJsonStr(identityCodes)); BizAssertions.assertTrue(
BizAssertions.assertTrue(CollectionUtils.isNotEmpty(identityCodes), "identityCodes列表不能为空"); CollectionUtils.isNotEmpty(identityCodes) || CollectionUtils.isNotEmpty(subBizCodes) ,
"identityCodes或subBizCodes列表不能为空");
List<Todo> todos;
if (CollectionUtils.isNotEmpty(identityCodes))
todos = todoDao.getByIdentityCodes(identityCodes);
else
todos = todoDao.getBySubBizCodes(subBizCodes, true);
Boolean updated = todoDao.batchSetExecutableProcessing(identityCodes, subBizCodes); Boolean updated = todoDao.batchSetExecutableProcessing(identityCodes, subBizCodes);
if (updated) { if (updated) {
List<Todo> updatedTodos = todoDao.getByIdentityCodes(identityCodes);
TodoRequestContext ctx = TodoRequestContext.create("batchSetProcessing", identityCodes); TodoRequestContext ctx = TodoRequestContext.create("batchSetProcessing", identityCodes);
todoLogger.logSetTodoProcessing(ctx, updatedTodos); todoLogger.logSetTodoProcessing(ctx, todos);
todoBroadcaster.fireTodoUpdates("batchSetProcessing", updatedTodos); todoBroadcaster.fireTodoUpdates("batchSetProcessing", todos);
} }
return updated; return updated;
} }

View File

@ -61,6 +61,17 @@ public class TodoDao extends ServiceImpl<TodoMapper, Todo> {
return Optional.ofNullable(todo); return Optional.ofNullable(todo);
} }
public List<Todo> getBySubBizCodes(List<String> subBizCodes, boolean toBeDoneOnly) {
if (CollectionUtils.isEmpty(subBizCodes))
return Collections.emptyList();
return lambdaQuery()
.in(Todo::getSubBizCode, subBizCodes)
.in(toBeDoneOnly, Todo::getState,
PendingMessageStateEnum.HAS_BEEN_SENT, PendingMessageStateEnum.PROCESSING)
.eq(Todo::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list();
}
public List<Todo> getBySubBizCode(String subBizCode) { public List<Todo> getBySubBizCode(String subBizCode) {
return lambdaQuery() return lambdaQuery()
.eq(Todo::getSubBizCode, subBizCode) .eq(Todo::getSubBizCode, subBizCode)