Commit 029bf125 by 穆龙飞

modify:增加子工单创建逻辑

parent 79126ede
Pipeline #85333 passed with stages
in 1 minute 46 seconds
package com.netease.mail.yanxuan.change.biz.biz;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.biz.service.ChangeSubFlowService;
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.bean.RequestLocalBean;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowOperationTypeEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowxOperationEnum;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeSubFlowCreateReq;
import com.netease.yanxuan.flowx.sdk.meta.dto.flow.FlowCreateReqDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Component
@Slf4j
public class ChangeSubFlowBiz {
@Autowired
private ChangeSubFlowService changeSubFlowService;
@Autowired
private FlowService flowService;
public String createAndSubmit(@Valid ChangeSubFlowCreateReq changeSubFlowCreateReq) {
String uid = RequestLocalBean.getUid();
String name = RequestLocalBean.getName();
Map<String, Object> content = new HashMap<>(10);
content.put("createUserName", uid);
content.put("createUser", uid);
content.put("createTime", System.currentTimeMillis());
content.put("updateTime", System.currentTimeMillis());
content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.PASS.getValue());
String flowName = "";
// 组装工单创建数据
FlowCreateReqDTO flowCreateReqDTO = buildFlowCreateReqDTO(ChangeFlowEnum.CHANGE_SUB_FLOW.getTopoId(), uid,
JSON.toJSONString(content), FlowxOperationEnum.CREATE.getName(), name, flowName);
// 创建工单
String subFlowId = flowService.createFlow(flowCreateReqDTO);
ChangeExecRecord execRecord = new ChangeExecRecord();
changeSubFlowService.createSubFlow(execRecord);
return "";
}
private FlowCreateReqDTO buildFlowCreateReqDTO(String topoId, String uid, String content, String operateResult,
String name, String flowName) {
FlowCreateReqDTO flowCreateReqDTO = new FlowCreateReqDTO();
flowCreateReqDTO.setTopoId(topoId);
flowCreateReqDTO.setUid(uid);
flowCreateReqDTO.setUserName(name);
flowCreateReqDTO.setOperateResult(operateResult);
flowCreateReqDTO.setWorkOrderId(StringUtils.joinWith("-", topoId, UUID.randomUUID().toString()));
flowCreateReqDTO.setContent(content);
flowCreateReqDTO.setFlowName(flowName);
return flowCreateReqDTO;
}
}
package com.netease.mail.yanxuan.change.biz.service;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
public interface ChangeSubFlowService {
/**
* 创建子工单
*/
void createSubFlow(ChangeExecRecord execRecord);
}
package com.netease.mail.yanxuan.change.biz.service.impl;
import com.netease.mail.yanxuan.change.biz.service.ChangeSubFlowService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeExecRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ChangeSubFlowServiceImpl implements ChangeSubFlowService {
@Autowired
private ChangeExecRecordMapper changeExecRecordMapper;
@Override
public void createSubFlow(ChangeExecRecord execRecord) {
changeExecRecordMapper.insertSelective(execRecord);
}
}
...@@ -13,13 +13,36 @@ import lombok.Getter; ...@@ -13,13 +13,36 @@ import lombok.Getter;
* @Date 2022/11/16 * @Date 2022/11/16
*/ */
public enum ChangeFlowEnum { public enum ChangeFlowEnum {
/**
* 老工作流
*/
CHANGE_FLOW("0000", "全链路变更", "qc-change-flow"), CHANGE_FLOW("0000", "全链路变更", "qc-change-flow"),
CHANGE_FLOW_START("79560500", "开始节点", "qc-change-flow"), CHANGE_FLOW_START("79560500", "开始节点", "qc-change-flow"),
CHANGE_FLOW_SUBMIT("79560501", "变更申请提交", "qc-change-flow"), CHANGE_FLOW_SUBMIT("79560501", "变更申请提交", "qc-change-flow"),
CHANGE_FLOW_EXE("79560502","变更执行", "qc-change-flow"), CHANGE_FLOW_EXE("79560502","变更执行", "qc-change-flow"),
CHANGE_FLOW_CONFIRM("79560503","变更结果确认", "qc-change-flow"), CHANGE_FLOW_CONFIRM("79560503","变更结果确认", "qc-change-flow"),
END("9999", "结束", "qc-change-flow"); END("9999", "结束", "qc-change-flow"),
/**
* 新工作流
*/
NEW_CHANGE_FLOW("0000", "全链路变更", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_START("79560701", "提交变更申请", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_CONFIRM_EXEC_PLAN("79560702", "确认变更方案", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_OWNER_APPROVE("79560703","部门负责人审批", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_ADMIN_APPROVE("79560704","变更管理员审批", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_QUALITY_APPROVE("79560705","质量部负责人审批", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_EXE("79560706","执行变更方案", "yanxuan-qc-change-flow"),
NEW_CHANGE_FLOW_CONFIRM("79560707","确认变更结果", "yanxuan-qc-change-flow"),
NEW_END("9999", "结束", "yanxuan-qc-change-flow"),
/**
* 子工作流
*/
CHANGE_SUB_FLOW("0000", "全链路变更子工单", "qc-change-sub-flow"),
CHANGE_SUB_FLOW_START("79560601", "确认行动方案", "qc-change-sub-flow"),
CHANGE_SUB_FLOW_SUBMIT("79560602", "审批行动方案", "qc-change-sub-flow"),
CHANGE_SUB_FLOW_EXE("79560603","审批变更方案", "qc-change-sub-flow"),
CHANGE_SUB_FLOW_CONFIRM("79560604","提交执行结果", "qc-change-sub-flow"),
SUB_FLOW_END("9999", "结束", "qc-change-sub-flow");
@Getter @Getter
private final String nodeId; private final String nodeId;
......
/**
* @(#)ChangeFlowCreateReq.java, 2022/11/15.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.dal.meta.model.req;
import lombok.Data;
/**
* @Author zcwang
* @Date 2022/11/15
*/
@Data
public class ChangeSubFlowCreateReq {
}
\ No newline at end of file
/**
* @(#)ChangeFlowController.java, 2022/11/14.
* <p/>
* Copyright 2022 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.web.controller;
import com.netease.mail.yanxuan.change.biz.biz.ChangeSubFlowBiz;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeSubFlowCreateReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
* @Author zcwang
* @Date 2022/11/14
*/
@Slf4j
@RestController
@RequestMapping("/change/sub/flow")
public class ChangeSubFlowController {
@Autowired
private ChangeSubFlowBiz changeSubFlowBiz;
/**
* 发起变更执行工单
*
* @return
*/
@PostMapping("/create")
public AjaxResult<String> createAndSubmit(@RequestBody @Valid ChangeSubFlowCreateReq changeSubFlowCreateReq) {
return AjaxResult.success(changeSubFlowBiz.createAndSubmit(changeSubFlowCreateReq));
}
}
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