|
@@ -1,8 +1,13 @@
|
|
|
package com.ruoyi.execution.produce.dispersed.runbpm;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.ruoyi.common.constant.HttpStatus;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.utils.CamelCaseConverterUtil;
|
|
|
import com.ruoyi.common.utils.bpm.XmlDataParserUtils;
|
|
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
|
|
import com.ruoyi.execution.produce.dispersed.entity.BpmExecuteNode;
|
|
@@ -10,6 +15,7 @@ import com.ruoyi.execution.produce.dispersed.entity.BpmExecuteNodeForm;
|
|
|
import com.ruoyi.execution.produce.dispersed.entity.BpmExecuteNodeMiddle;
|
|
|
import com.ruoyi.execution.produce.dispersed.entity.BpmExecuteProcess;
|
|
|
import com.ruoyi.execution.produce.dispersed.entity.runbpm.*;
|
|
|
+import com.ruoyi.execution.produce.dispersed.mapper.BpmExecuteNodeFormMapper;
|
|
|
import com.ruoyi.execution.produce.dispersed.mapper.BpmExecuteNodeMapper;
|
|
|
import com.ruoyi.execution.produce.dispersed.mapper.BpmExecuteNodeMiddleMapper;
|
|
|
import com.ruoyi.execution.produce.dispersed.mapper.BpmExecuteProcessMapper;
|
|
@@ -74,6 +80,9 @@ public class PreExecutionToolClass<R> {
|
|
|
private VerifyExecutionProcess iVerifyExecutionProcess;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BpmExecuteNodeFormMapper executeNodeFormMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 预执行流程自动执行开始节点
|
|
|
*
|
|
@@ -81,16 +90,16 @@ public class PreExecutionToolClass<R> {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
- @Async
|
|
|
+ //@Async
|
|
|
public AjaxResult ReadyToExecute(CommonEntity commonEntity) {
|
|
|
// 获取发起流程所需数据
|
|
|
IntoProduction intoProduction = this.obtainData(commonEntity);
|
|
|
/**
|
|
|
* 根据流程key校验当前流程数据的完整性,是否可以运行
|
|
|
*/
|
|
|
- if (!iVerifyExecutionProcess.VerifyProcessData(intoProduction.getTaskProcessKey())) {
|
|
|
- return AjaxResult.error(HttpStatus.EXECUTEPROCESS, "流程数据验证失败!");
|
|
|
- }
|
|
|
+ //if (!iVerifyExecutionProcess.VerifyProcessData(intoProduction.getTaskProcessKey())) {
|
|
|
+ // return AjaxResult.error(HttpStatus.EXECUTEPROCESS, "流程数据验证失败!");
|
|
|
+ //}
|
|
|
/**1️⃣1️⃣1️⃣ 得到当前投产需要执行的流程详细信息*/
|
|
|
//--得到当前流程的详细信息
|
|
|
BpmProcess bpmProcess = bpmProcessMapper.selectBpmProcessByProcessKey(intoProduction.getTaskProcessKey());
|
|
@@ -435,6 +444,12 @@ public class PreExecutionToolClass<R> {
|
|
|
return intoProduction;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询节点对应的表单信息
|
|
|
+ * @param nodeForm
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public Map<String, Object> getNodeFormInfos(Map<String, String> nodeForm) {
|
|
|
Set<String> nodeKey = nodeForm.keySet();
|
|
|
Map resultMap = new HashMap();
|
|
@@ -452,4 +467,141 @@ public class PreExecutionToolClass<R> {
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
+ // 弃用保留
|
|
|
+ public int updateNodeState(String taskProcessKey, String taskNodeKey, CommonEntity commonEntity) {
|
|
|
+ BpmExecuteNode bpmExecuteNode1 = new BpmExecuteNode();
|
|
|
+ bpmExecuteNode1.setTaskProcessKey(taskProcessKey);
|
|
|
+ bpmExecuteNode1.setTaskNodeKey(taskNodeKey);
|
|
|
+ bpmExecuteNode1.setTaskNodeState("1"); // 状态标识已经执行
|
|
|
+ // 修改当前节点的状态
|
|
|
+ runBpmExecuteNodeMapper.updateNodeState(bpmExecuteNode1);
|
|
|
+
|
|
|
+ // 得到当前节点的所有信息
|
|
|
+ BpmExecuteNode currentBpmExecuteNode = runBpmExecuteNodeMapper.queryBpmExecuteNodeBytaskNodeKey(taskProcessKey, taskNodeKey);
|
|
|
+ /**
|
|
|
+ * 执行当前节点配置的操作 例如:当前节点中的自动执行的脚本
|
|
|
+ * 得到当前节点的关联信息
|
|
|
+ */
|
|
|
+ BpmExecuteNodeMiddle bpmExecuteNodeMiddle = runBpmExecuteNodeMiddleMapper.queryBpmExecuteNodeMiddleByTaskNodeKey(taskProcessKey, taskNodeKey);
|
|
|
+ String script[] = bpmExecuteNodeMiddle.getTaskAutomaticScriptTriggerType().split(","); // 得到当前节点需要自动执行的脚本
|
|
|
+ // 1️⃣1️⃣1️⃣节点前执行的脚本
|
|
|
+ if (currentBpmExecuteNode.getTaskNodeBefore().equals("true")) {
|
|
|
+ // 调用执行脚本接口
|
|
|
+ if (script.length != 0 && !script[0].isEmpty()) {
|
|
|
+ for (int i = 0; i < script.length; i++) {
|
|
|
+ // 节点执行必要的参数
|
|
|
+ IScriptEntity iScriptEntity = new IScriptEntity();
|
|
|
+ iScriptEntity.setScriptFlowKey(taskProcessKey);
|
|
|
+ iScriptEntity.setScriptNodeKey(taskNodeKey);
|
|
|
+ iScriptEntity.setImplementationName(script[i]);
|
|
|
+ // 调用执行节点
|
|
|
+ iRunImplementationClass.RunScriptImplementationClassLogicCode(iScriptEntity, commonEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2️⃣2️⃣2️⃣执行节点绑定的正常脚本
|
|
|
+ IRunBPMEntity iRunBPMEntity = new IRunBPMEntity();
|
|
|
+ iRunBPMEntity.setImplementationName(commonEntity.getBasicMap().get("implementationName").toString());
|
|
|
+ iRunBPMEntity.setExecutionFlowKey(taskProcessKey);
|
|
|
+ iRunBPMEntity.setExecutionNodeKey(taskNodeKey);
|
|
|
+ iRunBPMEntity.setExecutionMap((Map<String, Object>) JSON.parse(commonEntity.toString()));
|
|
|
+ iRunImplementationClass.RunBPMImplementationClassLogicCode(iRunBPMEntity);
|
|
|
+ // 3️⃣3️⃣3️⃣节点后执行的脚本
|
|
|
+ if (currentBpmExecuteNode.getTaskNodeAfter().equals("true")) {
|
|
|
+ // 调用执行脚本接口
|
|
|
+ if (script.length != 0 && !script[0].isEmpty()) {
|
|
|
+ for (int i = 0; i < script.length; i++) {
|
|
|
+ // 节点执行必要的参数
|
|
|
+ IScriptEntity iScriptEntity = new IScriptEntity();
|
|
|
+ iScriptEntity.setScriptFlowKey(taskProcessKey);
|
|
|
+ iScriptEntity.setScriptNodeKey(taskNodeKey);
|
|
|
+ iScriptEntity.setImplementationName(script[i]);
|
|
|
+ // 调用执行节点
|
|
|
+ iRunImplementationClass.RunScriptImplementationClassLogicCode(iScriptEntity, commonEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 共通执行节点表单模版接口
|
|
|
+ */
|
|
|
+ public List<Map> getProcessNodeFormTemplate(BpmRunNodePlusVo bpmRunNodeV) {
|
|
|
+ //任务流程key
|
|
|
+ String taskProcessKey = bpmRunNodeV.getTaskProcessKey();
|
|
|
+ //任务节点key
|
|
|
+ String taskNodeKey = bpmRunNodeV.getTaskNodeKey();
|
|
|
+ //脚本名称
|
|
|
+ String taskScriptKey = bpmRunNodeV.getTaskScriptKey();
|
|
|
+ //根据流程key和节点key查询节点表单关系表【bpm_execute_node_form】
|
|
|
+ BpmExecuteNodeForm bpmExecuteNodeForm = iBpmExecuteNodeFormService.getBpmExecuteNodeForm(taskProcessKey, taskNodeKey,taskScriptKey);
|
|
|
+ //存放返回结果
|
|
|
+ List<Map> mapList=new ArrayList<>();
|
|
|
+ //节点对应的表单信息不能为空
|
|
|
+ if(bpmExecuteNodeForm!=null){
|
|
|
+ String taskNodeFromContent = bpmExecuteNodeForm.getTaskNodeFromContent();
|
|
|
+ //拿到当前节点对应的表单类型
|
|
|
+ String taskNodeFromType = bpmExecuteNodeForm.getTaskNodeFromType();
|
|
|
+ if(taskNodeFromType.equals("dragForm")){
|
|
|
+ HashMap hashMap=new HashMap();
|
|
|
+ //解析存进去的表单信息【task_node_from_content】
|
|
|
+ JSONObject taskNodeFromContentJson = JSONObject.parseObject(taskNodeFromContent);
|
|
|
+ //得到sqlKey
|
|
|
+ String sqlKey = taskNodeFromContentJson.get("sqlKey").toString();
|
|
|
+ //根据sqlKey查询表单数据
|
|
|
+ if(!sqlKey.isEmpty()){
|
|
|
+ Map<String, String> tableSqlBySqlKey = executeNodeFormMapper.getTableSqlBySqlKey(sqlKey);
|
|
|
+ hashMap.put("resultMap",tableSqlBySqlKey);
|
|
|
+ }
|
|
|
+ //得到【df_form_sql】
|
|
|
+ String dfFormSql = taskNodeFromContentJson.get("dfFormSql").toString();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Map<String, Object> sqlMap=null;
|
|
|
+ try {
|
|
|
+ sqlMap = objectMapper.readValue(dfFormSql, Map.class);
|
|
|
+ //循环得到每一个sql语句返回结果
|
|
|
+ for (Map.Entry<String, Object> entry : sqlMap.entrySet()) {
|
|
|
+ List<Map<String, Object>> resultMap = executeNodeFormMapper.executeSql(entry.getValue().toString());
|
|
|
+ sqlMap.put(entry.getKey(), resultMap);
|
|
|
+ }
|
|
|
+ //把原来的sql语句替换成下拉框数据
|
|
|
+ taskNodeFromContentJson.put("dfFormSql",JSONObject.toJSONString(sqlMap));
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //表单结构信息
|
|
|
+ hashMap.put("template",taskNodeFromContentJson);
|
|
|
+ //添加到返回集合中
|
|
|
+ mapList.add(hashMap);
|
|
|
+ }else if(taskNodeFromType.equals("composeForm")){
|
|
|
+ //参数为一个数组
|
|
|
+ JSONArray objects = JSON.parseArray(taskNodeFromContent);
|
|
|
+ //循环数组元素
|
|
|
+ objects.forEach(item->{
|
|
|
+ String s = item.toString();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
+ String tableSql = jsonObject.get("tableSql").toString();
|
|
|
+ String conditionArrayJson = jsonObject.get("condition").toString();
|
|
|
+ JSONArray jsonArray = JSON.parseArray(conditionArrayJson);
|
|
|
+ jsonArray.forEach(conditionItem->{
|
|
|
+ //处理下这个条件 去掉 #{ 去掉.
|
|
|
+ String conditionString = conditionItem.toString().replace("#{", "").replace(".", "_");
|
|
|
+ //转驼峰
|
|
|
+ String CamelConditionString = CamelCaseConverterUtil.toCamelCase(conditionString);
|
|
|
+ //
|
|
|
+ });
|
|
|
+ Map<String, String> stringHashMap = executeNodeFormMapper.tableSql(tableSql);
|
|
|
+ jsonObject.put("tableList", stringHashMap);
|
|
|
+ mapList.add(jsonObject);
|
|
|
+ });
|
|
|
+ }else if(taskNodeFromContent.equals("designForm")){
|
|
|
+ HashMap hashMap=new HashMap();
|
|
|
+ hashMap.put("resultMap","");
|
|
|
+ hashMap.put("template","");
|
|
|
+ mapList.add(hashMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return mapList;
|
|
|
+ }
|
|
|
}
|