|
|
|
|
@ -1,18 +1,24 @@ |
|
|
|
|
package org.springblade.plugin.workbench.service.impl; |
|
|
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.flowable.engine.RuntimeService; |
|
|
|
|
import org.flowable.engine.TaskService; |
|
|
|
|
import org.flowable.engine.runtime.ProcessInstance; |
|
|
|
|
import org.flowable.task.api.Task; |
|
|
|
|
import org.springblade.common.constant.CommonConstant; |
|
|
|
|
import org.springblade.common.constant.TenantConstant; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
import org.springblade.plugin.workbench.enumutil.RemindTypeEnum; |
|
|
|
|
import org.springblade.plugin.workbench.service.IWorkBenchService; |
|
|
|
|
import org.springblade.plugin.workbench.util.RemindOperation; |
|
|
|
|
import org.springblade.plugin.workflow.core.utils.WfTaskUtil; |
|
|
|
|
import org.springblade.system.cache.DictBizCache; |
|
|
|
|
import org.springblade.system.entity.DictBiz; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -26,19 +32,32 @@ public class WorkBenchServiceImpl implements IWorkBenchService { |
|
|
|
|
|
|
|
|
|
private final TaskService taskService; |
|
|
|
|
|
|
|
|
|
public void getTask(){ |
|
|
|
|
//获取正在运行的任务
|
|
|
|
|
List<Task> list = taskService.createTaskQuery().taskTenantId(WfTaskUtil.getTenantId()).list(); |
|
|
|
|
private final RuntimeService runtimeService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void getTaskToRemind(){ |
|
|
|
|
List<Task> list = new ArrayList<>(); |
|
|
|
|
//获取正在运行的任务 WfTaskUtil.getTenantId()
|
|
|
|
|
String tenantId = WfTaskUtil.getTenantId(); |
|
|
|
|
if(Func.isEmpty(tenantId) || Func.isBlank(tenantId)){ |
|
|
|
|
list = taskService.createTaskQuery().taskTenantId(TenantConstant.DEFAULT_TENANT_ID).list(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Map<String,List<Task>> taskRemindMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
//筛选出到期的任务
|
|
|
|
|
List<Task> collect = list.stream().filter(ts -> { |
|
|
|
|
Map<String, Object> variableMap = ts.getProcessVariables(); |
|
|
|
|
if(Func.isNotEmpty(variableMap.get("qiwangwanchengshijian")) && Func.isNotBlank(variableMap.get("qiwangwanchengshijian").toString())){ |
|
|
|
|
Date qiwangwanchengshijian = DateUtil.parse(variableMap.get("qiwangwanchengshijian").toString(), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if(DateUtil.between(DateUtil.now(), qiwangwanchengshijian).isNegative()){ |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
Map<String, Object> variableMap = runtimeService.getVariables(ts.getProcessInstanceId()); |
|
|
|
|
if(Func.isNotEmpty(variableMap)){ |
|
|
|
|
if(Func.isNotEmpty(variableMap.get("qiwangwanchengshijian")) && Func.isNotBlank(variableMap.get("qiwangwanchengshijian").toString())){ |
|
|
|
|
Date qiwangwanchengshijian = DateUtil.parse(variableMap.get("qiwangwanchengshijian").toString(), "yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if(DateUtil.between(DateUtil.now(), qiwangwanchengshijian).isNegative()){ |
|
|
|
|
return true; |
|
|
|
|
}else{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -47,14 +66,33 @@ public class WorkBenchServiceImpl implements IWorkBenchService { |
|
|
|
|
} |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
List<DictBiz> reminde_mode = DictBizCache.getList("reminde_mode"); |
|
|
|
|
Map<String,List<Task>> map = new HashMap<>(); |
|
|
|
|
//将到期任务按照提醒类型分类
|
|
|
|
|
collect.forEach(cl ->{ |
|
|
|
|
Map<String, Object> variableMap = runtimeService.getVariables(cl.getProcessInstanceId()); |
|
|
|
|
if(Func.isNotEmpty(variableMap.get("tixingmoshi")) && Func.isNotBlank(variableMap.get("tixingmoshi").toString())){ |
|
|
|
|
DictBiz tixingmoshi = DictBizCache.getById(Long.parseLong(variableMap.get("tixingmoshi").toString())); |
|
|
|
|
List<Task> tasks; |
|
|
|
|
if(map.get(tixingmoshi.getDictValue()) == null){ |
|
|
|
|
tasks = new ArrayList<Task>(); |
|
|
|
|
}else{ |
|
|
|
|
tasks = map.get(tixingmoshi.getDictValue()); |
|
|
|
|
} |
|
|
|
|
tasks.add(cl); |
|
|
|
|
map.put(tixingmoshi.getDictValue(), tasks); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//遍历map并根据具体的操作类去执行提醒
|
|
|
|
|
Iterator<Map.Entry<String, List<Task>>> iterator = map.entrySet().iterator(); |
|
|
|
|
while(iterator.hasNext()){ |
|
|
|
|
Map.Entry<String, List<Task>> next = iterator.next(); |
|
|
|
|
List<Task> tasks = next.getValue(); |
|
|
|
|
String key = next.getKey(); |
|
|
|
|
|
|
|
|
|
// //将到期任务按照提醒类型分类
|
|
|
|
|
// collect.forEach(cl ->{
|
|
|
|
|
// Map<String, Object> variableMap = cl.getProcessVariables();
|
|
|
|
|
// if(Func.isNotEmpty(variableMap.get("tixingmoshi")) && Func.isNotBlank(variableMap.get("tixingmoshi").toString())){
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
RemindOperation bean = SpringUtil.getContext().getBean(RemindTypeEnum.valueOf(key).getName(), RemindOperation.class); |
|
|
|
|
bean.remind(tasks); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|