|
@@ -1,15 +1,22 @@
|
|
|
package com.zkqy.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.zkqy.common.constant.HttpStatus;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
|
import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.SecurityUtils;
|
|
|
+import com.zkqy.common.utils.StringUtils;
|
|
|
import com.zkqy.common.utils.bpm.XmlDataParserUtils;
|
|
|
import com.zkqy.common.utils.uuid.IdUtils;
|
|
|
import com.zkqy.execution.produce.dispersed.entity.*;
|
|
|
import com.zkqy.execution.produce.dispersed.entity.runbpm.*;
|
|
|
import com.zkqy.execution.produce.dispersed.mapper.*;
|
|
|
+import com.zkqy.execution.produce.dispersed.service.IBpmApprovalStatusService;
|
|
|
import com.zkqy.execution.produce.dispersed.service.IBpmExecuteNodeFormService;
|
|
|
import com.zkqy.execution.produce.dispersed.service.IBpmExecuteNodeLogService;
|
|
|
import com.zkqy.execution.produce.dispersed.service.IBpmExecuteProcessService;
|
|
@@ -71,6 +78,9 @@ public class PreExecutionToolClass<R> {
|
|
|
@Autowired // 节点日志
|
|
|
private IBpmExecuteNodeLogService iBpmExecuteNodeLogService;
|
|
|
|
|
|
+ @Autowired // 审批流程中间表
|
|
|
+ private IBpmApprovalStatusService iBpmApprovalStatusService;
|
|
|
+
|
|
|
/**
|
|
|
* 预执行流程自动执行开始节点
|
|
|
*
|
|
@@ -84,13 +94,25 @@ public class PreExecutionToolClass<R> {
|
|
|
/**
|
|
|
* 根据流程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());
|
|
|
+
|
|
|
+ String taskKey = IdUtils.fastSimpleUUID(); // 得到流程的唯一标识
|
|
|
+ if (bpmProcess.getProcessType().toString().equals("1")) { // 当前被发起的流程是审批类型
|
|
|
+ // 发起审批类型的流程逻辑
|
|
|
+ BpmApprovalStatus bpmApprovalStatus = new BpmApprovalStatus();
|
|
|
+ bpmApprovalStatus.setTableName(intoProduction.getTableName());
|
|
|
+ bpmApprovalStatus.setTableId(intoProduction.getGuid());
|
|
|
+ bpmApprovalStatus.setApprovalState("5");// 当前流程发起后更改数据条状态
|
|
|
+ bpmApprovalStatus.setTaskKey(taskKey);
|
|
|
+ // 新增审批关系表
|
|
|
+ iBpmApprovalStatusService.insertBpmApprovalStatus(bpmApprovalStatus);
|
|
|
+ }
|
|
|
//---根据流程key得到当前流程的所有节点信息
|
|
|
List<BpmProcessConfiguration> bpmProcessConfigurationList =
|
|
|
bpmProcessConfigurationMapper.selectBpmProcessConfigurationList(
|
|
@@ -119,7 +141,7 @@ public class PreExecutionToolClass<R> {
|
|
|
/**2️⃣2️⃣2️⃣ 新增执行流程表数据*/
|
|
|
BpmExecuteProcess runBpmExecuteProcess = new BpmExecuteProcess();
|
|
|
// 当前流程启动的唯一标识
|
|
|
- runBpmExecuteProcess.setTaskKey(IdUtils.fastSimpleUUID());
|
|
|
+ runBpmExecuteProcess.setTaskKey(taskKey);
|
|
|
// 投产数据条的唯一标识
|
|
|
runBpmExecuteProcess.setTaskPlanKey(intoProduction.getGuid().split("=")[1]);
|
|
|
// 当前流程任务名称
|
|
@@ -276,6 +298,8 @@ public class PreExecutionToolClass<R> {
|
|
|
iBpmExecuteNodeLogService.insertBpmExecuteNodeLog(bpmExecuteNodeLog);
|
|
|
}
|
|
|
});
|
|
|
+ // 0L:表示工业类型 1L表示审批类型
|
|
|
+ if (bpmProcess.getProcessType() == 1L) return AjaxResult.success();
|
|
|
if (optionalStartNode.isPresent()) {
|
|
|
// optionalStartNode.get().getNodeKey(); 当前流程开始节点key
|
|
|
Optional<BpmUserScriptVo> optionalBpmUserScriptVo = bpmUserScriptVoList.stream().filter(item -> item.getNodeKey().equals(optionalStartNode.get().getNodeKey())).findFirst();
|
|
@@ -481,6 +505,122 @@ public class PreExecutionToolClass<R> {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 共通执行节点表单模版接口
|
|
|
+ */
|
|
|
+ public List<Map> getProcessNodeFormTemplate(BpmRunNodeFromVo bpmRunNodeFromVo) {
|
|
|
+ //任务流程key
|
|
|
+ String taskProcessKey = bpmRunNodeFromVo.getTaskProcessKey();
|
|
|
+ //任务节点key
|
|
|
+ String taskNodeKey = bpmRunNodeFromVo.getTaskNodeKey();
|
|
|
+ //脚本名称
|
|
|
+ // String taskScriptKey = bpmRunNodeFromVo.getTaskScriptKey();
|
|
|
+ //根据流程key和节点key查询节点表单关系表【bpm_execute_node_form】
|
|
|
+ BpmExecuteNodeForm bpmExecuteNodeForm = iBpmExecuteNodeFormService.getBpmExecuteNodeForm(taskProcessKey, taskNodeKey, null);
|
|
|
+ //存放返回结果
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+ //节点对应的表单信息不能为空
|
|
|
+ if (bpmExecuteNodeForm != null) {
|
|
|
+ String taskNodeFormContent = bpmExecuteNodeForm.getTaskNodeFormContent();
|
|
|
+
|
|
|
+ //拿到当前节点对应的表单类型
|
|
|
+ String taskNodeFormType = bpmExecuteNodeForm.getTaskNodeFormType();
|
|
|
+ if (taskNodeFormType.equals("dragForm")) {
|
|
|
+ HashMap hashMap = new HashMap();
|
|
|
+ //解析存进去的表单信息【task_node_from_content】
|
|
|
+ JSONObject taskNodeFromContentJson = JSONObject.parseObject(taskNodeFormContent);
|
|
|
+ //得到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 (taskNodeFormType.equals("dragFormGroup")) { // 当前节点绑定的是表单组类型
|
|
|
+ HashMap hashMap = new HashMap();
|
|
|
+ //解析存进去的表单信息【task_node_from_content】
|
|
|
+ JSONObject taskNodeFromContentJson = JSONObject.parseObject(taskNodeFormContent);
|
|
|
+ //得到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 (taskNodeFormType.equals("composeForm")) {
|
|
|
+ //参数为一个数组
|
|
|
+ JSONArray objects = JSON.parseArray(taskNodeFormContent);
|
|
|
+
|
|
|
+ //循环数组元素
|
|
|
+ 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 = StringUtils.toCamelCase(conditionString);
|
|
|
+ //
|
|
|
+ });
|
|
|
+
|
|
|
+ Map<String, String> stringHashMap = executeNodeFormMapper.tableSql(tableSql);
|
|
|
+ jsonObject.put("tableList", stringHashMap);
|
|
|
+ mapList.add(jsonObject);
|
|
|
+ });
|
|
|
+ } else if (taskNodeFormContent.equals("designForm")) {
|
|
|
+ HashMap hashMap = new HashMap();
|
|
|
+ hashMap.put("resultMap", "");
|
|
|
+ hashMap.put("template", "");
|
|
|
+ mapList.add(hashMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return mapList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查询节点对应的表单信息
|
|
|
*
|
|
@@ -494,6 +634,12 @@ public class PreExecutionToolClass<R> {
|
|
|
if (nodeForm.get(item).equals("dragForm")) { // 拖拽类型的表单
|
|
|
String fromInfo = iBpmExecuteProcessService.getFromInfo(item);
|
|
|
resultMap.put(item, fromInfo);
|
|
|
+ } else if (nodeForm.get(item).equals("dragFormGroup")) { // 拖拽的表单组
|
|
|
+
|
|
|
+ String groupTableInfo = iBpmExecuteProcessService.getGroupTableInfo(item);
|
|
|
+
|
|
|
+
|
|
|
+ resultMap.put(item, groupTableInfo);
|
|
|
} else if (nodeForm.get(item).equals("composeForm")) { // 组合类型的表单
|
|
|
String groupTableInfo = iBpmExecuteProcessService.getGroupTableInfo(item);
|
|
|
resultMap.put(item, groupTableInfo);
|
|
@@ -546,10 +692,99 @@ public class PreExecutionToolClass<R> {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 执行审批流程节点
|
|
|
+ *
|
|
|
+ * @param bpmRunNodeVo 当前节点信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public AjaxResult approvalNode(BpmRunNodeVo bpmRunNodeVo) {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 不能确定某张表可以发起流程,也就是发起审批的这个条数据需要回传后台标识
|
|
|
+ *
|
|
|
+ * 表名以及当前数据条的主键,
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 1️⃣1️⃣1️⃣ 准备执行节点所需数据
|
|
|
+ * * 审批节点不过是通过、未通过、驳回等状态信息
|
|
|
+ * * 审批备注与通过、不通过等状态是同一列数据,
|
|
|
+ * * 如果轮回审批,那么备注字段也会是同列,之前审批的状态以及审批备注,需要从日志表中获取
|
|
|
+ * * 把当前流程节点的完整执行记录到日志表中,审批流程的执行只修改状态
|
|
|
+ */
|
|
|
+ String taskProcessKey = bpmRunNodeVo.getTaskProcessKey(); // 任务流程编码
|
|
|
+ String taskNodeKey = bpmRunNodeVo.getTaskNodeKey(); // 任务节点编码
|
|
|
+ String taskNextNodeKey = XmlDataParserUtils.getNextNodeKey(bpmRunNodeVo.getTaskProcessXmlContent(), taskNodeKey);
|
|
|
+ // 获取当前节点的下个节点类型
|
|
|
+ String taskNextNodeType = XmlDataParserUtils.getNodeType(bpmRunNodeVo.getTaskProcessXmlContent(), taskNextNodeKey);
|
|
|
+
|
|
|
|
|
|
- public CommonEntity getProcessNodeFormTemplate(BpmRunNodeFromVo bpmRunNodeFromVo) {
|
|
|
- CommonEntity commonEntity = new CommonEntity();
|
|
|
- return commonEntity;
|
|
|
+ // 得到当前执行的流程信息
|
|
|
+ BpmExecuteProcess currentBpmExecuteProcess = runBpmExecuteProcessMapper.selectBpmExecuteProcessByTaskKey(taskProcessKey);
|
|
|
+ // 得到当前节点的所有信息-》审批类型节点会出现节点后给某张表插入数据
|
|
|
+ BpmExecuteNode currentBpmExecuteNode = runBpmExecuteNodeMapper.queryBpmExecuteNodeBytaskNodeKey(taskProcessKey, taskNodeKey);
|
|
|
+ // 审批备注
|
|
|
+ String approvalRemark = bpmRunNodeVo.getApprovalRemark();
|
|
|
+ // 审批状态 pass:通过、noPass:不通过、reject:驳回
|
|
|
+ String approvalStatus = bpmRunNodeVo.getApprovalStatus();
|
|
|
+ // 当前执行的节点全部信息
|
|
|
+ currentBpmExecuteNode.setTaskNodeOtherState(approvalStatus);
|
|
|
+ currentBpmExecuteNode.setTaskRemark(approvalRemark);
|
|
|
+
|
|
|
+ // 当前执行的流程
|
|
|
+ currentBpmExecuteProcess.setTaskNodeKey(taskNodeKey);
|
|
|
+ currentBpmExecuteProcess.setTaskNodeNextKey(taskNextNodeKey);
|
|
|
+
|
|
|
+ // 2️⃣2️⃣2️⃣ 开始执行当前节点
|
|
|
+ // 补充流程节点信息(如若驳回操作,会显示上次审批记录)
|
|
|
+ runBpmExecuteNodeMapper.updateBpmExecuteNode(currentBpmExecuteNode);
|
|
|
+ // --- 修改当前流程执行节点
|
|
|
+ runBpmExecuteProcessMapper.updateProcessNode(currentBpmExecuteProcess);
|
|
|
+ // --- 修改当前审批的数据条状态
|
|
|
+
|
|
|
+
|
|
|
+ // 3️⃣3️⃣3️⃣ 判断当前节点是否存在给其他表插入数据
|
|
|
+ // currentBpmExecuteNode.getTask
|
|
|
+
|
|
|
+ // ⚠️⚠️⚠️ 新增节点执行记录
|
|
|
+ BpmExecuteNodeLog bpmExecuteNodeLog = new BpmExecuteNodeLog(currentBpmExecuteNode);
|
|
|
+ iBpmExecuteNodeLogService.insertBpmExecuteNodeLog(bpmExecuteNodeLog);
|
|
|
+
|
|
|
+ // 4️⃣4️⃣4️⃣ 判断是否结束审批流程
|
|
|
+ if (taskNextNodeType.equals("endEvent")) {
|
|
|
+ // 当前节点是改流程的最后一个节点,默认执行结束节点
|
|
|
+ // 结束节点也是只修改状态
|
|
|
+ // runBpmExecuteProcessMapper.updateProcessNode();
|
|
|
+
|
|
|
+ // 审批流程结束,修改当前审批关联数据条的关联数据条的状态(bpm_approval_status)
|
|
|
+ // 审批状态 (0:已提交、1:已通过、2:不通过、4:驳回、5:审批中)
|
|
|
+ // iBpmApprovalStatusService.updateBpmApprovalStatus();
|
|
|
+// iBpmApprovalStatusService.updateBpmApprovalStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * €23092802001001001820€0990€23-0€0001€BTS高弹单丝轻网€100D/36f€001特黑€AA
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ /* 审批的发起操作,相当于这个流程的开始
|
|
|
+ 那么用户首次调用当前接口,都会就是一级审批
|
|
|
+ 需要当前操作的状态以及审批过后的备注信息 两列数据。
|
|
|
+ 修改节点状态,添加审批的数据,修改流程执行节点的key。
|
|
|
+ 如何当前节点有节点后需要插入的其他表数据则执行。
|
|
|
+
|
|
|
+ 理论上来讲每一个节点的表单都是一样的,都是审批数据条是否通过,以及审批意见
|
|
|
+ 如果需要审批的数据条是多表中的数据,也看作为一条数据来处理。
|
|
|
+
|
|
|
+ 流程发起时的表单数据开始存在用户的表中,所以同生产流程逻辑一样。
|
|
|
+ 在发起这个流程的时候记录当前的数据条的表名以及表主键
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
}
|