Commit 79cbb425 by jx-art

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

parents 1cd9d79c c6e60ed9
...@@ -10,6 +10,7 @@ import java.util.HashMap; ...@@ -10,6 +10,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -22,7 +23,6 @@ import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory; ...@@ -22,7 +23,6 @@ import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService; import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService; import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService;
import com.netease.mail.yanxuan.change.common.bean.CommonConstants; 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.bean.ResponseCode; 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.bean.ResponseCodeEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum; import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
...@@ -30,10 +30,9 @@ import com.netease.mail.yanxuan.change.common.enums.ChangeStatusEnum; ...@@ -30,10 +30,9 @@ import com.netease.mail.yanxuan.change.common.enums.ChangeStatusEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum; import com.netease.mail.yanxuan.change.common.enums.ChangeSubjectEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowOperationTypeEnum; import com.netease.mail.yanxuan.change.common.enums.FlowOperationTypeEnum;
import com.netease.mail.yanxuan.change.common.enums.FlowxOperationEnum; import com.netease.mail.yanxuan.change.common.enums.FlowxOperationEnum;
import com.netease.mail.yanxuan.change.common.enums.NeedFileEnum;
import com.netease.mail.yanxuan.change.common.util.DateUtils; import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord; import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq;
import com.netease.mail.yanxuan.change.integration.flow.FlowRpcService; 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.controller.communal.AjaxResponse;
...@@ -63,7 +62,7 @@ public class ChangeFlowBiz { ...@@ -63,7 +62,7 @@ public class ChangeFlowBiz {
@Autowired @Autowired
private FlowRpcService flowRpcService; private FlowRpcService flowRpcService;
public Boolean createAndSubmit(ChangeFlowCreateReq changeFlowCreateReq) { public List<String> createAndSubmit(ChangeFlowCreateReq changeFlowCreateReq) {
// String uid = RequestLocalBean.getUid(); // String uid = RequestLocalBean.getUid();
String uid = "1"; String uid = "1";
// String name = RequestLocalBean.getName(); // String name = RequestLocalBean.getName();
...@@ -91,35 +90,22 @@ public class ChangeFlowBiz { ...@@ -91,35 +90,22 @@ public class ChangeFlowBiz {
content.put("createTime", System.currentTimeMillis()); content.put("createTime", System.currentTimeMillis());
content.put("updateTime", System.currentTimeMillis()); content.put("updateTime", System.currentTimeMillis());
content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.PASS.getValue()); content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.PASS.getValue());
// 创建并提交工单 // 组装工单创建数据
createAndSubmitFlow(ChangeFlowEnum.CHANGE_FLOW_CONFIRM.getTopoId(), uid, name, JSON.toJSONString(content), FlowCreateReqDTO flowCreateReqDTO = buildFlowCreateReqDTO(ChangeFlowEnum.CHANGE_FLOW_CONFIRM.getTopoId(), uid, name, JSON.toJSONString(content),
FlowxOperationEnum.CREATE.getName()); FlowxOperationEnum.CREATE.getName());
// 创建工单
String flowId = createFlow(flowCreateReqDTO);
// 查询工单详情
FlowDataDTO flowDataDTO = detailFlow(flowId);
String nodeId = flowDataDTO.getFlowMeta().getCurrNodeDataList().get(0).getNodeId();
// 保存工单数据 // 保存工单数据
ChangeRecord changeRecord = buildRecord(changeFlowCreateReq); ChangeRecord changeRecord = buildRecord(flowId, nodeId, changeFlowCreateReq);
changeFlowService.saveRecord(changeRecord); changeFlowService.saveRecord(changeRecord);
return null; // 如果发起人=变更负责人
return submitFlow(flowId, nodeId, flowCreateReqDTO);
} }
private void createAndSubmitFlow(String topoId, String uid, String userName, String content, String operateResult) { private FlowDataDTO detailFlow(String flowId) {
// 先创建工单,创建完成后直接提交
FlowCreateReqDTO flowCreateReqDTO = new FlowCreateReqDTO();
flowCreateReqDTO.setTopoId(topoId);
flowCreateReqDTO.setUid(uid);
flowCreateReqDTO.setUserName(userName);
flowCreateReqDTO.setOperateResult(operateResult);
flowCreateReqDTO.setWorkOrderId(StringUtils.joinWith("-", topoId, UUID.randomUUID().toString()));
log.info("[createAndSubmitFlow] flowCreateReqDTO={}", flowCreateReqDTO);
AjaxResponse<String> flowCreateResponse = flowRpcService.create(CommonConstants.FLOWX_PRODUCT, flowCreateReqDTO);
String flowId;
if (ResponseCodeEnum.SUCCESS.getCode() == flowCreateResponse.getCode()) {
flowId = flowCreateResponse.getData();
log.info("[createAndSubmitFlow] flowId ={}", JSON.toJSONString(flowId));
} else {
log.error("[createAndSubmitFlow] create flow failed, query={}, errMsg={}", JSON.toJSONString(flowCreateReqDTO),
flowCreateResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.CREATE_FLOW_ERROR, flowCreateResponse.getErrorMsg());
}
// 查询工单详情,根据详情提交 // 查询工单详情,根据详情提交
FlowDataDTO flowDataDTO; FlowDataDTO flowDataDTO;
AjaxResponse<FlowDataDTO> flowDetailResponse = flowRpcService.getDetail(CommonConstants.FLOWX_PRODUCT, flowId); AjaxResponse<FlowDataDTO> flowDetailResponse = flowRpcService.getDetail(CommonConstants.FLOWX_PRODUCT, flowId);
...@@ -128,41 +114,78 @@ public class ChangeFlowBiz { ...@@ -128,41 +114,78 @@ public class ChangeFlowBiz {
log.info("[createAndSubmitFlow] flowDataDTO={}", JSON.toJSONString(flowDataDTO)); log.info("[createAndSubmitFlow] flowDataDTO={}", JSON.toJSONString(flowDataDTO));
} else { } else {
log.error("[createAndSubmitFlow] get flow detail failed, query={}, errMsg={}", JSON.toJSONString(flowId), log.error("[createAndSubmitFlow] get flow detail failed, query={}, errMsg={}", JSON.toJSONString(flowId),
flowCreateResponse.getErrorMsg()); flowDetailResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, flowCreateResponse.getErrorMsg()); throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, flowDetailResponse.getErrorMsg());
} }
return flowDataDTO;
}
private FlowCreateReqDTO buildFlowCreateReqDTO(String topoId, String uid, String userName, String content, String operateResult) {
FlowCreateReqDTO flowCreateReqDTO = new FlowCreateReqDTO();
flowCreateReqDTO.setTopoId(topoId);
flowCreateReqDTO.setUid(uid);
flowCreateReqDTO.setUserName(userName);
flowCreateReqDTO.setOperateResult(operateResult);
flowCreateReqDTO.setWorkOrderId(StringUtils.joinWith("-", topoId, UUID.randomUUID().toString()));
return flowCreateReqDTO;
}
private List<String> submitFlow(String flowId, String nodeId, FlowCreateReqDTO flowCreateReqDTO) {
NodeSubmitReqDTO nodeSubmitReqDTO = new NodeSubmitReqDTO(); NodeSubmitReqDTO nodeSubmitReqDTO = new NodeSubmitReqDTO();
nodeSubmitReqDTO.setNodeId(flowDataDTO.getFlowMeta().getCurrNodeDataList().get(0).getNodeId()); nodeSubmitReqDTO.setFlowId(flowId);
nodeSubmitReqDTO.setNodeId(nodeId);
nodeSubmitReqDTO.setUid(flowCreateReqDTO.getUid()); nodeSubmitReqDTO.setUid(flowCreateReqDTO.getUid());
nodeSubmitReqDTO.setUserName(flowCreateReqDTO.getUserName()); nodeSubmitReqDTO.setUserName(flowCreateReqDTO.getUserName());
nodeSubmitReqDTO.setFlowId(flowId); nodeSubmitReqDTO.setFlowId(flowId);
nodeSubmitReqDTO.setTopoId(flowCreateReqDTO.getTopoId()); nodeSubmitReqDTO.setTopoId(flowCreateReqDTO.getTopoId());
nodeSubmitReqDTO.setContent(flowCreateReqDTO.getContent()); nodeSubmitReqDTO.setContent(flowCreateReqDTO.getContent());
nodeSubmitReqDTO.setOperateResult(FlowxOperationEnum.CREATE.getName()); nodeSubmitReqDTO.setOperateResult(FlowxOperationEnum.SUBMIT.getName());
nodeSubmitReqDTO.setCreateTime(System.currentTimeMillis());
nodeSubmitReqDTO.setApproved(true);
List<String> nextNodeIdList;
// 提交工单 // 提交工单
AjaxResponse<List<String>> submitResponse = flowRpcService.submit(CommonConstants.FLOWX_PRODUCT, flowId); AjaxResponse<List<String>> submitResponse = flowRpcService.submit(CommonConstants.FLOWX_PRODUCT, nodeSubmitReqDTO);
if (ResponseCodeEnum.SUCCESS.getCode() == flowDetailResponse.getCode()) { if (ResponseCodeEnum.SUCCESS.getCode() == submitResponse.getCode()) {
List<String> nextNodeIdList = submitResponse.getData(); nextNodeIdList = submitResponse.getData();
log.info("[createAndSubmitFlow] nextNodeIdList={}", JSON.toJSONString(nextNodeIdList)); log.info("[createAndSubmitFlow] nextNodeIdList={}", JSON.toJSONString(nextNodeIdList));
} else { } else {
log.error("[createAndSubmitFlow] submit flow failed, query={}, errMsg={}", JSON.toJSONString(flowId), log.error("[createAndSubmitFlow] submit flow failed, query={}, errMsg={}", JSON.toJSONString(flowId),
submitResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.SUBMIT_FLOW_ERROR, submitResponse.getErrorMsg());
}
return nextNodeIdList;
}
private String createFlow(FlowCreateReqDTO flowCreateReqDTO) {
// 先创建工单,创建完成后直接提交
log.info("[createAndSubmitFlow] flowCreateReqDTO={}", flowCreateReqDTO);
AjaxResponse<String> flowCreateResponse = flowRpcService.create(CommonConstants.FLOWX_PRODUCT, flowCreateReqDTO);
String flowId;
if (ResponseCodeEnum.SUCCESS.getCode() == flowCreateResponse.getCode()) {
flowId = flowCreateResponse.getData();
log.info("[createAndSubmitFlow] flowId ={}", JSON.toJSONString(flowId));
} else {
log.error("[createAndSubmitFlow] create flow failed, query={}, errMsg={}", JSON.toJSONString(flowCreateReqDTO),
flowCreateResponse.getErrorMsg()); flowCreateResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.SUBMIT_FLOW_ERROR, flowCreateResponse.getErrorMsg()); throw ExceptionFactory.createBiz(ResponseCode.CREATE_FLOW_ERROR, flowCreateResponse.getErrorMsg());
} }
return flowId;
} }
private ChangeRecord buildRecord(ChangeFlowCreateReq changeFlowCreateReq) { private ChangeRecord buildRecord(String flowId, String nodeId, ChangeFlowCreateReq changeFlowCreateReq) {
ChangeRecord changeRecord = new ChangeRecord(); ChangeRecord changeRecord = new ChangeRecord();
// todo changeRecord.setFlowId(Long.parseLong(flowId));
changeRecord.setFlowId(1L); changeRecord.setFlowNode(nodeId);
// todo
changeRecord.setFlowNode("1");
changeRecord.setChangeSubject(changeFlowCreateReq.getChangeSubject()); changeRecord.setChangeSubject(changeFlowCreateReq.getChangeSubject());
changeRecord.setParentChangeClassId(changeFlowCreateReq.getParentChangeClassId()); changeRecord.setParentChangeClassId(changeFlowCreateReq.getParentChangeClassId());
changeRecord.setSonChangeClassId(changeFlowCreateReq.getSonChangeClassId()); changeRecord.setSonChangeClassId(changeFlowCreateReq.getSonChangeClassId());
changeRecord.setChangeLevel(changeFlowCreateReq.getChangeLevel()); changeRecord.setChangeLevel(changeFlowCreateReq.getChangeLevel());
changeRecord.setChangeCommander(changeFlowCreateReq.getChangeCommander()); changeRecord.setChangeCommander(changeFlowCreateReq.getChangeCommander());
changeRecord.setChangeDepartment(changeFlowCreateReq.getChangeDepartment());
List<ChangeExecConfigReq> changeExecProject = changeFlowCreateReq.getChangeExecProject();
List<String> execDepartmentList = changeExecProject.stream().map(ChangeExecConfigReq::getChangeExecDepartment)
.collect(Collectors.toList());
changeRecord.setParticipateChangeExecDepartment(JSON.toJSONString(execDepartmentList));
changeRecord.setChangeItem(changeFlowCreateReq.getChangeItems()); changeRecord.setChangeItem(changeFlowCreateReq.getChangeItems());
changeRecord.setChangeSupplier(changeFlowCreateReq.getChangeSupplier()); changeRecord.setChangeSupplier(changeFlowCreateReq.getChangeSupplier());
changeRecord.setChangeReason(changeFlowCreateReq.getChangeReason()); changeRecord.setChangeReason(changeFlowCreateReq.getChangeReason());
......
...@@ -22,5 +22,5 @@ public interface ChangeFlowService { ...@@ -22,5 +22,5 @@ public interface ChangeFlowService {
*/ */
TitleConfig getTitleConfig(); TitleConfig getTitleConfig();
Integer saveRecord(ChangeRecord changeRecord); Boolean saveRecord(ChangeRecord changeRecord);
} }
\ No newline at end of file
...@@ -35,7 +35,7 @@ public class ChangeFlowServiceImpl implements ChangeFlowService { ...@@ -35,7 +35,7 @@ public class ChangeFlowServiceImpl implements ChangeFlowService {
} }
@Override @Override
public Integer saveRecord(ChangeRecord changeRecord) { public Boolean saveRecord(ChangeRecord changeRecord) {
return changeRecordMapper.insertSelective(changeRecord); return changeRecordMapper.insertSelective(changeRecord) > 0;
} }
} }
\ No newline at end of file
...@@ -14,11 +14,12 @@ import lombok.Getter; ...@@ -14,11 +14,12 @@ import lombok.Getter;
*/ */
public enum ChangeFlowEnum { public enum ChangeFlowEnum {
CHANGE_FLOW_START("79560500", "开始节点", "qc-change-flow"), CHANGE_FLOW_START("79560500", "开始节点", "yanxuan-qc-change-flow"),
CHANGE_FLOW_SUBMIT("79560501", "变更申请提交", "qc-change-flow"), CHANGE_FLOW_SUBMIT("79560501", "发起变更", "yanxuan-qc-change-flow"),
CHANGE_FLOW_EXE("79560503","变更结果确认", "qc-change-flow"), CHANGE_FLOW_EXE("79560502","变更执行", "yanxuan-qc-change-flow"),
CHANGE_FLOW_CONFIRM("79560502","变更申请提交", "qc-change-flow"), CHANGE_FLOW_CONFIRM("79560503","变更结果确认", "yanxuan-qc-change-flow"),
END("9999", "结束", "qc-change-flow"); CHANGE_FLOW_CHANGE_SUBMIT("79560504","变更申请提交", "yanxuan-qc-change-flow"),
END("9999", "结束", "yanxuan-qc-change-flow");
@Getter @Getter
private final String nodeId; private final String nodeId;
......
...@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse; 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.base.FlowDataDTO;
import com.netease.yanxuan.flowx.sdk.meta.dto.flow.FlowCreateReqDTO; import com.netease.yanxuan.flowx.sdk.meta.dto.flow.FlowCreateReqDTO;
import com.netease.yanxuan.flowx.sdk.meta.dto.flow.NodeSubmitReqDTO;
import com.netease.yanxuan.missa.client.annotation.MissaClient; import com.netease.yanxuan.missa.client.annotation.MissaClient;
/** /**
...@@ -24,7 +25,7 @@ import com.netease.yanxuan.missa.client.annotation.MissaClient; ...@@ -24,7 +25,7 @@ import com.netease.yanxuan.missa.client.annotation.MissaClient;
* @Date 2022/11/16 * @Date 2022/11/16
*/ */
@Service @Service
@MissaClient(serviceCode = "yanxuan-flowx-server.service") @MissaClient(serviceCode = "yanxuan-flowx-server")
public interface FlowRpcService { public interface FlowRpcService {
/** /**
...@@ -41,6 +42,13 @@ public interface FlowRpcService { ...@@ -41,6 +42,13 @@ public interface FlowRpcService {
AjaxResponse<FlowDataDTO> getDetail(@PathVariable("product") String flowxProduct, AjaxResponse<FlowDataDTO> getDetail(@PathVariable("product") String flowxProduct,
@PathVariable("flowId") String flowId); @PathVariable("flowId") String flowId);
/**
* 工单提交
* @param flowxProduct
* @param nodeSubmitReqDTO
* @return
*/
@PostMapping(value = "/{product}/workOrderFlow/v1/submit") @PostMapping(value = "/{product}/workOrderFlow/v1/submit")
AjaxResponse<List<String>> submit(@PathVariable("product") String flowxProduct, String flowId); AjaxResponse<List<String>> submit(@PathVariable("product") String flowxProduct, NodeSubmitReqDTO nodeSubmitReqDTO);
} }
/**
* @(#)WorkflowApproveDTO.java, 2021年1月19日.
*
* Copyright 2021 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.integration.flow;
import java.util.Map;
public class FlowxSubmitDTO {
private String topoId;
/**
* 流程id
*/
private String flowId;
/**
* 当前节点
*/
private String currentNodeId;
/**
* 审核节点时是审核通过与否,自动执行节点时是执行成功与否
*/
private boolean approved;
/**
* 用户id
*/
private String uid;
/**
* 用户名
*/
private String userName;
/**
* 业务数据
*/
private String content;
/**
* 网关使用的判断条件传入
*/
private Map<String, Object> paramMap;
/**
* 审核节点时是不通过理由,自动执行节点时是执行结果描述
*/
private String rejectReason;
private String extension;
/**
* 操作结果
*/
private String operateResult;
private String approveFormExtensionInfo;
/**
* 备注
*/
private String remark;
public String getApproveFormExtensionInfo() {
return approveFormExtensionInfo;
}
public void setApproveFormExtensionInfo(String approveFormExtensionInfo) {
this.approveFormExtensionInfo = approveFormExtensionInfo;
}
public String getOperateResult() {
return operateResult;
}
public void setOperateResult(String operateResult) {
this.operateResult = operateResult;
}
public String getTopoId() {
return topoId;
}
public void setTopoId(String topoId) {
this.topoId = topoId;
}
public String getFlowId() {
return flowId;
}
public void setFlowId(String flowId) {
this.flowId = flowId;
}
public String getCurrentNodeId() {
return currentNodeId;
}
public void setCurrentNodeId(String currentNodeId) {
this.currentNodeId = currentNodeId;
}
public boolean isApproved() {
return approved;
}
public void setApproved(boolean approved) {
this.approved = approved;
}
public String getRejectReason() {
return rejectReason;
}
public void setRejectReason(String rejectReason) {
this.rejectReason = rejectReason;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Map<String, Object> getParamMap() {
return paramMap;
}
public void setParamMap(Map<String, Object> paramMap) {
this.paramMap = paramMap;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
*/ */
package com.netease.mail.yanxuan.change.web.controller; package com.netease.mail.yanxuan.change.web.controller;
import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -73,7 +75,7 @@ public class ChangeFlowController { ...@@ -73,7 +75,7 @@ public class ChangeFlowController {
* @return * @return
*/ */
@PostMapping("/create") @PostMapping("/create")
public AjaxResult<Boolean> createAndSubmit(@RequestBody @Valid ChangeFlowCreateReq changeFlowCreateReq) { public AjaxResult<List<String>> createAndSubmit(@RequestBody @Valid ChangeFlowCreateReq changeFlowCreateReq) {
log.info("[createAndSubmit] createAndSubmit req={}", JSON.toJSONString(changeFlowCreateReq)); log.info("[createAndSubmit] createAndSubmit req={}", JSON.toJSONString(changeFlowCreateReq));
return AjaxResult.success(changeFlowBiz.createAndSubmit(changeFlowCreateReq)); return AjaxResult.success(changeFlowBiz.createAndSubmit(changeFlowCreateReq));
} }
......
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