企业中有自己的业务系统,审批都在业务系统中审批,如何结合移动办公的开放平台实现统一审批至关重要。
场景很简单,自己的系统中可以审批,钉钉上也可以审批,使用H5来适配,统一待办任务
统一待办审批
- 目标:任务完成钉钉任务变成已完成任务
- 第一 、全局任务完成监听发送完成任务消息
- 第二 、完成任务的消息接口
- 第三 、接受mq消息处理
- 总结、这样子就能完成钉钉消息和flowable之间的任务同步了
目标:任务完成钉钉任务变成已完成任务
实现flowable钉钉相互之间可以创建待办,更新待办,删除待办flowMessageService.completeTaskToMq(entity, entity.getAssignee());
public boolean sendTaskMessage(ProcessInstance processInstance, TaskEntity entity, OperationTypeEnum operationType) {
boolean flag = false;
PlatformDingtalkTaskVo platformTask = new PlatformDingtalkTaskVo();
platformTask.setOperationType(operationType.getCode());
platformTask.setBussinessKey(processInstance.getBusinessKey());
platformTask.setFlowableProInstId(processInstance.getProcessInstanceId());
platformTask.setSubject(processInstance.getName());
if (entity != null) {
platformTask.setFlowableTaskId(entity.getId());
ApplyerVo applyerVo = prodFlowTaskService.getApplyerVoByTaskId(entity.getId());
if (applyerVo != null) {
List<String> thirdUnionIds = new ArrayList<>();
if (applyerVo.getApplyer() != null) {
thirdUnionIds.add(applyerVo.getApplyer().getThirdUnionId());
platformTask.setUnionId(applyerVo.getApplyer().getThirdUnionId());
platformTask.setCreatorId(applyerVo.getApplyer().getThirdUnionId());
platformTask.setOperatorId(applyerVo.getApplyer().getThirdUnionId());
platformTask.setMobile(applyerVo.getApplyer().getMobile());
flag = true;
}
if (CollectionUtils.isNotEmpty(applyerVo.getExecutors())) {
applyerVo.getExecutors().forEach(personal -> thirdUnionIds.add(personal.getThirdUnionId()));
flag = true;
}
platformTask.setExecutorIds(thirdUnionIds);
platformTask.setFlowableTaskName(entity.getName());
platformTask.setDingNotify("1");
platformTask.setPriority(20);
platformTask.setDueTime(DateUtil.addDate(new Date(), 1).getTime());
platformTask.setIsOnlyShowExecutor(true);
platformTask.setAppSn(processInstance.getTenantId());
String url = "/process/operate?modelKey=" + processInstance.getProcessDefinitionKey()
+ "&taskId=" + StringUtils.defaultIfEmpty(entity.getId(), "") + "&procInstId=" +
processInstance.getProcessInstanceId() + "&bizKey=" + processInstance.getBusinessKey();
platformTask.setAppUrl(url);
platformTask.setPcUrl(url);
String json = JSON.toJSONString(platformTask);
try {
if (!flag) {
log.error("未查询到审批的人信息,请确认!参数:" + json);
} else {
if (prodAppService.checkPlatformEnabled(processInstance.getTenantId())) {
this.convertAndSend(ProdflowConstant.FLOWABLE_TASK_MESSAGE_QUEUE, json);
}
}
} catch (Exception e) {
e.printStackTrace();
log.error("推送到MQ异常!原因:" + e.getMessage());
}
}
}
return flag;
}
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(params.getFlowableTaskId()).singleResult();
List<HistoricTaskInstance> historictaskInstances = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey(historicTaskInstance.getTaskDefinitionKey()).list();
if (CollectionUtils.isNotEmpty(historictaskInstances) && historictaskInstances.size() > 1) {
historictaskInstances.remove(historicTaskInstance);
historictaskInstances.forEach(hisTask -> {
if (ObjectUtil.isNotEmpty(hisTask.getEndTime())) {
PlatformDingtalkTask flowableTask = platformDingtalkTaskService.getByFlowableTaskId(hisTask.getId());
Boolean done = flowableTask.getDone();
if (!done) {
//删除第三方的任务操作
dingtalkSdkService.deleteTask(flowableTask.getUnionId(), flowableTask.getTaskId());
}
}
});
}
PlatformDingtalkTask updateTask = platformDingtalkTaskService.getByFlowableTaskId(params.getFlowableTaskId());
UpdateTodoTaskRequest updateTodoTaskRequest = this.updateDingtalkTask(params);
if (StringUtils.isNotBlank(updateTask.getExecutorIds())) {
updateTodoTaskRequest.setExecutorIds(FastJsonUtils.jsonToList(updateTask.getExecutorIds(), String.class));
}
updateTodoTaskRequest.setDone(true);
dingtalkSdkService.updateTask(params.getUnionId(), updateTask.getTaskId(), updateTodoTaskRequest);
updateTask.setDone(true);
platformDingtalkTaskService.updateById(updateTask);
最后给大家推荐一下滴滴bpm专家贺波历经三年结合自己10年的经验出的一本activiti的书籍,希望能帮助到大家。
深入Activiti流程引擎