Commit feb96a57 by “zcwang”

modify: 取消变更

parent 933e7902
......@@ -107,12 +107,12 @@ public class ChangeFlowBiz {
// 如果发起人=变更负责人
if (true) {
List<String> nextNodeIdList = submitFlow(flowId, flowDataDTO, uid,
String nextNodeId = submitFlow(flowId, flowDataDTO, uid,
ChangeFlowEnum.CHANGE_FLOW_START.getTopoId(), JSON.toJSONString(content));
if (CollectionUtils.isEmpty(nextNodeIdList)) {
if (null == nextNodeId) {
throw ExceptionFactory.createBiz(ResponseCode.SUBMIT_FLOW_ERROR, "首次提交节点失败");
}
return nextNodeIdList.get(0);
return nextNodeId;
}
return flowId;
}
......@@ -159,7 +159,7 @@ public class ChangeFlowBiz {
return flowCreateReqDTO;
}
private List<String> submitFlow(String flowId, FlowDataDTO flowDataDTO, String uid, String topoId, String content) {
private String submitFlow(String flowId, FlowDataDTO flowDataDTO, String uid, String topoId, String content) {
NodeSubmitReqDTO nodeSubmitReqDTO = new NodeSubmitReqDTO();
nodeSubmitReqDTO.setFlowId(flowId);
nodeSubmitReqDTO.setNodeId(flowDataDTO.getFlowMeta().getCurrNodeDataList().get(0).getNodeId());
......@@ -184,7 +184,10 @@ public class ChangeFlowBiz {
JSON.toJSONString(submitResponse));
throw ExceptionFactory.createBiz(ResponseCode.SUBMIT_FLOW_ERROR, "提交工单错误");
}
return nextNodeIdList;
if (CollectionUtils.isEmpty(nextNodeIdList)) {
return ChangeFlowEnum.END.getNodeId();
}
return nextNodeIdList.get(0);
}
private String createFlow(FlowCreateReqDTO flowCreateReqDTO) {
......@@ -245,14 +248,9 @@ public class ChangeFlowBiz {
log.info("[submitFlow] changeFlowReq:{}", JSON.toJSONString(changeFlowSubmitReq));
Long flowId = changeFlowSubmitReq.getFlowId();
// 查询工单有效性
ChangeRecord changeRecord = changeFlowService.getByFlowId(flowId);
if (changeRecord == null) {
throw ExceptionFactory.createBiz(ResponseCode.ERROR_FLOW_ID, "工单id不存在");
}
if (!changeRecord.getFlowNode().equals(changeFlowSubmitReq.getCurrentNodeId())) {
throw ExceptionFactory.createBiz(ResponseCode.NODE_ERROR, "工单已流转至其他节点");
}
ChangeRecord changeRecord = this.checkFlow(flowId, changeFlowSubmitReq.getCurrentNodeId());
// todo:检验操作权限
// String uid = RequestLocalBean.getUid();
String uid = "1";
String changeCommander = changeRecord.getChangeCommander();
......@@ -261,20 +259,54 @@ public class ChangeFlowBiz {
}
// 获取工单详情
FlowDataDTO flowDataDTO = this.flowDetail(flowId.toString());
if (flowDataDTO == null) {
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, "工单查询错误,不存在");
}
// 工单流传
Map<String, Object> content = new HashMap<>(CommonConstants.INIT_HASH_MAP_SIZE);
content.put("updateTime", System.currentTimeMillis());
content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.PASS.getValue());
List<String> nextNodeList = this.submitFlow(flowId.toString(), flowDataDTO, uid,
return this.submitFlow(flowId.toString(), flowDataDTO, uid,
ChangeFlowEnum.CHANGE_FLOW_SUBMIT.getTopoId(), JSON.toJSONString(content));
if (CollectionUtils.isEmpty(nextNodeList)) {
return ChangeFlowEnum.END.getNodeId();
}
return nextNodeList.get(0);
private ChangeRecord checkFlow(Long flowId, String currentNodeId) {
ChangeRecord changeRecord = changeFlowService.getByFlowId(flowId);
if (changeRecord == null) {
throw ExceptionFactory.createBiz(ResponseCode.ERROR_FLOW_ID, "工单id不存在");
}
if (!changeRecord.getFlowNode().equals(currentNodeId)) {
throw ExceptionFactory.createBiz(ResponseCode.NODE_ERROR, "工单已流转至其他节点");
}
return changeRecord;
}
public Boolean cancel(ChangeFlowCancelReq req) {
log.info("[cancel] req:{}", JSON.toJSONString(req));
Long flowId = req.getFlowId();
// 查询工单有效性
ChangeRecord changeRecord = checkFlow(flowId, ChangeFlowEnum.CHANGE_FLOW_EXE.getNodeId());
// todo:检查审核人
// 获取工单详情
FlowDataDTO flowDataDTO = this.flowDetail(flowId.toString());
if (flowDataDTO == null) {
throw ExceptionFactory.createBiz(ResponseCode.DETAIL_FLOW_ERROR, "工单查询错误,不存在");
}
// 工单流转
Map<String, Object> content = new HashMap<>(CommonConstants.INIT_HASH_MAP_SIZE);
content.put("updateTime", System.currentTimeMillis());
content.put(CommonConstants.FLOW_OPERATION_KEY, FlowOperationTypeEnum.REFUSE.getValue());
// String uid = RequestLocalBean.getUid();
String uid = "1";
String nextNodeId = this.submitFlow(String.valueOf(flowId), flowDataDTO, uid, ChangeFlowEnum.CHANGE_FLOW_EXE.getTopoId(), JSON.toJSONString(content));
log.info("[cancel] nextNodeId:{}", nextNodeId);
// 填充更新数据
changeRecord.setFlowNode(nextNodeId);
changeRecord.setState(ChangeStatusEnum.CANCEL.getStatus());
changeRecord.setCancelReason(req.getCancelReason());
changeRecord.setUpdateTime(DateUtils.getCurrentTime());
changeFlowService.updateRecord(changeRecord);
return false;
}
}
......@@ -6,6 +6,8 @@
*/
package com.netease.mail.yanxuan.change.biz.service;
import java.util.List;
import com.netease.mail.yanxuan.change.biz.config.TitleConfig;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
......@@ -35,4 +37,10 @@ public interface ChangeFlowService {
*/
ChangeRecord getByFlowId(Long flowId);
/**
* 更新工单信息
* @param changeRecord
* @return
*/
Boolean updateRecord(ChangeRecord changeRecord);
}
\ No newline at end of file
......@@ -6,6 +6,8 @@
*/
package com.netease.mail.yanxuan.change.biz.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -43,4 +45,9 @@ public class ChangeFlowServiceImpl implements ChangeFlowService {
public ChangeRecord getByFlowId(Long flowId) {
return changeRecordMapper.selectByFlowId(flowId);
}
@Override
public Boolean updateRecord(ChangeRecord changeRecord) {
return changeRecordMapper.updateByPrimaryKey(changeRecord) > 0;
}
}
\ 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