update - 完善接口 method 映射问题,同时新增发送消息时业务分类的名称广播

This commit is contained in:
wangli 2023-11-30 10:26:05 +08:00
parent 31c4b4f544
commit 231c8b3c15
5 changed files with 36 additions and 2 deletions

View File

@ -15,6 +15,8 @@ public enum BpmnErrorCode implements IProjectRespCode {
// ========== category 01-001 ==========
CATEGORY_VALUE_EXISTS("01001", "分类值【{}】已经存在"),
CATEGORY_ID_NOT_EXISTS("01002", "指定分类【{}】不存在"),
CATEGORY_DATA_ERROR("01003", "分类数据异常"),
// ========== convertor 02-001 ==========
CONVERTOR_UNKNOW_NODE_TYPE("02001", "节点类型【{}】暂不支持"),
CONVERTOR_META_DATA_FORMAT_ERROR("02002", "JSON 数据格式有误"),

View File

@ -8,10 +8,19 @@ import cn.axzo.workflow.common.model.response.BpmPageResult;
import cn.axzo.workflow.common.model.response.category.CategoryItemVO;
import java.util.List;
import java.util.Optional;
public interface CategoryService {
/**
* 获取指定分类
*
* @param type
* @param value
* @return
*/
Optional<CategoryItemVO> get(String type, String value);
/**
* 创建
*

View File

@ -18,12 +18,14 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static cn.axzo.workflow.core.common.enums.BpmnErrorCode.CATEGORY_DATA_ERROR;
import static cn.axzo.workflow.core.common.enums.BpmnErrorCode.CATEGORY_ID_NOT_EXISTS;
import static cn.axzo.workflow.core.common.enums.BpmnErrorCode.CATEGORY_VALUE_EXISTS;
@ -36,6 +38,20 @@ public class CategoryServiceImpl extends ServiceImpl<ExtAxDictMapper, ExtAxDict>
private final CategoryConverter categoryConverter;
@Override
public Optional<CategoryItemVO> get(String type, String value) {
List<ExtAxDict> list = this.lambdaQuery().eq(ExtAxDict::getType, type)
.eq(ExtAxDict::getValue, value)
.list();
if (CollectionUtils.isEmpty(list)) {
return Optional.empty();
} else if (list.size() > 1) {
throw new WorkflowEngineException(CATEGORY_DATA_ERROR, value);
} else {
return Optional.of(categoryConverter.toVo(list.get(0)));
}
}
@Override
public CategoryItemVO createCategory(CategoryCreateDTO dto) {
Optional<ExtAxDict> oneOpt = this.lambdaQuery().eq(ExtAxDict::getLabel, dto.getLabel())

View File

@ -10,6 +10,7 @@ import cn.axzo.workflow.common.model.response.mq.MessagePushDTO;
import cn.axzo.workflow.core.engine.event.MessagePushEvent;
import cn.axzo.workflow.core.listener.BpmnMessagePushEventListener;
import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
import cn.axzo.workflow.core.service.CategoryService;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
@ -30,6 +31,7 @@ import java.util.Map;
import java.util.Objects;
import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_ORG_RELATION;
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
import static cn.axzo.workflow.common.constant.BpmnConstants.COUNTERSIGN_ORIGIN_ASSIGNER;
import static cn.axzo.workflow.common.constant.BpmnConstants.COUNTERSIGN_REMAIN_ASSIGNER_LIST;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_DELETE_PROCESS_FLAG;
@ -77,6 +79,8 @@ public class RocketMqMessagePushEventListener implements BpmnMessagePushEventLis
private BpmnProcessInstanceService processInstanceService;
@Resource
private HistoryService historyService;
@Resource
private CategoryService categoryService;
@Value("${sendMq:true}")
private Boolean sendMQ;
@ -173,7 +177,9 @@ public class RocketMqMessagePushEventListener implements BpmnMessagePushEventLis
variables.put(VAR_TASK_START_TIME, sdf.format(tasks.get(0).getCreateTime()));
// TODO 操作类型 同意驳回加签评论转交等
variables.put(VAR_OPERATOR_TYPE, "");
variables.put(VAR_BUSINESS_NAME, "");
categoryService.get(BPM_MODEL_CATEGORY, processInstance.getCategory()).ifPresent(category -> {
variables.put(VAR_BUSINESS_NAME, category.getLabel());
});
// 传递业务的参数
REMOVE_KEYS.forEach(originVariables::remove);

View File

@ -51,8 +51,9 @@ public class ProcessCategoryController implements ProcessCategoryApi {
return success(categoryService.get(id));
}
@GetMapping("/getByIds")
@Override
public CommonResponse<List<CategoryItemVO>> getByIds(List<Long> ids) {
public CommonResponse<List<CategoryItemVO>> getByIds(@RequestParam List<Long> ids) {
return success(categoryService.getIds(ids));
}