提交 ef62e826 authored 作者: 黄夏豪's avatar 黄夏豪

新增了禁用流程的接口

上级 154d193b
...@@ -2,10 +2,7 @@ package com.tykj.workflowcore.workflow_editer.controller; ...@@ -2,10 +2,7 @@ package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.base.result.ResultUtil; import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.NodeInfo;
import com.tykj.workflowcore.workflow_editer.entity.VariableStorage; import com.tykj.workflowcore.workflow_editer.entity.VariableStorage;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser;
import com.tykj.workflowcore.workflow_editer.entity.vo.NodeInfoVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.VariableStorageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.VariableStorageVo;
import com.tykj.workflowcore.workflow_editer.service.*; import com.tykj.workflowcore.workflow_editer.service.*;
import com.tykj.workflowcore.workflow_editer.vo.DeployedVo; import com.tykj.workflowcore.workflow_editer.vo.DeployedVo;
...@@ -44,7 +41,7 @@ public class FlowsInfoController { ...@@ -44,7 +41,7 @@ public class FlowsInfoController {
private WorkFlowService workFlowService; private WorkFlowService workFlowService;
@Autowired @Autowired
private NodePageService nodePageService; private NodeInfoService nodeInfoService;
@Autowired @Autowired
private VariableStorageService variableStorageService; private VariableStorageService variableStorageService;
...@@ -57,10 +54,11 @@ public class FlowsInfoController { ...@@ -57,10 +54,11 @@ public class FlowsInfoController {
} }
return flowInfoService.getAllFlowsInfo(pageVo); return flowInfoService.getAllFlowsInfo(pageVo);
} }
@PostMapping("/getDeployedFlowsInfo") @PostMapping("/getDeployedFlowsInfo")
@ApiOperation(value = "查询已经部署的流程") @ApiOperation(value = "查询已经部署的流程")
public List<DeployedVo> getDeployedFlowsInfo(){ public List<DeployedVo> getDeployedFlowsInfo(){
ArrayList<DeployedVo> deployedVos = new ArrayList<>(); ArrayList<DeployedVo> deployedVos = new ArrayList<>();
//查询已经部署的流程 //查询已经部署的流程
List<FlowsInfo> deployedFlowsInfo = flowInfoService.getDeployedFlowsInfo(); List<FlowsInfo> deployedFlowsInfo = flowInfoService.getDeployedFlowsInfo();
...@@ -72,7 +70,7 @@ public class FlowsInfoController { ...@@ -72,7 +70,7 @@ public class FlowsInfoController {
DeployedVo deployedVo = new DeployedVo(); DeployedVo deployedVo = new DeployedVo();
BeanUtils.copyProperties(flowsInfo,deployedVo); BeanUtils.copyProperties(flowsInfo,deployedVo);
//通过节点id得到pageId //通过节点id得到pageId
Long pageId = nodePageService.findByNodeId(startId); Long pageId = nodeInfoService.findByNodeId(startId);
deployedVo.setPageId(pageId); deployedVo.setPageId(pageId);
deployedVos.add(deployedVo); deployedVos.add(deployedVo);
} }
...@@ -80,7 +78,7 @@ public class FlowsInfoController { ...@@ -80,7 +78,7 @@ public class FlowsInfoController {
} }
@GetMapping("/deploy") @GetMapping("/deploy")
@ApiOperation(value = "部署流程",notes = "0 部署成功") @ApiOperation(value = "部署流程",notes = "部署成功")
public ResponseEntity deploy(Long id) throws FileNotFoundException { public ResponseEntity deploy(Long id) throws FileNotFoundException {
//根据id 查询出flowsInfo //根据id 查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findById(id); FlowsInfo flowsInfo = flowInfoService.findById(id);
...@@ -91,11 +89,18 @@ public class FlowsInfoController { ...@@ -91,11 +89,18 @@ public class FlowsInfoController {
return ResultUtil.success(flowsInfo.getState(),"流程部署成功"); return ResultUtil.success(flowsInfo.getState(),"流程部署成功");
} }
@PostMapping("/disableFlow")
@ApiOperation(value = "禁用流程",notes = "分页查询")
public ResponseEntity disableFlow(@RequestBody Long flowId){
flowInfoService.disableFlow(flowId);
return ResultUtil.success("禁用成功");
}
@PostMapping("/saveXml") @PostMapping("/saveXml")
@ApiOperation(value = "保存xml以及其他流程信息") @ApiOperation(value = "保存xml以及其他流程信息")
public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) { public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) {
//保存节点信息 //保存节点信息
nodePageService.saveNodeInfoList(flowsInfoVo.getNodeInfoList()); nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList());
//保存xml信息 //保存xml信息
workFlowService.flowXml(flowsInfoVo); workFlowService.flowXml(flowsInfoVo);
return ResultUtil.success("文件保存成功"); return ResultUtil.success("文件保存成功");
......
...@@ -35,8 +35,8 @@ public interface FlowInfoService { ...@@ -35,8 +35,8 @@ public interface FlowInfoService {
* @param id flowInfo Id * @param id flowInfo Id
* @return FlowInfo对象 * @return FlowInfo对象
*/ */
FlowsInfo findById(Long id);
FlowsInfo findById(Long id);
/** /**
* 根据流程主键修改 * 根据流程主键修改
* @param flowsInfoVo flowsInfo * @param flowsInfoVo flowsInfo
...@@ -71,4 +71,11 @@ public interface FlowInfoService { ...@@ -71,4 +71,11 @@ public interface FlowInfoService {
*/ */
FlowsInfo findByFlowKey(String flowKey); FlowsInfo findByFlowKey(String flowKey);
/**
* 停用流程
* @param flowInfoId
* @return
*/
FlowsInfo disableFlow(Long flowInfoId);
} }
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
* *
* @Author: zsp * @Author: zsp
*/ */
public interface NodePageService { public interface NodeInfoService {
/** /**
* 通过节点id得到pageId * 通过节点id得到pageId
* @param nodeId 节点id * @param nodeId 节点id
......
package com.tykj.workflowcore.workflow_editer.service.impl; package com.tykj.workflowcore.workflow_editer.service.impl;
import com.github.wenhao.jpa.Specifications; import com.github.wenhao.jpa.Specifications;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.service.FlowInfoService; import com.tykj.workflowcore.workflow_editer.service.FlowInfoService;
...@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* ClassName: FlowInfoServiceImpl * ClassName: FlowInfoServiceImpl
...@@ -36,12 +38,9 @@ public class FlowInfoServiceImpl implements FlowInfoService { ...@@ -36,12 +38,9 @@ public class FlowInfoServiceImpl implements FlowInfoService {
@Override @Override
public List<FlowsInfo> getDeployedFlowsInfo() { public List<FlowsInfo> getDeployedFlowsInfo() {
FlowsInfo flowsInfo = new FlowsInfo(); FlowsInfo flowsInfo = new FlowsInfo();
flowsInfo.setState(0); flowsInfo.setState(0);
Specification<FlowsInfo> state = Specifications.<FlowsInfo>and().eq("state", flowsInfo.getState()).build(); Specification<FlowsInfo> state = Specifications.<FlowsInfo>and().eq("state", flowsInfo.getState()).build();
return flowsInfoMapper.findAll(state); return flowsInfoMapper.findAll(state);
} }
...@@ -89,4 +88,17 @@ public class FlowInfoServiceImpl implements FlowInfoService { ...@@ -89,4 +88,17 @@ public class FlowInfoServiceImpl implements FlowInfoService {
public FlowsInfo findByFlowKey(String flowKey) { public FlowsInfo findByFlowKey(String flowKey) {
return flowsInfoMapper.findByFlowKey(flowKey); return flowsInfoMapper.findByFlowKey(flowKey);
} }
@Override
public FlowsInfo disableFlow(Long flowInfoId) {
Optional<FlowsInfo> byId = flowsInfoMapper.findById(flowInfoId);
if (byId.isPresent()){
FlowsInfo flowsInfo = byId.get();
flowsInfo.setState(1);
flowsInfoMapper.save(flowsInfo);
}else {
throw new ApiException("要禁用的流程不存在");
}
return null;
}
} }
...@@ -2,7 +2,7 @@ package com.tykj.workflowcore.workflow_editer.service.impl; ...@@ -2,7 +2,7 @@ package com.tykj.workflowcore.workflow_editer.service.impl;
import com.tykj.workflowcore.workflow_editer.entity.NodeInfo; import com.tykj.workflowcore.workflow_editer.entity.NodeInfo;
import com.tykj.workflowcore.workflow_editer.mapper.NodePageMapper; import com.tykj.workflowcore.workflow_editer.mapper.NodePageMapper;
import com.tykj.workflowcore.workflow_editer.service.NodePageService; import com.tykj.workflowcore.workflow_editer.service.NodeInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
* @Author: zsp * @Author: zsp
*/ */
@Service @Service
public class NodePageServiceImpl implements NodePageService { public class NodeInfoServiceImpl implements NodeInfoService {
@Autowired @Autowired
private NodePageMapper nodePageMapper; private NodePageMapper nodePageMapper;
...@@ -34,6 +34,8 @@ public class NodePageServiceImpl implements NodePageService { ...@@ -34,6 +34,8 @@ public class NodePageServiceImpl implements NodePageService {
@Override @Override
public void saveNodeInfoList(List<NodeInfo> nodeInfos) { public void saveNodeInfoList(List<NodeInfo> nodeInfos) {
if (nodeInfos!=null){
nodePageMapper.saveAll(nodeInfos); nodePageMapper.saveAll(nodeInfos);
} }
}
} }
package com.tykj.workflowcore.workflow_editer.service.impl; package com.tykj.workflowcore.workflow_editer.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.api.entity.InvokeRequest; import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter; import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.workflow_editer.entity.*; import com.tykj.workflowcore.workflow_editer.entity.*;
import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.service.NodePageService; import com.tykj.workflowcore.workflow_editer.service.NodeInfoService;
import com.tykj.workflowcore.workflow_editer.service.UserService; import com.tykj.workflowcore.workflow_editer.service.UserService;
import com.tykj.workflowcore.workflow_editer.service.VariableStorageService; import com.tykj.workflowcore.workflow_editer.service.VariableStorageService;
import com.tykj.workflowcore.workflow_editer.service.WorkFlowService; import com.tykj.workflowcore.workflow_editer.service.WorkFlowService;
...@@ -22,14 +21,13 @@ import org.flowable.common.engine.impl.identity.Authentication; ...@@ -22,14 +21,13 @@ import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.*; import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentBuilder;
import org.flowable.engine.runtime.Execution; import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.ProcessDiagramGenerator; import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery; import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -66,8 +64,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -66,8 +64,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Autowired @Autowired
private HistoryService historyService; private HistoryService historyService;
@Autowired @Autowired
private NodePageService nodePageService; private NodeInfoService nodeInfoService;
@Autowired @Autowired
ProcessEngineConfigurationImpl processEngineConfiguration; ProcessEngineConfigurationImpl processEngineConfiguration;
@Autowired @Autowired
...@@ -203,7 +200,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -203,7 +200,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public Long createFlow(FlowsInfo flowsInfo ) { public Long createFlow(FlowsInfo flowsInfo ) {
FlowsInfo flowsInfo1 = flowsInfoMapper.save(flowsInfo); FlowsInfo flowsInfo1 = flowsInfoMapper.save(flowsInfo);
return flowsInfo1.getId(); return flowsInfo1.getId();
} }
...@@ -211,7 +207,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -211,7 +207,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public void deployXml(FlowsInfo flowsInfo) throws FileNotFoundException { public void deployXml(FlowsInfo flowsInfo) throws FileNotFoundException {
Deployment deploy = null; Deployment deploy = null;
try { try {
deploy = repositoryService.createDeployment().addInputStream(flowsInfo.getResourceName(), deploy = repositoryService.createDeployment().addInputStream(flowsInfo.getResourceName(),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论