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

[流程编辑器] 修改了保存流程的逻辑

[流程编辑器] 更新了回调函数的逻辑-》支持回调函数
上级 656b4923
...@@ -18,9 +18,6 @@ public class Parameter { ...@@ -18,9 +18,6 @@ public class Parameter {
@ApiModelProperty(value = "类名") @ApiModelProperty(value = "类名")
private String className; private String className;
@ApiModelProperty("流程表达式")
private String exp;
/** /**
* Map形式的实例对象 * Map形式的实例对象
* key为字段名 value为字段值 * key为字段名 value为字段值
......
...@@ -43,6 +43,12 @@ public class AggregationController { ...@@ -43,6 +43,12 @@ public class AggregationController {
return ResultUtil.success("","保存成功!"); return ResultUtil.success("","保存成功!");
} }
@PostMapping("/findTest")
public ResponseEntity findTest(Integer id) {
return ResultUtil.success(aggregationDao.findAllByTableInfoExIdAndParentId(id,null),"保存成功!");
}
@PostMapping("/test") @PostMapping("/test")
public ResponseEntity test(@RequestBody AggregationVO AggregationVO) { public ResponseEntity test(@RequestBody AggregationVO AggregationVO) {
String result= ""; String result= "";
......
...@@ -15,6 +15,7 @@ import java.util.List; ...@@ -15,6 +15,7 @@ import java.util.List;
*/ */
public interface AggregationDao extends JpaRepository<Aggregation, Integer>, JpaSpecificationExecutor<Aggregation> { public interface AggregationDao extends JpaRepository<Aggregation, Integer>, JpaSpecificationExecutor<Aggregation> {
List<Aggregation> findAllByTableInfoExIdAndParentId(Integer tableExId, Integer parentId); List<Aggregation> findAllByTableInfoExIdAndParentId(Integer tableExId,Integer parrentId);
} }
...@@ -88,7 +88,6 @@ public class AggregationImpl implements AggregationService { ...@@ -88,7 +88,6 @@ public class AggregationImpl implements AggregationService {
}else { }else {
throw new ApiException("id为:"+parentAggregation.getSideTableId()+"的副表不存在"); throw new ApiException("id为:"+parentAggregation.getSideTableId()+"的副表不存在");
} }
parentModeName = sideTableInfoOptional.get().getModelName(); parentModeName = sideTableInfoOptional.get().getModelName();
}else { }else {
//如果是第一层 则通过rootElement 查出副表的XML字符串 //如果是第一层 则通过rootElement 查出副表的XML字符串
...@@ -157,55 +156,4 @@ public class AggregationImpl implements AggregationService { ...@@ -157,55 +156,4 @@ public class AggregationImpl implements AggregationService {
return null; return null;
} }
// 假设获得的是一份XML
// public Element testDG(List<Aggregation> aggregations, Aggregation parentAggregation, Integer mainId, Element element){
// //循环
// Element elementCLass = DocumentHelper.createElement("class");
// if (parentAggregation!=null){
// elementCLass.addAttribute("name",parentAggregation.getSideTableId()+"_");
// }else {
// elementCLass.addAttribute("name",mainId+"_");
// }
// for (int i = 0; i < aggregations.size(); i++) {
// Aggregation aggregationChild = aggregations.get(i);
// if (aggregationChild.getAggregations()!=null&&aggregationChild.getAggregations().size()>0){
// Element elementClassChild = testDG(aggregationChild.getAggregations(), aggregationChild, mainId, element);
// Element elementSet = DocumentHelper.createElement("set");
// elementSet.addAttribute("setName","c"+elementClassChild.attribute("name").getValue());
// elementCLass.add(elementSet);
// }else {
// Element elementSet = DocumentHelper.createElement("set");
// elementSet.addAttribute("setName","c"+aggregationChild.getSideTableId());
// elementCLass.add(elementSet);
// }
// }
// element.add(elementCLass);
// return elementCLass;
// }
// Optional<TableInfo> sideTableById = tableInfoDao.findById(aggregationChild.getSideTableId());
// aggregationChild.setTableInfoExId(tableExId);
// if (!sideTableById.isPresent()){
// throw new ApiException("id为:"+aggregationChild.getSideTableId()+"的副表不存在");
// }
// if (aggregationChild.getRelationship().equals(AggregationType.ONE_TO_ONE)){
// AggregationUtil.addOneToOne(aggregationChild.getSideTableConnectionKey(), sideTableById.get().getModelName(), document);
// }
// if (aggregationChild.getRelationship().equals(AggregationType.ONE_TO_MANY)){
// //如果是一对多需要 为 aggregationRelationship 生成连接的KEY
// String mainTableConnectionKey = sideTableById.get().getModelName();
// AggregationUtil.addOneToMany(sideTableById.get().getModelName(), mainTableConnectionKey, aggregationChild.getSideTableConnectionKey(), document);
// }
// if (aggregationChild.getRelationship().equals(AggregationType.MANY_TO_MANY)){
// //如果是多对多需要 为 aggregationRelationship 生成连接的KEY
// String mainTableConnectionKey = mainTableInfo.getModelName()+"_Id";
// String sideTableConnectionKey = sideTableById.get().getModelName()+"_Id";
// aggregationChild.setMainTableConnectionKey(mainTableConnectionKey);
// aggregationChild.setSideTableConnectionKey(sideTableConnectionKey);
// //如果是多对多需要 为 aggregationRelationship 生成连接的中间表名
// String connectionTableName = mainTableInfo.getModelName()+"_"+sideTableById.get().getModelName()+"_"+ (UUID.randomUUID().toString().substring(0,8));
// aggregationChild.setConnectionTableName(connectionTableName);
// //Util.addManyToMany
// AggregationUtil.addManyToMany(sideTableById.get().getModelName(),connectionTableName,mainTableConnectionKey,sideTableConnectionKey,document);
// }
} }
...@@ -76,7 +76,7 @@ public class FlowsInfoController { ...@@ -76,7 +76,7 @@ public class FlowsInfoController {
@ApiOperation(value = "保存xml以及其他流程信息") @ApiOperation(value = "保存xml以及其他流程信息")
public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) throws IOException, XMLStreamException { public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) throws IOException, XMLStreamException {
//保存节点信息 //保存节点信息
nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList()); // nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList());
//保存xml信息 //保存xml信息
workFlowService.flowXml(flowsInfoVo); workFlowService.flowXml(flowsInfoVo);
return ResultUtil.success("文件保存成功"); return ResultUtil.success("文件保存成功");
......
package com.tykj.workflowcore.workflow_editer.entity; package com.tykj.workflowcore.workflow_editer.entity;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonGetter;
import com.tykj.workflowcore.base.entity.BaseEntity; import com.tykj.workflowcore.base.entity.BaseEntity;
import com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan; import com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan;
import com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo; import com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.ParameterVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -12,6 +14,7 @@ import lombok.Data; ...@@ -12,6 +14,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import java.util.List;
/** /**
* ClassName: VariableStorage * ClassName: VariableStorage
...@@ -41,12 +44,11 @@ public class VariableStorage extends BaseEntity { ...@@ -41,12 +44,11 @@ public class VariableStorage extends BaseEntity {
private String method; private String method;
@ApiModelProperty("详情json") @ApiModelProperty("详情json")
private String invokeRequest; private String parameterInfo;
@JsonGetter @JsonGetter
public InvokeRequestVo getInvokeRequest() { public List<ParameterVo> getParameterInfo() {
return JSON.parseObject(invokeRequest,InvokeRequestVo.class); return JSON.parseObject(parameterInfo,new TypeReference<List<ParameterVo>>(){});
} }
} }
package com.tykj.workflowcore.workflow_editer.entity.vo; package com.tykj.workflowcore.workflow_editer.entity.vo;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
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.NodeInfo;
...@@ -28,9 +29,6 @@ public class FlowsInfoVo { ...@@ -28,9 +29,6 @@ public class FlowsInfoVo {
@ApiModelProperty("主键id") @ApiModelProperty("主键id")
private Integer id; private Integer id;
@ApiModelProperty("发起人的名字")
private Integer userName;
@ApiModelProperty("流程名称") @ApiModelProperty("流程名称")
private String flowName; private String flowName;
...@@ -40,32 +38,25 @@ public class FlowsInfoVo { ...@@ -40,32 +38,25 @@ public class FlowsInfoVo {
@ApiModelProperty(value = "部署状态",notes = "0 已部署,1 未部署") @ApiModelProperty(value = "部署状态",notes = "0 已部署,1 未部署")
private Integer state = 1; private Integer state = 1;
@ApiModelProperty("流程创建时间")
private Date createTime;
@ApiModelProperty("流程修改时间")
private Date updateTime;
@ApiModelProperty("流程描述") @ApiModelProperty("流程描述")
private String flowDescribe; private String flowDescribe;
@ApiModelProperty @ApiModelProperty
private String fileXml; private String fileXml;
@ApiModelProperty("开始节点的id")
private String startId;
@ApiModelProperty("开始节点的id")
private String startPageId;
@ApiModelProperty("是否和之前一样 0是一样 1不一样")
private Integer isOld = 1;
@ApiModelProperty()
private List<NodeInfo> nodeInfoList;
public FlowsInfo toEntity(){ public FlowsInfo toEntity(){
FlowsInfo flowsInfo = new FlowsInfo(); FlowsInfo flowsInfo = new FlowsInfo();
BeanUtils.copyProperties(this,flowsInfo); BeanUtils.copyProperties(this,flowsInfo);
return flowsInfo; return flowsInfo;
} }
public FlowsInfo toEntity(FlowsInfo oldFlowsInfo){
if (!StrUtil.isEmpty(flowName)){
oldFlowsInfo.setFlowName(flowName);
}
if (!StrUtil.isEmpty(flowDescribe)){
oldFlowsInfo.setFlowDescribe(flowDescribe);
}
return oldFlowsInfo;
}
} }
package com.tykj.workflowcore.workflow_editer.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 回调接口配置Vo
* @author HuangXiahao
* @version V1.0
* @class parameterVo
* @packageName com.tykj.workflowcore.workflow_editer.entity.vo
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ParameterVo {
private String className;
private String exp;
private String name;
private List<ParameterVo> parameterVoList;
}
...@@ -10,6 +10,8 @@ import lombok.NoArgsConstructor; ...@@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import springfox.documentation.spring.web.json.Json; import springfox.documentation.spring.web.json.Json;
import java.util.List;
/** /**
* @author HuangXiahao * @author HuangXiahao
* @version V1.0 * @version V1.0
...@@ -36,12 +38,12 @@ public class VariableStorageVo { ...@@ -36,12 +38,12 @@ public class VariableStorageVo {
@ApiModelProperty("调用方法名") @ApiModelProperty("调用方法名")
private String method; private String method;
private InvokeRequestVo invokeRequest; private List<ParameterVo> parameterList;
public VariableStorage toEntity(){ public VariableStorage toEntity(){
VariableStorage variableStorage = new VariableStorage(); VariableStorage variableStorage = new VariableStorage();
BeanUtils.copyProperties(this,variableStorage); BeanUtils.copyProperties(this,variableStorage);
variableStorage.setInvokeRequest(JSON.toJSONString(invokeRequest)); variableStorage.setParameterInfo(JSON.toJSONString(parameterList));
return variableStorage; return variableStorage;
} }
} }
...@@ -7,8 +7,10 @@ import com.tykj.workflowcore.api.entity.Parameter; ...@@ -7,8 +7,10 @@ import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.workflow_editer.entity.CommandGetValue; import com.tykj.workflowcore.workflow_editer.entity.CommandGetValue;
import com.tykj.workflowcore.workflow_editer.entity.VariableStorage; import com.tykj.workflowcore.workflow_editer.entity.VariableStorage;
import com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo; import com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.ParameterVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo;
import com.tykj.workflowcore.workflow_editer.service.VariableStorageService; import com.tykj.workflowcore.workflow_editer.service.VariableStorageService;
import liquibase.pro.packaged.I;
import org.flowable.bpmn.model.EndEvent; import org.flowable.bpmn.model.EndEvent;
import org.flowable.common.engine.api.delegate.Expression; import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
...@@ -20,16 +22,14 @@ import org.flowable.engine.delegate.event.FlowableActivityEvent; ...@@ -20,16 +22,14 @@ import org.flowable.engine.delegate.event.FlowableActivityEvent;
import org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl; import org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity; import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* @author HuangXiahao * @author HuangXiahao
...@@ -97,17 +97,20 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener { ...@@ -97,17 +97,20 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
DelegateExecution execution = ((FlowableActivityEventImpl) event).getExecution(); DelegateExecution execution = ((FlowableActivityEventImpl) event).getExecution();
if (execution.getCurrentFlowElement() instanceof EndEvent){ if (execution.getCurrentFlowElement() instanceof EndEvent){
System.out.println("流程结束了"); System.out.println("流程结束了");
String processDefinitionId = execution.getProcessDefinitionId(); String processDefinitionId = ((ExecutionEntityImpl) execution).getProcessDefinitionKey();
String flowKey = processDefinitionId; String flowKey = processDefinitionId;
if (processDefinitionId.indexOf(":")>=0){ if (processDefinitionId.indexOf(":")>=0){
flowKey = processDefinitionId.substring(0,processDefinitionId.indexOf(":")); flowKey = processDefinitionId.substring(0,processDefinitionId.indexOf(":"));
} }
List<VariableStorage> variableStorageList = variableStorageService.searchVariableStorageList(new SearchVariableStorageVo(flowKey,execution.getCurrentActivityId())); List<VariableStorage> variableStorageList = variableStorageService.searchVariableStorageList(new SearchVariableStorageVo(flowKey,execution.getCurrentActivityId()));
for (VariableStorage variableStorage : variableStorageList) { for (VariableStorage variableStorage : variableStorageList) {
InvokeRequestVo variableInfo = variableStorage.getInvokeRequest(); List<ParameterVo> parameterVoList = variableStorage.getParameterInfo();
variableInfo.setProcessInstance(execution); InvokeRequest invokeRequest = new InvokeRequest();
invokeRequest.setClassName(variableStorage.getClassName());
invokeRequest.setName(variableStorage.getMethod());
invokeRequest.setParams(getApiInvokeParam(parameterVoList,execution));
//调用服务接口 //调用服务接口
apiController.invoke(getApiInvokeParam(variableInfo)); apiController.invoke(invokeRequest);
} }
} }
} }
...@@ -116,33 +119,38 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener { ...@@ -116,33 +119,38 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
/** /**
* 获取调用Api用的参数 * 获取调用Api用的参数
* *
* @param invokeRequestVo 调用服务接口vo * @param parameterVoList 调用服务接口vo
* @return 调用服务接口实体 * @return 调用服务接口实体
*/ */
public InvokeRequest getApiInvokeParam(InvokeRequestVo invokeRequestVo) { public List<Parameter> getApiInvokeParam(List<ParameterVo> parameterVoList,DelegateExecution execution) {
//拿出taskId //拿出taskId
DelegateExecution execution = invokeRequestVo.getProcessInstance(); List<Parameter> parameterList = new ArrayList<>();
List<Parameter> parameterList = invokeRequestVo.getParams(); for (int i = 0; i < parameterVoList.size(); i++) {
List<Parameter> newParameterList = new ArrayList<>(); ParameterVo parameterVo = parameterVoList.get(i);
for (int i = 0; i < parameterList.size(); i++) { Parameter parameter = new Parameter();
Parameter parameter = parameterList.get(i); parameter.setClassName(parameterVo.getClassName());
if (!StringUtils.isEmpty(parameter.getExp())) { Map<String, Object> instance = new HashMap<>();
//如果是表示式 如:${people} FillParameter(instance,parameterVoList.get(i),execution);
parameter.setInstance((Map<String, Object>) getProcessValue(execution, parameter.getExp())); parameter.setInstance((Map<String, Object>) instance.get(parameterVo.getName()));
} else { parameterList.add(parameter);
Map<String, Object> instance = parameter.getInstance(); }
JSONObject newInstance = new JSONObject(); return parameterList;
//遍历param的key }
Set<String> oldInstanceKey = instance.keySet();
for (String key : oldInstanceKey) { public Map<String, Object> FillParameter(Map<String, Object> instance,ParameterVo parameterVo,DelegateExecution execution){
newInstance.put(key, getProcessValue(execution, (String) instance.get(key))); if (!StringUtils.isEmpty(parameterVo.getExp())) {
} //如果是表示式 如:${people}
parameter.setInstance(newInstance); instance.put(parameterVo.getName(),getProcessValue(execution, parameterVo.getExp()));
}else {
instance.put(parameterVo.getName(),"");
}
List<ParameterVo> parameterVoList = parameterVo.getParameterVoList();
if (parameterVoList!=null&&parameterVoList.size()>0){
for (int i = 0; i < parameterVoList.size() ; i++) {
FillParameter(instance,parameterVoList.get(i),execution);
} }
newParameterList.add(i, parameter);
} }
invokeRequestVo.setParams(newParameterList); return instance;
return JSONObject.parseObject(JSONObject.toJSONString(invokeRequestVo), InvokeRequest.class);
} }
public Object getProcessValue(DelegateExecution execution, String exp) { public Object getProcessValue(DelegateExecution execution, String exp) {
......
...@@ -40,6 +40,7 @@ public class VariableStorageServiceImpl implements VariableStorageService { ...@@ -40,6 +40,7 @@ public class VariableStorageServiceImpl implements VariableStorageService {
if (searchVariableStorageVo!=null){ if (searchVariableStorageVo!=null){
predicateBuilder.eq(searchVariableStorageVo.getId()!=null,"id",searchVariableStorageVo.getId()); predicateBuilder.eq(searchVariableStorageVo.getId()!=null,"id",searchVariableStorageVo.getId());
predicateBuilder.eq(searchVariableStorageVo.getFlowKey()!=null,"flowKey",searchVariableStorageVo.getFlowKey()); predicateBuilder.eq(searchVariableStorageVo.getFlowKey()!=null,"flowKey",searchVariableStorageVo.getFlowKey());
predicateBuilder.eq(searchVariableStorageVo.getActivityId()!=null,"activityId",searchVariableStorageVo.getActivityId());
} }
return variableStorageMapper.findAll(predicateBuilder.build()); return variableStorageMapper.findAll(predicateBuilder.build());
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论