|
|
@ -1,15 +1,23 @@ |
|
|
|
package com.yxt.anrui.flowable.biz.flow3; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.yxt.anrui.flowable.api.flow.UpdateFlowFieldVo; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.apache.tomcat.util.threads.ThreadPoolExecutor; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: |
|
|
@ -19,11 +27,13 @@ import java.util.Map; |
|
|
|
@RestController |
|
|
|
@RequestMapping("v3/flow") |
|
|
|
public class Flow3Rest { |
|
|
|
Logger log = LoggerFactory.getLogger(Flow3Rest.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private Flow3Service flowService; |
|
|
|
|
|
|
|
public ResultBean<UpdateFlowFieldVo> startProcess2(BusinessVariables bv) { |
|
|
|
@PostMapping("/startProcess") |
|
|
|
public ResultBean<UpdateFlowFieldVo> startProcess(@RequestBody BusinessVariables bv) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
//获取表单中的参数
|
|
|
|
Map<String, Object> formVariables = bv.getFormVariables(); |
|
|
@ -32,14 +42,49 @@ public class Flow3Rest { |
|
|
|
String orgPath = bv.getOrgSidPath(); |
|
|
|
formVariables.put("createrOrgPath", orgPath); |
|
|
|
formVariables.put("businessSid", bv.getBusinessSid()); |
|
|
|
|
|
|
|
//启动流程实例
|
|
|
|
ResultBean<UpdateFlowFieldVo> startResultBean = flowService.businessStartProcessInstanceById2(bv); |
|
|
|
ResultBean<UpdateFlowFieldVo> startResultBean = flowService.businessStartProcessInstanceById(bv); |
|
|
|
return startResultBean; |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/submit2") |
|
|
|
public ResultBean submit222() { |
|
|
|
return flowService.submit222(); |
|
|
|
return flowService.submit333(); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/handleProsess") |
|
|
|
public ResultBean<UpdateFlowFieldVo> handleProsess(@RequestBody BusinessVariables bv) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = flowService.handleProsess(bv, true); |
|
|
|
//添加抄送
|
|
|
|
log.info("流程返回:{}", JSONObject.toJSONString(updateFlowFieldVoResultBean)); |
|
|
|
//需要判断办结后再执行 TODO
|
|
|
|
if (updateFlowFieldVoResultBean.getSuccess()) { |
|
|
|
log.info("流程返回:{}", JSONObject.toJSONString(updateFlowFieldVoResultBean)); |
|
|
|
if ("Event_end".equals(updateFlowFieldVoResultBean.getData().getTaskDefKey())) { |
|
|
|
try { |
|
|
|
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() |
|
|
|
.setNameFormat("demo-pool-%d").build(); |
|
|
|
ExecutorService pool = new ThreadPoolExecutor(2, 100, |
|
|
|
0L, TimeUnit.MILLISECONDS, |
|
|
|
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); |
|
|
|
|
|
|
|
Future future1 = pool.submit(() -> { |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
map.put("bv", bv); |
|
|
|
UpdateFlowFieldVo ufVo = updateFlowFieldVoResultBean.getData(); |
|
|
|
ufVo.setTaskId(bv.getTaskId()); |
|
|
|
map.put("uff", ufVo); |
|
|
|
flowService.cc(map, bv.getTaskDefKey()); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return rb.setMsg("抄送失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return updateFlowFieldVoResultBean; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|