|
|
@ -26,6 +26,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.yxt.anrui.flowable.api.flow.*; |
|
|
@ -33,9 +34,15 @@ import com.yxt.anrui.flowable.api.flowcomment.FlowComment; |
|
|
|
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|
|
|
import com.yxt.anrui.flowable.biz.flowtask.FlowTaskService; |
|
|
|
import com.yxt.anrui.flowable.biz.process.ProcessService; |
|
|
|
import com.yxt.anrui.flowable.feign.MessageFeign; |
|
|
|
import com.yxt.anrui.flowable.feign.form.MessageFlowVo; |
|
|
|
import com.yxt.anrui.flowable.feign.form.MessageFlowableQuery; |
|
|
|
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|
|
|
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysflowcc.SysFlowccVo; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.UserByRolesAndOrgQuery; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.UserQuery; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
@ -44,9 +51,11 @@ import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import org.flowable.bpmn.model.FlowElement; |
|
|
|
import org.flowable.bpmn.model.UserTask; |
|
|
|
import org.flowable.engine.HistoryService; |
|
|
|
import org.flowable.engine.TaskService; |
|
|
|
import org.flowable.task.api.DelegationState; |
|
|
|
import org.flowable.task.api.Task; |
|
|
|
import org.flowable.task.api.history.HistoricTaskInstance; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -83,6 +92,101 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
protected TaskService taskService; |
|
|
|
@Resource |
|
|
|
private ProcessService processService; |
|
|
|
@Resource |
|
|
|
private SysFlowccFeign sysFlowccFeign; |
|
|
|
@Autowired |
|
|
|
private MessageFeign messageFeign; |
|
|
|
@Resource |
|
|
|
protected HistoryService historyService; |
|
|
|
/** |
|
|
|
* 流程抄送的功能 |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ResultBean cc(Map<String,Object> map) { |
|
|
|
log.info("FlowableRest-cc:{}",JSONObject.toJSONString(map)); |
|
|
|
Object bv1 = map.get("bv"); |
|
|
|
BusinessVariables bv= new BusinessVariables(); |
|
|
|
BeanUtil.copyProperties(bv1,bv); |
|
|
|
Object uff1 = map.get("uff"); |
|
|
|
UpdateFlowFieldVo uff= new UpdateFlowFieldVo(); |
|
|
|
BeanUtil.copyProperties(uff1,uff); |
|
|
|
|
|
|
|
//流程定义的id
|
|
|
|
String modelId = bv.getModelId(); |
|
|
|
//抄送的角色的sid
|
|
|
|
ResultBean<SysFlowccVo> roleSidByModelId = sysFlowccFeign.getRoleSidByModelId(modelId); |
|
|
|
//组织机构sid
|
|
|
|
String orgSidPath = bv.getOrgSidPath(); |
|
|
|
if(!roleSidByModelId.getSuccess()){ |
|
|
|
return roleSidByModelId; |
|
|
|
} |
|
|
|
SysFlowccVo data = roleSidByModelId.getData(); |
|
|
|
if(StringUtils.isBlank(data.getRoleSid())){ |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,没有配置对应的角色!"); |
|
|
|
} |
|
|
|
List<String> list = Arrays.asList(data.getRoleSid().split(",")); |
|
|
|
UserByRolesAndOrgQuery userQuery = new UserByRolesAndOrgQuery(); |
|
|
|
userQuery.setRoleSids(list); |
|
|
|
userQuery.setOrgSidPath(orgSidPath); |
|
|
|
List<SysUserVo> sysUserVos = sysUserFeign.getUserByRoles(userQuery).getData(); |
|
|
|
if(sysUserVos==null||sysUserVos.size()<1){ |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,没有用户!"); |
|
|
|
} |
|
|
|
StringBuilder userName=new StringBuilder(); |
|
|
|
StringBuilder userSids=new StringBuilder(); |
|
|
|
sysUserVos.forEach(f->{ |
|
|
|
userName.append(f.getName()).append(","); |
|
|
|
userSids.append(f.getSid()).append(","); |
|
|
|
}); |
|
|
|
userSids.deleteCharAt(userSids.length()-1); |
|
|
|
//抄送的业务逻辑
|
|
|
|
MessageFlowableQuery mfq = new MessageFlowableQuery(); |
|
|
|
MessageFlowVo messageFlowVo = new MessageFlowVo(); |
|
|
|
BeanUtil.copyProperties(uff, messageFlowVo); |
|
|
|
mfq.setUfVo(messageFlowVo); |
|
|
|
//移动端的参数
|
|
|
|
//Map<String,Object> app = (Map<String, Object>) bv.getFormVariables().get("app");
|
|
|
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery() |
|
|
|
.includeProcessVariables().taskId(bv.getTaskId()).singleResult(); |
|
|
|
if(historicTaskInstance==null){ |
|
|
|
log.info("抄送失败:没有获取到业务参数!"); |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败!"); |
|
|
|
} |
|
|
|
Map<String, Object> processVariables = historicTaskInstance.getProcessVariables(); |
|
|
|
if(historicTaskInstance==null){ |
|
|
|
log.info("抄送失败:没有获取到业务参数!"); |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败!"); |
|
|
|
} |
|
|
|
Map<String,Object> app=new HashMap<>(); |
|
|
|
if(processVariables.get("app")!=null){ |
|
|
|
app= (Map<String, Object>) processVariables.get("app"); |
|
|
|
} |
|
|
|
log.info("抄送方法-historicTaskInstance:{}",JSONObject.toJSONString(historicTaskInstance)); |
|
|
|
mfq.setAppMap(app); |
|
|
|
mfq.setBusinessSid(bv.getBusinessSid()); |
|
|
|
|
|
|
|
mfq.setMsgContent( "系统抄送的流程审批,请查看"); |
|
|
|
// act_re_procdef
|
|
|
|
Map<String,String> process= processService.getProcessDefByDefId(historicTaskInstance.getProcessDefinitionId()); |
|
|
|
log.info("抄送成功-process:{}",process); |
|
|
|
if(process==null){ |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,流程定义不存在!"); |
|
|
|
} |
|
|
|
mfq.setModuleName(process.get("NAME_")); |
|
|
|
mfq.setMsgTitle(process.get("NAME_")); |
|
|
|
mfq.setUserSids(userSids.toString()); |
|
|
|
ResultBean<String> resultBean = messageFeign.pushMessageCC(mfq); |
|
|
|
log.info("抄送成功:{}",userName.toString()); |
|
|
|
log.info("抄送成功-resultBean:{}",resultBean); |
|
|
|
if(!resultBean.getSuccess()){ |
|
|
|
log.info("抄送失败,同送消息异常!:{}",JSONObject.toJSONString(resultBean)); |
|
|
|
return ResultBean.fireFail().setMsg("抄送失败,同送消息异常!"); |
|
|
|
} |
|
|
|
return ResultBean.fireSuccess().setMsg("抄送"+userName.toString()+"成功!"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean businessStart(BusinessVariables bv) { |
|
|
|
return flowableService.businessStart( bv); |
|
|
@ -193,7 +297,15 @@ public class FlowableRest implements FlowableFeign { |
|
|
|
Logger log= LoggerFactory.getLogger(FlowableRest.class); |
|
|
|
@Override |
|
|
|
public ResultBean<UpdateFlowFieldVo> handleProsess(BusinessVariables dto) { |
|
|
|
return handleProsess(dto,true); |
|
|
|
ResultBean<UpdateFlowFieldVo> updateFlowFieldVoResultBean = handleProsess(dto, true); |
|
|
|
if(updateFlowFieldVoResultBean.getSuccess()){ |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
map.put("bv",dto); |
|
|
|
map.put("uff",updateFlowFieldVoResultBean.getData()); |
|
|
|
cc(map); |
|
|
|
} |
|
|
|
return updateFlowFieldVoResultBean; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|