|
@@ -0,0 +1,70 @@
|
|
|
|
|
+package com.xjrsoft.module.liteflow.node;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
|
|
+import cn.hutool.db.Entity;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.xjrsoft.common.enums.WorkflowApproveType;
|
|
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
|
|
+import com.xjrsoft.module.workflow.entity.WorkflowRecord;
|
|
|
|
|
+import com.xjrsoft.module.workflow.mapper.WorkflowRecordMapper;
|
|
|
|
|
+import com.xjrsoft.module.workflow.service.IWorkflowExecuteService;
|
|
|
|
|
+import com.yomahub.liteflow.core.NodeComponent;
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
|
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+import org.springframework.transaction.support.TransactionSynchronization;
|
|
|
|
|
+import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 学生复读流程规则
|
|
|
|
|
+ */
|
|
|
|
|
+@Component("wf_student_repeat_study_node")
|
|
|
|
|
+public class WfStudentRepeatStudyNode extends NodeComponent {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WorkflowRecordMapper workflowRecordMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IWorkflowExecuteService workflowExecuteService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void process() throws Exception {
|
|
|
|
|
+ // 获取表单中数据编号
|
|
|
|
|
+ Map<String, Object> params = this.getFirstContextBean();
|
|
|
|
|
+ Object value = util.getFormDatKey(params, "id");
|
|
|
|
|
+ Long formId = Convert.toLong(value);
|
|
|
|
|
+ Object processInstanceId = params.get("processInstanceId");
|
|
|
|
|
+ if (processInstanceId == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ String processInstanceIdStr = Convert.toStr(processInstanceId);
|
|
|
|
|
+ if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
|
|
|
|
|
+ TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void afterCommit() {
|
|
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
|
|
+ Optional<HistoricProcessInstance> historicProcessInstanceOptional = workflowExecuteService.getHistoricProcessInstance(processInstanceId.toString());
|
|
|
|
|
+
|
|
|
|
|
+ if (historicProcessInstanceOptional.isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ HistoricProcessInstance historicProcessInstance = historicProcessInstanceOptional.get();
|
|
|
|
|
+ if (historicProcessInstance.getState().equals(HistoricProcessInstance.STATE_COMPLETED)) {
|
|
|
|
|
+ String tableName = "wf_student_repeat_study";
|
|
|
|
|
+ Entity where = Entity.create(tableName);
|
|
|
|
|
+ where.set("id", formId);
|
|
|
|
|
+ Map<String, Object> objectMap = SqlRunnerAdapter.db().dynamicSelectOne(tableName, where);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|