|
@@ -50,6 +50,7 @@ import org.flowable.engine.runtime.ProcessInstance;
|
|
import org.flowable.task.api.Task;
|
|
import org.flowable.task.api.Task;
|
|
import org.flowable.task.api.TaskQuery;
|
|
import org.flowable.task.api.TaskQuery;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.cloud.openfeign.SpringQueryMap;
|
|
import org.springframework.cloud.openfeign.SpringQueryMap;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -57,6 +58,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.*;
|
|
import java.util.concurrent.*;
|
|
@@ -105,6 +107,9 @@ public class FlowableTaskController {
|
|
@Autowired
|
|
@Autowired
|
|
private RedisUtils redisUtils;
|
|
private RedisUtils redisUtils;
|
|
|
|
|
|
|
|
+ @Value("${wechat.projecturl}")
|
|
|
|
+ private String projectUrl;
|
|
|
|
+
|
|
@GetMapping("todo")
|
|
@GetMapping("todo")
|
|
public ResponseEntity todoListData(Page<ProcessVo> page, Flow flow, String type) throws Exception {
|
|
public ResponseEntity todoListData(Page<ProcessVo> page, Flow flow, String type) throws Exception {
|
|
// page = flowTaskService.todoList ( page, flow, type );
|
|
// page = flowTaskService.todoList ( page, flow, type );
|
|
@@ -404,7 +409,7 @@ public class FlowableTaskController {
|
|
* 启动流程
|
|
* 启动流程
|
|
*/
|
|
*/
|
|
@PostMapping("start")
|
|
@PostMapping("start")
|
|
- public ResponseEntity start(@RequestBody Flow flow) {
|
|
|
|
|
|
+ public ResponseEntity start(@RequestBody Flow flow) throws UnsupportedEncodingException {
|
|
String procInsId = flowTaskService.startProcess(flow.getProcDefKey(), flow.getBusinessTable(), flow.getBusinessId(), flow.getTitle(), flow.getRecordType(), flow.getProcDefId(), flow.getDays());
|
|
String procInsId = flowTaskService.startProcess(flow.getProcDefKey(), flow.getBusinessTable(), flow.getBusinessId(), flow.getTitle(), flow.getRecordType(), flow.getProcDefId(), flow.getDays());
|
|
|
|
|
|
//指定下一步处理人
|
|
//指定下一步处理人
|
|
@@ -622,7 +627,7 @@ public class FlowableTaskController {
|
|
* @param flow
|
|
* @param flow
|
|
*/
|
|
*/
|
|
@PostMapping("audit")
|
|
@PostMapping("audit")
|
|
- public ResponseEntity auditTask(HttpServletRequest request, Flow flow) {
|
|
|
|
|
|
+ public ResponseEntity auditTask(HttpServletRequest request, Flow flow) throws UnsupportedEncodingException {
|
|
Map<String, Object> vars = Maps.newHashMap();
|
|
Map<String, Object> vars = Maps.newHashMap();
|
|
Map<String, String[]> map = request.getParameterMap();
|
|
Map<String, String[]> map = request.getParameterMap();
|
|
for (Map.Entry<String, String[]> entry : map.entrySet()) {
|
|
for (Map.Entry<String, String[]> entry : map.entrySet()) {
|
|
@@ -650,7 +655,7 @@ public class FlowableTaskController {
|
|
}
|
|
}
|
|
|
|
|
|
// 向审核人发送 公众号通知
|
|
// 向审核人发送 公众号通知
|
|
- public void sendMsgToOpenIds(String procInsId){
|
|
|
|
|
|
+ public void sendMsgToOpenIds(String procInsId) throws UnsupportedEncodingException {
|
|
|
|
|
|
TaskQuery todoTaskQuery = taskService.createTaskQuery()
|
|
TaskQuery todoTaskQuery = taskService.createTaskQuery()
|
|
.active()
|
|
.active()
|
|
@@ -664,7 +669,6 @@ public class FlowableTaskController {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
List<String> users = flowTaskService.getTaskAuditUsers(list.get(i).getId());
|
|
List<String> users = flowTaskService.getTaskAuditUsers(list.get(i).getId());
|
|
// 根据得到的审核人id,查询出对应的openId
|
|
// 根据得到的审核人id,查询出对应的openId
|
|
-
|
|
|
|
for (String user : users) {
|
|
for (String user : users) {
|
|
if (allUsersStringBuilder.length() > 0) {
|
|
if (allUsersStringBuilder.length() > 0) {
|
|
allUsersStringBuilder.append(","); // 添加逗号作为分隔符
|
|
allUsersStringBuilder.append(","); // 添加逗号作为分隔符
|
|
@@ -677,8 +681,57 @@ public class FlowableTaskController {
|
|
String[] openIdArray = openIds.split(",");
|
|
String[] openIdArray = openIds.split(",");
|
|
List<String> openIdsList = Arrays.asList(openIdArray);
|
|
List<String> openIdsList = Arrays.asList(openIdArray);
|
|
|
|
|
|
- SendMessageUtil.sendMessage(list.get(i), openIdsList);
|
|
|
|
|
|
+ Flow flow = new Flow();
|
|
|
|
+ String procDefId = list.get(i).getProcessDefinitionId();
|
|
|
|
+ String taskDefKey = list.get(i).getTaskDefinitionKey();
|
|
|
|
+// String procInsIdFromTask = list.get(i).getProcessInstanceId();
|
|
|
|
+ String procDefKey = SpringUtil.getBean(RepositoryService.class).createProcessDefinitionQuery()
|
|
|
|
+ .processDefinitionId(procDefId)
|
|
|
|
+ .singleResult()
|
|
|
|
+ .getKey();
|
|
|
|
+
|
|
|
|
+ flow.setProcDefId(procDefId);
|
|
|
|
+ flow.setTaskDefKey(taskDefKey);
|
|
|
|
+ flow.setProcInsId(procInsId);
|
|
|
|
+ flow.setProcDefKey(procDefKey);
|
|
|
|
+ flow = getFlowInfo(flow);
|
|
|
|
+
|
|
|
|
+ SendMessageUtil.sendMessage(list.get(i), openIdsList, flow, projectUrl);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Flow getFlowInfo(Flow flow){
|
|
|
|
+ // 获取流程XML上的表单KEY
|
|
|
|
+ String formKey = flowTaskService.getFormKey(flow.getProcDefId(), flow.getTaskDefKey());
|
|
|
|
+
|
|
|
|
+ NodeSetting typeNode = nodeSettingService.queryByKey(flow.getProcDefKey(), flow.getTaskDefKey(), "formType");
|
|
|
|
+ NodeSetting ReadOnlyNode = nodeSettingService.queryByKey(flow.getProcDefKey(), flow.getTaskDefKey(), "formReadOnly");
|
|
|
|
+ String formType = "1";
|
|
|
|
+ boolean formReadOnly = false;
|
|
|
|
+ if (typeNode != null) {
|
|
|
|
+ formType = typeNode.getValue();
|
|
|
|
+ formReadOnly = "true".equals(ReadOnlyNode.getValue());
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isBlank(formKey)) {
|
|
|
|
+ formType = "1";
|
|
|
|
+ } else if (formKey.indexOf("/") >= 0) {
|
|
|
|
+ formType = "2";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取流程实例对象
|
|
|
|
+ if (flow.getProcInsId() != null) {
|
|
|
|
+ if (flowTaskService.getProcIns(flow.getProcInsId()) != null) {
|
|
|
|
+ flow.setProcIns(flowTaskService.getProcIns(flow.getProcInsId()));
|
|
|
|
+ } else {
|
|
|
|
+ flow.setFinishedProcIns(flowTaskService.getFinishedProcIns(flow.getProcInsId()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ flow.setFormUrl(formKey);
|
|
|
|
+ flow.setFormReadOnly(formReadOnly);
|
|
|
|
+ flow.setFormType(formType);
|
|
|
|
+ return flow;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|