提交 a3e0d3d5 authored 作者: zhoushaopan's avatar zhoushaopan

[工作流模块]流程的假删除,以及启用,禁用

上级 ccec6ef1
...@@ -61,6 +61,18 @@ public class FlowsInfoController { ...@@ -61,6 +61,18 @@ public class FlowsInfoController {
public String editFlow(Long id){ public String editFlow(Long id){
return flowInfoService.editFlow(id).getFilePath(); return flowInfoService.editFlow(id).getFilePath();
} }
@GetMapping("/deploy")
@ApiOperation(value = "部署流程",notes = "部署成功")
public ResponseEntity deploy(Long id) throws FileNotFoundException {
//根据id 查询出flowsInfo
FlowsInfo flowsInfo = flowInfoService.findById(id);
if (flowsInfo.getState() == 0){
return ResultUtil.success(flowsInfo.getState(),"该流程已经被部署");
}
workFlowService.deployXml(flowsInfo);
return ResultUtil.success(flowsInfo.getState(),"流程部署成功");
}
@PostMapping("/saveXml") @PostMapping("/saveXml")
@ApiOperation(value = "保存xml以及其他流程信息") @ApiOperation(value = "保存xml以及其他流程信息")
......
...@@ -87,9 +87,9 @@ public class WorkFlowController { ...@@ -87,9 +87,9 @@ public class WorkFlowController {
@PostMapping("/isSuspension") @PostMapping("/isSuspension")
@ApiOperation("是否挂起") @ApiOperation("是否挂起")
public ResponseEntity isSuspension(@RequestBody SuspendVo suspendVo){ public void isSuspension(Long id){
workFlowService.suspendOrActivateProcessDefinitionByKey(suspendVo); workFlowService.suspendOrActivateProcessDefinitionByKey(id);
return ResultUtil.success("该流程已被暂停"); // return ResultUtil.success("该流程已被暂停");
} }
@DeleteMapping("/deleteFlow") @DeleteMapping("/deleteFlow")
......
...@@ -33,6 +33,10 @@ import java.util.Date; ...@@ -33,6 +33,10 @@ import java.util.Date;
@Where(clause = "deleted = 0") @Where(clause = "deleted = 0")
@Api("流程表") @Api("流程表")
public class FlowsInfo extends BaseEntity { public class FlowsInfo extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("流程id")
private Long id;
@ApiModelProperty("发起人的Id") @ApiModelProperty("发起人的Id")
private Long userId; private Long userId;
...@@ -71,4 +75,6 @@ public class FlowsInfo extends BaseEntity { ...@@ -71,4 +75,6 @@ public class FlowsInfo extends BaseEntity {
* @params: 部署id * @params: 部署id
*/ */
private String deployId; private String deployId;
@ApiModelProperty("是否删除")
private Integer deleted = 0;
} }
...@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor; ...@@ -17,7 +17,7 @@ import lombok.NoArgsConstructor;
@Data @Data
public class SearchFlowInfoVo extends JpaCustomPage { public class SearchFlowInfoVo extends JpaCustomPage {
@ApiModelProperty(value = "部署状态",notes = "0 已部署,1 未部署") @ApiModelProperty(value = "状态",notes = "0 可用,1 暂停")
private Integer state; private Integer state;
@ApiModelProperty("流程名称") @ApiModelProperty("流程名称")
......
...@@ -42,7 +42,7 @@ public interface WorkFlowService { ...@@ -42,7 +42,7 @@ public interface WorkFlowService {
* @param flowsInfo * @param flowsInfo
* @return 主键id * @return 主键id
*/ */
Integer createFlow(@RequestBody FlowsInfo flowsInfo); Long createFlow(@RequestBody FlowsInfo flowsInfo);
/** /**
* 部署xml流程文件 * 部署xml流程文件
...@@ -110,9 +110,9 @@ public interface WorkFlowService { ...@@ -110,9 +110,9 @@ public interface WorkFlowService {
/** /**
* 是否挂起 * 是否挂起
* @param suspendVo * @param id 流程id
*/ */
void suspendOrActivateProcessDefinitionByKey(SuspendVo suspendVo); void suspendOrActivateProcessDefinitionByKey(Long id);
/** /**
* 删除流程 * 删除流程
......
...@@ -6,6 +6,7 @@ import com.tykj.workflowcore.api.entity.Parameter; ...@@ -6,6 +6,7 @@ import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.api.service.SpringBeanService; import com.tykj.workflowcore.api.service.SpringBeanService;
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.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,6 +23,7 @@ import org.flowable.common.engine.impl.identity.Authentication; ...@@ -22,6 +23,7 @@ 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;
...@@ -29,6 +31,8 @@ import org.flowable.task.api.Task; ...@@ -29,6 +31,8 @@ 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.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -133,7 +137,6 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -133,7 +137,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
flowsInfo.setFlowKey(processId); flowsInfo.setFlowKey(processId);
flowsInfo.setFlowName(processName); flowsInfo.setFlowName(processName);
flowsInfo.setResourceName(file.getOriginalFilename()); flowsInfo.setResourceName(file.getOriginalFilename());
flowsInfo.setCreatedTime(new Date());
//状态为未部署 //状态为未部署
flowsInfo.setState(1); flowsInfo.setState(1);
flowsInfo.setFilePath(realPath); flowsInfo.setFilePath(realPath);
...@@ -144,7 +147,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -144,7 +147,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) { public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) {
Integer id = flowsInfoVo.getId(); Long id = flowsInfoVo.getId();
String flowKey = flowsInfoVo.getFlowKey(); String flowKey = flowsInfoVo.getFlowKey();
String fileXml = flowsInfoVo.getFileXml(); String fileXml = flowsInfoVo.getFileXml();
//生成xml文件 //生成xml文件
...@@ -190,26 +193,23 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -190,26 +193,23 @@ public class WorkFlowServiceImpl implements WorkFlowService {
FlowsInfo flowsInfo = new FlowsInfo(); FlowsInfo flowsInfo = new FlowsInfo();
BeanUtils.copyProperties(flowsInfoVo,flowsInfo); BeanUtils.copyProperties(flowsInfoVo,flowsInfo);
flowsInfo.setResourceName(flowKey+"bpmn20.xml"); flowsInfo.setResourceName(flowKey+"bpmn20.xml");
flowsInfo.setCreatedTime(new Date());
//状态为未部署 //状态为未部署
flowsInfo.setState(1); flowsInfo.setState(1);
flowsInfo.setFilePath(classLoader.getResource("").getPath()+"/xml/"+flowKey+"bpmn20.xml"); flowsInfo.setFilePath(classLoader.getResource("").getPath()+"/xml/"+flowKey+"bpmn20.xml");
flowsInfo.setId(id); flowsInfo.setId(id);
//更新并保存 //更新并保存
FlowsInfo save = flowsInfoMapper.save(flowsInfo); flowsInfoMapper.save(flowsInfo);
//自动部署
deployXml(save);
} }
@Override @Override
public Integer createFlow(FlowsInfo flowsInfo ) { public Long createFlow(FlowsInfo flowsInfo ) {
FlowsInfo flowsInfo1 = flowsInfoMapper.save(flowsInfo); FlowsInfo flowsInfo1 = flowsInfoMapper.save(flowsInfo);
return flowsInfo1.getId(); return flowsInfo1.getId();
} }
@Override @Override
public void deployXml(FlowsInfo flowsInfo) { 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(),
...@@ -335,12 +335,21 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -335,12 +335,21 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public void suspendOrActivateProcessDefinitionByKey(SuspendVo suspendVo) { public void suspendOrActivateProcessDefinitionByKey(Long id) {
if (suspendVo.getSuspensionState() == 1){ //通过流程ID 查询出flowsInfo
repositoryService.suspendProcessDefinitionByKey(suspendVo.getFlowKey(), true, new Date()); FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get();
String flowKey = flowsInfo.getFlowKey();
if (flowsInfo.getState() == 0){
//挂起
repositoryService.suspendProcessDefinitionByKey(flowKey, true, new Date());
flowsInfo.setState(1);
}else { }else {
repositoryService.activateProcessDefinitionById(suspendVo.getFlowKey(),true, new Date()); //激活
repositoryService.activateProcessDefinitionByKey(flowKey,true, new Date());
flowsInfo.setState(0);
} }
flowsInfoMapper.save(flowsInfo);
} }
...@@ -348,12 +357,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -348,12 +357,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
public void deleteFlow(Long id) { public void deleteFlow(Long id) {
//通过流程id查询出flowsInfo //通过流程id查询出flowsInfo
FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get(); FlowsInfo flowsInfo = flowsInfoMapper.findById(id).get();
//先判断流程是否已经部署 flowsInfo.setState(1);
if(flowsInfo.getDeployId() != null){
//已经部署了 (启用)
repositoryService.deleteDeployment(flowsInfo.getDeployId());
}
flowsInfo.setDeleted(1);
flowsInfoMapper.save(flowsInfo); flowsInfoMapper.save(flowsInfo);
} }
......
...@@ -26,7 +26,7 @@ import java.util.List; ...@@ -26,7 +26,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
public class FlowsInfoVo { public class FlowsInfoVo {
@ApiModelProperty("主键id") @ApiModelProperty("主键id")
private Integer id; private Long id;
@ApiModelProperty("发起人的名字") @ApiModelProperty("发起人的名字")
private Long userName; private Long userName;
......
...@@ -18,13 +18,13 @@ import lombok.NoArgsConstructor; ...@@ -18,13 +18,13 @@ import lombok.NoArgsConstructor;
public class SuspendVo { public class SuspendVo {
/** /**
* 流程主键 * 流程id
*/ */
private String flowKey; private Long id;
/** /**
* 是否挂起 1 挂起 0 激活 * 是否可用 0 挂起 1 激活
*/ */
private int suspensionState; private int state;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论