|
|
@ -29,6 +29,7 @@ package com.yxt.anrui.flowable.biz.flow; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import com.yxt.anrui.flowable.api.flow.*; |
|
|
|
import com.yxt.anrui.flowable.api.flowcomment.FlowComment; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
@ -49,6 +50,7 @@ import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import org.apache.tomcat.util.threads.ThreadPoolExecutor; |
|
|
|
import org.flowable.bpmn.model.FlowElement; |
|
|
|
import org.flowable.bpmn.model.UserTask; |
|
|
|
import org.flowable.engine.HistoryService; |
|
|
@ -63,6 +65,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: anrui-parent <br/> |
|
|
@ -98,13 +101,16 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
private MessageFeign messageFeign; |
|
|
|
@Resource |
|
|
|
protected HistoryService historyService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 流程抄送的功能 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ResultBean cc(Map<String, Object> map) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
log.info("FlowableRest-cc:{}", JSONObject.toJSONString(map)); |
|
|
|
Object bv1 = map.get("bv"); |
|
|
|
BusinessVariables bv = new BusinessVariables(); |
|
|
@ -115,16 +121,21 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
|
|
|
|
//流程定义的id
|
|
|
|
String modelId = bv.getModelId(); |
|
|
|
//将modelId根据冒号:分成三部分,取第一部分作为key
|
|
|
|
List<String> stringList = Arrays.asList(modelId.split(":")); |
|
|
|
modelId = stringList.get(0); |
|
|
|
//抄送的角色的sid
|
|
|
|
ResultBean<SysFlowccVo> roleSidByModelId = sysFlowccFeign.getRoleSidByModelId(modelId); |
|
|
|
//组织机构sid
|
|
|
|
String orgSidPath = bv.getOrgSidPath(); |
|
|
|
if(!roleSidByModelId.getSuccess()){ |
|
|
|
return roleSidByModelId; |
|
|
|
if (roleSidByModelId.getData() == null) { |
|
|
|
log.info("抄送失败,没有配置对应的角色!"); |
|
|
|
return rb.setMsg("抄送失败,没有配置对应的角色!"); |
|
|
|
} |
|
|
|
SysFlowccVo data = roleSidByModelId.getData(); |
|
|
|
if (StringUtils.isBlank(data.getRoleSid())) { |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,没有配置对应的角色!"); |
|
|
|
log.info("抄送失败,没有配置对应的角色!"); |
|
|
|
return rb.setMsg("抄送失败,没有配置对应的角色!"); |
|
|
|
} |
|
|
|
List<String> list = Arrays.asList(data.getRoleSid().split(",")); |
|
|
|
UserByRolesAndOrgQuery userQuery = new UserByRolesAndOrgQuery(); |
|
|
@ -132,7 +143,8 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
userQuery.setOrgSidPath(orgSidPath); |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRoles(userQuery).getData(); |
|
|
|
if (sysUserVos == null || sysUserVos.size() < 1) { |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,没有用户!"); |
|
|
|
log.info("抄送失败,没有用户!"); |
|
|
|
return rb.setMsg("抄送失败,没有用户!"); |
|
|
|
} |
|
|
|
StringBuilder userName = new StringBuilder(); |
|
|
|
StringBuilder userSids = new StringBuilder(); |
|
|
@ -152,12 +164,12 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
.includeProcessVariables().taskId(bv.getTaskId()).singleResult(); |
|
|
|
if (historicTaskInstance == null) { |
|
|
|
log.info("抄送失败:没有获取到业务参数!"); |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败!"); |
|
|
|
return rb.setMsg("抄送失败!"); |
|
|
|
} |
|
|
|
Map<String, Object> processVariables = historicTaskInstance.getProcessVariables(); |
|
|
|
if (historicTaskInstance == null) { |
|
|
|
log.info("抄送失败:没有获取到业务参数!"); |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败!"); |
|
|
|
return rb.setMsg("抄送失败!"); |
|
|
|
} |
|
|
|
Map<String, Object> app = new HashMap<>(); |
|
|
|
if (processVariables.get("app") != null) { |
|
|
@ -172,7 +184,8 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
Map<String, String> process = processService.getProcessDefByDefId(historicTaskInstance.getProcessDefinitionId()); |
|
|
|
log.info("抄送成功-process:{}", process); |
|
|
|
if (process == null) { |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,流程定义不存在!"); |
|
|
|
log.info("抄送失败,流程定义不存在!"); |
|
|
|
return rb.setMsg("抄送失败,流程定义不存在!"); |
|
|
|
} |
|
|
|
mfq.setModuleName(process.get("NAME_")); |
|
|
|
mfq.setMsgTitle(process.get("NAME_")); |
|
|
@ -182,9 +195,9 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
log.info("抄送成功-resultBean:{}", resultBean); |
|
|
|
if (!resultBean.getSuccess()) { |
|
|
|
log.info("抄送失败,同送消息异常!:{}", JSONObject.toJSONString(resultBean)); |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,同送消息异常!"); |
|
|
|
return rb.setMsg("抄送失败,同送消息异常!"); |
|
|
|
} |
|
|
|
return ResultBean.fireSuccess().setMsg("抄送"+userName.toString()+"成功!"); |
|
|
|
return rb.success().setMsg("抄送" + userName.toString() + "成功!"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -295,22 +308,56 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
} |
|
|
|
|
|
|
|
Logger log = LoggerFactory.getLogger(FlowableRest.class); |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<UpdateFlowFieldVo> handleProsess(BusinessVariables dto) { |
|
|
|
ResultBean<UpdateFlowFieldVo> rb = ResultBean.fireFail(); |
|
|
|
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = handleProsess(dto, true); |
|
|
|
//需要判断办结后再执行 TODO
|
|
|
|
if (updateFlowFieldVoResultBean.getSuccess()) { |
|
|
|
/* 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", dto); |
|
|
|
map.put("uff", updateFlowFieldVoResultBean.getData()); |
|
|
|
//cc(map);
|
|
|
|
cc(map); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return rb.setMsg("抄送失败"); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
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", dto); |
|
|
|
map.put("uff", updateFlowFieldVoResultBean.getData()); |
|
|
|
cc(map); |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return rb.setMsg("抄送失败"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return updateFlowFieldVoResultBean; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param dto |
|
|
|
* @param b 是否连续跳转环节 |
|
|
|
* @return |
|
|
@ -466,6 +513,7 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
vo.setNextNodeUserSids(nextUserSid); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<UpdateFlowFieldVo> revokeProcess(com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
@ -557,4 +605,9 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
vo.setTaskDefKey("Event_end"); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<List<FlowListVo>> selectFlowList() { |
|
|
|
return flowableService.selectFlowList(); |
|
|
|
} |
|
|
|
} |
|
|
|