rev:流程引擎
This commit is contained in:
@@ -1,15 +1,28 @@
|
||||
package org.nl.wms.flow_manage.flow.controller.execution;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.IActReProcdefService;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.dao.ActReProcdef;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IActRuExecutionService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IFlowOperationService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.ExecutionQuery;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.StartProcessInstanceVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
@@ -23,14 +36,61 @@ public class ExecutionController {
|
||||
|
||||
@Autowired
|
||||
IFlowOperationService flowOperationService;
|
||||
@Autowired
|
||||
private IActRuExecutionService executionService;
|
||||
@Autowired
|
||||
private IActReProcdefService procdefService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> getAll(ExecutionQuery query, PageQuery page) {
|
||||
return new ResponseEntity<>(executionService.getAll(query, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> add(@Validated @RequestBody ActRuExecution dto) {
|
||||
dto.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
dto.setCreate_time(DateUtil.now());
|
||||
dto.setProc_inst_id(IdUtil.getStringId());
|
||||
executionService.save(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody ActRuExecution dto) {
|
||||
dto.setStatus("30");
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
executionService.updateById(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
if (ids.length > 0) {
|
||||
executionService.removeByIds(Arrays.asList(ids));
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/open")
|
||||
public ResponseEntity<Object> getBpmnByModelId(JSONObject form){
|
||||
public ResponseEntity<Object> getBpmnByModelId(JSONObject form) {
|
||||
StartProcessInstanceVo startProcessInstanceVo = form.toJavaObject(StartProcessInstanceVo.class);
|
||||
return new ResponseEntity<>(flowOperationService.startFormFlow(startProcessInstanceVo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/confirm")
|
||||
public ResponseEntity<Object> flowConfirm(String inst_id){
|
||||
public ResponseEntity<Object> flowConfirm(String inst_id) {
|
||||
return new ResponseEntity<>(flowOperationService.flowConfirm(inst_id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/queryByParentId/{id}")
|
||||
public ResponseEntity<Object> queryByParentId(@PathVariable String id) {
|
||||
LambdaQueryWrapper<ActRuExecution> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(ActRuExecution::getParent_id, id);
|
||||
return new ResponseEntity<>(executionService.list(lqw), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getDeploymentById/{id}")
|
||||
public ResponseEntity<Object> getDeploymentById(@PathVariable String id) {
|
||||
return new ResponseEntity<>(procdefService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.common.utils.FileUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.cmd.CommandExecutor;
|
||||
import org.nl.wms.flow_manage.flow.framework.engine.cmd.unify.impl.StartInstanceCmd;
|
||||
@@ -70,6 +69,7 @@ public class ActDeModelController {
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody ActDeModel dto) {
|
||||
dto.setStatus("30");
|
||||
dto.setUpdated_id(SecurityUtils.getCurrentUserId());
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
modelService.updateById(dto);
|
||||
@@ -129,6 +129,12 @@ public class ActDeModelController {
|
||||
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/publish")
|
||||
public ResponseEntity<Object> publish(@Validated @RequestBody ActDeModel dto) {
|
||||
modelService.publish(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.nl.wms.flow_manage.flow.service.execution;
|
||||
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.ExecutionQuery;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface IActRuExecutionService extends IService<ActRuExecution> {
|
||||
|
||||
Object getAll(ExecutionQuery query, PageQuery page);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import lombok.Data;
|
||||
@@ -21,7 +24,7 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName(value = "act_ru_execution",autoResultMap = true)
|
||||
@TableName(value = "act_ru_execution", autoResultMap = true)
|
||||
public class ActRuExecution implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -97,5 +100,11 @@ public class ActRuExecution implements Serializable {
|
||||
@TableField(typeHandler = FastjsonTypeHandler.class)
|
||||
private JSONObject form_data;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ActRuExecution> children = new ArrayList<>();
|
||||
|
||||
@TableField(exist = false)
|
||||
private Boolean hasChildren = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.nl.wms.flow_manage.flow.service.execution.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.common.domain.entity.BaseQuery;
|
||||
import org.nl.common.domain.entity.QParam;
|
||||
import org.nl.common.enums.QueryTEnum;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.nl.wms.flow_manage.flow.service.model.dao.ActDeModel;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/5/4 19:49
|
||||
*/
|
||||
@Data
|
||||
public class ExecutionQuery extends BaseQuery<ActRuExecution> {
|
||||
|
||||
|
||||
private String search;
|
||||
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
super.doP.put("name", QParam.builder().k(new String[]{"name"}).type(QueryTEnum.LK).build());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,21 @@
|
||||
package org.nl.wms.flow_manage.flow.service.execution.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.entity.PageQuery;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dao.mapper.ActRuExecutionMapper;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.IActRuExecutionService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.flow_manage.flow.service.execution.dto.ExecutionQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 流程实例表 服务实现类
|
||||
@@ -17,4 +27,22 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ActRuExecutionServiceImpl extends ServiceImpl<ActRuExecutionMapper, ActRuExecution> implements IActRuExecutionService {
|
||||
|
||||
@Override
|
||||
public Object getAll(ExecutionQuery query, PageQuery page) {
|
||||
//判断是否存在子实例
|
||||
LambdaQueryWrapper<ActRuExecution> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.isNull(ActRuExecution::getParent_id);
|
||||
Page<ActRuExecution> executionPage = this.page(page.build(), lqw);
|
||||
List<ActRuExecution> records = executionPage.getRecords();
|
||||
for (ActRuExecution record : records) {
|
||||
LambdaQueryWrapper<ActRuExecution> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ActRuExecution::getParent_id, record.getProc_inst_id());
|
||||
List<ActRuExecution> list = this.list(lambdaQueryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
record.setHasChildren(true);
|
||||
record.setChildren(list);
|
||||
}
|
||||
}
|
||||
return TableDataInfo.build(executionPage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface IActDeModelService extends IService<ActDeModel> {
|
||||
|
||||
|
||||
void publish(ActDeModel dto);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package org.nl.wms.flow_manage.flow.service.model.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.dao.ActReProcdef;
|
||||
import org.nl.wms.flow_manage.flow.service.deployment.dao.mapper.ActReProcdefMapper;
|
||||
import org.nl.wms.flow_manage.flow.service.model.dao.ActDeModel;
|
||||
import org.nl.wms.flow_manage.flow.service.model.dao.mapper.ActDeModelMapper;
|
||||
import org.nl.wms.flow_manage.flow.service.model.IActDeModelService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -18,4 +24,32 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class ActDeModelServiceImpl extends ServiceImpl<ActDeModelMapper, ActDeModel> implements IActDeModelService {
|
||||
|
||||
|
||||
@Autowired(required = false)
|
||||
private ActDeModelMapper modelMapper;
|
||||
@Autowired(required = false)
|
||||
private ActReProcdefMapper procdefMapper;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void publish(ActDeModel dto) {
|
||||
Assert.notNull(dto, "参数不能为空!");
|
||||
//往实例表中添加数据
|
||||
dto.setStatus("10");
|
||||
dto.setVersion(dto.getVersion() + 1);
|
||||
dto.setUpdated_id(SecurityUtils.getCurrentUserId());
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
modelMapper.updateById(dto);
|
||||
|
||||
ActReProcdef procdef = new ActReProcdef();
|
||||
procdef.setDeployment_id(IdUtil.getStringId());
|
||||
procdef.setName(dto.getName());
|
||||
procdef.setModel_key(dto.getModel_key());
|
||||
procdef.setVersion(String.valueOf(dto.getVersion()));
|
||||
procdef.setDescription(dto.getDescription());
|
||||
procdef.setModel_editor_json(dto.getModel_editor_json());
|
||||
procdef.setStatus("1");
|
||||
procdefMapper.insert(procdef);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user