Commit 397f29e2 by “zcwang”

数据落库

parent f99bd994
......@@ -10,6 +10,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -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.change.ChangeConfigService;
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.ResponseCodeEnum;
import com.netease.mail.yanxuan.change.common.enums.ChangeFlowEnum;
......@@ -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.FlowOperationTypeEnum;
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.dal.entity.ChangeConfig;
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.integration.flow.FlowRpcService;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse;
......@@ -91,35 +90,30 @@ public class ChangeFlowBiz {
content.put("createTime", System.currentTimeMillis());
content.put("updateTime", System.currentTimeMillis());
content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.PASS.getValue());
// 创建并提交工单
createAndSubmitFlow(ChangeFlowEnum.CHANGE_FLOW_CONFIRM.getTopoId(), uid, name, JSON.toJSONString(content),
FlowxOperationEnum.CREATE.getName());
// 组装工单创建数据
FlowCreateReqDTO flowCreateReqDTO = buildFlowCreateReqDTO(ChangeFlowEnum.CHANGE_FLOW_CONFIRM.getTopoId(), uid, name, JSON.toJSONString(content),
FlowxOperationEnum.CREATE.getName());
// 创建工单
String flowId = createFlow(flowCreateReqDTO);
// 提交工单
String nodeId = submitFlow(flowId, flowCreateReqDTO);
// 保存工单数据
ChangeRecord changeRecord = buildRecord(changeFlowCreateReq);
ChangeRecord changeRecord = buildRecord(flowId, nodeId, changeFlowCreateReq);
changeFlowService.saveRecord(changeRecord);
return null;
}
private void createAndSubmitFlow(String topoId, String uid, String userName, String content, String operateResult) {
// 先创建工单,创建完成后直接提交
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()));
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());
}
return flowCreateReqDTO;
}
private String submitFlow(String flowId, FlowCreateReqDTO flowCreateReqDTO) {
// 查询工单详情,根据详情提交
FlowDataDTO flowDataDTO;
AjaxResponse<FlowDataDTO> flowDetailResponse = flowRpcService.getDetail(CommonConstants.FLOWX_PRODUCT, flowId);
......@@ -128,8 +122,8 @@ public class ChangeFlowBiz {
log.info("[createAndSubmitFlow] flowDataDTO={}", JSON.toJSONString(flowDataDTO));
} else {
log.error("[createAndSubmitFlow] get flow detail failed, query={}, errMsg={}", JSON.toJSONString(flowId),
flowCreateResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, flowCreateResponse.getErrorMsg());
flowDetailResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, flowDetailResponse.getErrorMsg());
}
NodeSubmitReqDTO nodeSubmitReqDTO = new NodeSubmitReqDTO();
......@@ -139,30 +133,51 @@ public class ChangeFlowBiz {
nodeSubmitReqDTO.setFlowId(flowId);
nodeSubmitReqDTO.setTopoId(flowCreateReqDTO.getTopoId());
nodeSubmitReqDTO.setContent(flowCreateReqDTO.getContent());
nodeSubmitReqDTO.setOperateResult(FlowxOperationEnum.CREATE.getName());
nodeSubmitReqDTO.setOperateResult(FlowxOperationEnum.SUBMIT.getName());
List<String> nextNodeIdList;
// 提交工单
AjaxResponse<List<String>> submitResponse = flowRpcService.submit(CommonConstants.FLOWX_PRODUCT, flowId);
if (ResponseCodeEnum.SUCCESS.getCode() == flowDetailResponse.getCode()) {
List<String> nextNodeIdList = submitResponse.getData();
nextNodeIdList = submitResponse.getData();
log.info("[createAndSubmitFlow] nextNodeIdList={}", JSON.toJSONString(nextNodeIdList));
} else {
log.error("[createAndSubmitFlow] submit flow failed, query={}, errMsg={}", JSON.toJSONString(flowId),
submitResponse.getErrorMsg());
throw ExceptionFactory.createBiz(ResponseCode.SUBMIT_FLOW_ERROR, submitResponse.getErrorMsg());
}
return nextNodeIdList.get(0);
}
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());
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();
// todo
changeRecord.setFlowId(1L);
// todo
changeRecord.setFlowNode("1");
changeRecord.setFlowId(Long.parseLong(flowId));
changeRecord.setFlowNode(nodeId);
changeRecord.setChangeSubject(changeFlowCreateReq.getChangeSubject());
changeRecord.setParentChangeClassId(changeFlowCreateReq.getParentChangeClassId());
changeRecord.setSonChangeClassId(changeFlowCreateReq.getSonChangeClassId());
changeRecord.setChangeLevel(changeFlowCreateReq.getChangeLevel());
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.setChangeSupplier(changeFlowCreateReq.getChangeSupplier());
changeRecord.setChangeReason(changeFlowCreateReq.getChangeReason());
......
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