|
@@ -16,16 +16,15 @@ 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;
|
|
|
+import com.zkqy.execution.produce.dispersed.service.*;
|
|
|
import com.zkqy.execution.produce.utils.VerifyExecutionProcess;
|
|
|
+import lombok.val;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@@ -72,7 +71,7 @@ public class PreExecutionToolClass<R> {
|
|
|
@Autowired // 校验执行流程的数据
|
|
|
private VerifyExecutionProcess iVerifyExecutionProcess;
|
|
|
|
|
|
- @Autowired // 节点表单
|
|
|
+ @Autowired // 节点
|
|
|
private BpmExecuteNodeFormMapper executeNodeFormMapper;
|
|
|
|
|
|
@Autowired // 节点日志
|
|
@@ -81,8 +80,15 @@ public class PreExecutionToolClass<R> {
|
|
|
@Autowired // 审批流程中间表
|
|
|
private IBpmApprovalStatusService iBpmApprovalStatusService;
|
|
|
|
|
|
+ @Autowired // 通用查询
|
|
|
+ private ICommonService commonService;
|
|
|
+
|
|
|
+ @Autowired // 表单组
|
|
|
+ private IDragFormGroupService iDragFormGroupService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 预执行流程自动执行开始节点
|
|
|
+ * 预执行流程、自动执行开始节点
|
|
|
*
|
|
|
* @param commonEntity
|
|
|
* @return
|
|
@@ -132,6 +138,14 @@ public class PreExecutionToolClass<R> {
|
|
|
if (item.getNodeRolePermission() != null) {
|
|
|
bpmUserScriptVo.setBpmNodeHandleUserList(bpmNodeHandleUserMapper.selectBpmNodeHandleUserList(new BpmNodeHandleUser(item.getNodeRolePermission())));
|
|
|
}
|
|
|
+ // 判断流程类型是否是审批类型
|
|
|
+ // 审批类型默认是没有脚本的
|
|
|
+// if (bpmProcess.getProcessType().equals("1")) {
|
|
|
+// bpmNodeScriptRelevanceList.addAll(bpmUserScriptVo.getBpmNodeScriptRelevanceList());
|
|
|
+// bpmUserScriptVoList.add(bpmUserScriptVo);
|
|
|
+// } else if (bpmProcess.getProcessType().equals("0")) {
|
|
|
+//
|
|
|
+// }
|
|
|
bpmUserScriptVo.setBpmNodeScriptRelevanceList(bpmNodeScriptRelevanceMapper.selectBpmNodeScriptRelevanceList(new BpmNodeScriptRelevance(item.getNodeKey())));
|
|
|
bpmNodeScriptRelevanceList.addAll(bpmUserScriptVo.getBpmNodeScriptRelevanceList());
|
|
|
bpmUserScriptVoList.add(bpmUserScriptVo);
|
|
@@ -323,6 +337,7 @@ public class PreExecutionToolClass<R> {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 执行流程节点共通接口
|
|
|
*
|
|
@@ -507,6 +522,7 @@ public class PreExecutionToolClass<R> {
|
|
|
|
|
|
/**
|
|
|
* 共通执行节点表单模版接口
|
|
|
+ * * 目前只有审批节点在调用这个接口
|
|
|
*/
|
|
|
public List<Map> getProcessNodeFormTemplate(BpmRunNodeFromVo bpmRunNodeFromVo) {
|
|
|
//任务流程key
|
|
@@ -532,10 +548,12 @@ public class PreExecutionToolClass<R> {
|
|
|
//得到sqlKey
|
|
|
String sqlKey = taskNodeFromContentJson.get("sqlKey").toString();
|
|
|
//根据sqlKey查询表单数据
|
|
|
- if (!sqlKey.isEmpty()) {
|
|
|
- Map<String, String> tableSqlBySqlKey = executeNodeFormMapper.getTableSqlBySqlKey(sqlKey);
|
|
|
- hashMap.put("resultMap", tableSqlBySqlKey);
|
|
|
- }
|
|
|
+
|
|
|
+// 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();
|
|
@@ -552,37 +570,108 @@ public class PreExecutionToolClass<R> {
|
|
|
} catch (JsonProcessingException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ // 获取当前流程审批的表单数据关系
|
|
|
+ BpmApprovalStatus bpmApprovalStatus = iBpmApprovalStatusService.selectBpmApprovalStatusByTaskKey(bpmRunNodeFromVo.getTaskProcessKey());
|
|
|
+ // 通用查询方法
|
|
|
+ CommonEntity common = new CommonEntity();
|
|
|
+ common.getBasicMap().put("tableName", bpmApprovalStatus.getTableName());
|
|
|
+ common.getQueryMap().put(bpmApprovalStatus.getTableId().split("=")[0], bpmApprovalStatus.getTableId().split("=")[1]);
|
|
|
+ // 添加结果当前回显表单的数据信息
|
|
|
+ taskNodeFromContentJson.put("resultMap", commonService.selectList(common));
|
|
|
//表单结构信息
|
|
|
hashMap.put("template", taskNodeFromContentJson);
|
|
|
//添加到返回集合中
|
|
|
mapList.add(hashMap);
|
|
|
- } else if (taskNodeFormType.equals("dragFormGroup")) { // 当前节点绑定的是表单组类型
|
|
|
+ } 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);
|
|
|
+
|
|
|
+ // 主表单逻辑
|
|
|
+ if (taskNodeFromContentJson.get("mainForm") != null) {
|
|
|
+ Map<String, Object> mianFormMap = (Map<String, Object>) ((Map) taskNodeFromContentJson.get("mainForm")).get("showTemplate");
|
|
|
+ //得到sqlKey
|
|
|
+ String sqlKey = mianFormMap.get("sqlKey").toString();
|
|
|
+ //根据sqlKey查询表单数据
|
|
|
+ if (!sqlKey.isEmpty()) {
|
|
|
+ Map<String, String> tableSqlBySqlKey = executeNodeFormMapper.getTableSqlBySqlKey(sqlKey);
|
|
|
+ hashMap.put("resultMap", tableSqlBySqlKey);
|
|
|
}
|
|
|
- //把原来的sql语句替换成下拉框数据
|
|
|
- taskNodeFromContentJson.put("dfFormSql", JSONObject.toJSONString(sqlMap));
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ //得到【df_form_sql】
|
|
|
+ String dfFormSql = mianFormMap.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语句替换成下拉框数据
|
|
|
+ mianFormMap.put("dfFormSql", JSONObject.toJSONString(sqlMap));
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从表单逻辑
|
|
|
+ if (taskNodeFromContentJson.get("subFormList") != null) {
|
|
|
+ ((ArrayList) taskNodeFromContentJson.get("subFormList")).forEach(item -> {
|
|
|
+ Map<String, Object> itemMap = (Map<String, Object>) ((Map) item).get("showTemplate");
|
|
|
+
|
|
|
+ //得到sqlKey
|
|
|
+ String sqlKey = itemMap.get("sqlKey").toString();
|
|
|
+
|
|
|
+ //根据sqlKey查询表单数据
|
|
|
+ if (!sqlKey.isEmpty()) {
|
|
|
+ Map<String, String> tableSqlBySqlKey = executeNodeFormMapper.getTableSqlBySqlKey(sqlKey);
|
|
|
+ hashMap.put("resultMap", tableSqlBySqlKey);
|
|
|
+ }
|
|
|
+ //得到【df_form_sql】
|
|
|
+ String dfFormSql = itemMap.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语句替换成下拉框数据
|
|
|
+ itemMap.put("dfFormSql", JSONObject.toJSONString(sqlMap));
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ // 获取当前流程审批的表单数据关系
|
|
|
+ BpmApprovalStatus bpmApprovalStatus = iBpmApprovalStatusService.selectBpmApprovalStatusByTaskKey(bpmRunNodeFromVo.getTaskProcessKey());
|
|
|
+ // 通用查询方法
|
|
|
+ CommonEntity common = new CommonEntity();
|
|
|
+ common.getBasicMap().put("tableName", bpmApprovalStatus.getTableName());
|
|
|
+ common.getQueryMap().put(bpmApprovalStatus.getTableId().split("=")[0], bpmApprovalStatus.getTableId().split("=")[1]);
|
|
|
+ // 添加结果当前回显表单的数据信息
|
|
|
+
|
|
|
+ // 主
|
|
|
+ List<CommonEntity> retCommonEntityList = commonService.selectList(common);
|
|
|
+
|
|
|
+ ((Map) taskNodeFromContentJson.get("mainForm")).put("showValue", retCommonEntityList);
|
|
|
+
|
|
|
+ // 从
|
|
|
+ ((ArrayList) taskNodeFromContentJson.get("subFormList")).forEach(item -> {
|
|
|
+ String[] congTableOInfo = ((Map) item).get("formItem").toString().split("\\.");
|
|
|
+ String[] zhuTableOWhere = ((Map) item).get("relateMainItem").toString().split("\\.");
|
|
|
+ CommonEntity congCommon = new CommonEntity();
|
|
|
+ congCommon.getBasicMap().put("tableName", congTableOInfo[0]);
|
|
|
+ Object val = retCommonEntityList.get(0).getResultMap().get(StringUtils.toCamelCase(zhuTableOWhere[1]));
|
|
|
+ congCommon.getQueryMap().put(congTableOInfo[1], val);
|
|
|
+ commonService.selectList(congCommon);
|
|
|
+ ((Map) item).put("showValue", commonService.selectList(congCommon));
|
|
|
+ });
|
|
|
+ taskNodeFromContentJson.put("resultMap", retCommonEntityList);
|
|
|
//表单结构信息
|
|
|
hashMap.put("template", taskNodeFromContentJson);
|
|
|
//添加到返回集合中
|
|
@@ -632,14 +721,29 @@ public class PreExecutionToolClass<R> {
|
|
|
Map resultMap = new HashMap();
|
|
|
nodeKey.forEach(item -> {
|
|
|
if (nodeForm.get(item).equals("dragForm")) { // 拖拽类型的表单
|
|
|
- String fromInfo = iBpmExecuteProcessService.getFromInfo(item);
|
|
|
+ String fromInfo = iBpmExecuteProcessService.getFromInfoByFormKey(item);
|
|
|
resultMap.put(item, fromInfo);
|
|
|
} else if (nodeForm.get(item).equals("dragFormGroup")) { // 拖拽的表单组
|
|
|
-
|
|
|
- String groupTableInfo = iBpmExecuteProcessService.getGroupTableInfo(item);
|
|
|
-
|
|
|
-
|
|
|
- resultMap.put(item, groupTableInfo);
|
|
|
+ // 得到当前表格组的信息
|
|
|
+ DragFormGroup dragFormGroup = iDragFormGroupService.selectDragFormGroupByKey(item);
|
|
|
+ // 根据表单组中的keys信息 获取对应动态表单的信息
|
|
|
+ String[] formKeys = JSON.parseArray(dragFormGroup.getFormKeys()).toArray(String.class);
|
|
|
+ List<CommonEntity> commonEntityList = iBpmExecuteProcessService.getFromInfoByFormKeys(formKeys);
|
|
|
+ // 当前表单组关系
|
|
|
+ Map<String, Object> relationJsonMap = (Map<String, Object>) JSON.parse(dragFormGroup.getRelationJson());
|
|
|
+ // 得到当前主表单key
|
|
|
+ ((Map) relationJsonMap.get("mainForm")).get("formKey");
|
|
|
+ // 主表单增加模版信息
|
|
|
+ commonEntityList.forEach(ctem -> {
|
|
|
+ if (ctem.getResultMap().get("formKey").equals(((Map) relationJsonMap.get("mainForm")).get("formKey"))) {
|
|
|
+ ((Map) relationJsonMap.get("mainForm")).put("showTemplate", ctem.getResultMap());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 从表单增加模版信息
|
|
|
+ ((ArrayList) relationJsonMap.get("subFormList")).forEach(rtem -> {
|
|
|
+ ((Map) rtem).put("showTemplate", commonEntityList.stream().filter(ctem -> ctem.getResultMap().get("formKey").equals(((Map) rtem).get("formKey"))).findFirst().get().getResultMap());
|
|
|
+ });
|
|
|
+ resultMap.put(item, relationJsonMap.toString());
|
|
|
} else if (nodeForm.get(item).equals("composeForm")) { // 组合类型的表单
|
|
|
String groupTableInfo = iBpmExecuteProcessService.getGroupTableInfo(item);
|
|
|
resultMap.put(item, groupTableInfo);
|
|
@@ -699,14 +803,11 @@ public class PreExecutionToolClass<R> {
|
|
|
* @return
|
|
|
*/
|
|
|
public AjaxResult approvalNode(BpmRunNodeVo bpmRunNodeVo) {
|
|
|
-
|
|
|
/**
|
|
|
* 不能确定某张表可以发起流程,也就是发起审批的这个条数据需要回传后台标识
|
|
|
*
|
|
|
* 表名以及当前数据条的主键,
|
|
|
*/
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 1️⃣1️⃣1️⃣ 准备执行节点所需数据
|
|
|
* * 审批节点不过是通过、未通过、驳回等状态信息
|
|
@@ -719,8 +820,6 @@ public class PreExecutionToolClass<R> {
|
|
|
String taskNextNodeKey = XmlDataParserUtils.getNextNodeKey(bpmRunNodeVo.getTaskProcessXmlContent(), taskNodeKey);
|
|
|
// 获取当前节点的下个节点类型
|
|
|
String taskNextNodeType = XmlDataParserUtils.getNodeType(bpmRunNodeVo.getTaskProcessXmlContent(), taskNextNodeKey);
|
|
|
-
|
|
|
-
|
|
|
// 得到当前执行的流程信息
|
|
|
BpmExecuteProcess currentBpmExecuteProcess = runBpmExecuteProcessMapper.selectBpmExecuteProcessByTaskKey(taskProcessKey);
|
|
|
// 得到当前节点的所有信息-》审批类型节点会出现节点后给某张表插入数据
|
|
@@ -752,22 +851,21 @@ public class PreExecutionToolClass<R> {
|
|
|
BpmExecuteNodeLog bpmExecuteNodeLog = new BpmExecuteNodeLog(currentBpmExecuteNode);
|
|
|
iBpmExecuteNodeLogService.insertBpmExecuteNodeLog(bpmExecuteNodeLog);
|
|
|
|
|
|
- // 4️⃣4️⃣4️⃣ 判断是否结束审批流程
|
|
|
- if (taskNextNodeType.equals("endEvent")) {
|
|
|
+ // 4️⃣4️⃣4️⃣ 判断是否结束审批流程 || 不通过流程直接结束 || 驳回流程直接结束
|
|
|
+ if (approvalStatus.equals("noPass") || approvalStatus.equals("reject") || taskNextNodeType.equals("endEvent")) {
|
|
|
// 当前节点是改流程的最后一个节点,默认执行结束节点
|
|
|
- // 结束节点也是只修改状态
|
|
|
- // runBpmExecuteProcessMapper.updateProcessNode();
|
|
|
|
|
|
// 审批流程结束,修改当前审批关联数据条的关联数据条的状态(bpm_approval_status)
|
|
|
- // 审批状态 (0:已提交、1:已通过、2:不通过、4:驳回、5:审批中)
|
|
|
- // iBpmApprovalStatusService.updateBpmApprovalStatus();
|
|
|
-// iBpmApprovalStatusService.updateBpmApprovalStatus();
|
|
|
- }
|
|
|
+ // 具体修改数据条的状态应当是根据结束节点的上个节点的状态来判断
|
|
|
+ String status = getuApprovalStatus(approvalStatus);
|
|
|
|
|
|
- /**
|
|
|
- * €23092802001001001820€0990€23-0€0001€BTS高弹单丝轻网€100D/36f€001特黑€AA
|
|
|
- */
|
|
|
+ // 更新审批的数据条状态
|
|
|
+ iBpmApprovalStatusService.updateBpmApprovalStatusByTaskKey(new BpmApprovalStatus(status, bpmRunNodeVo.getTaskProcessKey()));
|
|
|
|
|
|
+ // 结束当前流程
|
|
|
+ return AjaxResult.success(runBpmExecuteProcessMapper.endProcess(bpmRunNodeVo.getTaskProcessKey()));
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/* 审批的发起操作,相当于这个流程的开始
|
|
|
那么用户首次调用当前接口,都会就是一级审批
|
|
@@ -780,11 +878,39 @@ public class PreExecutionToolClass<R> {
|
|
|
|
|
|
流程发起时的表单数据开始存在用户的表中,所以同生产流程逻辑一样。
|
|
|
在发起这个流程的时候记录当前的数据条的表名以及表主键
|
|
|
-
|
|
|
*/
|
|
|
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // 当前节点在操作最后一个审批节点时根据审批的节点状态来更改当前审批数据条的状态
|
|
|
+ public String getuApprovalStatus(String code) {
|
|
|
+ // 审批状态 pass:通过、noPass:不通过、reject:驳回
|
|
|
+ // '审批状态 (0:已提交、1:已通过、2:不通过、4:驳回、5:审批中)'
|
|
|
+ if ("pass".equals(code)) return "1";
|
|
|
+ if ("noPass".equals(code)) return "2";
|
|
|
+ if ("reject".equals(code)) return "4";
|
|
|
+ return "5";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 撤销申请数据条操作
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult revokeApplication(BpmRunNodeVo bpmRunNodeVo) {
|
|
|
+ // 当前执行流程编号
|
|
|
+ String taskKey = bpmRunNodeVo.getTaskProcessKey();
|
|
|
+ // 得到当前数据条的表信息,修改当前数据条的审批状态值
|
|
|
+ BpmApprovalStatus bpmApprovalStatus = iBpmApprovalStatusService.selectBpmApprovalStatusByTaskKey(taskKey);
|
|
|
+ // 删除申请流程(修改申请数据条的状态)
|
|
|
+ // 在流程状态中4 表示撤销
|
|
|
+ iBpmExecuteProcessService.updateProcessStateByKey("4", taskKey);
|
|
|
+ // 修改提交审批的数据条状态-》 调用共通接口执行
|
|
|
+ // 数据条审批状态(默认字段 0:未提交 1:已提交 2:已撤销 3:已通过)
|
|
|
+ iBpmApprovalStatusService.updateApprovalStatusByTableName(bpmApprovalStatus.getTableName(), "2", bpmApprovalStatus.getTableId());
|
|
|
+ // 修改中间表状态:撤回
|
|
|
+ iBpmApprovalStatusService.updateBpmApprovalStatusByTaskKey(new BpmApprovalStatus("3", taskKey));
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
}
|