Commit e406d60a by jx-art

Merge remote-tracking branch 'origin/feature-changeFlow-221110' into feature-changeFlow-221110

parents 90663abd acc199e3
Pipeline #43185 passed with stages
in 1 minute 33 seconds
/**
* @(#)FlowService.java, 2022/11/29.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.service.rpc;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.common.bean.CommonConstants;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.bean.ResponseCodeEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowxOperationEnum;
import com.netease.mail.yanxuan.change.integration.flow.FlowRpcService;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse;
import com.netease.yanxuan.flowx.sdk.meta.dto.base.FlowDataDTO;
import com.netease.yanxuan.flowx.sdk.meta.dto.flow.FlowCreateReqDTO;
import com.netease.yanxuan.flowx.sdk.meta.dto.flow.NodeSubmitReqDTO;
import lombok.extern.slf4j.Slf4j;
/**
* @Author zcwang
* @Date 2022/11/29
* 工单流转相关操作
*/
@Slf4j
@Component
public class FlowService {
@Autowired
private FlowRpcService flowRpcService;
/**
* 创建工单
* @param flowCreateReqDTO
* @return
*/
public String createFlow(FlowCreateReqDTO flowCreateReqDTO) {
// 先创建工单,创建完成后直接提交
log.info("[createFlow] flowCreateReqDTO={}", flowCreateReqDTO);
AjaxResponse<String> flowCreateResponse = flowRpcService.create(CommonConstants.FLOWX_PRODUCT,
flowCreateReqDTO);
String flowId;
if (ResponseCodeEnum.SUCCESS.getCode() == flowCreateResponse.getCode()) {
flowId = flowCreateResponse.getData();
log.info("[createFlow] flowId ={}", JSON.toJSONString(flowId));
} else {
log.error("[createFlow] create flow failed, query={}, errMsg={}", JSON.toJSONString(flowCreateReqDTO),
JSON.toJSONString(flowCreateResponse));
throw ExceptionFactory.createBiz(ResponseCode.CREATE_FLOW_ERROR, "创建工单错误");
}
return flowId;
}
/**
* 提交工单
* @param flowId
* @param flowDataDTO
* @param uid
* @param topoId
* @param content
* @param approved
* @return
*/
public String submitFlow(String flowId, FlowDataDTO flowDataDTO, String uid, String topoId, String content, boolean approved) {
NodeSubmitReqDTO nodeSubmitReqDTO = new NodeSubmitReqDTO();
nodeSubmitReqDTO.setFlowId(flowId);
nodeSubmitReqDTO.setNodeId(flowDataDTO.getFlowMeta().getCurrNodeDataList().get(0).getNodeId());
nodeSubmitReqDTO.setUid(uid);
nodeSubmitReqDTO.setUserName(uid);
nodeSubmitReqDTO.setTopoId(topoId);
nodeSubmitReqDTO.setContent(content);
nodeSubmitReqDTO.setOperateResult(FlowxOperationEnum.SUBMIT.getName());
nodeSubmitReqDTO.setCreateTime(System.currentTimeMillis());
nodeSubmitReqDTO.setApproved(approved);
nodeSubmitReqDTO.setOccLock(flowDataDTO.getOccLock() + 1);
log.info("[submitFlow] nodeSubmitReqDTO={}", JSON.toJSONString(nodeSubmitReqDTO));
List<String> nextNodeIdList;
// 提交工单
AjaxResponse<List<String>> submitResponse = flowRpcService.submit(CommonConstants.FLOWX_PRODUCT,
nodeSubmitReqDTO);
if (ResponseCodeEnum.SUCCESS.getCode() == submitResponse.getCode()) {
nextNodeIdList = submitResponse.getData();
log.info("[submitFlow] nextNodeIdList={}", JSON.toJSONString(nextNodeIdList));
} else {
log.error("[submitFlow] submit flow failed, query={}, errMsg={}", JSON.toJSONString(nodeSubmitReqDTO),
JSON.toJSONString(submitResponse));
throw ExceptionFactory.createBiz(ResponseCode.SUBMIT_FLOW_ERROR, "提交工单错误");
}
if (CollectionUtils.isEmpty(nextNodeIdList)) {
return ChangeFlowEnum.END.getNodeId();
}
return nextNodeIdList.get(0);
}
/**
* 查询工单详情
* @param flowId
* @return
*/
public FlowDataDTO flowDetail(String flowId) {
// 查询工单详情,根据详情提交
FlowDataDTO flowDataDTO;
AjaxResponse<FlowDataDTO> flowDetailResponse = flowRpcService.getDetail(CommonConstants.FLOWX_PRODUCT, flowId);
if (ResponseCodeEnum.SUCCESS.getCode() == flowDetailResponse.getCode()) {
flowDataDTO = flowDetailResponse.getData();
log.info("[detailFlow] flowDataDTO={}", JSON.toJSONString(flowDataDTO));
} else {
log.error("[detailFlow] get flow detail failed, query={}, errMsg={}", JSON.toJSONString(flowId),
JSON.toJSONString(flowDetailResponse));
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, "查询工单详情错误");
}
return flowDataDTO;
}
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
/**
* @Author zcwang
* @Date 2022/11/29
* 待办相关操作
*/
@Component
@Slf4j
......@@ -78,10 +79,12 @@ public class TodoService {
}
/**
* 完成代
* 处理待
* @param entity
* @param operateType
* @see OperateTypeEnum
*/
public void finishTodoTask(ChangeRecord entity) {
public void progressTodoTask(ChangeRecord entity, Integer operateType) {
String changeCommander = entity.getChangeCommander();
String flowId = String.valueOf(entity.getFlowId());
log.info("[finishSupplierTodoTask] taskFlowId={}, supplierId={}", flowId, changeCommander);
......
......@@ -19,6 +19,7 @@ import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.biz.ChangeFlowBiz;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.biz.service.rpc.FlowService;
import com.netease.mail.yanxuan.change.common.bean.CommonConstants;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowOperationTypeEnum;
......@@ -44,7 +45,7 @@ public class AutoSubmit extends IJobHandler {
private ChangeFlowService changeFlowService;
@Autowired
private ChangeFlowBiz changeFlowBiz;
private FlowService flowService;
@Override
public ReturnT<String> execute(String... strings) throws Exception {
......@@ -80,7 +81,7 @@ public class AutoSubmit extends IJobHandler {
// 执行变更节点,提交节点
if (ChangeFlowEnum.CHANGE_FLOW_EXE.getNodeId().equals(flowNode)) {
// 获取工单详情
FlowDataDTO flowDataDTO = changeFlowBiz.flowDetail(flowId.toString());
FlowDataDTO flowDataDTO = flowService.flowDetail(flowId.toString());
if (flowDataDTO == null) {
log.debug("[progressRecord] get flowDataDTO error, flowId{}", flowId);
}
......@@ -89,7 +90,7 @@ public class AutoSubmit extends IJobHandler {
content.put("updateTime", System.currentTimeMillis());
content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.PASS.getValue());
try {
String execNode = changeFlowBiz.submitFlow(flowId.toString(), flowDataDTO, uid,
String execNode = flowService.submitFlow(flowId.toString(), flowDataDTO, uid,
ChangeFlowEnum.CHANGE_FLOW_EXE.getTopoId(), JSON.toJSONString(content), true);
// 更新工单数据
changeRecord.setFlowNode(execNode);
......
......@@ -110,7 +110,7 @@ public class ChangeFlowVO {
/**
* 变更行动部门
*/
private List<ChangeFlowExecVO> changeExecDepartment;
private List<ChangeFlowExecVO> changeExecProjectList;
/**
* 变更行动部门列表
......
......@@ -12,9 +12,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.biz.ChangeFlowBiz;
import com.netease.mail.yanxuan.change.biz.service.rpc.TodoService;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
import com.netease.mail.yanxuan.change.common.enums.OperateTypeEnum;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import lombok.extern.slf4j.Slf4j;
......@@ -38,10 +38,10 @@ public class TestController {
return AjaxResult.success();
}
@PostMapping("/finishToDo")
public AjaxResult<Void> finishTodoTask(ChangeRecord entity) {
log.info("[createToDoTask] entity:{}", JSON.toJSONString(entity));
todoService.finishTodoTask(entity);
@PostMapping("/progressTodo")
public AjaxResult<Void> progressTodoTask(ChangeRecord entity, Integer operateType) {
log.info("[createToDoTask] entity:{}, operateType:{}", JSON.toJSONString(entity), operateType);
todoService.progressTodoTask(entity, operateType);
return AjaxResult.success();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment