|
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
|
|
import com.huyi.flowable.BaseResult;
|
|
import com.huyi.flowable.BaseResult;
|
|
import com.huyi.flowable.mapper.MeHistoryMapper;
|
|
import com.huyi.flowable.mapper.MeHistoryMapper;
|
|
import com.huyi.flowable.mapper.TaskMapper;
|
|
import com.huyi.flowable.mapper.TaskMapper;
|
|
|
|
+import com.huyi.flowable.message.MessageService;
|
|
import com.huyi.flowable.util.HttpClient;
|
|
import com.huyi.flowable.util.HttpClient;
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
import org.flowable.bpmn.constants.BpmnXMLConstants;
|
|
import org.flowable.bpmn.constants.BpmnXMLConstants;
|
|
@@ -15,7 +16,6 @@ import org.flowable.engine.ProcessEngineConfiguration;
|
|
import org.flowable.engine.history.HistoricActivityInstance;
|
|
import org.flowable.engine.history.HistoricActivityInstance;
|
|
import org.flowable.engine.history.HistoricProcessInstance;
|
|
import org.flowable.engine.history.HistoricProcessInstance;
|
|
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
|
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
|
-import org.flowable.engine.repository.Deployment;
|
|
|
|
import org.flowable.engine.runtime.Execution;
|
|
import org.flowable.engine.runtime.Execution;
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
import org.flowable.engine.runtime.ProcessInstanceBuilder;
|
|
import org.flowable.engine.runtime.ProcessInstanceBuilder;
|
|
@@ -23,7 +23,6 @@ import org.flowable.image.ProcessDiagramGenerator;
|
|
import org.flowable.task.api.Task;
|
|
import org.flowable.task.api.Task;
|
|
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 javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -41,6 +40,10 @@ public class FlowProcess extends FlowableConfig {
|
|
protected MeHistoryMapper meHistoryMapper;
|
|
protected MeHistoryMapper meHistoryMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private TaskMapper taskMapper;
|
|
private TaskMapper taskMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ protected MessageService messageService;
|
|
|
|
+ @Autowired
|
|
|
|
+ protected HttpClient httpClient;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -64,7 +67,8 @@ public class FlowProcess extends FlowableConfig {
|
|
.businessKey(businessKey) // 业务表主键
|
|
.businessKey(businessKey) // 业务表主键
|
|
.start(); // 启动(即创建)流程实例
|
|
.start(); // 启动(即创建)流程实例
|
|
Authentication.setAuthenticatedUserId(null); // 这个方法最终使用一个ThreadLocal类型的变量进行存储,也就是与当前的线程绑定,所以流程实例启动完毕之后,需要设置为null,防止多线程的时候出问题。
|
|
Authentication.setAuthenticatedUserId(null); // 这个方法最终使用一个ThreadLocal类型的变量进行存储,也就是与当前的线程绑定,所以流程实例启动完毕之后,需要设置为null,防止多线程的时候出问题。
|
|
-
|
|
|
|
|
|
+ // 增加消息通知
|
|
|
|
+ messageService.addStartFlowMessage(instance);
|
|
return instance;
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -75,16 +79,19 @@ public class FlowProcess extends FlowableConfig {
|
|
* @param reason 终止原因
|
|
* @param reason 终止原因
|
|
*/
|
|
*/
|
|
public void deleteProcessInstanceById(String processInstanceId, String reason, HttpServletRequest request,String state){
|
|
public void deleteProcessInstanceById(String processInstanceId, String reason, HttpServletRequest request,String state){
|
|
- ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
|
|
|
+ if (reason == null||"null".equals(reason) ) {
|
|
|
|
+ throw new FlowableException("审批拒绝不能为空!");
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
|
// 获取菜单id与公司id
|
|
// 获取菜单id与公司id
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
param.put("procdefId", processInstance.getProcessDefinitionId());
|
|
param.put("procdefId", processInstance.getProcessDefinitionId());
|
|
List<Map<String, Object>> configList = meHistoryMapper.queryMeHistory(param);
|
|
List<Map<String, Object>> configList = meHistoryMapper.queryMeHistory(param);
|
|
try{
|
|
try{
|
|
- String menuListStr = HttpClient.doPost(HttpClient.REJECT_APPROVAL, "id=" + processInstance.getBusinessKey()
|
|
|
|
|
|
+ String menuListStr = httpClient.doPost(HttpClient.REJECT_APPROVAL, "id=" + processInstance.getBusinessKey()
|
|
+ "&menuId=" + configList.get(0).get("menuId")
|
|
+ "&menuId=" + configList.get(0).get("menuId")
|
|
- + "&companyId=" + configList.get(0).get("companyId")+"&state="+state, request);
|
|
|
|
|
|
+ + "&companyId=" + configList.get(0).get("companyId")+"&state="+state + "&reason=" + reason, request);
|
|
|
|
|
|
JSONObject res = JSONObject.fromObject(menuListStr);
|
|
JSONObject res = JSONObject.fromObject(menuListStr);
|
|
// 请求失败
|
|
// 请求失败
|
|
@@ -94,9 +101,7 @@ public class FlowProcess extends FlowableConfig {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw new FlowableException("操作失败!");
|
|
throw new FlowableException("操作失败!");
|
|
}
|
|
}
|
|
- if (reason == null||"null".equals(reason) ) {
|
|
|
|
- throw new FlowableException("审批拒绝不能为空!");
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
runtimeService.deleteProcessInstance(processInstanceId, reason);
|
|
runtimeService.deleteProcessInstance(processInstanceId, reason);
|
|
}
|
|
}
|
|
|
|
|