初始代码
This commit is contained in:
52
yunzhupaas-flowable/yunzhupaas-flowable-biz/pom.xml
Normal file
52
yunzhupaas-flowable/yunzhupaas-flowable-biz/pom.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-flowable</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-flowable-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-flowable-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-generater-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-system-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-permission-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-base-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-security</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.flowable.util.*;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.context.SpringContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/23 17:42
|
||||
*/
|
||||
@Slf4j
|
||||
public class AutoAuditJob extends QuartzJobBean {
|
||||
|
||||
private static RedisUtil redisUtil;
|
||||
private static ConfigValueUtil configValueUtil;
|
||||
private static OperatorService operatorService;
|
||||
private static ConditionService conditionService;
|
||||
private static TaskUtil taskUtil;
|
||||
private static TaskService taskService;
|
||||
private static ServiceUtil serviceUtil;
|
||||
private static OperatorUtil operatorUtil;
|
||||
|
||||
static {
|
||||
redisUtil = SpringContext.getBean(RedisUtil.class);
|
||||
configValueUtil = SpringContext.getBean(ConfigValueUtil.class);
|
||||
operatorService = SpringContext.getBean(OperatorService.class);
|
||||
conditionService = SpringContext.getBean(ConditionService.class);
|
||||
taskUtil = SpringContext.getBean(TaskUtil.class);
|
||||
taskService = SpringContext.getBean(TaskService.class);
|
||||
serviceUtil = SpringContext.getBean(ServiceUtil.class);
|
||||
operatorUtil = SpringContext.getBean(OperatorUtil.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
List<FlowTimeModel> list = FlowJobUtil.getOperator(redisUtil);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (FlowTimeModel timeModel : list) {
|
||||
FlowModel flowModel = timeModel.getFlowModel();
|
||||
Map<String, Object> formData = flowModel.getFormData();
|
||||
String deploymentId = flowModel.getDeploymentId();
|
||||
Map<String, NodeModel> nodes = flowModel.getNodes();
|
||||
|
||||
UserInfo userInfo = flowModel.getUserInfo();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}
|
||||
|
||||
TaskEntity taskEntity = taskService.getById(timeModel.getTaskId());
|
||||
if (null == taskEntity) {
|
||||
taskEntity = flowModel.getTaskEntity();
|
||||
}
|
||||
|
||||
String operatorId = timeModel.getOperatorId();
|
||||
try {
|
||||
OperatorEntity operator = operatorService.getInfo(operatorId);
|
||||
if (null != operator) {
|
||||
flowModel.setTaskEntity(taskEntity);
|
||||
if (operator.getSignTime() == null) {
|
||||
operator.setSignTime(new Date());
|
||||
}
|
||||
if (operator.getStartHandleTime() == null) {
|
||||
operator.setStartHandleTime(new Date());
|
||||
}
|
||||
FlowMethod flowMethod = new FlowMethod();
|
||||
flowMethod.setTaskEntity(taskEntity);
|
||||
flowMethod.setFormData(formData == null ? new HashMap<>() : formData);
|
||||
flowMethod.setDeploymentId(deploymentId);
|
||||
flowMethod.setNodeCode(operator.getNodeCode());
|
||||
flowMethod.setNodes(nodes);
|
||||
// 判断节点的线的条件
|
||||
Map<String, Boolean> resMap = conditionService.handleCondition(flowMethod);
|
||||
try {
|
||||
conditionService.checkCondition(resMap, nodes);
|
||||
} catch (WorkFlowException e) {
|
||||
continue;
|
||||
}
|
||||
List<NodeModel> nextApprover;
|
||||
boolean mark = true;
|
||||
try {
|
||||
nextApprover = taskUtil.getNextApprover(flowMethod);
|
||||
} catch (WorkFlowException e) {
|
||||
nextApprover = null;
|
||||
mark = false;
|
||||
}
|
||||
if (!mark) {
|
||||
continue;
|
||||
}
|
||||
NodeModel nodeModel = nodes.get(operator.getNodeCode());
|
||||
if (!taskUtil.checkBranch(nodeModel) && taskUtil.checkNextCandidates(nextApprover)
|
||||
&& taskUtil.checkNextError(flowModel, nextApprover, false, false) == 0) {
|
||||
String handleId = operator.getHandleId();
|
||||
String username = "";
|
||||
UserEntity user = serviceUtil.getUserInfo(handleId);
|
||||
if (user != null) {
|
||||
username = user.getAccount() + "(" + user.getRealName() + ")";
|
||||
}
|
||||
String str = ObjectUtil.equals(operator.getIsProcessing(), 0) ? "自动审批通过" : "自动办理通过";
|
||||
flowModel.setHandleOpinion(username + str);
|
||||
UserEntity userEntity = serviceUtil.getUserInfo(operator.getHandleId());
|
||||
if (null != userEntity) {
|
||||
userInfo.setUserId(userEntity.getId());
|
||||
userInfo.setUserName(userEntity.getRealName());
|
||||
userInfo.setUserAccount(userEntity.getAccount());
|
||||
}
|
||||
operatorService.auditWithCheck(operator.getId(), flowModel);
|
||||
operatorUtil.handleEvent();
|
||||
List<OperatorEntity> operatorList = flowModel.getList();
|
||||
if (CollectionUtil.isNotEmpty(operatorList)) {
|
||||
TimeUtil.timeModel(operatorList, flowModel, redisUtil);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("超时自动审批异常", e);
|
||||
try {
|
||||
operatorUtil.compensate(taskEntity);
|
||||
} catch (Exception ex) {
|
||||
log.error("超时自动审批补偿异常", ex);
|
||||
}
|
||||
} finally {
|
||||
// TimeUtil.deleteJob(timeModel.getId());
|
||||
FlowJobUtil.remove(timeModel, redisUtil);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.RecordEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.OperatorStateEnum;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.TemplateJsonModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.TimeConfig;
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.flowable.util.*;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.AuthUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import com.yunzhupaas.util.context.SpringContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/12/10 9:17
|
||||
*/
|
||||
@Slf4j
|
||||
public class AutoTransferJob extends QuartzJobBean {
|
||||
private static RedisUtil redisUtil;
|
||||
private static ConfigValueUtil configValueUtil;
|
||||
private static OperatorService operatorService;
|
||||
private static TaskUtil taskUtil;
|
||||
private static TaskService taskService;
|
||||
private static ServiceUtil serviceUtil;
|
||||
private static MsgUtil msgUtil;
|
||||
private static RedisLock redisLock;
|
||||
|
||||
static {
|
||||
redisUtil = SpringContext.getBean(RedisUtil.class);
|
||||
configValueUtil = SpringContext.getBean(ConfigValueUtil.class);
|
||||
operatorService = SpringContext.getBean(OperatorService.class);
|
||||
taskUtil = SpringContext.getBean(TaskUtil.class);
|
||||
taskService = SpringContext.getBean(TaskService.class);
|
||||
serviceUtil = SpringContext.getBean(ServiceUtil.class);
|
||||
msgUtil = SpringContext.getBean(MsgUtil.class);
|
||||
redisLock = SpringContext.getBean(RedisLock.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
List<FlowTimeModel> list = FlowJobUtil.getTransfer(redisUtil);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
Set<String> nodeCodes = new TreeSet<>();
|
||||
for (FlowTimeModel timeModel : list) {
|
||||
FlowModel flowModel = timeModel.getFlowModel();
|
||||
|
||||
UserInfo userInfo = flowModel.getUserInfo();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}
|
||||
|
||||
String operatorId = timeModel.getOperatorId();
|
||||
|
||||
boolean lock = redisLock.lock("transfer-" + operatorId, operatorId, 2, TimeUnit.SECONDS);
|
||||
if (!lock)
|
||||
continue;
|
||||
|
||||
String nodeCode = flowModel.getNodeCode();
|
||||
|
||||
Map<String, Object> formData = flowModel.getFormData();
|
||||
Map<String, NodeModel> nodes = flowModel.getNodes();
|
||||
|
||||
NodeModel nodeModel = nodes.get(nodeCode);
|
||||
TimeConfig config = nodeModel.getOverTimeConfig();
|
||||
|
||||
if (ObjectUtil.equals(config.getOverTimeType(), 6) || ObjectUtil.equals(config.getOverTimeType(), 9)) {
|
||||
if (nodeCodes.contains(flowModel.getNodeCode())) {
|
||||
log.info("自动转审失败,该经办已处理(id:" + operatorId + ",code:" + nodeCode + ")");
|
||||
FlowJobUtil.removeTransfer(timeModel, redisUtil);
|
||||
continue;
|
||||
}
|
||||
nodeCodes.add(nodeCode);
|
||||
}
|
||||
OperatorEntity operator = operatorService.getById(operatorId);
|
||||
if (null == operator || operator.getHandleStatus() != null) {
|
||||
TimeUtil.deleteJob(timeModel.getId());
|
||||
FlowJobUtil.remove(timeModel, redisUtil);
|
||||
continue;
|
||||
}
|
||||
if (ObjectUtil.equals(operator.getStatus(), OperatorStateEnum.Transfer.getCode())) {
|
||||
log.info("转审状态的经办,不执行: " + operator.getId());
|
||||
FlowJobUtil.removeTransfer(timeModel, redisUtil);
|
||||
continue;
|
||||
}
|
||||
// 指派类型的转审,判断整个节点 是否存在转审类型的经办
|
||||
if (ObjectUtil.equals(config.getOverTimeType(), 6) || ObjectUtil.equals(config.getOverTimeType(), 9)) {
|
||||
QueryWrapper<OperatorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OperatorEntity::getTaskId, operator.getTaskId())
|
||||
.eq(OperatorEntity::getNodeId, operator.getNodeId())
|
||||
.eq(OperatorEntity::getStatus, OperatorStateEnum.Transfer.getCode());
|
||||
long count = operatorService.count(queryWrapper);
|
||||
if (count > 0) {
|
||||
log.info("节点存在转审状态的经办,不执行: " + operator.getId() + " " + operator.getNodeId());
|
||||
FlowJobUtil.removeTransfer(timeModel, redisUtil);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
String userId = operator.getHandleId();
|
||||
if (!ObjectUtil.equals(userInfo.getUserId(), userId)) {
|
||||
String token = AuthUtil.loginTempUser(userId, userInfo.getTenantId());
|
||||
userInfo = UserProvider.getUser(token);
|
||||
UserProvider.setLoginUser(userInfo);
|
||||
flowModel.setUserInfo(userInfo);
|
||||
}
|
||||
UserProvider.setLocalLoginUser(userInfo);
|
||||
|
||||
try {
|
||||
TaskEntity taskEntity = taskService.getById(operator.getTaskId());
|
||||
if (null == taskEntity) {
|
||||
taskEntity = flowModel.getTaskEntity();
|
||||
}
|
||||
String handleIds = null;
|
||||
if (ObjectUtil.equals(config.getOverTimeType(), 6)) {
|
||||
// 指定人员
|
||||
// 349057407209541--user
|
||||
if (CollectionUtil.isNotEmpty(config.getReApprovers())) {
|
||||
String handleId = config.getReApprovers().get(0).split("--")[0];
|
||||
UserEntity userEntity = serviceUtil.getUserInfo(handleId);
|
||||
if (!ObjectUtil.equals(userId, handleId) && null != userEntity
|
||||
&& ObjectUtil.equals(userEntity.getEnabledMark(), 1)) {
|
||||
handleIds = handleId;
|
||||
}
|
||||
}
|
||||
if (StringUtil.isNotEmpty(handleIds)) {
|
||||
flowModel.setHandleIds(handleIds);
|
||||
flowModel.setAutoTransferFlag(true);
|
||||
taskService.assign(operator.getTaskId(), flowModel);
|
||||
this.delete(timeModel);
|
||||
}
|
||||
} else if (ObjectUtil.equals(config.getOverTimeType(), 9)) {
|
||||
// 接口
|
||||
String interfaceId = config.getInterfaceId();
|
||||
List<TemplateJsonModel> templateJson = config.getTemplateJson();
|
||||
if (StringUtil.isNotEmpty(interfaceId)) {
|
||||
RecordEntity record = new RecordEntity();
|
||||
record.setTaskId(taskEntity.getId());
|
||||
record.setNodeCode(operator.getNodeCode());
|
||||
record.setHandleId(operator.getHandleId());
|
||||
|
||||
// UserEntity createUser =
|
||||
// serviceUtil.getUserInfo(taskEntity.getCreatorUserId());
|
||||
// UserEntity delegate = StringUtil.isNotEmpty(taskEntity.getDelegateUserId()) ?
|
||||
// serviceUtil.getUserInfo(taskEntity.getDelegateUserId()) : null;
|
||||
|
||||
Map<String, String> parameterMap = msgUtil.parameterMap(formData, templateJson, record,
|
||||
taskEntity);
|
||||
ActionResult result = serviceUtil.infoToId(interfaceId, parameterMap);
|
||||
if (Objects.equals(200, result.getCode())) {
|
||||
Object data = result.getData();
|
||||
if (data instanceof Map) {
|
||||
JSONObject map = new JSONObject((Map) data);
|
||||
List<String> handleId = StringUtil.isNotEmpty(map.getString("handleId"))
|
||||
? Arrays.asList(map.getString("handleId").split(","))
|
||||
: new ArrayList<>();
|
||||
handleId = serviceUtil.getUserName(handleId, true)
|
||||
.stream().map(UserEntity::getId).filter(e -> !ObjectUtil.equals(userId, e))
|
||||
.sorted().collect(Collectors.toList());
|
||||
handleIds = CollectionUtil.isNotEmpty(handleId) ? handleId.get(0) : null;
|
||||
}
|
||||
}
|
||||
if (StringUtil.isNotEmpty(handleIds)) {
|
||||
flowModel.setHandleIds(handleIds);
|
||||
flowModel.setAutoTransferFlag(true);
|
||||
taskService.assign(operator.getTaskId(), flowModel);
|
||||
this.delete(timeModel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 超时审批人,2.同一部门 7.同一角色 3.同一岗位 8.同一分组
|
||||
UserEntity userEntity = serviceUtil.getUserInfo(userId);
|
||||
if (null != userEntity) {
|
||||
Integer overTimeExtraRule = config.getOverTimeExtraRule();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
taskUtil.getByRule(userIds, userEntity, overTimeExtraRule);
|
||||
userIds = serviceUtil.getUserName(userIds, true)
|
||||
.stream().map(UserEntity::getId).filter(e -> !ObjectUtil.equals(userId, e)).sorted()
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(userIds)) {
|
||||
handleIds = userIds.get(0);
|
||||
}
|
||||
}
|
||||
if (StringUtil.isNotEmpty(handleIds)) {
|
||||
flowModel.setHandleIds(handleIds);
|
||||
operatorService.transfer(operatorId, flowModel);
|
||||
this.delete(timeModel);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("超时自动转审异常", e);
|
||||
this.delete(timeModel);
|
||||
} finally {
|
||||
FlowJobUtil.removeTransfer(timeModel, redisUtil);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void delete(FlowTimeModel timeModel) {
|
||||
TimeUtil.deleteJob(timeModel.getId());
|
||||
FlowJobUtil.remove(timeModel, redisUtil);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import org.quartz.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/23 18:16
|
||||
*/
|
||||
@Configuration
|
||||
public class FlowJobConfig {
|
||||
@Bean
|
||||
public JobDetail autoAuditDetail() {
|
||||
JobDetail jobDetail = JobBuilder.newJob(AutoAuditJob.class)
|
||||
.storeDurably() // 必须调用该方法,添加任务
|
||||
.build();
|
||||
return jobDetail;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Trigger autoAuditTrigger() {
|
||||
// 任务频率
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger()
|
||||
.forJob(autoAuditDetail())
|
||||
.withSchedule(cronScheduleBuilder)
|
||||
.build();
|
||||
return trigger;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JobDetail autoTransferDetail() {
|
||||
JobDetail jobDetail = JobBuilder.newJob(AutoTransferJob.class)
|
||||
.storeDurably() // 必须调用该方法,添加任务
|
||||
.build();
|
||||
return jobDetail;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Trigger autoTransferTrigger() {
|
||||
// 任务频率
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/8 * * * * ?");
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger()
|
||||
.forJob(autoTransferDetail())
|
||||
.withSchedule(cronScheduleBuilder)
|
||||
.build();
|
||||
return trigger;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.flowable.util.TimeUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.3.0 flowable
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/6/15 17:37
|
||||
*/
|
||||
@Slf4j
|
||||
public class FlowJobUtil {
|
||||
/**
|
||||
* 自动审批
|
||||
*/
|
||||
public static final String OPERATOR_REDIS_KEY = "flowable_OperatorList";
|
||||
|
||||
/**
|
||||
* 自动转审
|
||||
*/
|
||||
public static final String OPERATOR_TRANSFER = "flowable_transfer";
|
||||
|
||||
/**
|
||||
* 超时
|
||||
*/
|
||||
public static final String TIME_REDIS_KEY = "flowable_TimeModel";
|
||||
|
||||
/**
|
||||
* 提醒
|
||||
*/
|
||||
public static final String NOTICE_REDIS_KEY = "flowable_NoticeModel";
|
||||
|
||||
public static FlowTimeModel getModel(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
String id = model.getOperatorId();
|
||||
String hashValues = redisUtil.getHashValues(model.getOverTime() ? TIME_REDIS_KEY : NOTICE_REDIS_KEY, id);
|
||||
FlowTimeModel integrateModel = StringUtil.isNotEmpty(hashValues) ? JsonUtil.getJsonToBean(hashValues, FlowTimeModel.class) : null;
|
||||
return integrateModel;
|
||||
}
|
||||
|
||||
public static void insertModel(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
String integrateId = model.getOperatorId();
|
||||
redisUtil.insertHash(model.getOverTime() ? TIME_REDIS_KEY : NOTICE_REDIS_KEY, integrateId, JsonUtil.getObjectToString(model));
|
||||
}
|
||||
|
||||
public static void removeModel(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
redisUtil.removeHash(model.getOverTime() ? TIME_REDIS_KEY : NOTICE_REDIS_KEY, model.getOperatorId());
|
||||
}
|
||||
|
||||
public static void insertOperator(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
redisUtil.insertHash(OPERATOR_REDIS_KEY, model.getOperatorId(), JsonUtil.getObjectToString(model));
|
||||
}
|
||||
|
||||
public static void remove(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
redisUtil.removeHash(OPERATOR_TRANSFER, model.getOperatorId());
|
||||
redisUtil.removeHash(OPERATOR_REDIS_KEY, model.getOperatorId());
|
||||
redisUtil.removeHash(TIME_REDIS_KEY, model.getOperatorId());
|
||||
redisUtil.removeHash(NOTICE_REDIS_KEY, model.getOperatorId());
|
||||
}
|
||||
|
||||
public static void removeTransfer(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
redisUtil.removeHash(OPERATOR_TRANSFER, model.getOperatorId());
|
||||
}
|
||||
|
||||
public static List<FlowTimeModel> getOperator(RedisUtil redisUtil) {
|
||||
List<FlowTimeModel> list = new ArrayList<>();
|
||||
List<String> hashValues = redisUtil.getHashValues(OPERATOR_REDIS_KEY);
|
||||
if (CollectionUtil.isNotEmpty(hashValues)) {
|
||||
for (String hashValue : hashValues) {
|
||||
FlowTimeModel integrateModel = StringUtil.isNotEmpty(hashValue) ? JsonUtil.getJsonToBean(hashValue, FlowTimeModel.class) : null;
|
||||
list.add(integrateModel);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void insertTransfer(FlowTimeModel model, RedisUtil redisUtil) {
|
||||
redisUtil.insertHash(OPERATOR_TRANSFER, model.getOperatorId(), JsonUtil.getObjectToString(model));
|
||||
}
|
||||
|
||||
public static List<FlowTimeModel> getTransfer(RedisUtil redisUtil) {
|
||||
List<FlowTimeModel> list = new ArrayList<>();
|
||||
List<String> hashValues = redisUtil.getHashValues(OPERATOR_TRANSFER);
|
||||
if (CollectionUtil.isNotEmpty(hashValues)) {
|
||||
for (String hashValue : hashValues) {
|
||||
FlowTimeModel integrateModel = StringUtil.isNotEmpty(hashValue) ? JsonUtil.getJsonToBean(hashValue, FlowTimeModel.class) : null;
|
||||
list.add(integrateModel);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void deleteByOperatorId(String operatorId, RedisUtil redisUtil) {
|
||||
FlowTimeModel timeModel = new FlowTimeModel();
|
||||
timeModel.setOperatorId(operatorId);
|
||||
FlowTimeModel flowTimeModel = FlowJobUtil.getModel(timeModel, redisUtil);
|
||||
if (null != flowTimeModel) {
|
||||
TimeUtil.deleteJob(flowTimeModel.getId());
|
||||
FlowJobUtil.remove(flowTimeModel, redisUtil);
|
||||
}
|
||||
timeModel.setOverTime(true);
|
||||
FlowTimeModel overTimeModel = FlowJobUtil.getModel(timeModel, redisUtil);
|
||||
if (null != overTimeModel) {
|
||||
TimeUtil.deleteJob(overTimeModel.getId());
|
||||
FlowJobUtil.remove(overTimeModel, redisUtil);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.TimeConfig;
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.flowable.util.OverTimeUtil;
|
||||
import com.yunzhupaas.flowable.util.TimeUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.context.SpringContext;
|
||||
import org.quartz.*;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
|
||||
@DisallowConcurrentExecution
|
||||
public class FlowTime extends QuartzJobBean {
|
||||
|
||||
private static RedisUtil redisUtil;
|
||||
private static ConfigValueUtil configValueUtil;
|
||||
private static OverTimeUtil overTimeUtil;
|
||||
|
||||
|
||||
static {
|
||||
redisUtil = SpringContext.getBean(RedisUtil.class);
|
||||
configValueUtil = SpringContext.getBean(ConfigValueUtil.class);
|
||||
overTimeUtil = SpringContext.getBean(OverTimeUtil.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDetail jobDetail = context.getJobDetail();
|
||||
String jobName = jobDetail.getKey().getName();
|
||||
JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
||||
FlowTimeModel model = FlowJobUtil.getModel(JsonUtil.getJsonToBean(jobDataMap, FlowTimeModel.class), redisUtil);
|
||||
boolean isModel = model == null;
|
||||
FlowTimeModel timeModel = isModel ? JsonUtil.getJsonToBean(jobDataMap, FlowTimeModel.class) : model;
|
||||
if (timeModel != null) {
|
||||
FlowModel flowModel = timeModel.getFlowModel();
|
||||
UserInfo userInfo = flowModel.getUserInfo();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}
|
||||
try {
|
||||
overTimeUtil.overMsg(timeModel);
|
||||
Boolean isPause = timeModel.getIsPause();
|
||||
timeModel.setIsPause(false);
|
||||
boolean overTime = timeModel.getOverTime();
|
||||
FlowJobUtil.insertModel(timeModel, redisUtil);
|
||||
if (overTime) {
|
||||
if (isPause) {
|
||||
return;
|
||||
}
|
||||
NodeModel nodeModel = timeModel.getChildNode();
|
||||
TimeConfig time = nodeModel.getOverTimeConfig();
|
||||
Integer num = time.getOverAutoApproveTime();
|
||||
Boolean overAutoApprove = timeModel.getChildNode().getOverTimeConfig().getOverAutoApprove();
|
||||
if (overAutoApprove && ObjectUtil.equals(timeModel.getNum(), num)) {
|
||||
// 放在另一个redis的key(用于自动审批)
|
||||
FlowJobUtil.insertOperator(timeModel, redisUtil);
|
||||
}
|
||||
Boolean overAutoTransfer = timeModel.getChildNode().getOverTimeConfig().getOverAutoTransfer();
|
||||
Integer transferNum = time.getOverAutoTransferTime();
|
||||
if (!overAutoApprove && overAutoTransfer && ObjectUtil.equals(timeModel.getTransferNum(), transferNum)) {
|
||||
FlowJobUtil.insertTransfer(timeModel, redisUtil);
|
||||
}
|
||||
} else {
|
||||
// 下一次时间大于结束时间 删除提醒缓存
|
||||
if (timeModel.getEndDate().getTime() < context.getNextFireTime().getTime()) {
|
||||
FlowJobUtil.removeModel(timeModel, redisUtil);
|
||||
TimeUtil.deleteJob(jobName);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FlowJobUtil.removeModel(timeModel, redisUtil);
|
||||
TimeUtil.deleteJob(jobName);
|
||||
}
|
||||
} else {
|
||||
TimeUtil.deleteJob(jobName);
|
||||
FlowJobUtil.removeModel(model, redisUtil);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.flowable.util.TimeUtil;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/23 17:49
|
||||
*/
|
||||
// @Component
|
||||
public class JobRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
// 获取缓存中定时相关信息
|
||||
List<FlowTimeModel> list = FlowJobUtil.getOperator(redisUtil);
|
||||
for (FlowTimeModel timeModel : list) {
|
||||
Date date = new Date();
|
||||
// 判断当前时间是否已经 超过了结束时间
|
||||
if (date.getTime() > timeModel.getEndDate().getTime()) {
|
||||
continue;
|
||||
}
|
||||
if (timeModel.getOn()) {
|
||||
timeModel.setId(RandomUtil.uuId());
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.putAll(JsonUtil.entityToMap(timeModel));
|
||||
FlowJobUtil.insertModel(timeModel, redisUtil);
|
||||
TimeUtil.addJob(timeModel.getId(), timeModel.getDuring(), FlowTime.class, jobDataMap,
|
||||
timeModel.getStartDate(), timeModel.getEndDate());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/20 16:48
|
||||
*/
|
||||
@Slf4j
|
||||
public class QuartzJobUtil {
|
||||
private static final SchedulerFactory schedulerFactory = new StdSchedulerFactory();
|
||||
|
||||
public static void addJob(String jobName, String cron, Class<? extends Job> jobClass, JobDataMap jobDataMap,
|
||||
Date startDate, Date endDate) {
|
||||
if (jobDataMap == null) {
|
||||
jobDataMap = new JobDataMap();
|
||||
}
|
||||
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName).setJobData(jobDataMap).build();
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.forJob(jobDetail)
|
||||
.withIdentity(jobName)
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(cron))
|
||||
.startAt(startDate == null ? new Date() : startDate)
|
||||
.endAt(endDate != null ? endDate : null)
|
||||
.build();
|
||||
try {
|
||||
// 获取实例化的 Scheduler。
|
||||
Scheduler scheduler = getScheduler();
|
||||
// 将任务及其触发器放入调度器
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
// 调度器开始调度任务
|
||||
if (!scheduler.isShutdown()) {
|
||||
scheduler.start();
|
||||
}
|
||||
} catch (SchedulerException e) {
|
||||
log.error("新增调度失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static Scheduler getScheduler() {
|
||||
try {
|
||||
return schedulerFactory.getScheduler();
|
||||
} catch (SchedulerException e) {
|
||||
e.getMessage();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void deleteJob(String jobName) {
|
||||
try {
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
||||
Scheduler scheduler = getScheduler();
|
||||
scheduler.pauseTrigger(triggerKey);
|
||||
scheduler.unscheduleJob(triggerKey);
|
||||
scheduler.deleteJob(JobKey.jobKey(jobName));
|
||||
} catch (SchedulerException e) {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.Method;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.flowable.entity.TemplateJsonEntity;
|
||||
import com.yunzhupaas.flowable.model.trigger.TimeTriggerModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.TriggerModel;
|
||||
import com.yunzhupaas.flowable.service.TemplateJsonService;
|
||||
import com.yunzhupaas.util.AuthUtil;
|
||||
import com.yunzhupaas.util.Constants;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.context.SpringContext;
|
||||
import org.quartz.*;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/20 9:28
|
||||
*/
|
||||
// @DisallowConcurrentExecution
|
||||
public class TimeTriggerJob extends QuartzJobBean {
|
||||
private static RedisUtil redisUtil;
|
||||
private static ConfigValueUtil configValueUtil;
|
||||
private static TemplateJsonService templateJsonService;
|
||||
|
||||
static {
|
||||
redisUtil = SpringContext.getBean(RedisUtil.class);
|
||||
configValueUtil = SpringContext.getBean(ConfigValueUtil.class);
|
||||
templateJsonService = SpringContext.getBean(TemplateJsonService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDetail jobDetail = context.getJobDetail();
|
||||
String jobName = jobDetail.getKey().getName();
|
||||
JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
||||
TimeTriggerModel jsonToBean = JsonUtil.getJsonToBean(jobDataMap, TimeTriggerModel.class);
|
||||
TimeTriggerModel timeTriggerModel = TriggerJobUtil.getModel(jsonToBean, redisUtil);
|
||||
TimeTriggerModel model = timeTriggerModel == null ? jsonToBean : timeTriggerModel;
|
||||
|
||||
UserInfo userInfo = model.getUserInfo();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}
|
||||
|
||||
TemplateJsonEntity jsonEntity = templateJsonService.getById(model.getFlowId());
|
||||
|
||||
if (null != jsonEntity && ObjectUtil.equals(jsonEntity.getState(), 1)) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
model.setTime(currentTimeMillis);
|
||||
Integer num = model.getNum();
|
||||
Integer endTimeType = model.getEndTimeType();
|
||||
Integer endLimit = model.getEndLimit();
|
||||
int currentNum = num + 1;
|
||||
|
||||
boolean isNext = true;
|
||||
// 触发次数、指定时间
|
||||
if (ObjectUtil.equals(endTimeType, 1)) {
|
||||
isNext = currentNum <= endLimit;
|
||||
} else if (ObjectUtil.equals(endTimeType, 2)) {
|
||||
isNext = currentTimeMillis <= model.getEndTime();
|
||||
}
|
||||
|
||||
model.setNum(currentNum);
|
||||
if (isNext) {
|
||||
TriggerJobUtil.insertModel(model, redisUtil);
|
||||
|
||||
String token = AuthUtil.loginTempUser(userInfo.getUserId(), userInfo.getTenantId(), true);
|
||||
String url = configValueUtil.getApiDomain() + "/api/workflow/trigger/TimeExecute";
|
||||
|
||||
TriggerModel triggerModel = new TriggerModel();
|
||||
triggerModel.setUserInfo(userInfo);
|
||||
triggerModel.setId(model.getFlowId());
|
||||
HttpRequest request = HttpRequest.of(url).method(Method.POST)
|
||||
.body(JsonUtil.getObjectToString(triggerModel));
|
||||
request.header(Constants.AUTHORIZATION, token);
|
||||
request.execute().body();
|
||||
} else {
|
||||
TriggerJobUtil.removeModel(model, redisUtil);
|
||||
QuartzJobUtil.deleteJob(jobName);
|
||||
}
|
||||
} else {
|
||||
TriggerJobUtil.removeModel(model, redisUtil);
|
||||
QuartzJobUtil.deleteJob(jobName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import com.yunzhupaas.flowable.model.trigger.TimeTriggerModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/20 14:55
|
||||
*/
|
||||
@Component
|
||||
public class TimeTriggerRunner implements ApplicationRunner {
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
List<String> hashValues = redisUtil.getHashValues(TriggerJobUtil.TRIGGER_MODEL);
|
||||
for (String value : hashValues) {
|
||||
TimeTriggerModel model = JsonUtil.getJsonToBean(value, TimeTriggerModel.class);
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.putAll(JsonUtil.entityToMap(model));
|
||||
Date startTime = new Date(model.getStartTime());
|
||||
Date endTime = null != model.getEndTime() ? new Date(model.getEndTime()) : null;
|
||||
boolean isAdd = null != endTime ? endTime.getTime() > System.currentTimeMillis() : true;
|
||||
if (isAdd) {
|
||||
QuartzJobUtil.addJob(model.getId(), model.getCron(), TimeTriggerJob.class, jobDataMap, startTime,
|
||||
endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.flowable.job;
|
||||
|
||||
import com.yunzhupaas.flowable.model.trigger.TimeTriggerModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/20 10:22
|
||||
*/
|
||||
@Slf4j
|
||||
public class TriggerJobUtil {
|
||||
public static final String TRIGGER_MODEL = "trigger_model";
|
||||
|
||||
public static TimeTriggerModel getModel(TimeTriggerModel model, RedisUtil redisUtil) {
|
||||
String hashValues = redisUtil.getHashValues(TRIGGER_MODEL, model.getId());
|
||||
TimeTriggerModel timeTriggerModel = StringUtil.isNotEmpty(hashValues)
|
||||
? JsonUtil.getJsonToBean(hashValues, TimeTriggerModel.class)
|
||||
: null;
|
||||
return timeTriggerModel;
|
||||
}
|
||||
|
||||
public static void insertModel(TimeTriggerModel model, RedisUtil redisUtil) {
|
||||
String id = model.getId();
|
||||
redisUtil.insertHash(TRIGGER_MODEL, id, JsonUtil.getObjectToString(model));
|
||||
}
|
||||
|
||||
public static void removeModel(TimeTriggerModel model, RedisUtil redisUtil) {
|
||||
redisUtil.removeHash(TRIGGER_MODEL, model.getId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.CandidatesEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 16:00
|
||||
*/
|
||||
public interface CandidatesMapper extends SuperMapper<CandidatesEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.CirculateEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 16:00
|
||||
*/
|
||||
public interface CirculateMapper extends SuperMapper<CirculateEntity> {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.CommentEntity;
|
||||
|
||||
/**
|
||||
* 流程评论
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
*/
|
||||
public interface CommentMapper extends SuperMapper<CommentEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.CommonEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/22 20:30
|
||||
*/
|
||||
public interface CommonMapper extends SuperMapper<CommonEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.DelegateInfoEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/2 13:39
|
||||
*/
|
||||
public interface DelegateInfoMapper extends SuperMapper<DelegateInfoEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.DelegateEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/13 16:54
|
||||
*/
|
||||
public interface DelegateMapper extends SuperMapper<DelegateEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.LaunchUserEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 9:44
|
||||
*/
|
||||
public interface LaunchUserMapper extends SuperMapper<LaunchUserEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.NodeRecordEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/6/25 17:06
|
||||
*/
|
||||
public interface NodeRecordMapper extends SuperMapper<NodeRecordEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 15:28
|
||||
*/
|
||||
public interface OperatorMapper extends SuperMapper<OperatorEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.RecordEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/23 9:20
|
||||
*/
|
||||
public interface RecordMapper extends SuperMapper<RecordEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.RejectDataEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/8 18:06
|
||||
*/
|
||||
public interface RejectDataMapper extends SuperMapper<RejectDataEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.RevokeEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/24 13:39
|
||||
*/
|
||||
public interface RevokeMapper extends SuperMapper<RevokeEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.SubtaskDataEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/12/6 15:32
|
||||
*/
|
||||
public interface SubtaskDataMapper extends SuperMapper<SubtaskDataEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TaskLineEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/23 17:35
|
||||
*/
|
||||
public interface TaskLineMapper extends SuperMapper<TaskLineEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/17 15:07
|
||||
*/
|
||||
public interface TaskMapper extends SuperMapper<TaskEntity> {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TemplateJsonEntity;
|
||||
|
||||
public interface TemplateJsonMapper extends SuperMapper<TemplateJsonEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
|
||||
public interface TemplateMapper extends SuperMapper<TemplateEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
|
||||
public interface TemplateNodeMapper extends SuperMapper<TemplateNodeEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TriggerRecordEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/10 17:14
|
||||
*/
|
||||
public interface TriggerRecordMapper extends SuperMapper<TriggerRecordEntity> {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.flowable.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.flowable.entity.TriggerTaskEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/10 17:11
|
||||
*/
|
||||
public interface TriggerTaskMapper extends SuperMapper<TriggerTaskEntity> {
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.CandidatesEntity;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 16:01
|
||||
*/
|
||||
public interface CandidatesService extends SuperService<CandidatesEntity> {
|
||||
|
||||
/**
|
||||
* 获取候选人
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param nodeCode 节点编码
|
||||
*/
|
||||
List<CandidatesEntity> getList(String taskId, String nodeCode);
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param fo 参数类
|
||||
* @param taskId 任务id
|
||||
* @param nodeEntityList 节点集合
|
||||
* @param operator 经办实体
|
||||
*/
|
||||
void create(FlowModel fo, String taskId, List<TemplateNodeEntity> nodeEntityList, OperatorEntity operator);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeIds 节点编码集合
|
||||
*/
|
||||
void deleteByCodes(String taskId, List<String> nodeIds);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeIds 节点编码
|
||||
* @param userId 用户主键
|
||||
*/
|
||||
void delete(String taskId, List<String> nodeIds, List<String> userId);
|
||||
|
||||
/**
|
||||
* 获取选择分支
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeCode 节点编码
|
||||
*/
|
||||
List<String> getBranch(String taskId, String nodeCode);
|
||||
|
||||
/**
|
||||
* 保存选择分支
|
||||
*
|
||||
* @param branchList 选择分支
|
||||
* @param operator 经办
|
||||
*/
|
||||
void createBranch(List<String> branchList, OperatorEntity operator);
|
||||
|
||||
/**
|
||||
* 删除选择分支
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeCode 节点编码
|
||||
*/
|
||||
void deleteBranch(String taskId, String nodeCode);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.CirculateEntity;
|
||||
import com.yunzhupaas.flowable.model.operator.OperatorVo;
|
||||
import com.yunzhupaas.flowable.model.task.TaskPagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/4/29 下午5:14
|
||||
*/
|
||||
public interface CirculateService extends SuperService<CirculateEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
List<CirculateEntity> getList(String taskId);
|
||||
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*
|
||||
* @param pagination 分页
|
||||
*/
|
||||
List<OperatorVo> getList(TaskPagination pagination);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.CommentEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.model.comment.CommentPagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/4/24 上午9:07
|
||||
*/
|
||||
public interface CommentService extends SuperService<CommentEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 请求参数
|
||||
* @return
|
||||
*/
|
||||
List<CommentEntity> getlist(CommentPagination pagination);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @return
|
||||
*/
|
||||
List<CommentEntity> getList();
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<CommentEntity> getlist(List<String> idList);
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
CommentEntity getInfo(String id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void create(CommentEntity entity) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param entity 实体对象
|
||||
* @return
|
||||
*/
|
||||
void update(String id, CommentEntity entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param entity 实体对象
|
||||
* @return
|
||||
*/
|
||||
void delete(CommentEntity entity,boolean delComment);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.CommonEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/22 20:31
|
||||
*/
|
||||
public interface CommonService extends SuperService<CommonEntity> {
|
||||
/**
|
||||
* 根据用户主键获取常用
|
||||
*
|
||||
* @param userId 用户主键
|
||||
*/
|
||||
List<CommonEntity> getCommonByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 设置常用流程
|
||||
*
|
||||
* @param flowId 流程版本主键
|
||||
*/
|
||||
int setCommonFLow(String flowId);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.DelegateEntity;
|
||||
import com.yunzhupaas.flowable.entity.DelegateInfoEntity;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateCrForm;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateListVO;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegatePagination;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateUpForm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/2 13:40
|
||||
*/
|
||||
public interface DelegateInfoService extends SuperService<DelegateInfoEntity> {
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页参数
|
||||
*/
|
||||
List<DelegateListVO> getList(DelegatePagination pagination);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param delegateIds 委托主键集合
|
||||
*/
|
||||
List<DelegateInfoEntity> getList(List<String> delegateIds);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param delegateId 委托主键
|
||||
*/
|
||||
List<DelegateInfoEntity> getList(String delegateId);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param toUserId 被委托人/代理人id
|
||||
*/
|
||||
List<DelegateInfoEntity> getByToUserId(String toUserId);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param toUserIds 被委托人/代理人id
|
||||
*/
|
||||
List<DelegateInfoEntity> getByToUserIds(List<String> toUserIds);
|
||||
|
||||
/**
|
||||
* 新增被 委托/代理 的用户
|
||||
*
|
||||
* @param fo 参数
|
||||
* @param delegateEntity 委托实体
|
||||
*/
|
||||
void create(DelegateCrForm fo, DelegateEntity delegateEntity);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param fo 参数
|
||||
* @param delegateEntity 委托实体
|
||||
*/
|
||||
void update(DelegateUpForm fo, DelegateEntity delegateEntity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param delegateId 委托主键
|
||||
*/
|
||||
void delete(String delegateId);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.DelegateEntity;
|
||||
import com.yunzhupaas.flowable.entity.DelegateInfoEntity;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateUserVo;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateCrForm;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateListVO;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegatePagination;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateUpForm;
|
||||
import com.yunzhupaas.flowable.model.template.TemplatePageLisVO;
|
||||
import com.yunzhupaas.flowable.model.template.TemplatePagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/13 16:55
|
||||
*/
|
||||
public interface DelegateService extends SuperService<DelegateEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页参数
|
||||
*/
|
||||
List<DelegateListVO> getList(DelegatePagination pagination);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 委托主键
|
||||
*/
|
||||
DelegateEntity getInfo(String id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param fo 参数
|
||||
*/
|
||||
void create(DelegateCrForm fo);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param entity 实体
|
||||
* @param fo 参数
|
||||
*/
|
||||
boolean update(DelegateEntity entity, DelegateUpForm fo);
|
||||
|
||||
/**
|
||||
* 委托结束
|
||||
*
|
||||
* @param id 主键
|
||||
* @param entity 实体
|
||||
*/
|
||||
boolean updateStop(String id, DelegateEntity entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param entity 实体
|
||||
*/
|
||||
void delete(DelegateEntity entity);
|
||||
|
||||
/**
|
||||
* 获取被委托人/代理人
|
||||
*
|
||||
* @param userId 委托人
|
||||
* @param flowId 流程主键
|
||||
*/
|
||||
List<String> getToUser(String userId, String flowId);
|
||||
|
||||
/**
|
||||
* 根据 被委托人/代理人id 获取列表
|
||||
*
|
||||
* @param toUserId 被委托人/代理人id
|
||||
*/
|
||||
List<DelegateEntity> getByToUserId(String toUserId);
|
||||
|
||||
/**
|
||||
* 根据 被委托人/代理人id 获取列表
|
||||
*
|
||||
* @param toUserId 被委托人/代理人id
|
||||
* @param type 类型
|
||||
*/
|
||||
List<DelegateEntity> getByToUserId(String toUserId, Integer type);
|
||||
|
||||
/**
|
||||
* 获取我的委托发起
|
||||
*
|
||||
* @param pagination 分页参数
|
||||
*/
|
||||
List<TemplatePageLisVO> getFlow(TemplatePagination pagination);
|
||||
|
||||
// /**
|
||||
// * 获取委托人列表
|
||||
// */
|
||||
// ListVO<CandidateUserVo> getUserList() throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取委托人列表
|
||||
*/
|
||||
ListVO<CandidateUserVo> getUserList(String templateId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取当前用户所有发起委托列表
|
||||
*/
|
||||
List<DelegateEntity> getLaunchDelagateList();
|
||||
|
||||
/**
|
||||
* 根据条件查询相关委托信息
|
||||
*
|
||||
* @param fo 参数
|
||||
*/
|
||||
List<DelegateEntity> selectSameParamAboutDelaget(DelegateCrForm fo);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
List<DelegateEntity> getList();
|
||||
|
||||
/**
|
||||
* 确认
|
||||
*
|
||||
* @param delegateInfo 委托信息
|
||||
*/
|
||||
void notarize(DelegateInfoEntity delegateInfo);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.LaunchUserEntity;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 9:45
|
||||
*/
|
||||
public interface LaunchUserService extends SuperService<LaunchUserEntity> {
|
||||
|
||||
/**
|
||||
* 根据任务id获取发起用户
|
||||
*
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
LaunchUserEntity getInfoByTask(String taskId);
|
||||
|
||||
/**
|
||||
* 创建发起用户
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param userId 用户id
|
||||
*/
|
||||
void createLaunchUser(String taskId, String userId);
|
||||
|
||||
/**
|
||||
* 删除发起用户
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
void delete(String taskId);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.NodeRecordEntity;
|
||||
import com.yunzhupaas.flowable.model.record.NodeRecordModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/6/25 17:07
|
||||
*/
|
||||
public interface NodeRecordService extends SuperService<NodeRecordEntity> {
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
List<NodeRecordEntity> getList(String taskId);
|
||||
|
||||
/**
|
||||
* 节点记录保存
|
||||
*
|
||||
* @param model 参数
|
||||
*/
|
||||
void create(NodeRecordModel model);
|
||||
|
||||
/**
|
||||
* 节点记录更新
|
||||
*
|
||||
* @param model 参数
|
||||
*/
|
||||
void update(NodeRecordModel model);
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateCheckVo;
|
||||
import com.yunzhupaas.flowable.model.operator.FlowBatchModel;
|
||||
import com.yunzhupaas.flowable.model.operator.OperatorVo;
|
||||
import com.yunzhupaas.flowable.model.operator.ReducePagination;
|
||||
import com.yunzhupaas.flowable.model.operator.ReduceUserModel;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.task.TaskPagination;
|
||||
import com.yunzhupaas.flowable.model.templatenode.BackNodeModel;
|
||||
import com.yunzhupaas.model.FlowWorkListVO;
|
||||
import com.yunzhupaas.permission.model.user.WorkHandoverModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 15:29
|
||||
*/
|
||||
public interface OperatorService extends SuperService<OperatorEntity> {
|
||||
|
||||
/**
|
||||
* 经办实体
|
||||
*
|
||||
* @param id 经办主键
|
||||
*/
|
||||
OperatorEntity getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
List<OperatorEntity> getList(String taskId);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 参数
|
||||
*/
|
||||
List<OperatorVo> getList(TaskPagination pagination);
|
||||
|
||||
/**
|
||||
* 处理经办
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
List<OperatorEntity> handleOperator(FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 同意
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void auditWithCheck(String id, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 同意
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void audit(String id, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 同意(发起时自动通过)
|
||||
*
|
||||
* @param operator 经办实体
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void audit(OperatorEntity operator, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 签收
|
||||
*
|
||||
* @param flowModel 参数,ids 、type 0 签收 1 退签
|
||||
*/
|
||||
void sign(FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 开始办理
|
||||
*
|
||||
* @param flowModel 参数,ids
|
||||
*/
|
||||
void startHandle(FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 暂存
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void saveAudit(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 加签
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void addSign(String id, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取加签的人
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param pagination 参数
|
||||
*/
|
||||
List<ReduceUserModel> getReduceList(String id, ReducePagination pagination) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 减签
|
||||
*
|
||||
* @param id 记录主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void reduce(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取退回的节点
|
||||
*
|
||||
* @param id 经办主键
|
||||
*/
|
||||
List<BackNodeModel> getFallbacks(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void back(String id, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 撤回
|
||||
*
|
||||
* @param id 记录主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void recall(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 转审
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void transfer(String id, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 协办
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void assist(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 协办保存
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void assistSave(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 批量审批流程分类列表
|
||||
*/
|
||||
List<FlowBatchModel> batchFlowSelector();
|
||||
|
||||
/**
|
||||
* 批量审批流程版本列表
|
||||
*
|
||||
* @param templateId 流程定义主键
|
||||
*/
|
||||
List<FlowBatchModel> batchVersionSelector(String templateId);
|
||||
|
||||
/**
|
||||
* 批量审批节点列表
|
||||
*
|
||||
* @param flowId 流程定义版本主键
|
||||
*/
|
||||
List<FlowBatchModel> batchNodeSelector(String flowId);
|
||||
|
||||
/**
|
||||
* 批量审批节点属性
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
Map<String, Object> batchNode(FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 批量审批获取候选人
|
||||
*
|
||||
* @param flowId 版本主键
|
||||
* @param operatorId 经办主键
|
||||
* @param batchType 类型,0.同意 1.拒绝
|
||||
*/
|
||||
CandidateCheckVo batchCandidates(String flowId, String operatorId, Integer batchType) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 批量审批
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void batch(FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 流程交接
|
||||
*
|
||||
* @param fromId 移交人
|
||||
*/
|
||||
FlowWorkListVO flowWork(String fromId);
|
||||
|
||||
/**
|
||||
* 流程交接
|
||||
*
|
||||
* @param workHandoverModel 参数
|
||||
*/
|
||||
boolean flowWork(WorkHandoverModel workHandoverModel);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.RecordEntity;
|
||||
import com.yunzhupaas.flowable.model.operator.OperatorVo;
|
||||
import com.yunzhupaas.flowable.model.record.RecordVo;
|
||||
import com.yunzhupaas.flowable.model.task.TaskPagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/23 9:21
|
||||
*/
|
||||
public interface RecordService extends SuperService<RecordEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
List<RecordEntity> getList(String taskId);
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*
|
||||
* @param pagination 分页
|
||||
*/
|
||||
List<OperatorVo> getList(TaskPagination pagination);
|
||||
|
||||
/**
|
||||
* 消息汇总列表
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param statusList 状态
|
||||
*/
|
||||
List<RecordEntity> getRecordList(String taskId, List<Integer> statusList);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 记录主键
|
||||
*/
|
||||
RecordEntity getInfo(String id);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param entity 记录实体
|
||||
*/
|
||||
void create(RecordEntity entity);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param id 主键
|
||||
* @param entity 实体
|
||||
*/
|
||||
void update(String id, RecordEntity entity);
|
||||
|
||||
/**
|
||||
* 变更状态为作废
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeCodeList 节点编码
|
||||
*/
|
||||
void updateStatusToInvalid(String taskId, List<String> nodeCodeList);
|
||||
|
||||
/**
|
||||
* 记录列表
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeId 节点id
|
||||
*/
|
||||
List<RecordVo> getList(String taskId, String nodeId);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.RejectDataEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/8 18:07
|
||||
*/
|
||||
public interface RejectDataService extends SuperService<RejectDataEntity> {
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
RejectDataEntity getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param taskEntity 任务
|
||||
* @param operatorEntityList 经办集合
|
||||
* @param nodeCode 节点编码
|
||||
*/
|
||||
RejectDataEntity create(TaskEntity taskEntity, List<OperatorEntity> operatorEntityList, String nodeCode);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.RevokeEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/24 13:39
|
||||
*/
|
||||
public interface RevokeService extends SuperService<RevokeEntity> {
|
||||
/**
|
||||
* 获取撤销任务关联
|
||||
*
|
||||
* @param revokeTaskId 撤销任务主键
|
||||
*/
|
||||
RevokeEntity getRevokeTask(String revokeTaskId);
|
||||
|
||||
/**
|
||||
* 用于判断原任务是否能撤销
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
Boolean checkExist(String taskId);
|
||||
|
||||
/**
|
||||
* 假删除
|
||||
*
|
||||
* @param revokeTaskId 撤销任务主键
|
||||
*/
|
||||
void deleteRevoke(String revokeTaskId);
|
||||
|
||||
/**
|
||||
* 根据任务id获取撤销任务id
|
||||
*
|
||||
* @param ids 任务id
|
||||
*/
|
||||
List<String> getByTaskId(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.SubtaskDataEntity;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/12/6 15:33
|
||||
*/
|
||||
public interface SubtaskDataService extends SuperService<SubtaskDataEntity> {
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param parentId 父实例主键
|
||||
* @param parentCode 父节点编码
|
||||
*/
|
||||
List<SubtaskDataEntity> getList(String parentId, String parentCode);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param subTaskData 依次创建子流程参数集合
|
||||
*/
|
||||
void save(List<FlowModel> subTaskData);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.TaskLineEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/23 17:36
|
||||
*/
|
||||
public interface TaskLineService extends SuperService<TaskLineEntity> {
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
List<TaskLineEntity> getList(String taskId);
|
||||
|
||||
/**
|
||||
* 保存任务条件
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param conditionResMap 条件
|
||||
*/
|
||||
void create(String taskId, Map<String, Boolean> conditionResMap);
|
||||
|
||||
/**
|
||||
* 获取最新的(值为true的)线的集合
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
List<String> getLineKeyList(String taskId);
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateCheckFo;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateCheckVo;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateUserFo;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateUserVo;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.task.TaskPagination;
|
||||
import com.yunzhupaas.flowable.model.task.TaskUserListModel;
|
||||
import com.yunzhupaas.flowable.model.task.ViewFormModel;
|
||||
import com.yunzhupaas.flowable.model.template.BeforeInfoVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/17 15:08
|
||||
*/
|
||||
public interface TaskService extends SuperService<TaskEntity> {
|
||||
|
||||
TaskEntity getInfoSubmit(String id, SFunction<TaskEntity, ?>... columns);
|
||||
|
||||
List<TaskEntity> getInfosSubmit(String[] ids, SFunction<TaskEntity, ?>... columns);
|
||||
|
||||
/**
|
||||
* 我发起的 列表
|
||||
*
|
||||
* @param pagination 分页
|
||||
*/
|
||||
List<TaskEntity> getList(TaskPagination pagination);
|
||||
|
||||
/**
|
||||
* 监控列表
|
||||
*
|
||||
* @param pagination 分页参数
|
||||
*/
|
||||
List<TaskEntity> getMonitorList(TaskPagination pagination);
|
||||
|
||||
/**
|
||||
* 任务实体
|
||||
*
|
||||
* @param id 任务主键
|
||||
*/
|
||||
TaskEntity getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 发起、审批详情
|
||||
*
|
||||
* @param id 任务id
|
||||
* @param fo 参数类
|
||||
*/
|
||||
BeforeInfoVo getInfo(String id, FlowModel fo) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取能走的节点,判断候选人
|
||||
*
|
||||
* @param id 经办主键
|
||||
* @param fo 参数类
|
||||
*/
|
||||
CandidateCheckVo checkCandidates(String id, CandidateCheckFo fo) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取候选人
|
||||
*
|
||||
* @param fo 参数类
|
||||
*/
|
||||
List<CandidateUserVo> getCandidateUser(String id, CandidateUserFo fo) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 暂存、提交
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void batchSaveOrSubmit(FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 暂存、提交
|
||||
*
|
||||
* @param fo 参数类
|
||||
*/
|
||||
void saveOrSubmit(FlowModel fo) throws Exception;
|
||||
|
||||
/**
|
||||
* 发起撤回
|
||||
*
|
||||
* @param id 任务主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void recall(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 催办
|
||||
*
|
||||
* @param id 任务主键
|
||||
*/
|
||||
boolean press(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 撤销
|
||||
*
|
||||
* @param id 任务主键
|
||||
*/
|
||||
void revoke(String id, FlowModel flowModel) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
List<TaskEntity> delete(String id) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param ids 主键数组
|
||||
*/
|
||||
void deleteBatch(List<String> ids) throws Exception;
|
||||
|
||||
/**
|
||||
* 递归获取子流程
|
||||
*
|
||||
* @param idList 需要递归的任务主键集合
|
||||
* @param idAll 结果任务主键集合
|
||||
*/
|
||||
void deleTaskAll(List<String> idList, List<String> idAll);
|
||||
|
||||
/**
|
||||
* 终止、复活
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 参数
|
||||
* @param isCancel 标识,true 终止
|
||||
*/
|
||||
void cancel(String id, FlowModel flowModel, boolean isCancel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 判断是否存在异步子流程
|
||||
*
|
||||
* @param id 任务主键
|
||||
*/
|
||||
boolean checkAsync(String id);
|
||||
|
||||
/**
|
||||
* 挂起、恢复
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 参数
|
||||
* @param isSuspend 标识,true 挂起、false 恢复
|
||||
*/
|
||||
void pause(String id, FlowModel flowModel, Boolean isSuspend) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 指派
|
||||
*
|
||||
* @param id 主键
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
void assign(String id, FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取流程所关联的用户信息
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
TaskUserListModel getTaskUserList(String taskId);
|
||||
|
||||
/**
|
||||
* 子流程详情
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
List<BeforeInfoVo> subFlowInfo(FlowModel flowModel) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 消息跳转流程校验
|
||||
*
|
||||
* @param id 经办或抄送主键
|
||||
*/
|
||||
String checkInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 更新归档状态
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
void updateIsFile(String taskId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取发起表单
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
ViewFormModel getStartForm(String taskId) throws WorkFlowException;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TemplateJsonEntity;
|
||||
import com.yunzhupaas.flowable.model.templatejson.TemplateJsonInfoVO;
|
||||
import com.yunzhupaas.flowable.model.templatenode.TemplateNodeUpFrom;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TemplateJsonService extends SuperService<TemplateJsonEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TemplateJsonEntity> getListByTemplateIds(List<String> id);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TemplateJsonEntity> getList(String templateId);
|
||||
|
||||
/**
|
||||
* 获取启用的列表
|
||||
*/
|
||||
List<TemplateJsonEntity> getListOfEnable();
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return ignore
|
||||
*/
|
||||
TemplateJsonEntity getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param entity 实体对象
|
||||
* @return ignore
|
||||
*/
|
||||
boolean update(String id, TemplateJsonEntity entity);
|
||||
|
||||
/**
|
||||
* 流程保存或发布
|
||||
*
|
||||
* @param from 主键值
|
||||
* @return ignore
|
||||
*/
|
||||
void save(TemplateNodeUpFrom from) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param from 对象
|
||||
* @return ignore
|
||||
*/
|
||||
void create(TemplateNodeUpFrom from);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void delete(TemplateJsonEntity entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 实体对象
|
||||
*/
|
||||
void delete(List<String> id);
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void copy(TemplateJsonEntity entity, String id);
|
||||
|
||||
/**
|
||||
* 版本详情
|
||||
*
|
||||
* @param id 版本主键
|
||||
*/
|
||||
TemplateJsonInfoVO getInfoVo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取表单
|
||||
*
|
||||
* @param id 版本主键
|
||||
*/
|
||||
VisualdevEntity getFormInfo(String id) throws WorkFlowException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TemplateNodeService extends SuperService<TemplateNodeEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TemplateNodeEntity> getList(String flowId);
|
||||
|
||||
/**
|
||||
* 获取节点
|
||||
*
|
||||
* @param flowIds 版本主键集合
|
||||
*/
|
||||
List<TemplateNodeEntity> getList(List<String> flowIds, String nodeType);
|
||||
|
||||
/**
|
||||
* 根据用户主键 获取节点
|
||||
*
|
||||
* @param userId 用户主键
|
||||
*/
|
||||
List<TemplateNodeEntity> getListLikeUserId(String userId);
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return ignore
|
||||
*/
|
||||
TemplateNodeEntity getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void create(TemplateNodeEntity entity);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param entity 实体对象
|
||||
* @return ignore
|
||||
*/
|
||||
boolean update(String id, TemplateNodeEntity entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void delete(TemplateNodeEntity entity);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param idList
|
||||
*/
|
||||
void deleteList(List<String> idList);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param idList
|
||||
*/
|
||||
void delete(List<String> idList);
|
||||
|
||||
/**
|
||||
* 获取开始节点表单列表
|
||||
*/
|
||||
List<TemplateNodeEntity> getListStart();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
import com.yunzhupaas.flowable.model.template.*;
|
||||
import com.yunzhupaas.flowable.model.templatejson.FlowFormModel;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TemplateService extends SuperService<TemplateEntity> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TemplateEntity> getList(TemplatePagination pagination);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<TemplatePageVo> getSelector(TemplatePagination pagination);
|
||||
|
||||
/**
|
||||
* 树形常用
|
||||
*/
|
||||
List<TemplateTreeListVo> getTreeCommon();
|
||||
|
||||
/**
|
||||
* 树形集合
|
||||
*/
|
||||
List<TemplateTreeListVo> treeList(Integer formType);
|
||||
|
||||
/**
|
||||
* 权限树形集合
|
||||
*/
|
||||
List<TemplateTreeListVo> treeListWithPower();
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页参数
|
||||
* @param isPage 是否分页
|
||||
*/
|
||||
List<TemplateEntity> getListAll(TemplatePagination pagination, boolean isPage);
|
||||
|
||||
/**
|
||||
* 根据版本主键集合获取流程模板集合
|
||||
*
|
||||
* @param flowIds 版本主键集合
|
||||
*/
|
||||
List<TemplateEntity> getListByFlowIds(List<String> flowIds);
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return ignore
|
||||
*/
|
||||
TemplateEntity getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 验证名称
|
||||
*
|
||||
* @param fullName 名称
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
boolean isExistByFullName(String fullName, String id);
|
||||
|
||||
/**
|
||||
* 验证编码
|
||||
*
|
||||
* @param enCode 编码
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
boolean isExistByEnCode(String enCode, String id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void create(TemplateEntity entity, String flowXml, Map<String, Map<String, Object>> flowNodes) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键值
|
||||
* @param entity 实体对象
|
||||
* @return ignore
|
||||
*/
|
||||
boolean update(String id, TemplateEntity entity) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void delete(TemplateEntity entity) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 复制
|
||||
*
|
||||
* @param entity 实体对象
|
||||
*/
|
||||
void copy(TemplateEntity entity) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param id 定义主键
|
||||
*/
|
||||
TemplateExportModel export(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 导入
|
||||
*
|
||||
* @param model 导出model
|
||||
* @param type 类型
|
||||
*/
|
||||
void importData(TemplateExportModel model, String type) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
List<TemplateEntity> getList(List<String> ids);
|
||||
|
||||
/**
|
||||
* 查询(status为 1、2 的)
|
||||
*/
|
||||
List<TemplateEntity> getListOfHidden(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据表单主键获取流程(权限过滤)
|
||||
*
|
||||
* @param formId 表单主键
|
||||
*/
|
||||
FlowByFormModel getFlowByFormId(String formId, Boolean start);
|
||||
|
||||
/**
|
||||
* 子流程可发起人员
|
||||
*
|
||||
* @param flowId 流程主键
|
||||
* @param pagination 分页参数
|
||||
*/
|
||||
List<UserEntity> getSubFlowUserList(String flowId, TemplatePagination pagination) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 根据模板主键获取表单
|
||||
*
|
||||
* @param templateId 流程模板主键
|
||||
*/
|
||||
VisualdevEntity getFormByTemplateId(String templateId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 根据模板主键获取表单主键和流程版本主键
|
||||
*
|
||||
* @param templateId 流程模板主键
|
||||
*/
|
||||
FlowFormModel getFormIdAndFlowId(String templateId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 根据模板主键获取表单主键和流程版本主键
|
||||
*
|
||||
* @param templateId 流程模板主键
|
||||
*/
|
||||
FlowFormModel getFormIdAndFlowId(List<String> userId ,String templateId) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 获取启用的流程版本的表单集合
|
||||
*/
|
||||
List<String> getFormList();
|
||||
|
||||
/**
|
||||
* 获取流程templateId和表单formId组成的map
|
||||
*/
|
||||
Map<String, String> getFlowFormMap();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.flowable.entity.TriggerRecordEntity;
|
||||
import com.yunzhupaas.flowable.entity.TriggerTaskEntity;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowableTaskModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/10 17:15
|
||||
*/
|
||||
public interface TriggerRecordService extends SuperService<TriggerRecordEntity> {
|
||||
|
||||
List<TriggerRecordEntity> getList(String triggerTaskId);
|
||||
|
||||
List<TriggerRecordEntity> getListByTaskId(String taskId);
|
||||
|
||||
void create(TriggerRecordEntity entity);
|
||||
|
||||
void create(TriggerTaskEntity triggerTask, NodeModel nodeModel, FlowableTaskModel taskModel);
|
||||
|
||||
void createStart(String triggerId);
|
||||
|
||||
void createEnd(String triggerId);
|
||||
|
||||
void delete(List<String> triggerTaskIds);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.yunzhupaas.flowable.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TriggerTaskEntity;
|
||||
import com.yunzhupaas.flowable.model.trigger.TriggerInfoListModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.TriggerInfoModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.TriggerPagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/10 17:12
|
||||
*/
|
||||
public interface TriggerTaskService extends SuperService<TriggerTaskEntity> {
|
||||
/**
|
||||
* 获取任务下的触发记录
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeCode 节点编码
|
||||
*/
|
||||
List<TriggerInfoListModel> getListByTaskId(String taskId, String nodeCode);
|
||||
|
||||
/**
|
||||
* 判断是否有任务流程
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
* @param nodeCode 节点编码
|
||||
*/
|
||||
boolean existTriggerTask(String taskId, String nodeCode);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pagination 分页参数
|
||||
*/
|
||||
List<TriggerTaskEntity> getList(TriggerPagination pagination);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
TriggerInfoModel getInfo(String id) throws WorkFlowException;
|
||||
|
||||
/**
|
||||
* 重试
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
void retry(String id) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param entity 实体
|
||||
*/
|
||||
void saveTriggerTask(TriggerTaskEntity entity);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param entity 实体
|
||||
*/
|
||||
void updateTriggerTask(TriggerTaskEntity entity);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids 任务流程实例主键
|
||||
*/
|
||||
void batchDelete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据任务主键删除
|
||||
*
|
||||
* @param taskId 任务主键
|
||||
*/
|
||||
void deleteByTaskId(List<String> taskId);
|
||||
|
||||
/**
|
||||
* 判断流程版本下是否存在任务流程
|
||||
*
|
||||
* @param flowIds 流程版本主键集合
|
||||
*/
|
||||
boolean checkByFlowIds(List<String> flowIds);
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.yulichang.extension.mapping.wrapper.MappingQuery;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.CandidatesEntity;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
import com.yunzhupaas.flowable.mapper.CandidatesMapper;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.CandidatesService;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 16:03
|
||||
*/
|
||||
@Service
|
||||
public class CandidatesServiceImpl extends SuperServiceImpl<CandidatesMapper, CandidatesEntity>
|
||||
implements CandidatesService {
|
||||
@Autowired
|
||||
private OperatorService operatorService;
|
||||
|
||||
@Override
|
||||
public List<CandidatesEntity> getList(String taskId, String nodeCode) {
|
||||
QueryWrapper<CandidatesEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotEmpty(taskId)) {
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getTaskId, taskId);
|
||||
}
|
||||
if (StringUtil.isNotEmpty(nodeCode)) {
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getNodeCode, nodeCode);
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
public List<CandidatesEntity> getListByCode(String taskId, String nodeCode) {
|
||||
QueryWrapper<CandidatesEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getTaskId, taskId).eq(CandidatesEntity::getNodeCode, nodeCode);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(FlowModel fo, String taskId, List<TemplateNodeEntity> nodeEntityList, OperatorEntity operator) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
// 候选人
|
||||
Map<String, List<String>> candidateList = fo.getCandidateList();
|
||||
for (String key : candidateList.keySet()) {
|
||||
TemplateNodeEntity nodeEntity = nodeEntityList.stream().filter(e -> e.getNodeCode().equals(key)).findFirst()
|
||||
.orElse(null);
|
||||
if (null == nodeEntity) {
|
||||
continue;
|
||||
}
|
||||
// 删除原先的节点的候选人
|
||||
// this.delete(taskId, nodeEntity.getNodeCode());
|
||||
|
||||
List<String> list = candidateList.get(key);
|
||||
this.create(taskId, nodeEntity, operator, userInfo, list, FlowNature.Candidates);
|
||||
}
|
||||
// 异常人
|
||||
Map<String, List<String>> errorRuleUserList = fo.getErrorRuleUserList();
|
||||
for (String key : errorRuleUserList.keySet()) {
|
||||
TemplateNodeEntity nodeEntity = nodeEntityList.stream().filter(e -> e.getNodeCode().equals(key)).findFirst()
|
||||
.orElse(null);
|
||||
if (null == nodeEntity) {
|
||||
continue;
|
||||
}
|
||||
List<String> list = errorRuleUserList.get(key);
|
||||
this.create(taskId, nodeEntity, operator, userInfo, list, FlowNature.CandidatesError);
|
||||
}
|
||||
}
|
||||
|
||||
public void create(String taskId, TemplateNodeEntity nodeEntity, OperatorEntity operator, UserInfo userInfo,
|
||||
List<String> list, Integer type) {
|
||||
CandidatesEntity entity = new CandidatesEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setTaskId(taskId);
|
||||
entity.setNodeCode(nodeEntity.getNodeCode());
|
||||
|
||||
String nodeId = "";
|
||||
if (operator != null) {
|
||||
entity.setOperatorId(operator.getId());
|
||||
nodeId = operator.getNodeId();
|
||||
} else {
|
||||
entity.setOperatorId(FlowNature.ParentId);
|
||||
}
|
||||
List<CandidatesEntity> entityList = this.getListByCode(taskId, nodeEntity.getNodeCode());
|
||||
if (CollectionUtil.isNotEmpty(entityList)) {
|
||||
QueryWrapper<OperatorEntity> operatorWrapper = new QueryWrapper<>();
|
||||
operatorWrapper.lambda().eq(OperatorEntity::getTaskId, taskId).eq(OperatorEntity::getNodeId, nodeId);
|
||||
List<OperatorEntity> opList = operatorService.list(operatorWrapper);
|
||||
if (CollectionUtil.isNotEmpty(opList)) {
|
||||
List<String> opIds = opList.stream().map(OperatorEntity::getId).collect(Collectors.toList());
|
||||
List<CandidatesEntity> deleteList = entityList.stream()
|
||||
.filter(e -> !opIds.contains(e.getOperatorId())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(deleteList)) {
|
||||
this.removeByIds(deleteList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity.setAccount(userInfo.getUserAccount());
|
||||
entity.setHandleId(userInfo.getUserId());
|
||||
entity.setType(type);
|
||||
|
||||
entity.setCandidates(String.join(",", list));
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
public void delete(String taskId, String nodeCode) {
|
||||
QueryWrapper<CandidatesEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getTaskId, taskId)
|
||||
.eq(CandidatesEntity::getNodeCode, nodeCode);
|
||||
List<CandidatesEntity> list = this.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.removeByIds(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByCodes(String taskId, List<String> nodeIds) {
|
||||
QueryWrapper<CandidatesEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getTaskId, taskId);
|
||||
if (CollectionUtil.isNotEmpty(nodeIds)) {
|
||||
queryWrapper.lambda().in(CandidatesEntity::getNodeCode, nodeIds);
|
||||
}
|
||||
List<CandidatesEntity> list = this.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.removeByIds(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String taskId, List<String> nodeIds, List<String> userId) {
|
||||
QueryWrapper<CandidatesEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getTaskId, taskId).in(CandidatesEntity::getHandleId, userId);
|
||||
if (CollectionUtil.isNotEmpty(nodeIds)) {
|
||||
queryWrapper.lambda().in(CandidatesEntity::getNodeCode, nodeIds);
|
||||
}
|
||||
List<CandidatesEntity> list = this.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.removeByIds(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBranch(String taskId, String nodeCode) {
|
||||
List<String> resList = new ArrayList<>();
|
||||
QueryWrapper<CandidatesEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CandidatesEntity::getTaskId, taskId).eq(CandidatesEntity::getNodeCode, nodeCode)
|
||||
.eq(CandidatesEntity::getType, FlowNature.Branch);
|
||||
List<CandidatesEntity> list = this.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (CandidatesEntity entity : list) {
|
||||
if (StringUtil.isNotEmpty(entity.getCandidates())) {
|
||||
List<String> branch = Arrays.stream(entity.getCandidates().split(",")).collect(Collectors.toList());
|
||||
resList.addAll(branch);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createBranch(List<String> branchList, OperatorEntity operator) {
|
||||
if (CollectionUtil.isNotEmpty(branchList)) {
|
||||
this.deleteBranch(operator.getTaskId(), operator.getNodeCode());
|
||||
CandidatesEntity entity = new CandidatesEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setTaskId(operator.getTaskId());
|
||||
entity.setNodeCode(operator.getNodeCode());
|
||||
entity.setOperatorId(operator.getId());
|
||||
entity.setType(FlowNature.Branch);
|
||||
entity.setCandidates(String.join(",", branchList));
|
||||
this.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBranch(String taskId, String nodeCode) {
|
||||
QueryWrapper<CandidatesEntity> wrapper = new MappingQuery<>();
|
||||
wrapper.lambda().eq(CandidatesEntity::getTaskId, taskId).eq(CandidatesEntity::getNodeCode, nodeCode)
|
||||
.eq(CandidatesEntity::getType, FlowNature.Branch);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.CirculateEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.TaskStatusEnum;
|
||||
import com.yunzhupaas.flowable.mapper.CirculateMapper;
|
||||
import com.yunzhupaas.flowable.service.CirculateService;
|
||||
import com.yunzhupaas.flowable.model.operator.OperatorVo;
|
||||
import com.yunzhupaas.flowable.model.task.TaskPagination;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/4/29 下午5:21
|
||||
*/
|
||||
@Service
|
||||
public class CirculateServiceImpl extends SuperServiceImpl<CirculateMapper, CirculateEntity> implements CirculateService {
|
||||
|
||||
@Override
|
||||
public List<CirculateEntity> getList(String taskId) {
|
||||
QueryWrapper<CirculateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CirculateEntity::getTaskId, taskId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OperatorVo> getList(TaskPagination pagination) {
|
||||
String userId = StringUtil.isNotEmpty(pagination.getUserId()) ? pagination.getUserId() : UserProvider.getLoginUserId();
|
||||
MPJLambdaWrapper<CirculateEntity> wrapper = JoinWrappers.lambda(CirculateEntity.class)
|
||||
.selectAll(TaskEntity.class)
|
||||
.leftJoin(TaskEntity.class, TaskEntity::getId, CirculateEntity::getTaskId)
|
||||
.selectAs(CirculateEntity::getNodeName, OperatorVo::getNodeName)
|
||||
.selectAs(CirculateEntity::getNodeCode, OperatorVo::getNodeCode)
|
||||
.selectAs(CirculateEntity::getId, OperatorVo::getId)
|
||||
.selectAs(TaskEntity::getId, OperatorVo::getTaskId)
|
||||
.selectAs(TaskEntity::getUrgent, OperatorVo::getFlowUrgent)
|
||||
.selectAs(CirculateEntity::getCreatorTime, OperatorVo::getCreatorTime)
|
||||
.ne(TaskEntity::getStatus, TaskStatusEnum.CANCEL.getCode())
|
||||
.eq(CirculateEntity::getUserId, userId);
|
||||
//关键字(流程名称、流程编码)
|
||||
String keyWord = pagination.getKeyword();
|
||||
if (ObjectUtil.isNotEmpty(keyWord)) {
|
||||
wrapper.and(t -> t.like(TaskEntity::getEnCode, keyWord).or().like(TaskEntity::getFullName, keyWord));
|
||||
}
|
||||
//日期范围(近7天、近1月、近3月、自定义)
|
||||
if (ObjectUtil.isNotEmpty(pagination.getStartTime()) && ObjectUtil.isNotEmpty(pagination.getEndTime())) {
|
||||
wrapper.between(TaskEntity::getStartTime, new Date(pagination.getStartTime()), new Date(pagination.getEndTime()));
|
||||
}
|
||||
//所属流程
|
||||
String templateId = pagination.getTemplateId();
|
||||
if (ObjectUtil.isNotEmpty(templateId)) {
|
||||
wrapper.eq(TaskEntity::getTemplateId, templateId);
|
||||
}
|
||||
//所属分类
|
||||
String category = pagination.getFlowCategory();
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
wrapper.in(TaskEntity::getFlowCategory, category.split(","));
|
||||
}
|
||||
//是否已读
|
||||
Integer status = pagination.getStatus();
|
||||
if (ObjectUtil.isNotEmpty(status)) {
|
||||
wrapper.in(CirculateEntity::getCirculateRead, status);
|
||||
}
|
||||
//发起人员
|
||||
String creatorUserId = pagination.getCreatorUserId();
|
||||
if (ObjectUtil.isNotEmpty(creatorUserId)) {
|
||||
wrapper.in(TaskEntity::getCreatorUserId, creatorUserId);
|
||||
}
|
||||
//紧急程度
|
||||
Integer flowUrgent = pagination.getFlowUrgent();
|
||||
if (ObjectUtil.isNotEmpty(flowUrgent)) {
|
||||
wrapper.in(TaskEntity::getUrgent, flowUrgent);
|
||||
}
|
||||
wrapper.orderByDesc(CirculateEntity::getCreatorTime);
|
||||
Page<OperatorVo> page = new Page(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
Page<OperatorVo> data = this.selectJoinListPage(page, OperatorVo.class, wrapper);
|
||||
return pagination.setData(data.getRecords(), page.getTotal());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.mapper.CommentMapper;
|
||||
import com.yunzhupaas.flowable.util.MsgUtil;
|
||||
import com.yunzhupaas.flowable.util.ServiceUtil;
|
||||
import com.yunzhupaas.flowable.util.TaskUtil;
|
||||
import com.yunzhupaas.flowable.model.comment.CommentPagination;
|
||||
import com.yunzhupaas.flowable.model.message.FlowMsgModel;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.task.TaskUserListModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.MsgConfig;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.flowable.service.CommentService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 流程评论
|
||||
*
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
*/
|
||||
@Service
|
||||
public class CommentServiceImpl extends SuperServiceImpl<CommentMapper, CommentEntity> implements CommentService {
|
||||
|
||||
@Autowired
|
||||
private MsgUtil msgUtil;
|
||||
@Autowired
|
||||
private TaskUtil taskUtil;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Override
|
||||
public List<CommentEntity> getlist(CommentPagination pagination) {
|
||||
QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CommentEntity::getTaskId, pagination.getTaskId());
|
||||
queryWrapper.lambda().isNull(CommentEntity::getDeleteMark);
|
||||
queryWrapper.lambda().orderByDesc(CommentEntity::getCreatorTime);
|
||||
Page<CommentEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<CommentEntity> userIPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(userIPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentEntity> getList() {
|
||||
QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommentEntity> getlist(List<String> idList) {
|
||||
List<CommentEntity> list = new ArrayList<>();
|
||||
if (!idList.isEmpty()) {
|
||||
QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(CommentEntity::getId, idList);
|
||||
list.addAll(this.list(queryWrapper));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommentEntity getInfo(String id) {
|
||||
QueryWrapper<CommentEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CommentEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(CommentEntity entity) throws WorkFlowException {
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
entity.setId(RandomUtil.uuId());
|
||||
if (this.save(entity)) {
|
||||
this.sendMsg(entity);
|
||||
}
|
||||
}
|
||||
|
||||
// 发送评论消息
|
||||
public void sendMsg(CommentEntity entity) throws WorkFlowException {
|
||||
FlowModel flowModel = new FlowModel();
|
||||
taskUtil.setFlowModel(entity.getTaskId(), flowModel);
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
List<TemplateNodeEntity> nodeEntityList = flowModel.getNodeEntityList();
|
||||
TemplateNodeEntity start = nodeEntityList.stream()
|
||||
.filter(e -> e.getNodeType().equals(NodeEnum.start.getType())).findFirst().orElse(null);
|
||||
if (null == start) {
|
||||
return;
|
||||
}
|
||||
// 开始节点的评论配置
|
||||
NodeModel startNode = JsonUtil.getJsonToBean(start.getNodeJson(), NodeModel.class);
|
||||
MsgConfig commentMsgConfig = startNode.getCommentMsgConfig();
|
||||
if (commentMsgConfig.getOn() != 1 && commentMsgConfig.getOn() != 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
String text = entity.getText();
|
||||
|
||||
// 不包含@{ 且 回复ID为空(不发消息)
|
||||
if (StringUtil.isBlank(text) || !text.contains("@{") && StringUtil.isBlank(entity.getReplyId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> userIds = new ArrayList<>();
|
||||
|
||||
// 回复的人
|
||||
if (StringUtil.isNotEmpty(entity.getReplyId())) {
|
||||
CommentEntity reply = this.getInfo(entity.getReplyId());
|
||||
if (reply != null) {
|
||||
userIds.add(reply.getCreatorUserId());
|
||||
}
|
||||
}
|
||||
|
||||
String regex = "@\\{([^}]*)\\}";
|
||||
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
|
||||
List<String> userNameList = new ArrayList<>();
|
||||
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
userNameList.add(group.substring(2, group.length() - 1));
|
||||
}
|
||||
|
||||
// 获取@的人的account
|
||||
List<String> accountList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(userNameList)) {
|
||||
for (String userName : userNameList) {
|
||||
String[] split = userName.split("/");
|
||||
if (split.length >= 2) {
|
||||
String account = split[split.length - 1];
|
||||
accountList.add(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<UserEntity> userList = serviceUtil.getUserByAccount(accountList.stream().distinct().collect(Collectors.toList()));
|
||||
|
||||
List<String> ids = userList.stream().map(UserEntity::getId).collect(Collectors.toList());
|
||||
userIds.addAll(ids);
|
||||
|
||||
// 过滤自己
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
userIds = userIds.stream().filter(e -> !e.equals(userId)).distinct().collect(Collectors.toList());
|
||||
|
||||
if (userIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<OperatorEntity> operatorList = new ArrayList<>();
|
||||
List<CirculateEntity> circulateList = new ArrayList<>();
|
||||
|
||||
List<String> userIdList = new ArrayList<>(userIds);
|
||||
|
||||
TaskUserListModel model = taskService.getTaskUserList(taskEntity.getId());
|
||||
|
||||
// 经办
|
||||
for (OperatorEntity operator : model.getOperatorList()) {
|
||||
String handleId = operator.getHandleId();
|
||||
if (userIdList.contains(handleId)) {
|
||||
operatorList.add(operator);
|
||||
userIdList.remove(handleId);
|
||||
}
|
||||
}
|
||||
|
||||
// 抄送
|
||||
if (!userIdList.isEmpty()) {
|
||||
for (CirculateEntity circulate : model.getCirculateList()) {
|
||||
String circulateUserId = circulate.getUserId();
|
||||
if (userIdList.contains(circulateUserId)) {
|
||||
circulateList.add(circulate);
|
||||
userIdList.remove(circulateUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发起人
|
||||
boolean startHandleId = false;
|
||||
if (!userIdList.isEmpty()) {
|
||||
if (userIdList.contains(taskEntity.getCreatorUserId())) {
|
||||
startHandleId = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 消息
|
||||
FlowMsgModel flowMsgModel = new FlowMsgModel();
|
||||
flowMsgModel.setNodeList(flowModel.getNodeEntityList());
|
||||
flowMsgModel.setCirculateList(circulateList);
|
||||
flowMsgModel.setFlowModel(flowModel);
|
||||
flowMsgModel.setTaskEntity(taskEntity);
|
||||
flowMsgModel.setOperatorList(operatorList);
|
||||
flowMsgModel.setStartHandId(startHandleId);
|
||||
flowMsgModel.setComment(true);
|
||||
flowMsgModel.setWait(false);
|
||||
msgUtil.message(flowMsgModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String id, CommentEntity entity) {
|
||||
entity.setId(id);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(CommentEntity entity, boolean delComment) {
|
||||
if (entity != null) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
if (delComment) {
|
||||
entity.setDeleteShow(1);
|
||||
} else {
|
||||
entity.setDeleteMark(1);
|
||||
}
|
||||
entity.setDeleteTime(new Date());
|
||||
entity.setDeleteUserId(userInfo.getUserId());
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.CommonEntity;
|
||||
import com.yunzhupaas.flowable.mapper.CommonMapper;
|
||||
import com.yunzhupaas.flowable.service.CommonService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/22 20:32
|
||||
*/
|
||||
@Service
|
||||
public class CommonServiceImpl extends SuperServiceImpl<CommonMapper, CommonEntity> implements CommonService {
|
||||
|
||||
@Override
|
||||
public List<CommonEntity> getCommonByUserId(String userId) {
|
||||
|
||||
QueryWrapper<CommonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CommonEntity::getCreatorUserId, userId);
|
||||
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setCommonFLow(String flowId) {
|
||||
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
String userId = userInfo.getUserId();
|
||||
|
||||
QueryWrapper<CommonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(CommonEntity::getFlowId, flowId)
|
||||
.eq(CommonEntity::getCreatorUserId, userId);
|
||||
List<CommonEntity> list = this.list(queryWrapper);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.removeByIds(list);
|
||||
return 2;
|
||||
} else {
|
||||
CommonEntity entity = new CommonEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setFlowId(flowId);
|
||||
entity.setCreatorUserId(userId);
|
||||
this.save(entity);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.model.systemconfig.SysConfigModel;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.DelegateEntity;
|
||||
import com.yunzhupaas.flowable.entity.DelegateInfoEntity;
|
||||
import com.yunzhupaas.flowable.mapper.DelegateInfoMapper;
|
||||
import com.yunzhupaas.flowable.model.delegate.*;
|
||||
import com.yunzhupaas.flowable.model.message.DelegateModel;
|
||||
import com.yunzhupaas.flowable.service.DelegateInfoService;
|
||||
import com.yunzhupaas.flowable.util.MsgUtil;
|
||||
import com.yunzhupaas.flowable.util.ServiceUtil;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/2 13:41
|
||||
*/
|
||||
@Service
|
||||
public class DelegateInfoServiceImpl extends SuperServiceImpl<DelegateInfoMapper, DelegateInfoEntity>
|
||||
implements DelegateInfoService {
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private MsgUtil msgUtil;
|
||||
|
||||
@Override
|
||||
public List<DelegateListVO> getList(DelegatePagination pagination) {
|
||||
Integer type = ObjectUtil.equals(pagination.getType(), 2) ? 0 : 1;
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
MPJLambdaWrapper<DelegateInfoEntity> wrapper = JoinWrappers.lambda(DelegateInfoEntity.class)
|
||||
.leftJoin(DelegateEntity.class, DelegateEntity::getId, DelegateInfoEntity::getDelegateId)
|
||||
.selectAs(DelegateInfoEntity::getId, DelegateInfoModel::getId)
|
||||
.selectAs(DelegateInfoEntity::getDelegateId, DelegateInfoModel::getDelegateId)
|
||||
.selectAs(DelegateInfoEntity::getToUserName, DelegateInfoModel::getToUserName)
|
||||
.selectAs(DelegateInfoEntity::getStatus, DelegateInfoModel::getConfirmStatus)
|
||||
.selectAs(DelegateEntity::getFlowName, DelegateInfoModel::getFlowName)
|
||||
.selectAs(DelegateEntity::getUserName, DelegateInfoModel::getUserName)
|
||||
.selectAs(DelegateEntity::getStartTime, DelegateInfoModel::getStartTime)
|
||||
.selectAs(DelegateEntity::getEndTime, DelegateInfoModel::getEndTime)
|
||||
.selectAs(DelegateEntity::getType, DelegateInfoModel::getType)
|
||||
.selectAs(DelegateEntity::getDescription, DelegateInfoModel::getDescription)
|
||||
.eq(DelegateInfoEntity::getToUserId, userId)
|
||||
.eq(DelegateEntity::getType, type);
|
||||
|
||||
String keyword = pagination.getKeyword();
|
||||
if (StringUtil.isNotBlank(keyword)) {
|
||||
wrapper.and(
|
||||
t -> t.like(DelegateEntity::getUserName, keyword).or().like(DelegateEntity::getFlowName, keyword));
|
||||
}
|
||||
|
||||
wrapper.orderByDesc(DelegateInfoEntity::getCreatorTime);
|
||||
Page<DelegateInfoModel> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
Page<DelegateInfoModel> data = this.selectJoinListPage(page, DelegateInfoModel.class, wrapper);
|
||||
List<DelegateInfoModel> dataList = pagination.setData(data.getRecords(), page.getTotal());
|
||||
|
||||
List<DelegateListVO> voList = new ArrayList<>();
|
||||
long time = new Date().getTime();
|
||||
List<String> delegateIds = dataList.stream().map(DelegateInfoModel::getDelegateId).distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<DelegateInfoEntity> list = this.getList(delegateIds);
|
||||
for (DelegateInfoModel model : dataList) {
|
||||
DelegateListVO vo = JsonUtil.getJsonToBean(model, DelegateListVO.class);
|
||||
List<DelegateInfoEntity> infoList = list.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getDelegateId(), model.getDelegateId()))
|
||||
.collect(Collectors.toList());
|
||||
long rejectCount = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 2)).count();
|
||||
long acceptCount = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 1)).count();
|
||||
if (time >= vo.getEndTime() || rejectCount == infoList.size()) {// 已失效,1、所有人都拒绝;2、到达结束时间或终止委托
|
||||
vo.setStatus(2);
|
||||
} else if (time >= vo.getStartTime() && acceptCount > 0) {// 生效中,对方接受且到达开始时间的状态
|
||||
vo.setStatus(1);
|
||||
} else {// 未生效,两种场景1:对方已接受但未达到开始时间状态为未生效,2、对方未接受状态为未生效
|
||||
vo.setStatus(0);
|
||||
}
|
||||
voList.add(vo);
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateInfoEntity> getList(List<String> delegateIds) {
|
||||
if (CollectionUtil.isEmpty(delegateIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<DelegateInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(DelegateInfoEntity::getDelegateId, delegateIds);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateInfoEntity> getList(String delegateId) {
|
||||
QueryWrapper<DelegateInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(DelegateInfoEntity::getDelegateId, delegateId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateInfoEntity> getByToUserId(String toUserId) {
|
||||
QueryWrapper<DelegateInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(DelegateInfoEntity::getToUserId, toUserId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateInfoEntity> getByToUserIds(List<String> userIds) {
|
||||
List<DelegateInfoEntity> resList = new ArrayList<>();
|
||||
if (CollectionUtil.isEmpty(userIds)) {
|
||||
return resList;
|
||||
}
|
||||
QueryWrapper<DelegateInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(DelegateInfoEntity::getToUserId, userIds);
|
||||
resList = this.list(queryWrapper);
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(DelegateCrForm fo, DelegateEntity delegateEntity) {
|
||||
this.save(fo.getToUserId(), delegateEntity);
|
||||
}
|
||||
|
||||
public void save(List<String> toUserIdList, DelegateEntity delegateEntity) {
|
||||
if (CollectionUtil.isNotEmpty(toUserIdList)) {
|
||||
Integer type = delegateEntity.getType();
|
||||
// 获取全局配置,是否确认
|
||||
SysConfigModel sysConfig = serviceUtil.getSysConfig();
|
||||
Integer ack = ObjectUtil.equals(type, 0) ? sysConfig.getDelegateAck() : sysConfig.getProxyAck();
|
||||
List<UserEntity> userList = serviceUtil.getUserName(toUserIdList);
|
||||
List<DelegateInfoEntity> list = new ArrayList<>();
|
||||
for (String toUserId : toUserIdList) {
|
||||
DelegateInfoEntity entity = new DelegateInfoEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setStatus(0);
|
||||
if (ObjectUtil.equals(ack, 0)) {
|
||||
entity.setStatus(1);
|
||||
}
|
||||
entity.setDelegateId(delegateEntity.getId());
|
||||
entity.setToUserId(toUserId);
|
||||
UserEntity user = userList.stream().filter(e -> ObjectUtil.equals(e.getId(), toUserId)).findFirst()
|
||||
.orElse(null);
|
||||
if (null != user) {
|
||||
entity.setToUserName(user.getRealName() + "/" + user.getAccount());
|
||||
}
|
||||
list.add(entity);
|
||||
}
|
||||
this.saveBatch(list);
|
||||
|
||||
// 委托消息
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
DelegateModel model = new DelegateModel();
|
||||
model.setToUserIds(toUserIdList);
|
||||
model.setType(type);
|
||||
model.setUserInfo(userInfo);
|
||||
model.setDelegate(ObjectUtil.equals(type, 0));
|
||||
msgUtil.delegateMsg(model);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DelegateUpForm fo, DelegateEntity delegateEntity) {
|
||||
String delegateId = delegateEntity.getId();
|
||||
List<String> toUserIdList = fo.getToUserId();
|
||||
if (CollectionUtil.isNotEmpty(toUserIdList)) {
|
||||
List<String> createList = new ArrayList<>();
|
||||
List<String> deleteList = new ArrayList<>();
|
||||
List<DelegateInfoEntity> list = this.getList(delegateId);
|
||||
|
||||
for (String userId : toUserIdList) {
|
||||
DelegateInfoEntity infoEntity = list.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getToUserId(), userId)).findFirst().orElse(null);
|
||||
if (null == infoEntity) {
|
||||
createList.add(userId);
|
||||
}
|
||||
}
|
||||
for (DelegateInfoEntity entity : list) {
|
||||
String userId = toUserIdList.stream()
|
||||
.filter(e -> ObjectUtil.equals(entity.getToUserId(), e)).findFirst().orElse(null);
|
||||
if (StringUtil.isEmpty(userId)) {
|
||||
deleteList.add(entity.getToUserId());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(deleteList)) {
|
||||
QueryWrapper<DelegateInfoEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DelegateInfoEntity::getDelegateId, delegateId)
|
||||
.in(DelegateInfoEntity::getToUserId, deleteList);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(createList)) {
|
||||
this.save(createList, delegateEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String delegateId) {
|
||||
QueryWrapper<DelegateInfoEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DelegateInfoEntity::getDelegateId, delegateId);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.base.vo.ListVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.constant.PermissionConst;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.DelegateEntity;
|
||||
import com.yunzhupaas.flowable.entity.DelegateInfoEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateJsonEntity;
|
||||
import com.yunzhupaas.flowable.mapper.DelegateMapper;
|
||||
import com.yunzhupaas.flowable.model.candidates.CandidateUserVo;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateCrForm;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateListVO;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegatePagination;
|
||||
import com.yunzhupaas.flowable.model.delegate.DelegateUpForm;
|
||||
import com.yunzhupaas.flowable.model.message.DelegateModel;
|
||||
import com.yunzhupaas.flowable.model.template.TemplatePageLisVO;
|
||||
import com.yunzhupaas.flowable.model.template.TemplatePagination;
|
||||
import com.yunzhupaas.flowable.model.util.FlowConstant;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.DelegateInfoService;
|
||||
import com.yunzhupaas.flowable.service.DelegateService;
|
||||
import com.yunzhupaas.flowable.service.TemplateJsonService;
|
||||
import com.yunzhupaas.flowable.service.TemplateService;
|
||||
import com.yunzhupaas.flowable.util.MsgUtil;
|
||||
import com.yunzhupaas.flowable.util.ServiceUtil;
|
||||
import com.yunzhupaas.message.model.SentMessageForm;
|
||||
import com.yunzhupaas.permission.entity.OrganizeEntity;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/13 16:56
|
||||
*/
|
||||
@Service
|
||||
public class DelegateServiceImpl extends SuperServiceImpl<DelegateMapper, DelegateEntity> implements DelegateService {
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
@Autowired
|
||||
private TemplateJsonService templateJsonService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private MsgUtil msgUtil;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private DelegateInfoService delegateInfoService;
|
||||
|
||||
@Override
|
||||
public List<DelegateListVO> getList(DelegatePagination pagination) {
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
String keyword = pagination.getKeyword();
|
||||
QueryWrapper<DelegateEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DelegateEntity::getUserId, userId);
|
||||
|
||||
QueryWrapper<DelegateInfoEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotBlank(keyword)) {
|
||||
queryWrapper.lambda().like(DelegateInfoEntity::getToUserName, keyword);
|
||||
}
|
||||
List<DelegateInfoEntity> delegateInfoList = delegateInfoService.list(queryWrapper);
|
||||
List<String> delegateIds = delegateInfoList.stream().map(DelegateInfoEntity::getDelegateId).distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(delegateIds)) {
|
||||
if (StringUtil.isNotBlank(keyword)) {
|
||||
wrapper.lambda().and(
|
||||
e -> e.in(DelegateEntity::getId, delegateIds).or().like(DelegateEntity::getFlowName, keyword));
|
||||
} else {
|
||||
wrapper.lambda().in(DelegateEntity::getId, delegateIds);
|
||||
}
|
||||
} else {
|
||||
if (StringUtil.isNotBlank(keyword)) {
|
||||
wrapper.lambda().like(DelegateEntity::getFlowName, keyword);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.equals(pagination.getType(), 1)) {
|
||||
wrapper.lambda().eq(DelegateEntity::getType, 0);// 委托
|
||||
} else {
|
||||
wrapper.lambda().eq(DelegateEntity::getType, 1);// 代理
|
||||
}
|
||||
wrapper.lambda().orderByAsc(DelegateEntity::getSortCode).orderByDesc(DelegateEntity::getCreatorTime);
|
||||
Page<DelegateEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<DelegateEntity> iPage = this.page(page, wrapper);
|
||||
List<DelegateEntity> dataList = pagination.setData(iPage.getRecords(), page.getTotal());
|
||||
|
||||
List<DelegateListVO> voList = new ArrayList<>();
|
||||
long time = new Date().getTime();
|
||||
List<String> ids = dataList.stream().map(DelegateEntity::getId).distinct().collect(Collectors.toList());
|
||||
List<DelegateInfoEntity> list = delegateInfoService.getList(ids);
|
||||
for (DelegateEntity delegate : dataList) {
|
||||
DelegateListVO vo = JsonUtil.getJsonToBean(delegate, DelegateListVO.class);
|
||||
List<DelegateInfoEntity> infoList = list.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getDelegateId(), delegate.getId())).collect(Collectors.toList());
|
||||
List<String> toUserNameList = infoList.stream().map(DelegateInfoEntity::getToUserName)
|
||||
.collect(Collectors.toList());
|
||||
vo.setToUserName(String.join(",", toUserNameList));
|
||||
long rejectCount = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 2)).count();
|
||||
long acceptCount = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 1)).count();
|
||||
if (time >= vo.getEndTime() || rejectCount == infoList.size()) {// 已失效,1、所有人都拒绝;2、到达结束时间或终止委托
|
||||
vo.setStatus(2);
|
||||
} else if (time >= vo.getStartTime() && acceptCount > 0) {// 生效中,对方接受且到达开始时间的状态
|
||||
vo.setStatus(1);
|
||||
} else {// 未生效,两种场景1:对方已接受但未达到开始时间状态为未生效,2、对方未接受状态为未生效
|
||||
vo.setStatus(0);
|
||||
}
|
||||
if (acceptCount > 0) {
|
||||
vo.setIsEdit(false);
|
||||
}
|
||||
voList.add(vo);
|
||||
}
|
||||
return voList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DelegateEntity getInfo(String id) {
|
||||
if (StringUtil.isBlank(id)) {
|
||||
return null;
|
||||
}
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(DelegateCrForm fo) {
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
DelegateEntity entity = JsonUtil.getJsonToBean(fo, DelegateEntity.class);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setSortCode(RandomUtil.parses());
|
||||
entity.setCreatorUserId(userId);
|
||||
|
||||
this.save(entity);
|
||||
delegateInfoService.create(fo, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(DelegateEntity entity, DelegateUpForm fo) {
|
||||
BeanUtil.copyProperties(fo, entity, CopyOptions.create().setIgnoreNullValue(true));
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(userInfo.getUserId());
|
||||
delegateInfoService.update(fo, entity);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateStop(String id, DelegateEntity entity) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
entity.setId(id);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(userInfo.getUserId());
|
||||
DelegateModel delegate = new DelegateModel();
|
||||
List<DelegateInfoEntity> infoList = delegateInfoService.getList(entity.getId());
|
||||
delegate.setToUserIds(infoList.stream().map(DelegateInfoEntity::getToUserId).collect(Collectors.toList()));
|
||||
delegate.setType(FlowNature.EndMsg);
|
||||
delegate.setUserInfo(userInfo);
|
||||
boolean isDelegate = ObjectUtil.equals(entity.getType(), 0);
|
||||
delegate.setDelegate(isDelegate);
|
||||
msgUtil.delegateMsg(delegate);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DelegateEntity entity) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getToUser(String userId, String flowId) {
|
||||
Date thisTime = DateUtil.getNowDate();
|
||||
QueryWrapper<DelegateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(DelegateEntity::getType, 1);
|
||||
queryWrapper.lambda().le(DelegateEntity::getStartTime, thisTime).ge(DelegateEntity::getEndTime, thisTime);
|
||||
if (StringUtil.isNotEmpty(userId)) {
|
||||
queryWrapper.lambda().eq(DelegateEntity::getUserId, userId);
|
||||
}
|
||||
List<DelegateEntity> list = this.list(queryWrapper);
|
||||
List<DelegateEntity> listRes = new ArrayList<>();
|
||||
if (StringUtil.isNotEmpty(flowId)) {
|
||||
for (DelegateEntity item : list) {
|
||||
if (StringUtil.isNotEmpty(item.getFlowId())) {
|
||||
String[] split = item.getFlowId().split(",");
|
||||
if (Arrays.asList(split).contains(flowId)) {
|
||||
listRes.add(item);
|
||||
}
|
||||
} else {// 为空是全部流程
|
||||
listRes.add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
listRes = list;
|
||||
}
|
||||
List<String> toUser = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(listRes)) {
|
||||
List<String> ids = listRes.stream().map(DelegateEntity::getId).distinct().collect(Collectors.toList());
|
||||
List<DelegateInfoEntity> infoList = delegateInfoService.getList(ids);
|
||||
toUser = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 1))
|
||||
.map(DelegateInfoEntity::getToUserId).collect(Collectors.toList());
|
||||
}
|
||||
return toUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateEntity> getByToUserId(String toUserId) {
|
||||
return this.getByToUserId(toUserId, 1);
|
||||
}
|
||||
|
||||
// 根据 被委托人/代理人id 获取列表
|
||||
@Override
|
||||
public List<DelegateEntity> getByToUserId(String toUserId, Integer type) {
|
||||
List<DelegateInfoEntity> infoList = delegateInfoService.getByToUserId(toUserId);
|
||||
List<String> ids = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 1))
|
||||
.map(DelegateInfoEntity::getDelegateId).distinct().collect(Collectors.toList());
|
||||
List<DelegateEntity> list = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
Date thisTime = DateUtil.getNowDate();
|
||||
QueryWrapper<DelegateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(DelegateEntity::getId, ids).eq(DelegateEntity::getType, type)
|
||||
.le(DelegateEntity::getStartTime, thisTime).ge(DelegateEntity::getEndTime, thisTime);
|
||||
list = this.list(queryWrapper);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// 获取我的委托发起(统一到发起流程列表,待删除)
|
||||
@Override
|
||||
public List<TemplatePageLisVO> getFlow(TemplatePagination pagination) {
|
||||
List<DelegateEntity> list = this.getLaunchDelagateList();
|
||||
if (list.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> templateIdList = new ArrayList<>();
|
||||
int num = 0;
|
||||
for (DelegateEntity entity : list) {
|
||||
if (StringUtil.isNotEmpty(entity.getFlowId())) {
|
||||
templateIdList.addAll(Arrays.asList(entity.getFlowId().split(",")));
|
||||
}
|
||||
num += StringUtil.isEmpty(entity.getFlowId()) ? 1 : 0;
|
||||
}
|
||||
if (num == 0) {
|
||||
pagination.setTemplateIdList(templateIdList);
|
||||
}
|
||||
|
||||
List<TemplateEntity> templateList = templateService.getListAll(pagination, true);
|
||||
return JsonUtil.getJsonToList(templateList, TemplatePageLisVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListVO<CandidateUserVo> getUserList(String templateId) throws WorkFlowException {
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
TemplateEntity template = templateService.getById(templateId);
|
||||
if (null == template) {
|
||||
TemplateJsonEntity jsonEntity = templateJsonService.getById(templateId);
|
||||
if (null != jsonEntity) {
|
||||
template = templateService.getById(jsonEntity.getTemplateId());
|
||||
}
|
||||
}
|
||||
if (null == template) {
|
||||
throw new WorkFlowException(MsgCode.WF122.get());
|
||||
}
|
||||
if (!ObjectUtil.equals(template.getStatus(), 1)) {
|
||||
throw new WorkFlowException(MsgCode.WF140.get());
|
||||
}
|
||||
List<String> userIds = this.getDelegateUser(userId, template);
|
||||
List<UserEntity> userName = serviceUtil.getUserName(userIds);
|
||||
|
||||
List<String> userIdAll = userName.stream().map(UserEntity::getId).collect(Collectors.toList());
|
||||
Map<String, List<UserRelationEntity>> userMap = serviceUtil.getListByUserIdAll(userIdAll).stream()
|
||||
.filter(t -> PermissionConst.ORGANIZE.equals(t.getObjectType()))
|
||||
.collect(Collectors.groupingBy(UserRelationEntity::getUserId));
|
||||
List<CandidateUserVo> jsonToList = new ArrayList<>();
|
||||
for (UserEntity entity : userName) {
|
||||
List<UserRelationEntity> listByUserId = userMap.get(entity.getId()) != null ? userMap.get(entity.getId())
|
||||
: new ArrayList<>();
|
||||
StringJoiner joiner = new StringJoiner(",");
|
||||
for (UserRelationEntity relation : listByUserId) {
|
||||
List<OrganizeEntity> organizeId = serviceUtil.getOrganizeId(relation.getObjectId());
|
||||
if (organizeId.size() > 0) {
|
||||
String organizeName = organizeId.stream().map(OrganizeEntity::getFullName)
|
||||
.collect(Collectors.joining("/"));
|
||||
joiner.add(organizeName);
|
||||
}
|
||||
}
|
||||
CandidateUserVo vo = JsonUtil.getJsonToBean(entity, CandidateUserVo.class);
|
||||
vo.setFullName(entity.getRealName() + "/" + entity.getAccount());
|
||||
vo.setHeadIcon(UploaderUtil.uploaderImg(entity.getHeadIcon()));
|
||||
vo.setOrganize(joiner.toString());
|
||||
jsonToList.add(vo);
|
||||
}
|
||||
if (jsonToList.isEmpty()) {
|
||||
throw new WorkFlowException(MsgCode.WF125.get());
|
||||
}
|
||||
ListVO<CandidateUserVo> vo = new ListVO<>();
|
||||
vo.setList(jsonToList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
public List<String> getDelegateUser(String userId, TemplateEntity template) throws WorkFlowException {
|
||||
List<String> ids = new ArrayList<>();
|
||||
List<DelegateEntity> delegateList = this.getByToUserId(userId, 0);
|
||||
if (CollectionUtil.isNotEmpty(delegateList)) {
|
||||
int permissionCount = 0;
|
||||
for (DelegateEntity delegateEntity : delegateList) {
|
||||
String flowId = delegateEntity.getFlowId();
|
||||
if (StringUtil.isNotBlank(flowId)) {
|
||||
if (flowId.contains(template.getId())) {
|
||||
if (ObjectUtil.equals(template.getVisibleType(), 1)) {
|
||||
ids.add(delegateEntity.getUserId());
|
||||
continue;
|
||||
}
|
||||
List<String> launchPermission = serviceUtil.getLaunchPermission(delegateEntity.getUserId());
|
||||
if (launchPermission.contains(template.getId())) {
|
||||
ids.add(delegateEntity.getUserId());
|
||||
} else {
|
||||
permissionCount++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 全部流程
|
||||
if (ObjectUtil.equals(template.getVisibleType(), 1)) {
|
||||
ids.add(delegateEntity.getUserId());
|
||||
continue;
|
||||
}
|
||||
List<String> launchPermission = serviceUtil.getLaunchPermission(delegateEntity.getUserId());
|
||||
if (launchPermission.contains(template.getId())) {
|
||||
ids.add(delegateEntity.getUserId());
|
||||
} else {
|
||||
permissionCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(ids) && delegateList.size() == permissionCount) {
|
||||
throw new WorkFlowException(MsgCode.WF129.get());
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户所有发起委托列表
|
||||
*/
|
||||
@Override
|
||||
public List<DelegateEntity> getLaunchDelagateList() {
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
Date thisTime = DateUtil.getNowDate();
|
||||
List<DelegateInfoEntity> infoList = delegateInfoService.getByToUserId(userId);
|
||||
List<String> ids = infoList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 1))
|
||||
.map(DelegateInfoEntity::getDelegateId).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(ids)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<DelegateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(DelegateEntity::getId, ids)
|
||||
.le(DelegateEntity::getStartTime, thisTime).ge(DelegateEntity::getEndTime, thisTime)
|
||||
.eq(DelegateEntity::getType, 0);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateEntity> selectSameParamAboutDelaget(DelegateCrForm fo) {
|
||||
List<DelegateInfoEntity> infoList = delegateInfoService.getByToUserIds(fo.getToUserId());
|
||||
if (CollectionUtil.isEmpty(infoList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> ids = infoList.stream().map(DelegateInfoEntity::getDelegateId).distinct()
|
||||
.collect(Collectors.toList());
|
||||
QueryWrapper<DelegateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(DelegateEntity::getUserId, fo.getUserId()).in(DelegateEntity::getId, ids)
|
||||
.eq(DelegateEntity::getType, Integer.valueOf(fo.getType()))
|
||||
.gt(DelegateEntity::getEndTime, new Date());
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DelegateEntity> getList() {
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
QueryWrapper<DelegateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda()
|
||||
.and(t -> t.eq(DelegateEntity::getCreatorUserId, userId).or().eq(DelegateEntity::getUserId, userId));
|
||||
return this.baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notarize(DelegateInfoEntity delegateInfo) {
|
||||
delegateInfoService.updateById(delegateInfo);
|
||||
// 判断全部拒绝,更新时间
|
||||
DelegateEntity entity = this.getById(delegateInfo.getDelegateId());
|
||||
List<DelegateInfoEntity> infoList = delegateInfoService.getList(entity.getId());
|
||||
boolean isAllReject = infoList.stream().allMatch(e -> ObjectUtil.equals(e.getStatus(), 2));
|
||||
if (isAllReject) {
|
||||
Date date = new Date();
|
||||
entity.setStartTime(date);
|
||||
entity.setEndTime(date);
|
||||
this.updateById(entity);
|
||||
}
|
||||
if (!ObjectUtil.equals(delegateInfo.getStatus(), 0)) {
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
List<String> toUserIds = ImmutableList.of(entity.getUserId());
|
||||
|
||||
SentMessageForm flowMsgModel = new SentMessageForm();
|
||||
flowMsgModel.setToUserIds(toUserIds);
|
||||
flowMsgModel.setUserInfo(userInfo);
|
||||
flowMsgModel.setTemplateId("PZXTLG022");
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
parameterMap.put(FlowConstant.MANDATOR, userInfo.getUserName());
|
||||
parameterMap.put(FlowConstant.TITLE, ObjectUtil.equals(entity.getType(), 0) ? "委托" : "代理");
|
||||
parameterMap.put(FlowConstant.ACTION, ObjectUtil.equals(delegateInfo.getStatus(), 1) ? "接受" : "拒绝");
|
||||
flowMsgModel.setParameterMap(parameterMap);
|
||||
|
||||
Integer delegateType = FlowNature.EndMsg.equals(entity.getType()) ? 0
|
||||
: ObjectUtil.equals(entity.getType(), 0) ? 1 : 3;
|
||||
Map<String, String> contentMsg = new HashMap<>();
|
||||
contentMsg.put("type", delegateType + "");
|
||||
flowMsgModel.setContentMsg(contentMsg);
|
||||
flowMsgModel.setFlowType(2);
|
||||
flowMsgModel.setType(2);
|
||||
|
||||
List<SentMessageForm> messageListAll = new ArrayList<>();
|
||||
messageListAll.add(flowMsgModel);
|
||||
serviceUtil.sendDelegateMsg(messageListAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.LaunchUserEntity;
|
||||
import com.yunzhupaas.flowable.mapper.LaunchUserMapper;
|
||||
import com.yunzhupaas.flowable.service.LaunchUserService;
|
||||
import com.yunzhupaas.flowable.util.ServiceUtil;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 9:46
|
||||
*/
|
||||
@Service
|
||||
public class LaunchUserServiceImpl extends SuperServiceImpl<LaunchUserMapper, LaunchUserEntity>
|
||||
implements LaunchUserService {
|
||||
@Resource
|
||||
private ServiceUtil serviceUtil;
|
||||
|
||||
@Override
|
||||
public LaunchUserEntity getInfoByTask(String taskId) {
|
||||
QueryWrapper<LaunchUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLaunchUser(String taskId, String userId) {
|
||||
LaunchUserEntity launchUserEntity = this.getInfoByTask(taskId);
|
||||
if (null != launchUserEntity) {
|
||||
return;
|
||||
}
|
||||
UserEntity user = serviceUtil.getUserInfo(userId);
|
||||
if (null != user) {
|
||||
LaunchUserEntity entity = new LaunchUserEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setTaskId(taskId);
|
||||
entity.setOrganizeId(user.getOrganizeId());
|
||||
entity.setPositionId(user.getPositionId());
|
||||
entity.setManagerId(user.getManagerId());
|
||||
List<UserEntity> list = serviceUtil.getListByManagerId(user.getId());
|
||||
String subordinate = list.stream().map(UserEntity::getId).collect(Collectors.joining(","));
|
||||
entity.setSubordinate(subordinate);
|
||||
entity.setSuperior(user.getManagerId());
|
||||
// Department用到时,再递归获取 serviceUtil.getDepartmentAll
|
||||
this.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String taskId) {
|
||||
QueryWrapper<LaunchUserEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId);
|
||||
List<LaunchUserEntity> list = this.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.removeByIds(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.NodeRecordEntity;
|
||||
import com.yunzhupaas.flowable.mapper.NodeRecordMapper;
|
||||
import com.yunzhupaas.flowable.model.record.NodeRecordModel;
|
||||
import com.yunzhupaas.flowable.service.NodeRecordService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/6/25 17:08
|
||||
*/
|
||||
@Service
|
||||
public class NodeRecordServiceImpl extends SuperServiceImpl<NodeRecordMapper, NodeRecordEntity>
|
||||
implements NodeRecordService {
|
||||
@Override
|
||||
public List<NodeRecordEntity> getList(String taskId) {
|
||||
QueryWrapper<NodeRecordEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(NodeRecordEntity::getTaskId, taskId).orderByAsc(NodeRecordEntity::getCreatorTime);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(NodeRecordModel model) {
|
||||
NodeRecordEntity entity = JsonUtil.getJsonToBean(model, NodeRecordEntity.class);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(NodeRecordModel model) {
|
||||
QueryWrapper<NodeRecordEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(NodeRecordEntity::getTaskId, model.getTaskId())
|
||||
.eq(NodeRecordEntity::getNodeCode, model.getNodeCode());
|
||||
if (ObjectUtil.isNotEmpty(model.getNodeId())) {
|
||||
wrapper.lambda().eq(NodeRecordEntity::getNodeId, model.getNodeId());
|
||||
}
|
||||
wrapper.lambda().orderByDesc(NodeRecordEntity::getCreatorTime);
|
||||
List<NodeRecordEntity> list = this.list(wrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
NodeRecordEntity entity = list.get(0);
|
||||
entity.setNodeStatus(model.getNodeStatus());
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,255 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.enums.RecordEnum;
|
||||
import com.yunzhupaas.flowable.enums.TaskStatusEnum;
|
||||
import com.yunzhupaas.flowable.mapper.RecordMapper;
|
||||
import com.yunzhupaas.flowable.model.operator.OperatorVo;
|
||||
import com.yunzhupaas.flowable.model.record.RecordVo;
|
||||
import com.yunzhupaas.flowable.model.task.TaskPagination;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.DelegateService;
|
||||
import com.yunzhupaas.flowable.service.RecordService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.flowable.util.RecordUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/23 9:22
|
||||
*/
|
||||
@Service
|
||||
public class RecordServiceImpl extends SuperServiceImpl<RecordMapper, RecordEntity> implements RecordService {
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private RecordUtil recordUtil;
|
||||
@Autowired
|
||||
private DelegateService delegateService;
|
||||
|
||||
@Override
|
||||
public List<RecordEntity> getList(String taskId) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RecordEntity::getTaskId, taskId).orderByAsc(RecordEntity::getHandleTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RecordEntity> getRecordList(String taskId, List<Integer> statusList) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RecordEntity::getTaskId, taskId);
|
||||
if (CollectionUtil.isNotEmpty(statusList)) {
|
||||
queryWrapper.lambda().in(RecordEntity::getHandleType, statusList);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(RecordEntity::getHandleTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OperatorVo> getList(TaskPagination pagination) {
|
||||
String loginUserId = UserProvider.getLoginUserId();
|
||||
if (StringUtil.isNotEmpty(pagination.getUserId())) {
|
||||
loginUserId = pagination.getUserId();
|
||||
}
|
||||
Integer[] handleStatus = new Integer[] { 0, 1, 3, 5, 7, 18 };
|
||||
MPJLambdaWrapper<RecordEntity> recordWrapper = JoinWrappers.lambda(RecordEntity.class)
|
||||
.leftJoin(TaskEntity.class, TaskEntity::getId, RecordEntity::getTaskId)
|
||||
.select(RecordEntity::getHandleId)
|
||||
.select(RecordEntity::getNodeCode)
|
||||
.select(RecordEntity::getTaskId)
|
||||
.selectMax(RecordEntity::getHandleTime)
|
||||
.in(RecordEntity::getHandleType, handleStatus)
|
||||
.isNotNull(RecordEntity::getOperatorId)
|
||||
.groupBy(RecordEntity::getTaskId, RecordEntity::getNodeCode, RecordEntity::getHandleId);
|
||||
|
||||
List<DelegateEntity> delegateList = delegateService.getByToUserId(loginUserId);
|
||||
String finalLoginUserId = loginUserId;
|
||||
recordWrapper.and(t -> {
|
||||
t.eq(RecordEntity::getHandleId, finalLoginUserId);
|
||||
for (DelegateEntity delegate : delegateList) {
|
||||
if (StringUtil.isNotEmpty(delegate.getFlowId())) {
|
||||
String[] flowIds = delegate.getFlowId().split(",");
|
||||
t.or(tw -> tw.in(TaskEntity::getTemplateId, flowIds)
|
||||
.eq(RecordEntity::getHandleId, delegate.getUserId())
|
||||
.eq(RecordEntity::getCreatorUserId, finalLoginUserId)
|
||||
.between(RecordEntity::getHandleTime, delegate.getStartTime(), delegate.getEndTime()));
|
||||
} else {
|
||||
t.or(t1 -> t1.eq(RecordEntity::getHandleId, delegate.getUserId())
|
||||
.eq(RecordEntity::getCreatorUserId, finalLoginUserId)
|
||||
.between(RecordEntity::getHandleTime, delegate.getStartTime(), delegate.getEndTime()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<RecordEntity> recordList = this.selectJoinList(RecordEntity.class, recordWrapper);
|
||||
|
||||
if (recordList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> taskId = recordList.stream().map(RecordEntity::getTaskId).collect(Collectors.toList());
|
||||
List<String> nodeCode = recordList.stream().map(RecordEntity::getNodeCode).collect(Collectors.toList());
|
||||
List<Date> handleTime = recordList.stream().map(RecordEntity::getHandleTime).collect(Collectors.toList());
|
||||
MPJLambdaWrapper<TaskEntity> wrapper = JoinWrappers.lambda(TaskEntity.class)
|
||||
.leftJoin(RecordEntity.class, RecordEntity::getTaskId, TaskEntity::getId)
|
||||
.leftJoin(OperatorEntity.class, OperatorEntity::getId, RecordEntity::getOperatorId)
|
||||
.selectAll(TaskEntity.class)
|
||||
.selectAs(TaskEntity::getUrgent, OperatorVo::getFlowUrgent)
|
||||
.selectAs(RecordEntity::getId, OperatorVo::getId)
|
||||
.selectAs(RecordEntity::getNodeName, OperatorVo::getCurrentNodeName)
|
||||
.selectAs(RecordEntity::getNodeCode, OperatorVo::getNodeCode)
|
||||
.selectAs(RecordEntity::getHandleType, OperatorVo::getStatus)
|
||||
.selectAs(RecordEntity::getHandleId, OperatorVo::getHandleId)
|
||||
.selectAs(RecordEntity::getHandleTime, OperatorVo::getCreatorTime)
|
||||
.selectAs(OperatorEntity::getHandleId, OperatorVo::getOperatorHandleId)
|
||||
.selectAs(RecordEntity::getTaskId, OperatorVo::getTaskId)
|
||||
.selectAs(RecordEntity::getCreatorUserId, OperatorVo::getRecordCreatorUserId)
|
||||
.selectAs(TaskEntity::getCreatorUserId, OperatorVo::getCreatorUserId)
|
||||
.in(RecordEntity::getTaskId, taskId)
|
||||
.in(RecordEntity::getNodeCode, nodeCode)
|
||||
.ne(TaskEntity::getStatus, TaskStatusEnum.CANCEL.getCode());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(handleTime)) {
|
||||
wrapper.and(e -> {
|
||||
for (Date date : handleTime) {
|
||||
Calendar start = Calendar.getInstance();
|
||||
start.setTime(date);
|
||||
start.set(Calendar.MILLISECOND, 0);
|
||||
Calendar end = Calendar.getInstance();
|
||||
end.setTime(date);
|
||||
end.set(Calendar.MILLISECOND, 999);
|
||||
e.or(t -> t.between(RecordEntity::getHandleTime, start.getTime(), end.getTime()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Integer status = pagination.getStatus();
|
||||
if (null != status) {
|
||||
switch (status) {
|
||||
case 1:
|
||||
// 同意
|
||||
wrapper.eq(RecordEntity::getHandleType, RecordEnum.audit.getCode());
|
||||
break;
|
||||
case 2:
|
||||
// 拒绝
|
||||
wrapper.eq(RecordEntity::getHandleType, RecordEnum.reject.getCode());
|
||||
break;
|
||||
case 3:
|
||||
// 转审
|
||||
List<Integer> transferList = ImmutableList.of(RecordEnum.transfer.getCode(),
|
||||
RecordEnum.transferProcessing.getCode());
|
||||
wrapper.in(RecordEntity::getHandleType, transferList);
|
||||
break;
|
||||
case 4:
|
||||
// 加签
|
||||
wrapper.eq(RecordEntity::getHandleType, RecordEnum.addSign.getCode());
|
||||
break;
|
||||
case 5:
|
||||
// 退回
|
||||
wrapper.eq(RecordEntity::getHandleType, RecordEnum.back.getCode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
String keyWord = pagination.getKeyword();
|
||||
if (ObjectUtil.isNotEmpty(keyWord)) {
|
||||
wrapper.and(t -> t.like(TaskEntity::getEnCode, keyWord).or().like(TaskEntity::getFullName, keyWord));
|
||||
}
|
||||
// 所属分类
|
||||
String category = pagination.getFlowCategory();
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
wrapper.in(TaskEntity::getFlowCategory, category.split(","));
|
||||
}
|
||||
// 所属流程
|
||||
String templateId = pagination.getTemplateId();
|
||||
if (ObjectUtil.isNotEmpty(templateId)) {
|
||||
wrapper.eq(TaskEntity::getTemplateId, templateId);
|
||||
}
|
||||
// 紧急程度
|
||||
Integer flowUrgent = pagination.getFlowUrgent();
|
||||
if (ObjectUtil.isNotEmpty(flowUrgent)) {
|
||||
wrapper.eq(TaskEntity::getUrgent, flowUrgent);
|
||||
}
|
||||
// 发起人员
|
||||
String creatorUserId = pagination.getCreatorUserId();
|
||||
if (ObjectUtil.isNotEmpty(creatorUserId)) {
|
||||
wrapper.eq(TaskEntity::getCreatorUserId, creatorUserId);
|
||||
}
|
||||
// 日期范围(近7天、近1月、近3月、自定义)
|
||||
if (ObjectUtil.isNotEmpty(pagination.getStartTime()) && ObjectUtil.isNotEmpty(pagination.getEndTime())) {
|
||||
wrapper.between(TaskEntity::getStartTime, new Date(pagination.getStartTime()),
|
||||
new Date(pagination.getEndTime()));
|
||||
}
|
||||
wrapper.orderByDesc(RecordEntity::getHandleTime);
|
||||
|
||||
Page<OperatorVo> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
Page<OperatorVo> data = taskService.selectJoinListPage(page, OperatorVo.class, wrapper);
|
||||
for (OperatorVo record : data.getRecords()) {
|
||||
if (!ObjectUtil.equals(record.getRecordCreatorUserId(), record.getHandleId())) {
|
||||
boolean isUser = ObjectUtil.equals(record.getHandleId(), loginUserId)
|
||||
&& ObjectUtil.equals(record.getOperatorHandleId(), record.getRecordCreatorUserId());
|
||||
record.setDelegateUser(!isUser ? record.getRecordCreatorUserId() : null);
|
||||
}
|
||||
}
|
||||
return pagination.setData(data.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordEntity getInfo(String id) {
|
||||
if (StringUtil.isBlank(id)) {
|
||||
return null;
|
||||
}
|
||||
return this.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(RecordEntity entity) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String id, RecordEntity entity) {
|
||||
entity.setId(id);
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatusToInvalid(String taskId, List<String> nodeCodeList) {
|
||||
UpdateWrapper<RecordEntity> wrapper = new UpdateWrapper<>();
|
||||
wrapper.lambda().eq(RecordEntity::getTaskId, taskId);
|
||||
if (CollectionUtil.isNotEmpty(nodeCodeList)) {
|
||||
wrapper.lambda().in(RecordEntity::getNodeCode, nodeCodeList);
|
||||
}
|
||||
wrapper.lambda().set(RecordEntity::getStatus, FlowNature.Invalid);
|
||||
this.update(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RecordVo> getList(String taskId, String nodeId) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RecordEntity::getTaskId, taskId).like(RecordEntity::getNodeId, nodeId)
|
||||
.orderByDesc(RecordEntity::getHandleTime).orderByDesc(RecordEntity::getId);
|
||||
List<RecordEntity> list = this.list(queryWrapper);
|
||||
return recordUtil.getRecordList(list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.RejectDataEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.mapper.RejectDataMapper;
|
||||
import com.yunzhupaas.flowable.service.RejectDataService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/8 18:08
|
||||
*/
|
||||
@Service
|
||||
public class RejectDataServiceImpl extends SuperServiceImpl<RejectDataMapper, RejectDataEntity>
|
||||
implements RejectDataService {
|
||||
|
||||
@Override
|
||||
public RejectDataEntity getInfo(String id) throws WorkFlowException {
|
||||
RejectDataEntity entity = this.getById(id);
|
||||
if (entity == null) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RejectDataEntity create(TaskEntity taskEntity, List<OperatorEntity> operatorEntityList, String nodeCode) {
|
||||
RejectDataEntity entity = new RejectDataEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setTaskJson(JsonUtil.getObjectToString(taskEntity));
|
||||
entity.setOperatorJson(JsonUtil.getObjectToString(operatorEntityList));
|
||||
entity.setNodeCode(nodeCode);
|
||||
this.save(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.RevokeEntity;
|
||||
import com.yunzhupaas.flowable.mapper.RevokeMapper;
|
||||
import com.yunzhupaas.flowable.service.RevokeService;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/24 13:40
|
||||
*/
|
||||
@Service
|
||||
public class RevokeServiceImpl extends SuperServiceImpl<RevokeMapper, RevokeEntity> implements RevokeService {
|
||||
@Override
|
||||
public RevokeEntity getRevokeTask(String revokeTaskId) {
|
||||
QueryWrapper<RevokeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RevokeEntity::getRevokeTaskId, revokeTaskId);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean checkExist(String taskId) {
|
||||
QueryWrapper<RevokeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RevokeEntity::getTaskId, taskId).isNull(RevokeEntity::getDeleteMark);
|
||||
return this.count(queryWrapper) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRevoke(String revokeTaskId) {
|
||||
RevokeEntity revokeEntity = this.getRevokeTask(revokeTaskId);
|
||||
if (null != revokeEntity) {
|
||||
revokeEntity.setDeleteMark(-1);
|
||||
revokeEntity.setDeleteTime(new Date());
|
||||
revokeEntity.setDeleteUserId(UserProvider.getLoginUserId());
|
||||
this.updateById(revokeEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getByTaskId(List<String> ids) {
|
||||
if (CollectionUtil.isEmpty(ids)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<RevokeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(RevokeEntity::getTaskId, ids);
|
||||
List<RevokeEntity> list = this.list(wrapper);
|
||||
return list.stream().map(RevokeEntity::getRevokeTaskId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.SubtaskDataEntity;
|
||||
import com.yunzhupaas.flowable.mapper.SubtaskDataMapper;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.service.SubtaskDataService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/12/6 15:35
|
||||
*/
|
||||
@Service
|
||||
public class SubtaskDataServiceImpl extends SuperServiceImpl<SubtaskDataMapper, SubtaskDataEntity>
|
||||
implements SubtaskDataService {
|
||||
|
||||
@Override
|
||||
public List<SubtaskDataEntity> getList(String parentId, String parentCode) {
|
||||
QueryWrapper<SubtaskDataEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SubtaskDataEntity::getParentId, parentId)
|
||||
.eq(SubtaskDataEntity::getNodeCode, parentCode)
|
||||
.orderByAsc(SubtaskDataEntity::getSortCode);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(List<FlowModel> subTaskData) {
|
||||
if (CollectionUtil.isEmpty(subTaskData)) {
|
||||
return;
|
||||
}
|
||||
List<SubtaskDataEntity> list = new ArrayList<>();
|
||||
for (int i = 0; i < subTaskData.size(); i++) {
|
||||
FlowModel model = subTaskData.get(i);
|
||||
SubtaskDataEntity entity = new SubtaskDataEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setParentId(model.getParentId());
|
||||
entity.setNodeCode(model.getSubCode());
|
||||
entity.setSubtaskJson(JsonUtil.getObjectToString(model));
|
||||
int sortCode = i + 1;
|
||||
entity.setSortCode((long) sortCode);
|
||||
list.add(entity);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
this.saveBatch(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.RevokeEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskLineEntity;
|
||||
import com.yunzhupaas.flowable.mapper.TaskLineMapper;
|
||||
import com.yunzhupaas.flowable.service.RevokeService;
|
||||
import com.yunzhupaas.flowable.service.TaskLineService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/23 17:37
|
||||
*/
|
||||
@Service
|
||||
public class TaskLineServiceImpl extends SuperServiceImpl<TaskLineMapper, TaskLineEntity> implements TaskLineService {
|
||||
@Autowired
|
||||
private RevokeService revokeService;
|
||||
|
||||
@Override
|
||||
public List<TaskLineEntity> getList(String taskId) {
|
||||
QueryWrapper<TaskLineEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TaskLineEntity::getTaskId, taskId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(String taskId, Map<String, Boolean> conditionResMap) {
|
||||
if (CollectionUtil.isEmpty(conditionResMap)) {
|
||||
return;
|
||||
}
|
||||
List<TaskLineEntity> createList = new ArrayList<>();
|
||||
List<TaskLineEntity> updateList = new ArrayList<>();
|
||||
|
||||
List<TaskLineEntity> list = this.getList(taskId);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
conditionResMap.forEach((k, v) -> {
|
||||
TaskLineEntity entity = list.stream().filter(e -> ObjectUtil.equals(k, e.getLineKey())).findFirst()
|
||||
.orElse(null);
|
||||
if (null != entity) {
|
||||
Boolean b = conditionResMap.get(entity.getLineKey());
|
||||
if (null != b) {
|
||||
entity.setLineValue(String.valueOf(b));
|
||||
updateList.add(entity);
|
||||
}
|
||||
} else {
|
||||
entity = new TaskLineEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setTaskId(taskId);
|
||||
entity.setLineKey(k);
|
||||
entity.setLineValue(String.valueOf(v));
|
||||
createList.add(entity);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
conditionResMap.forEach((k, v) -> {
|
||||
TaskLineEntity entity = new TaskLineEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setTaskId(taskId);
|
||||
entity.setLineKey(k);
|
||||
entity.setLineValue(String.valueOf(v));
|
||||
createList.add(entity);
|
||||
});
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(createList)) {
|
||||
this.saveBatch(createList);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(updateList)) {
|
||||
this.updateBatchById(updateList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLineKeyList(String taskId) {
|
||||
List<String> resList = new ArrayList<>();
|
||||
RevokeEntity revokeEntity = revokeService.getRevokeTask(taskId);
|
||||
if (null != revokeEntity) {
|
||||
taskId = revokeEntity.getTaskId();
|
||||
}
|
||||
List<TaskLineEntity> list = this.getList(taskId);
|
||||
Map<String, List<TaskLineEntity>> collect = list.stream()
|
||||
.collect(Collectors.groupingBy(TaskLineEntity::getLineKey));
|
||||
collect.forEach((k, v) -> {
|
||||
List<TaskLineEntity> sortList = v.stream()
|
||||
.sorted(Comparator.comparing(TaskLineEntity::getCreatorTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
boolean bo = Boolean.parseBoolean(sortList.get(0).getLineValue());
|
||||
if (bo) {
|
||||
resList.add(k);
|
||||
}
|
||||
});
|
||||
return resList;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,360 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateJsonEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.job.QuartzJobUtil;
|
||||
import com.yunzhupaas.flowable.job.TimeTriggerJob;
|
||||
import com.yunzhupaas.flowable.job.TriggerJobUtil;
|
||||
import com.yunzhupaas.flowable.mapper.TemplateJsonMapper;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowAbleUrl;
|
||||
import com.yunzhupaas.flowable.model.template.FlowConfigModel;
|
||||
import com.yunzhupaas.flowable.model.templatejson.TemplateJsonInfoVO;
|
||||
import com.yunzhupaas.flowable.model.templatenode.TemplateNodeUpFrom;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.TimeTriggerModel;
|
||||
import com.yunzhupaas.flowable.service.TemplateJsonService;
|
||||
import com.yunzhupaas.flowable.service.TemplateNodeService;
|
||||
import com.yunzhupaas.flowable.service.TemplateService;
|
||||
import com.yunzhupaas.flowable.util.ServiceUtil;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class TemplateJsonServiceImpl extends SuperServiceImpl<TemplateJsonMapper, TemplateJsonEntity> implements TemplateJsonService {
|
||||
|
||||
@Autowired
|
||||
private FlowAbleUrl flowAbleUrl;
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
@Autowired
|
||||
private TemplateNodeService templateNodeService;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public List<TemplateJsonEntity> getListByTemplateIds(List<String> id) {
|
||||
List<TemplateJsonEntity> list = new ArrayList<>();
|
||||
if (!id.isEmpty()) {
|
||||
QueryWrapper<TemplateJsonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateJsonEntity::getTemplateId, id);
|
||||
list.addAll(this.list(queryWrapper));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateJsonEntity> getList(String templateId) {
|
||||
QueryWrapper<TemplateJsonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateJsonEntity::getTemplateId, templateId);
|
||||
List<TemplateJsonEntity> list = this.list(queryWrapper);
|
||||
|
||||
List<TemplateJsonEntity> resList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
// 启用中
|
||||
List<TemplateJsonEntity> enableList = list.stream().filter(e -> ObjectUtil.equals(e.getState(), 1))
|
||||
.sorted(Comparator.comparing(TemplateJsonEntity::getCreatorTime).reversed()).collect(Collectors.toList());
|
||||
// 已归档
|
||||
List<TemplateJsonEntity> historicList = list.stream().filter(e -> ObjectUtil.equals(e.getState(), 2))
|
||||
.sorted(Comparator.comparing(TemplateJsonEntity::getCreatorTime).reversed()).collect(Collectors.toList());
|
||||
// 设计中
|
||||
List<TemplateJsonEntity> designList = list.stream().filter(e -> ObjectUtil.equals(e.getState(), 0))
|
||||
.sorted(Comparator.comparing(TemplateJsonEntity::getCreatorTime).reversed()).collect(Collectors.toList());
|
||||
|
||||
resList.addAll(enableList);
|
||||
resList.addAll(historicList);
|
||||
resList.addAll(designList);
|
||||
}
|
||||
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateJsonEntity> getListOfEnable() {
|
||||
QueryWrapper<TemplateJsonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateJsonEntity::getState, 1);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateJsonEntity getInfo(String id) throws WorkFlowException {
|
||||
QueryWrapper<TemplateJsonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateJsonEntity::getId, id);
|
||||
TemplateJsonEntity jsonEntity = this.getOne(queryWrapper);
|
||||
if (jsonEntity == null) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
return jsonEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, TemplateJsonEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@DSTransactional
|
||||
@Override
|
||||
public void save(TemplateNodeUpFrom from) throws WorkFlowException {
|
||||
String templateJsonId = from.getFlowId();
|
||||
String id = from.getId();
|
||||
String flowXml = from.getFlowXml();
|
||||
Map<String, Map<String, Object>> flowNodes = from.getFlowNodes();
|
||||
TemplateJsonEntity jsonEntity = getInfo(templateJsonId);
|
||||
jsonEntity.setFlowXml(flowXml);
|
||||
TemplateEntity entity = templateService.getInfo(id);
|
||||
String flowConfig = from.getFlowConfig();
|
||||
entity.setFlowConfig(flowConfig);
|
||||
FlowConfigModel config = JsonUtil.getJsonToBean(flowConfig, FlowConfigModel.class);
|
||||
config = config == null ? new FlowConfigModel() : config;
|
||||
entity.setVisibleType(config.getVisibleType());
|
||||
//发布流程
|
||||
if (Objects.equals(from.getType(), 1)) {
|
||||
if (StringUtil.isEmpty(jsonEntity.getFlowableId())) {
|
||||
String deploymentId = flowAbleUrl.deployFlowAble(flowXml, templateJsonId);
|
||||
jsonEntity.setFlowableId(deploymentId);
|
||||
}
|
||||
//改流程版本
|
||||
if (StringUtil.isNotEmpty(id)) {
|
||||
TemplateJsonEntity info = getList(id).stream().filter(t -> Objects.equals(t.getState(), 1)).findFirst().orElse(null);
|
||||
int state = jsonEntity.getState();
|
||||
if (info != null) {
|
||||
// 变更归档状态,排序码
|
||||
//info.setSortCode(0L);
|
||||
info.setState(2);
|
||||
this.update(info.getId(), info);
|
||||
}
|
||||
jsonEntity.setState(1);
|
||||
//jsonEntity.setSortCode(1L);
|
||||
entity.setFlowId(templateJsonId);
|
||||
entity.setFlowableId(jsonEntity.getFlowableId());
|
||||
entity.setVersion(jsonEntity.getVersion());
|
||||
entity.setEnabledMark(1);
|
||||
entity.setStatus(1);
|
||||
// 归档状态的仅启用
|
||||
if (Objects.equals(2, state)) {
|
||||
templateService.update(entity.getId(), entity);
|
||||
this.update(jsonEntity.getId(), jsonEntity);
|
||||
// this.timeTrigger(jsonEntity.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
templateService.update(entity.getId(), entity);
|
||||
|
||||
TemplateNodeEntity timeTriggerNode = null;
|
||||
if (ObjectUtil.isNotEmpty(flowNodes)) {
|
||||
List<TemplateNodeEntity> list = templateNodeService.getList(jsonEntity.getId());
|
||||
List<String> deleteList = list.stream().map(TemplateNodeEntity::getId).collect(Collectors.toList());
|
||||
templateNodeService.delete(deleteList);
|
||||
// 开始节点的表单
|
||||
String startFormId = null;
|
||||
for (String key : flowNodes.keySet()) {
|
||||
NodeModel startNode = JsonUtil.getJsonToBean(flowNodes.get(key), NodeModel.class);
|
||||
if (ObjectUtil.equals(startNode.getType(), NodeEnum.start.getType())) {
|
||||
startFormId = startNode.getFormId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
String formId = null;
|
||||
for (String key : flowNodes.keySet()) {
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(flowNodes.get(key), NodeModel.class);
|
||||
if (ObjectUtil.equals(nodeModel.getType(), NodeEnum.global.getType())) {
|
||||
formId = nodeModel.getFormId();
|
||||
}
|
||||
TemplateNodeEntity nodeEntity = list.stream().filter(t -> ObjectUtil.equals(t.getNodeCode(), key)).findFirst().orElse(new TemplateNodeEntity());
|
||||
nodeEntity.setId(StringUtil.isNotEmpty(nodeEntity.getId()) ? nodeEntity.getId() : RandomUtil.uuId());
|
||||
nodeEntity.setFlowId(jsonEntity.getId());
|
||||
nodeEntity.setNodeCode(key);
|
||||
nodeEntity.setNodeJson(JsonUtil.getObjectToString(flowNodes.get(key)));
|
||||
nodeEntity.setNodeType(nodeModel.getType());
|
||||
if (StringUtil.isNotEmpty(nodeModel.getFormId())) {
|
||||
nodeEntity.setFormId(nodeModel.getFormId());
|
||||
} else {
|
||||
nodeEntity.setFormId(startFormId);
|
||||
}
|
||||
// 触发节点:定时、webhook 将flowId设置到formId字段 通知将msgId设置到formId
|
||||
if (ObjectUtil.equals(nodeModel.getType(), NodeEnum.timeTrigger.getType())) {
|
||||
nodeEntity.setFormId(nodeEntity.getFlowId());
|
||||
if (Objects.equals(from.getType(), 1)) {
|
||||
timeTriggerNode = nodeEntity;
|
||||
}
|
||||
} else if (ObjectUtil.equals(nodeModel.getType(), NodeEnum.webhookTrigger.getType())) {
|
||||
nodeEntity.setFormId(nodeEntity.getFlowId());
|
||||
} else if (ObjectUtil.equals(nodeModel.getType(), NodeEnum.noticeTrigger.getType())) {
|
||||
nodeEntity.setFormId(nodeModel.getNoticeId());
|
||||
}
|
||||
templateNodeService.setIgnoreLogicDelete().removeById(nodeEntity.getId());
|
||||
templateNodeService.setIgnoreLogicDelete().saveOrUpdate(nodeEntity);
|
||||
templateNodeService.clearIgnoreLogicDelete();
|
||||
}
|
||||
// 保存表单关联
|
||||
if (null != formId) {
|
||||
List<String> formIds = new ArrayList<>();
|
||||
formIds.add(formId);
|
||||
}
|
||||
}
|
||||
this.update(jsonEntity.getId(), jsonEntity);
|
||||
if (null != timeTriggerNode) {
|
||||
this.timeTrigger(timeTriggerNode);
|
||||
}
|
||||
}
|
||||
|
||||
public void timeTrigger(String flowId) {
|
||||
List<TemplateNodeEntity> list = templateNodeService.getList(flowId);
|
||||
List<TemplateNodeEntity> timeTriggerList = list.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getNodeType(), NodeEnum.timeTrigger.getType())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(timeTriggerList)) {
|
||||
for (TemplateNodeEntity nodeEntity : timeTriggerList) {
|
||||
this.timeTrigger(nodeEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void timeTrigger(TemplateNodeEntity nodeEntity) {
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(nodeEntity.getNodeJson(), NodeModel.class);
|
||||
String id = RandomUtil.uuId();
|
||||
TimeTriggerModel model = new TimeTriggerModel();
|
||||
model.setId(id);
|
||||
model.setFlowId(nodeEntity.getFlowId());
|
||||
model.setUserInfo(UserProvider.getUser());
|
||||
model.setCron(nodeModel.getCron());
|
||||
model.setEndLimit(nodeModel.getEndLimit());
|
||||
model.setEndTimeType(nodeModel.getEndTimeType());
|
||||
|
||||
String start = nodeModel.getStartTime();
|
||||
String end = nodeModel.getEndTime();
|
||||
Date startTime = ObjectUtil.isNotEmpty(start) ? new Date(Long.parseLong(start)) : new Date();
|
||||
Date endTime = ObjectUtil.equals(nodeModel.getEndTimeType(), 2) ? new Date(Long.parseLong(end)) : null;
|
||||
model.setStartTime(startTime.getTime());
|
||||
model.setEndTime(endTime != null ? endTime.getTime() : null);
|
||||
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.putAll(JsonUtil.entityToMap(model));
|
||||
|
||||
redisUtil.removeHash(TriggerJobUtil.TRIGGER_MODEL, model.getId());
|
||||
boolean isAdd = endTime == null || endTime.getTime() > System.currentTimeMillis();
|
||||
if (isAdd) {
|
||||
QuartzJobUtil.addJob(id, nodeModel.getCron(), TimeTriggerJob.class, jobDataMap, startTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
@DSTransactional
|
||||
@Override
|
||||
public void create(TemplateNodeUpFrom from) {
|
||||
Map<String, Map<String, Object>> flowNodes = from.getFlowNodes();
|
||||
String flowXml = from.getFlowXml();
|
||||
String templateJsonId = from.getFlowId();
|
||||
String id = from.getId();
|
||||
List<TemplateJsonEntity> jsonList = getList(id);
|
||||
int version = jsonList.stream().map(TemplateJsonEntity::getVersion).mapToInt(Integer::parseInt).max().orElse(0) + 1;
|
||||
TemplateJsonEntity entity = new TemplateJsonEntity();
|
||||
entity.setId(StringUtil.isNotEmpty(templateJsonId) ? templateJsonId : RandomUtil.uuId());
|
||||
entity.setTemplateId(id);
|
||||
entity.setFlowXml(flowXml);
|
||||
NodeModel startNode = JsonUtil.getJsonToList(new ArrayList<>(flowNodes.values()), NodeModel.class).stream().filter(t -> NodeEnum.start.getType().equals(t.getType())).findFirst().orElse(null);
|
||||
entity.setVersion(String.valueOf(version));
|
||||
entity.setState(0);
|
||||
entity.setSortCode(0L);
|
||||
String formId = null != startNode ? startNode.getFormId() : null;
|
||||
for (String key : flowNodes.keySet()) {
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(flowNodes.get(key), NodeModel.class);
|
||||
TemplateNodeEntity nodeEntity = new TemplateNodeEntity();
|
||||
nodeEntity.setId(StringUtil.isNotEmpty(nodeEntity.getId()) ? nodeEntity.getId() : RandomUtil.uuId());
|
||||
nodeEntity.setFlowId(entity.getId());
|
||||
nodeEntity.setNodeCode(key);
|
||||
nodeEntity.setNodeJson(JsonUtil.getObjectToString(flowNodes.get(key)));
|
||||
nodeEntity.setNodeType(nodeModel.getType());
|
||||
nodeEntity.setFormId(StringUtil.isBlank(nodeModel.getFormId()) ? formId : nodeModel.getFormId());
|
||||
templateNodeService.setIgnoreLogicDelete().removeById(nodeEntity.getId());
|
||||
templateNodeService.setIgnoreLogicDelete().saveOrUpdate(nodeEntity);
|
||||
templateNodeService.clearIgnoreLogicDelete();
|
||||
}
|
||||
this.setIgnoreLogicDelete().removeById(entity.getId());
|
||||
this.setIgnoreLogicDelete().saveOrUpdate(entity);
|
||||
this.clearIgnoreLogicDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(TemplateJsonEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> idList) {
|
||||
if (idList.size() > 0) {
|
||||
QueryWrapper<TemplateJsonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateJsonEntity::getId, idList);
|
||||
this.remove(queryWrapper);
|
||||
templateNodeService.delete(idList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(TemplateJsonEntity entity, String flowId) {
|
||||
List<TemplateNodeEntity> list = templateNodeService.getList(entity.getId());
|
||||
Map<String, Map<String, Object>> flowNodes = new HashMap<>();
|
||||
for (TemplateNodeEntity nodeEntity : list) {
|
||||
Map<String, Object> map = JsonUtil.stringToMap(nodeEntity.getNodeJson());
|
||||
if (ObjectUtil.equals(nodeEntity.getNodeType(), NodeEnum.webhookTrigger.getType())) {
|
||||
map.put("webhookUrl", "");
|
||||
}
|
||||
flowNodes.put(nodeEntity.getNodeCode(), map);
|
||||
}
|
||||
TemplateNodeUpFrom from = new TemplateNodeUpFrom();
|
||||
from.setId(entity.getTemplateId());
|
||||
from.setFlowXml(entity.getFlowXml());
|
||||
from.setFlowNodes(flowNodes);
|
||||
from.setFlowId(flowId);
|
||||
create(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateJsonInfoVO getInfoVo(String id) throws WorkFlowException {
|
||||
TemplateJsonEntity jsonEntity = this.getInfo(id);
|
||||
TemplateEntity entity = templateService.getInfo(jsonEntity.getTemplateId());
|
||||
TemplateJsonInfoVO vo = JsonUtil.getJsonToBean(entity, TemplateJsonInfoVO.class);
|
||||
vo.setFlowXml(jsonEntity.getFlowXml());
|
||||
List<TemplateNodeEntity> templateNodeList = templateNodeService.getList(jsonEntity.getId());
|
||||
Map<String, Map<String, Object>> flowNodes = new HashMap<>();
|
||||
for (TemplateNodeEntity nodeEntity : templateNodeList) {
|
||||
flowNodes.put(nodeEntity.getNodeCode(), JsonUtil.stringToMap(nodeEntity.getNodeJson()));
|
||||
}
|
||||
vo.setFlowableId(jsonEntity.getFlowableId());
|
||||
vo.setFlowNodes(flowNodes);
|
||||
vo.setFlowId(jsonEntity.getId());
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisualdevEntity getFormInfo(String id) throws WorkFlowException {
|
||||
TemplateEntity template = templateService.getInfo(id);
|
||||
String flowId = template.getFlowId();
|
||||
TemplateJsonEntity jsonEntity = this.getInfo(flowId);
|
||||
List<TemplateNodeEntity> templateNodeList = templateNodeService.getList(jsonEntity.getId());
|
||||
TemplateNodeEntity global = templateNodeList.stream().filter(e -> ObjectUtil.equals(e.getNodeType(), NodeEnum.global.getType())).findFirst().orElse(null);
|
||||
if (null != global) {
|
||||
return serviceUtil.getFormInfo(global.getFormId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.TemplateJsonEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.mapper.TemplateNodeMapper;
|
||||
import com.yunzhupaas.flowable.service.TemplateJsonService;
|
||||
import com.yunzhupaas.flowable.service.TemplateNodeService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class TemplateNodeServiceImpl extends SuperServiceImpl<TemplateNodeMapper, TemplateNodeEntity> implements TemplateNodeService {
|
||||
|
||||
@Autowired
|
||||
private TemplateJsonService templateJsonService;
|
||||
|
||||
@Override
|
||||
public List<TemplateNodeEntity> getList(String flowId) {
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateNodeEntity::getFlowId, flowId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateNodeEntity> getList(List<String> flowIds, String nodeType) {
|
||||
if (flowIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateNodeEntity::getFlowId, flowIds);
|
||||
if (StringUtil.isNotBlank(nodeType)) {
|
||||
queryWrapper.lambda().eq(TemplateNodeEntity::getNodeType, nodeType);
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateNodeEntity> getListLikeUserId(String userId) {
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().like(TemplateNodeEntity::getNodeJson, userId);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateNodeEntity getInfo(String id) throws WorkFlowException {
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateNodeEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(TemplateNodeEntity entity) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, TemplateNodeEntity entity) {
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(TemplateNodeEntity entity) {
|
||||
if (entity != null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteList(List<String> idList) {
|
||||
if (!idList.isEmpty()) {
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateNodeEntity::getId, idList);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> idList) {
|
||||
if (!idList.isEmpty()) {
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateNodeEntity::getId, idList);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateNodeEntity> getListStart() {
|
||||
List<TemplateJsonEntity> listOfEnable = templateJsonService.getListOfEnable();
|
||||
List<String> flowIds = listOfEnable.stream().map(TemplateJsonEntity::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(flowIds)) {
|
||||
QueryWrapper<TemplateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().select(TemplateNodeEntity::getFlowId, TemplateNodeEntity::getFormId);
|
||||
queryWrapper.lambda().eq(TemplateNodeEntity::getNodeType, NodeEnum.start.getType()).in(TemplateNodeEntity::getFlowId, flowIds);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,730 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.mapper.TemplateMapper;
|
||||
import com.yunzhupaas.flowable.model.template.*;
|
||||
import com.yunzhupaas.flowable.model.templatejson.FlowFormModel;
|
||||
import com.yunzhupaas.flowable.model.templatejson.TemplateJsonExportModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.TemplateNodeUpFrom;
|
||||
import com.yunzhupaas.flowable.service.*;
|
||||
import com.yunzhupaas.flowable.util.ServiceUtil;
|
||||
import com.yunzhupaas.flowable.util.TaskUtil;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class TemplateServiceImpl extends SuperServiceImpl<TemplateMapper, TemplateEntity> implements TemplateService {
|
||||
|
||||
@Autowired
|
||||
private TemplateJsonService templateJsonService;
|
||||
@Autowired
|
||||
private TemplateNodeService templateNodeService;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private DelegateService delegateService;
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
@Autowired
|
||||
private TaskUtil taskUtil;
|
||||
@Autowired
|
||||
private TriggerTaskService triggerTaskService;
|
||||
|
||||
@Override
|
||||
public List<TemplateEntity> getList(TemplatePagination pagination) {
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
String keyword = pagination.getKeyword();
|
||||
if (ObjectUtil.isNotEmpty(keyword)) {
|
||||
queryWrapper.lambda().and(t -> t.like(TemplateEntity::getEnCode, keyword).or().like(TemplateEntity::getFullName, keyword));
|
||||
}
|
||||
String category = pagination.getCategory();
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
queryWrapper.lambda().eq(TemplateEntity::getCategory, category);
|
||||
}
|
||||
Integer type = pagination.getType();
|
||||
if (ObjectUtil.isNotEmpty(type)) {
|
||||
queryWrapper.lambda().eq(TemplateEntity::getType, type);
|
||||
}
|
||||
Integer enabledMark = pagination.getEnabledMark();
|
||||
if (ObjectUtil.isNotEmpty(enabledMark)) {
|
||||
queryWrapper.lambda().eq(TemplateEntity::getEnabledMark, enabledMark);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(TemplateEntity::getSortCode).orderByDesc(TemplateEntity::getCreatorTime);
|
||||
Page<TemplateEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<TemplateEntity> userPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(userPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplatePageVo> getSelector(TemplatePagination pagination) {
|
||||
// 流程权限
|
||||
List<String> flowId = new ArrayList<>();
|
||||
List<String> id = new ArrayList<>();
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
if (StringUtil.isNotBlank(pagination.getDelegateUser())) {
|
||||
userId = pagination.getDelegateUser();
|
||||
}
|
||||
// 权限
|
||||
boolean commonUser = serviceUtil.isCommonUser(userId);
|
||||
// 是否委托列表
|
||||
if (ObjectUtil.equals(pagination.getIsDelegate(), 1)) {
|
||||
if (commonUser) {
|
||||
flowId.addAll(serviceUtil.getLaunchPermission(userId));
|
||||
}
|
||||
} else {
|
||||
if (ObjectUtil.equals(pagination.getIsAuthority(), 1)) {
|
||||
if (commonUser) {
|
||||
flowId.addAll(serviceUtil.getLaunchPermission(userId));
|
||||
}
|
||||
// 委托
|
||||
List<DelegateEntity> delegateEntityList = delegateService.getByToUserId(userId, 0);
|
||||
for (DelegateEntity delegate : delegateEntityList) {
|
||||
List<String> launchPermission = serviceUtil.getLaunchPermission(delegate.getUserId());
|
||||
if (StringUtil.isNotEmpty(delegate.getFlowId())) {
|
||||
launchPermission.retainAll(Arrays.asList(delegate.getFlowId().split(",")));
|
||||
}
|
||||
id.addAll(launchPermission);
|
||||
}
|
||||
flowId.addAll(id);
|
||||
flowId = flowId.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
MPJLambdaWrapper<TemplateEntity> wrapper = JoinWrappers.lambda(TemplateEntity.class)
|
||||
.selectAll(TemplateEntity.class)
|
||||
.eq(TemplateEntity::getEnabledMark, 1).ne(TemplateEntity::getType, 2)
|
||||
.eq(TemplateEntity::getStatus, 1);
|
||||
if (ObjectUtil.equals(pagination.getIsLaunch(), 1)) {
|
||||
wrapper.in(TemplateEntity::getShowType, 0, 1);
|
||||
}
|
||||
|
||||
if (ObjectUtil.equals(pagination.getIsAuthority(), 1)) {
|
||||
if (commonUser) {
|
||||
List<String> finalFlowId = flowId;
|
||||
wrapper.and(t -> t.eq(TemplateEntity::getVisibleType, 1)
|
||||
.or().in(!finalFlowId.isEmpty(), TemplateEntity::getId, finalFlowId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//关键字(流程名称、流程编码)
|
||||
String keyWord = pagination.getKeyword();
|
||||
if (ObjectUtil.isNotEmpty(keyWord)) {
|
||||
wrapper.and(t -> t.like(TemplateEntity::getEnCode, keyWord).or().like(TemplateEntity::getFullName, keyWord));
|
||||
}
|
||||
//所属分类
|
||||
String category = pagination.getCategory();
|
||||
if (ObjectUtil.isNotEmpty(category)) {
|
||||
if (StringUtil.equals(category, "commonFlow")) {
|
||||
wrapper.leftJoin(CommonEntity.class, CommonEntity::getFlowId, TemplateJsonEntity::getId)
|
||||
.eq(CommonEntity::getCreatorUserId, userId).isNotNull(CommonEntity::getFlowId);
|
||||
} else {
|
||||
wrapper.in(TemplateEntity::getCategory, category.split(","));
|
||||
}
|
||||
}
|
||||
wrapper.orderByAsc(TemplateEntity::getSortCode).orderByDesc(TemplateEntity::getCreatorTime);
|
||||
Page<TemplatePageVo> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<TemplatePageVo> userPage = this.selectJoinListPage(page, TemplatePageVo.class, wrapper);
|
||||
|
||||
List<TemplatePageVo> records = userPage.getRecords();
|
||||
// 设置常用流程标识
|
||||
List<CommonEntity> commonList = commonService.getCommonByUserId(userId);
|
||||
if (CollectionUtil.isNotEmpty(commonList)) {
|
||||
List<String> flowIds = commonList.stream().map(CommonEntity::getFlowId).distinct().collect(Collectors.toList());
|
||||
for (TemplatePageVo record : records) {
|
||||
if (flowIds.contains(record.getId())) {
|
||||
record.setIsCommonFlow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pagination.setData(records, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateTreeListVo> getTreeCommon() {
|
||||
String userId = UserProvider.getLoginUserId();
|
||||
List<TemplateTreeListVo> vos = new ArrayList<>();
|
||||
List<CommonEntity> commonList = commonService.getCommonByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(commonList)) {
|
||||
return vos;
|
||||
}
|
||||
List<String> flowIds = commonList.stream().map(CommonEntity::getFlowId).collect(Collectors.toList());
|
||||
List<TemplateEntity> templateList = this.getList(flowIds);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(templateList)) {
|
||||
TemplateTreeListVo allVo = new TemplateTreeListVo();
|
||||
allVo.setId(RandomUtil.uuId());
|
||||
allVo.setFullName("全部流程");
|
||||
List<TemplateTreeListVo> childrenList = this.getChildren(templateList);
|
||||
allVo.setChildren(childrenList);
|
||||
vos.add(allVo);
|
||||
|
||||
Map<String, List<TemplateTreeListVo>> map = childrenList.stream().collect(Collectors.groupingBy(TemplateTreeListVo::getCategory));
|
||||
List<String> categoryIds = map.keySet().stream().collect(Collectors.toList());
|
||||
|
||||
List<DictionaryDataEntity> dictionNameList = serviceUtil.getDictionName(categoryIds);
|
||||
for (DictionaryDataEntity dict : dictionNameList) {
|
||||
TemplateTreeListVo vo = new TemplateTreeListVo();
|
||||
vo.setId(dict.getId());
|
||||
vo.setFullName(dict.getFullName());
|
||||
vo.setChildren(map.get(dict.getId()));
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
public List<TemplateTreeListVo> getChildren(List<TemplateEntity> templates) {
|
||||
List<TemplateTreeListVo> resList = new ArrayList<>();
|
||||
for (TemplateEntity template : templates) {
|
||||
TemplateTreeListVo vo = JsonUtil.getJsonToBean(template, TemplateTreeListVo.class);
|
||||
resList.add(vo);
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateTreeListVo> treeList(Integer formType) {
|
||||
List<DictionaryDataEntity> dictionList = serviceUtil.getDiList();
|
||||
|
||||
TemplatePagination pagination = new TemplatePagination();
|
||||
List<TemplateEntity> list = getListAll(pagination, false);
|
||||
|
||||
List<TemplateNodeEntity> startNodeList;
|
||||
// formType 1.系统表单 2.在线开发表单
|
||||
if (null != formType) {
|
||||
// 版本主键
|
||||
List<String> flowIds = list.stream().map(TemplateEntity::getFlowId).collect(Collectors.toList());
|
||||
startNodeList = templateNodeService.getList(flowIds, NodeEnum.start.getType());
|
||||
} else {
|
||||
startNodeList = new ArrayList<>();
|
||||
}
|
||||
List<String> formIds = startNodeList.stream().map(TemplateNodeEntity::getFormId).collect(Collectors.toList());
|
||||
List<VisualdevEntity> formList = serviceUtil.getFormList(formIds);
|
||||
|
||||
List<TemplateTreeListVo> vos = new ArrayList<>();
|
||||
|
||||
for (DictionaryDataEntity dict : dictionList) {
|
||||
TemplateTreeListVo vo = new TemplateTreeListVo();
|
||||
vo.setFullName(dict.getFullName());
|
||||
vo.setId(dict.getId());
|
||||
vo.setDisabled(true);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
List<TemplateEntity> childList = list.stream()
|
||||
.filter(e -> dict.getId().equals(e.getCategory())).collect(Collectors.toList());
|
||||
|
||||
if (null != formType) {
|
||||
childList = childList.stream().filter(e -> {
|
||||
// 是流程显示类型
|
||||
if (ObjectUtil.equals(e.getShowType(), 1)) {
|
||||
return false;
|
||||
}
|
||||
TemplateNodeEntity node = startNodeList.stream().filter(a -> a.getFlowId().equals(e.getFlowId())).findFirst().orElse(null);
|
||||
if (null != node) {
|
||||
VisualdevEntity form = formList.stream().filter(b -> b.getId().equals(node.getFormId())).findFirst().orElse(null);
|
||||
if (null != form) {
|
||||
return form.getType().equals(1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(childList)) {
|
||||
childList = childList.stream()
|
||||
.sorted(Comparator.comparing(TemplateEntity::getSortCode, Comparator.nullsLast(Comparator.naturalOrder())).thenComparing(TemplateEntity::getCreatorTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
vo.setNum(childList.size());
|
||||
vo.setChildren(JsonUtil.getJsonToList(childList, TemplateTreeListVo.class));
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateTreeListVo> treeListWithPower() {
|
||||
List<TemplateTreeListVo> vos = new ArrayList<>();
|
||||
|
||||
MPJLambdaWrapper<TemplateEntity> wrapper = JoinWrappers.lambda(TemplateEntity.class)
|
||||
.selectAll(TemplateEntity.class)
|
||||
.eq(TemplateEntity::getVisibleType, 2)
|
||||
.isNotNull(TemplateEntity::getFlowId);
|
||||
|
||||
List<TemplateEntity> list = this.selectJoinList(TemplateEntity.class, wrapper);
|
||||
List<String> categoryList = list.stream().map(TemplateEntity::getCategory).collect(Collectors.toList());
|
||||
List<DictionaryDataEntity> dictionList = serviceUtil.getDictionName(categoryList);
|
||||
for (DictionaryDataEntity dict : dictionList) {
|
||||
TemplateTreeListVo vo = new TemplateTreeListVo();
|
||||
vo.setFullName(dict.getFullName());
|
||||
vo.setId(dict.getId());
|
||||
vo.setDisabled(true);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
List<TemplateEntity> childList = list.stream()
|
||||
.filter(e -> dict.getId().equals(e.getCategory()))
|
||||
.sorted(Comparator.comparing(TemplateEntity::getSortCode, Comparator.nullsLast(Comparator.naturalOrder())).thenComparing(TemplateEntity::getCreatorTime, Comparator.reverseOrder()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(childList)) {
|
||||
vo.setNum(childList.size());
|
||||
vo.setChildren(JsonUtil.getJsonToList(childList, TemplateTreeListVo.class));
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateEntity> getListAll(TemplatePagination pagination, boolean isPage) {
|
||||
// 定义变量判断是否需要使用修改时间倒序
|
||||
boolean flag = false;
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getEnabledMark, 1).eq(TemplateEntity::getStatus, 1);
|
||||
if (ObjectUtil.isNotEmpty(pagination.getType())) {
|
||||
flag = true;
|
||||
queryWrapper.lambda().eq(TemplateEntity::getType, pagination.getType());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
flag = true;
|
||||
queryWrapper.lambda().like(TemplateEntity::getFullName, pagination.getKeyword());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getCategory())) {
|
||||
flag = true;
|
||||
queryWrapper.lambda().eq(TemplateEntity::getCategory, pagination.getCategory());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getTemplateIdList())) {
|
||||
queryWrapper.lambda().in(TemplateEntity::getId, pagination.getTemplateIdList());
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(TemplateEntity::getSortCode).orderByDesc(TemplateEntity::getCreatorTime);
|
||||
if (flag) {
|
||||
queryWrapper.lambda().orderByDesc(TemplateEntity::getLastModifyTime);
|
||||
}
|
||||
queryWrapper.lambda().select(
|
||||
TemplateEntity::getId, TemplateEntity::getEnCode,
|
||||
TemplateEntity::getFullName,
|
||||
TemplateEntity::getFlowId,
|
||||
TemplateEntity::getStatus, TemplateEntity::getShowType,
|
||||
TemplateEntity::getType, TemplateEntity::getIcon,
|
||||
TemplateEntity::getCategory, TemplateEntity::getIconBackground,
|
||||
TemplateEntity::getCreatorUserId, TemplateEntity::getSortCode,
|
||||
TemplateEntity::getEnabledMark, TemplateEntity::getCreatorTime
|
||||
);
|
||||
if (isPage) {
|
||||
Page<TemplateEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<TemplateEntity> userPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(userPage.getRecords(), page.getTotal());
|
||||
} else {
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateEntity> getListByFlowIds(List<String> flowIds) {
|
||||
List<TemplateEntity> list = new ArrayList<>();
|
||||
List<TemplateJsonEntity> jsonEntityList = templateJsonService.listByIds(flowIds);
|
||||
if (CollectionUtil.isNotEmpty(jsonEntityList)) {
|
||||
List<String> templateIds = jsonEntityList.stream().map(TemplateJsonEntity::getTemplateId).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(templateIds)) {
|
||||
QueryWrapper<TemplateEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(TemplateEntity::getId, templateIds).eq(TemplateEntity::getStatus, 1);
|
||||
list = this.list(wrapper);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateEntity getInfo(String id) throws WorkFlowException {
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getId, id);
|
||||
TemplateEntity templateEntity = this.getOne(queryWrapper);
|
||||
if (templateEntity == null) {
|
||||
throw new WorkFlowException(MsgCode.WF122.get());
|
||||
}
|
||||
return templateEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByFullName(String fullName, String id) {
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getFullName, fullName);
|
||||
if (!StringUtils.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(TemplateEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExistByEnCode(String enCode, String id) {
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getEnCode, enCode);
|
||||
if (!StringUtils.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(TemplateEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0 ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(TemplateEntity entity, String flowXml, Map<String, Map<String, Object>> flowNodes) throws WorkFlowException {
|
||||
if (isExistByFullName(entity.getFullName(), entity.getId())) {
|
||||
throw new WorkFlowException(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (isExistByEnCode(entity.getEnCode(), entity.getId())) {
|
||||
throw new WorkFlowException(MsgCode.EXIST002.get());
|
||||
}
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
entity.setId(StringUtil.isNotEmpty(entity.getId()) ? entity.getId() : RandomUtil.uuId());
|
||||
entity.setCreatorUserId(userInfo.getUserId());
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setFlowId(null);
|
||||
entity.setEnabledMark(0);
|
||||
entity.setStatus(0);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setLastModifyTime(null);
|
||||
this.setIgnoreLogicDelete().removeById(entity.getId());
|
||||
this.setIgnoreLogicDelete().saveOrUpdate(entity);
|
||||
this.clearIgnoreLogicDelete();
|
||||
TemplateNodeUpFrom from = new TemplateNodeUpFrom();
|
||||
from.setId(entity.getId());
|
||||
from.setFlowXml(flowXml);
|
||||
from.setFlowNodes(flowNodes);
|
||||
templateJsonService.create(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(String id, TemplateEntity entity) throws WorkFlowException {
|
||||
if (isExistByFullName(entity.getFullName(), id)) {
|
||||
throw new WorkFlowException(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (isExistByEnCode(entity.getEnCode(), id)) {
|
||||
throw new WorkFlowException(MsgCode.EXIST002.get());
|
||||
}
|
||||
entity.setId(id);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(TemplateEntity entity) throws WorkFlowException {
|
||||
if (entity != null) {
|
||||
if (ObjectUtil.equals(entity.getType(), 2)) {
|
||||
List<TemplateJsonEntity> list = templateJsonService.getList(entity.getId());
|
||||
List<String> flowIds = list.stream().map(TemplateJsonEntity::getId).collect(Collectors.toList());
|
||||
if (triggerTaskService.checkByFlowIds(flowIds)) {
|
||||
throw new WorkFlowException(MsgCode.WF139.get());
|
||||
}
|
||||
} else {
|
||||
List<TaskEntity> taskList = taskUtil.getTaskByTemplate(entity.getId());
|
||||
if (CollectionUtil.isNotEmpty(taskList)) {
|
||||
throw new WorkFlowException(MsgCode.WF124.get());
|
||||
}
|
||||
}
|
||||
this.removeById(entity.getId());
|
||||
List<String> idList = templateJsonService.getList(entity.getId()).stream().map(TemplateJsonEntity::getId).collect(Collectors.toList());
|
||||
templateJsonService.delete(idList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copy(TemplateEntity entity) throws WorkFlowException {
|
||||
try {
|
||||
TemplateJsonEntity jsonEntity = StringUtil.isNotEmpty(entity.getFlowId()) ? templateJsonService.getInfo(entity.getFlowId()) : null;
|
||||
String formXml = jsonEntity != null ? jsonEntity.getFlowXml() : null;
|
||||
List<TemplateNodeEntity> list = jsonEntity != null ? templateNodeService.getList(jsonEntity.getId()) : new ArrayList<>();
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
|
||||
entity.setEnCode(entity.getEnCode() + copyNum);
|
||||
entity.setId(null);
|
||||
Map<String, Map<String, Object>> flowNodes = new HashMap<>();
|
||||
for (TemplateNodeEntity nodeEntity : list) {
|
||||
flowNodes.put(nodeEntity.getNodeCode(), JsonUtil.stringToMap(nodeEntity.getNodeJson()));
|
||||
}
|
||||
this.create(entity, formXml, flowNodes);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
throw new WorkFlowException(MsgCode.PRI006.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateExportModel export(String id) throws WorkFlowException {
|
||||
TemplateEntity entity = getInfo(id);
|
||||
TemplateExportModel exportModel = new TemplateExportModel();
|
||||
exportModel.setTemplate(entity);
|
||||
// 版本
|
||||
TemplateJsonEntity jsonEntity = templateJsonService.getInfo(entity.getFlowId());
|
||||
TemplateJsonExportModel versionModel = JsonUtil.getJsonToBean(jsonEntity, TemplateJsonExportModel.class);
|
||||
// 节点
|
||||
List<TemplateNodeEntity> list = templateNodeService.getList(entity.getFlowId());
|
||||
exportModel.setNodeList(list);
|
||||
exportModel.setFlowVersion(versionModel);
|
||||
return exportModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importData(TemplateExportModel model, String type) throws WorkFlowException {
|
||||
TemplateEntity entity = model.getTemplate();
|
||||
TemplateJsonExportModel versionModel = model.getFlowVersion();
|
||||
if (null != entity) {
|
||||
entity.setFlowId(null);
|
||||
entity.setVersion(null);
|
||||
entity.setCreatorUserId(UserProvider.getLoginUserId());
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setEnabledMark(0);
|
||||
|
||||
List<String> errList = new ArrayList<>();
|
||||
// type: 0.当导入数据不存在,作为新数据导入;数据已存在,不做处理 1.当导入数据已存在,增加相同记录新数据,名称和编码自动增加随机码
|
||||
TemplateEntity templateEntity = checkImportEntity(entity, type, errList);
|
||||
|
||||
if (!errList.isEmpty()) {
|
||||
StringJoiner joiner = new StringJoiner(";");
|
||||
joiner.add(String.join("、", errList) + "重复");
|
||||
if (StringUtil.isNotEmpty(joiner.toString())) {
|
||||
throw new WorkFlowException(joiner.toString());
|
||||
}
|
||||
}
|
||||
Map<String, Map<String, Object>> flowNodes = new HashMap<>();
|
||||
for (TemplateNodeEntity nodeEntity : model.getNodeList()) {
|
||||
flowNodes.put(nodeEntity.getNodeCode(), JsonUtil.stringToMap(nodeEntity.getNodeJson()));
|
||||
}
|
||||
this.create(templateEntity, versionModel.getFlowXml(), flowNodes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateEntity> getList(List<String> ids) {
|
||||
if (ids.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateEntity::getId, ids).eq(TemplateEntity::getStatus, 1);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateEntity> getListOfHidden(List<String> ids) {
|
||||
if (ids.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TemplateEntity::getId, ids).in(TemplateEntity::getStatus, 1, 2);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
// 校验导入的实体
|
||||
public TemplateEntity checkImportEntity(TemplateEntity templateEntity, String type, List<String> errList) {
|
||||
TemplateEntity entity = JsonUtil.getJsonToBean(templateEntity, TemplateEntity.class);
|
||||
boolean skip = Objects.equals("0", type);
|
||||
int num = 0;
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getId, entity.getId());
|
||||
if (this.count(queryWrapper) > 0) {
|
||||
num++;
|
||||
if (skip) {
|
||||
errList.add("ID");
|
||||
}
|
||||
}
|
||||
queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getEnCode, entity.getEnCode());
|
||||
if (this.count(queryWrapper) > 0) {
|
||||
num++;
|
||||
if (skip) {
|
||||
errList.add("编码");
|
||||
}
|
||||
}
|
||||
queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TemplateEntity::getFullName, entity.getFullName());
|
||||
if (this.count(queryWrapper) > 0) {
|
||||
num++;
|
||||
if (skip) {
|
||||
errList.add("名称");
|
||||
}
|
||||
}
|
||||
if (num > 0 && !skip) {
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
|
||||
entity.setEnCode(entity.getEnCode() + copyNum);
|
||||
}
|
||||
entity.setId(RandomUtil.uuId());
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowByFormModel getFlowByFormId(String formId, Boolean start) {
|
||||
FlowByFormModel res = new FlowByFormModel();
|
||||
List<TemplateByFormModel> resList = new ArrayList<>();
|
||||
|
||||
QueryWrapper<TemplateNodeEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(TemplateNodeEntity::getFormId, formId);
|
||||
// start 传true 仅发起节点 false 全部节点
|
||||
start = null == start || start;
|
||||
if (start) {
|
||||
wrapper.lambda().eq(TemplateNodeEntity::getNodeType, NodeEnum.start.getType());
|
||||
}
|
||||
List<TemplateNodeEntity> nodeList = templateNodeService.list(wrapper);
|
||||
if (CollectionUtil.isEmpty(nodeList)) {
|
||||
return res;
|
||||
}
|
||||
List<String> flowIds = nodeList.stream().map(TemplateNodeEntity::getFlowId).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(flowIds)) {
|
||||
return res;
|
||||
}
|
||||
List<TemplateJsonEntity> versionList = templateJsonService.listByIds(flowIds);
|
||||
if (CollectionUtil.isEmpty(versionList)) {
|
||||
return res;
|
||||
}
|
||||
// 获取启用版本
|
||||
versionList = versionList.stream().filter(e -> e.getState().equals(1))
|
||||
.sorted(Comparator.comparing(TemplateJsonEntity::getCreatorTime).reversed()).collect(Collectors.toList());
|
||||
// 获取流程
|
||||
List<String> templateIds = versionList.stream().map(TemplateJsonEntity::getTemplateId).distinct().collect(Collectors.toList());
|
||||
List<TemplateEntity> templateList = CollectionUtil.isNotEmpty(templateIds) ? this.listByIds(templateIds) : new ArrayList<>();
|
||||
// 获取权限流程
|
||||
String loginUserId = UserProvider.getLoginUserId();
|
||||
List<String> templatePermissionIds = serviceUtil.getLaunchPermission(loginUserId);
|
||||
//是否普通用户
|
||||
boolean commonUser = serviceUtil.isCommonUser(loginUserId);
|
||||
for (TemplateJsonEntity jsonEntity : versionList) {
|
||||
TemplateByFormModel model = new TemplateByFormModel();
|
||||
model.setId(jsonEntity.getId());
|
||||
|
||||
TemplateEntity template = templateList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getId(), jsonEntity.getTemplateId())).findFirst().orElse(null);
|
||||
if (null == template || !ObjectUtil.equals(template.getStatus(), 1)) {
|
||||
continue;
|
||||
}
|
||||
if (commonUser && ObjectUtil.equals(template.getVisibleType(), 2)) {
|
||||
// 带权限
|
||||
if (templatePermissionIds.contains(jsonEntity.getId())) {
|
||||
model.setFullName(template.getFullName());
|
||||
resList.add(model);
|
||||
}
|
||||
} else {
|
||||
model.setFullName(template.getFullName());
|
||||
resList.add(model);
|
||||
}
|
||||
}
|
||||
res.setList(resList);
|
||||
res.setIsConfig(true);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserEntity> getSubFlowUserList(String flowId, TemplatePagination pagination) throws WorkFlowException {
|
||||
TemplateEntity template = this.getInfo(flowId);
|
||||
return serviceUtil.getLaunchUserByTemplateId(template, pagination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisualdevEntity getFormByTemplateId(String templateId) throws WorkFlowException {
|
||||
TemplateEntity template = this.getInfo(templateId);
|
||||
List<TemplateNodeEntity> nodeEntityList = templateNodeService.getList(template.getFlowId());
|
||||
|
||||
TemplateNodeEntity nodeEntity = nodeEntityList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getNodeType(), NodeEnum.start.getType())).findFirst().orElse(null);
|
||||
if (null == nodeEntity) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
return serviceUtil.getFormInfo(nodeEntity.getFormId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowFormModel getFormIdAndFlowId(String templateId) throws WorkFlowException {
|
||||
List<String> userId = ImmutableList.of(UserProvider.getLoginUserId());
|
||||
FlowFormModel model = getFormIdAndFlowId(userId, templateId);
|
||||
if (model.getUserId().isEmpty()) {
|
||||
throw new WorkFlowException(MsgCode.WF029.get());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowFormModel getFormIdAndFlowId(List<String> userIdAll, String templateId) throws WorkFlowException {
|
||||
List<String> userList = new ArrayList<>();
|
||||
TemplateEntity template = this.getInfo(templateId);
|
||||
List<TemplateNodeEntity> nodeEntityList = templateNodeService.getList(template.getFlowId());
|
||||
// 判断权限
|
||||
for (String userId : userIdAll) {
|
||||
userList.add(userId);
|
||||
if (ObjectUtil.equals(template.getVisibleType(), 2)) {
|
||||
boolean commonUser = serviceUtil.isCommonUser(userId);
|
||||
if (commonUser) {
|
||||
List<String> flowIds = serviceUtil.getLaunchPermission(userId);
|
||||
if (!flowIds.contains(template.getId())) {
|
||||
userList.remove(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TemplateNodeEntity nodeEntity = nodeEntityList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getNodeType(), NodeEnum.start.getType())).findFirst().orElse(null);
|
||||
if (null == nodeEntity) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
FlowFormModel model = new FlowFormModel();
|
||||
model.setFormId(nodeEntity.getFormId());
|
||||
model.setFlowId(template.getFlowId());
|
||||
model.setUserId(userList);
|
||||
return model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFormList() {
|
||||
List<String> resList = new ArrayList<>();
|
||||
List<TemplateJsonEntity> list = templateJsonService.getListOfEnable();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
List<String> flowIds = list.stream().map(TemplateJsonEntity::getId).distinct().collect(Collectors.toList());
|
||||
List<TemplateNodeEntity> startNodeList = templateNodeService.getList(flowIds, NodeEnum.start.getType());
|
||||
resList = startNodeList.stream().map(TemplateNodeEntity::getFormId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getFlowFormMap() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
List<TemplateNodeEntity> listStart = templateNodeService.getListStart();
|
||||
List<String> collect = listStart.stream().map(TemplateNodeEntity::getFlowId).collect(Collectors.toList());
|
||||
if (ObjectUtil.isNotEmpty(collect)) {
|
||||
QueryWrapper<TemplateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().select(TemplateEntity::getId, TemplateEntity::getFlowId);
|
||||
queryWrapper.lambda().in(TemplateEntity::getFlowId, collect);
|
||||
Map<String, String> flowTempMap = this.list(queryWrapper).stream().collect(Collectors.toMap(TemplateEntity::getFlowId, TemplateEntity::getId));
|
||||
for (TemplateNodeEntity templateNodeEntity : listStart) {
|
||||
if (ObjectUtil.isNotEmpty(flowTempMap.get(templateNodeEntity.getFlowId()))) {
|
||||
map.put(flowTempMap.get(templateNodeEntity.getFlowId()), templateNodeEntity.getFormId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.dynamic.datasource.tx.DsPropagation;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.flowable.entity.TriggerRecordEntity;
|
||||
import com.yunzhupaas.flowable.entity.TriggerTaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.TriggerRecordEnum;
|
||||
import com.yunzhupaas.flowable.mapper.TriggerRecordMapper;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowableTaskModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.TriggerRecordService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/10 17:18
|
||||
*/
|
||||
@Service
|
||||
public class TriggerRecordServiceImpl extends SuperServiceImpl<TriggerRecordMapper, TriggerRecordEntity>
|
||||
implements TriggerRecordService {
|
||||
|
||||
@Override
|
||||
public List<TriggerRecordEntity> getList(String triggerTaskId) {
|
||||
if (StringUtil.isBlank(triggerTaskId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<TriggerRecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TriggerRecordEntity::getTriggerId, triggerTaskId)
|
||||
.orderByAsc(TriggerRecordEntity::getStartTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TriggerRecordEntity> getListByTaskId(String taskId) {
|
||||
if (StringUtil.isBlank(taskId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryWrapper<TriggerRecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TriggerRecordEntity::getTaskId, taskId).orderByDesc(TriggerRecordEntity::getStartTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
// @DSTransactional(propagation = DsPropagation.NOT_SUPPORTED)
|
||||
public void create(TriggerRecordEntity entity) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setCreatorTime(new Date());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
// @DSTransactional(propagation = DsPropagation.NOT_SUPPORTED)
|
||||
public void create(TriggerTaskEntity triggerTask, NodeModel nodeModel, FlowableTaskModel taskModel) {
|
||||
TriggerRecordEntity entity = new TriggerRecordEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setStatus(TriggerRecordEnum.PASSED.getCode());
|
||||
Date date = new Date();
|
||||
entity.setStartTime(date);
|
||||
entity.setEndTime(date);
|
||||
|
||||
entity.setNodeCode(nodeModel.getNodeId());
|
||||
entity.setNodeName(nodeModel.getNodeName());
|
||||
entity.setNodeId(taskModel.getTaskId());
|
||||
|
||||
entity.setTriggerId(triggerTask.getId());
|
||||
if (StringUtil.isNotEmpty(triggerTask.getTaskId())) {
|
||||
entity.setTaskId(triggerTask.getTaskId());
|
||||
}
|
||||
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
// @DSTransactional(propagation = DsPropagation.NOT_SUPPORTED)
|
||||
public void createStart(String triggerId) {
|
||||
TriggerRecordEntity entity = new TriggerRecordEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setStatus(TriggerRecordEnum.PASSED.getCode());
|
||||
Date date = new Date();
|
||||
entity.setStartTime(date);
|
||||
entity.setEndTime(date);
|
||||
entity.setTriggerId(triggerId);
|
||||
entity.setNodeCode(FlowNature.START_CODE);
|
||||
entity.setNodeName(FlowNature.START_NAME);
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createEnd(String triggerId) {
|
||||
TriggerRecordEntity entity = new TriggerRecordEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setStatus(TriggerRecordEnum.PASSED.getCode());
|
||||
Date date = new Date();
|
||||
entity.setStartTime(date);
|
||||
entity.setEndTime(date);
|
||||
entity.setTriggerId(triggerId);
|
||||
entity.setNodeCode(FlowNature.END_CODE);
|
||||
entity.setNodeName(FlowNature.END_NAME);
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> triggerTaskIds) {
|
||||
if (CollectionUtil.isNotEmpty(triggerTaskIds)) {
|
||||
QueryWrapper<TriggerRecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TriggerRecordEntity::getTriggerId, triggerTaskIds);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.yunzhupaas.flowable.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.enums.DivideRuleEnum;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.enums.TaskStatusEnum;
|
||||
import com.yunzhupaas.flowable.mapper.TriggerTaskMapper;
|
||||
import com.yunzhupaas.flowable.model.templatejson.TemplateJsonInfoVO;
|
||||
import com.yunzhupaas.flowable.model.templatenode.ButtonModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.TaskNodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.*;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.*;
|
||||
import com.yunzhupaas.flowable.util.TriggerUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/9/10 17:13
|
||||
*/
|
||||
@Service
|
||||
public class TriggerTaskServiceImpl extends SuperServiceImpl<TriggerTaskMapper, TriggerTaskEntity>
|
||||
implements TriggerTaskService {
|
||||
@Autowired
|
||||
private TriggerRecordService triggerRecordService;
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
@Autowired
|
||||
private TemplateJsonService templateJsonService;
|
||||
@Autowired
|
||||
private TemplateNodeService templateNodeService;
|
||||
@Autowired
|
||||
private TriggerUtil triggerUtil;
|
||||
|
||||
@Override
|
||||
public List<TriggerInfoListModel> getListByTaskId(String taskId, String nodeCode) {
|
||||
QueryWrapper<TriggerTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotBlank(taskId)) {
|
||||
queryWrapper.lambda().eq(TriggerTaskEntity::getTaskId, taskId);
|
||||
}
|
||||
if (StringUtil.isNotBlank(nodeCode)) {
|
||||
queryWrapper.lambda().eq(TriggerTaskEntity::getNodeId, nodeCode);
|
||||
}
|
||||
queryWrapper.lambda().orderByDesc(TriggerTaskEntity::getStartTime);
|
||||
List<TriggerTaskEntity> list = this.list(queryWrapper);
|
||||
List<TriggerInfoListModel> modelList = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (TriggerTaskEntity triggerTask : list) {
|
||||
TriggerInfoListModel model = JsonUtil.getJsonToBean(triggerTask, TriggerInfoListModel.class);
|
||||
List<TriggerRecordEntity> recordList = triggerRecordService.getList(triggerTask.getId());
|
||||
model.setRecordList(recordList);
|
||||
modelList.add(model);
|
||||
}
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existTriggerTask(String taskId, String nodeId) {
|
||||
if (StringUtil.isBlank(taskId) || StringUtil.isBlank(nodeId)) {
|
||||
return false;
|
||||
}
|
||||
QueryWrapper<TriggerTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TriggerTaskEntity::getTaskId, taskId)
|
||||
.eq(TriggerTaskEntity::getNodeId, nodeId);
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TriggerTaskEntity> getList(TriggerPagination pagination) {
|
||||
QueryWrapper<TriggerTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().and(e -> e.like(TriggerTaskEntity::getFullName, pagination.getKeyword())
|
||||
.or().like(TriggerTaskEntity::getId, pagination.getKeyword()));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getStartTime()) && ObjectUtil.isNotEmpty(pagination.getEndTime())) {
|
||||
queryWrapper.lambda().between(TriggerTaskEntity::getStartTime, new Date(pagination.getStartTime()),
|
||||
new Date(pagination.getEndTime()));
|
||||
}
|
||||
queryWrapper.lambda().isNull(TriggerTaskEntity::getTaskId).orderByDesc(TriggerTaskEntity::getCreatorTime);
|
||||
Page<TriggerTaskEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
Page<TriggerTaskEntity> iPage = this.page(page, queryWrapper);
|
||||
return pagination.setData(iPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggerInfoModel getInfo(String id) throws WorkFlowException {
|
||||
TriggerTaskEntity triggerTask = this.getById(id);
|
||||
if (null == triggerTask) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
TriggerInfoModel model = new TriggerInfoModel();
|
||||
model.setTaskInfo(JsonUtil.getJsonToBean(triggerTask, TriggerTaskModel.class));
|
||||
TemplateJsonInfoVO jsonInfoVO = templateJsonService.getInfoVo(triggerTask.getFlowId());
|
||||
model.setFlowInfo(jsonInfoVO);
|
||||
List<TriggerRecordEntity> recordList = triggerRecordService.getList(triggerTask.getId());
|
||||
List<TaskNodeModel> nodeList = this.getNodeList(triggerTask, recordList);
|
||||
model.setNodeList(nodeList);
|
||||
recordList = recordList.stream().filter(e -> e.getStatus() != null).collect(Collectors.toList());
|
||||
model.setRecordList(recordList);
|
||||
ButtonModel btnInfo = model.getBtnInfo();
|
||||
if (ObjectUtil.equals(triggerTask.getStatus(), TaskStatusEnum.RUNNING.getCode())) {
|
||||
btnInfo.setHasCancelBtn(true);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public List<TaskNodeModel> getNodeList(TriggerTaskEntity triggerTask, List<TriggerRecordEntity> recordList) {
|
||||
List<TaskNodeModel> list = new ArrayList<>();
|
||||
if (ObjectUtil.equals(triggerTask.getStatus(), TaskStatusEnum.CANCEL.getCode())) {
|
||||
return list;
|
||||
}
|
||||
String flowId = triggerTask.getFlowId();
|
||||
List<TemplateNodeEntity> nodeEntityList = templateNodeService.getList(flowId);
|
||||
List<String> typeList = ImmutableList.of(NodeEnum.global.getType(), NodeEnum.connect.getType(), "confluence",
|
||||
"gateway");
|
||||
List<String> divideList = Arrays.stream(DivideRuleEnum.values()).map(DivideRuleEnum::getType)
|
||||
.collect(Collectors.toList());
|
||||
divideList.addAll(typeList);
|
||||
for (TemplateNodeEntity node : nodeEntityList) {
|
||||
if (divideList.contains(node.getNodeType())) {
|
||||
continue;
|
||||
}
|
||||
TaskNodeModel model = new TaskNodeModel();
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(node.getNodeJson(), NodeModel.class);
|
||||
model.setNodeName(nodeModel.getNodeName());
|
||||
model.setNodeCode(nodeModel.getNodeId());
|
||||
model.setNodeType(nodeModel.getType());
|
||||
|
||||
String type = null;
|
||||
String nodeCode = node.getNodeCode();
|
||||
if (ObjectUtil.equals(node.getNodeType(), NodeEnum.start.getType())) {
|
||||
nodeCode = FlowNature.START_CODE;
|
||||
} else if (ObjectUtil.equals(node.getNodeType(), NodeEnum.end.getType())) {
|
||||
nodeCode = FlowNature.END_CODE;
|
||||
}
|
||||
String finalNodeCode = nodeCode;
|
||||
TriggerRecordEntity record = recordList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getNodeCode(), finalNodeCode)).findFirst().orElse(null);
|
||||
if (null != record) {
|
||||
if (ObjectUtil.equals(record.getStatus(), 1)) {
|
||||
type = "3";
|
||||
} else if (ObjectUtil.equals(record.getStatus(), 0)) {
|
||||
type = "0";
|
||||
} else {
|
||||
type = "1";
|
||||
}
|
||||
}
|
||||
model.setType(type);
|
||||
list.add(model);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
// @DSTransactional
|
||||
public void retry(String id) throws Exception {
|
||||
TriggerTaskEntity triggerTask = this.getById(id);
|
||||
if (null == triggerTask) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
TemplateJsonEntity jsonEntity = templateJsonService.getInfo(triggerTask.getFlowId());
|
||||
TemplateEntity template = templateService.getInfo(jsonEntity.getTemplateId());
|
||||
if (!ObjectUtil.equals(template.getStatus(), 1)) {
|
||||
throw new WorkFlowException(MsgCode.WF146.get());
|
||||
}
|
||||
ExecuteModel model = new ExecuteModel();
|
||||
model.setFlowId(triggerTask.getFlowId());
|
||||
List<Map> jsonToList = JsonUtil.getJsonToList(triggerTask.getData(), Map.class);
|
||||
List<Map<String, Object>> dataList = triggerUtil.castListMap(jsonToList);
|
||||
model.setDataList(dataList);
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
model.setUserInfo(userInfo);
|
||||
model.setParentId(triggerTask.getId());
|
||||
triggerUtil.execute(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTriggerTask(TriggerTaskEntity entity) {
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTriggerTask(TriggerTaskEntity entity) {
|
||||
this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDelete(List<String> ids) {
|
||||
if (ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
this.removeByIds(ids);
|
||||
triggerRecordService.delete(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByTaskId(List<String> taskId) {
|
||||
if (CollectionUtil.isEmpty(taskId)) {
|
||||
return;
|
||||
}
|
||||
QueryWrapper<TriggerTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TriggerTaskEntity::getTaskId, taskId);
|
||||
List<TriggerTaskEntity> list = this.list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
List<String> ids = list.stream().map(TriggerTaskEntity::getId).collect(Collectors.toList());
|
||||
this.setIgnoreLogicDelete().removeByIds(ids);
|
||||
this.clearIgnoreLogicDelete();
|
||||
QueryWrapper<TriggerRecordEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().in(TriggerRecordEntity::getTriggerId, ids);
|
||||
triggerRecordService.setIgnoreLogicDelete().remove(wrapper);
|
||||
triggerRecordService.clearIgnoreLogicDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkByFlowIds(List<String> flowIds) {
|
||||
if (CollectionUtil.isNotEmpty(flowIds)) {
|
||||
QueryWrapper<TriggerTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(TriggerTaskEntity::getFlowId, flowIds);
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,735 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.model.systemconfig.SysConfigModel;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.enums.OperatorStateEnum;
|
||||
import com.yunzhupaas.flowable.enums.RecordEnum;
|
||||
import com.yunzhupaas.flowable.enums.TaskStatusEnum;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowAbleUrl;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowableNodeModel;
|
||||
import com.yunzhupaas.flowable.model.flowable.NextOrPrevFo;
|
||||
import com.yunzhupaas.flowable.model.operator.AddSignModel;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.ButtonModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.TaskNodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.FileConfig;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.PrintConfig;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.ProperCond;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.*;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/5/16 17:35
|
||||
*/
|
||||
@Component
|
||||
public class ButtonUtil {
|
||||
@Autowired
|
||||
private OperatorService operatorService;
|
||||
@Autowired
|
||||
private FlowAbleUrl flowAbleUrl;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private OperatorUtil operatorUtil;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private RevokeService revokeService;
|
||||
@Autowired
|
||||
private DelegateService delegateService;
|
||||
@Autowired
|
||||
private TriggerRecordService triggerRecordService;
|
||||
@Autowired
|
||||
private RecordService recordService;
|
||||
|
||||
/**
|
||||
* 按钮控制
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
public ButtonModel handleButton(FlowModel flowModel) throws WorkFlowException {
|
||||
String opType = flowModel.getOpType();
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
OperatorEntity operatorEntity = flowModel.getOperatorEntity();
|
||||
RecordEntity recordEntity = flowModel.getRecordEntity();
|
||||
Map<String, Object> formData = flowModel.getFormData();
|
||||
List<TaskNodeModel> nodeList = flowModel.getNodeList();
|
||||
TemplateEntity template = flowModel.getTemplateEntity();
|
||||
UserInfo userInfo = flowModel.getUserInfo() == null ? UserProvider.getUser() : flowModel.getUserInfo();
|
||||
String userId = userInfo.getUserId();
|
||||
|
||||
List<TemplateNodeEntity> nodeEntityList = flowModel.getNodeEntityList();
|
||||
Map<String, NodeModel> nodes = new HashMap<>();
|
||||
for (TemplateNodeEntity nodeEntity : nodeEntityList) {
|
||||
nodes.put(nodeEntity.getNodeCode(), JsonUtil.getJsonToBean(nodeEntity.getNodeJson(), NodeModel.class));
|
||||
}
|
||||
flowModel.setNodes(nodes);
|
||||
RevokeEntity revokeEntity = revokeService.getRevokeTask(taskEntity.getId());
|
||||
|
||||
// 全局节点
|
||||
NodeModel global = nodes.get(NodeEnum.global.getType());
|
||||
|
||||
ButtonModel model = new ButtonModel();
|
||||
FlowMethod flowMethod = new FlowMethod();
|
||||
flowMethod.setNodes(nodes);
|
||||
flowMethod.setTaskEntity(taskEntity);
|
||||
flowMethod.setFormData(formData);
|
||||
flowMethod.setPrintNodeList(nodeList);
|
||||
switch (opType) {
|
||||
case "-1": // 我发起的新建/编辑
|
||||
// List<Integer> templateStatus = ImmutableList.of(1, 2);
|
||||
// if (!templateStatus.contains(template.getStatus())) {
|
||||
// break;
|
||||
// }
|
||||
// 是否是退回撤回的任务
|
||||
List<Integer> taskStatus = ImmutableList.of(TaskStatusEnum.BACKED.getCode(),
|
||||
TaskStatusEnum.RECALL.getCode());
|
||||
boolean isBack = null != taskEntity && taskStatus.contains(taskEntity.getStatus());
|
||||
if (isBack) {
|
||||
// 是否是委托的任务
|
||||
boolean isDelegate = StringUtil.isNotBlank(taskEntity.getDelegateUserId());
|
||||
if (isDelegate) {
|
||||
if (ObjectUtil.equals(taskEntity.getParentId(), "0")) {
|
||||
model.setHasDelegateSubmitBtn(this.checkDelegateSubmit(userId, template));
|
||||
}
|
||||
} else {
|
||||
model.setHasSubmitBtn(true);
|
||||
}
|
||||
model.setHasSaveBtn(true);
|
||||
} else {
|
||||
boolean commonUser = serviceUtil.isCommonUser(userId);
|
||||
if (commonUser && ObjectUtil.equals(template.getVisibleType(), 2)) {
|
||||
List<String> permission = serviceUtil.getLaunchPermission(userId);
|
||||
if (permission.contains(template.getId())) {
|
||||
model.setHasSubmitBtn(true);
|
||||
model.setHasSaveBtn(true);
|
||||
}
|
||||
} else {
|
||||
model.setHasSubmitBtn(true);
|
||||
model.setHasSaveBtn(true);
|
||||
}
|
||||
// 委托发起
|
||||
if (null == taskEntity.getId()) {
|
||||
model.setHasDelegateSubmitBtn(this.checkDelegateSubmit(userId, template));
|
||||
} else {
|
||||
if (ObjectUtil.equals(taskEntity.getParentId(), "0")) {
|
||||
model.setHasDelegateSubmitBtn(this.checkDelegateSubmit(userId, template));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "0": // 我发起的详情
|
||||
// 打印
|
||||
TemplateNodeEntity start = nodeEntityList.stream()
|
||||
.filter(e -> e.getNodeType().equals(NodeEnum.start.getType())).findFirst().orElse(null);
|
||||
if (null != start) {
|
||||
NodeModel startNode = JsonUtil.getJsonToBean(start.getNodeJson(), NodeModel.class);
|
||||
flowMethod.setNodeModel(startNode);
|
||||
model.setHasPrintBtn(this.checkPrint(flowMethod));
|
||||
}
|
||||
// 催办
|
||||
List<Integer> statusList = ImmutableList.of(TaskStatusEnum.RUNNING.getCode(),
|
||||
TaskStatusEnum.REVOKING.getCode());
|
||||
if (global.getHasInitiatorPressOverdueNode() && statusList.contains(taskEntity.getStatus())) {
|
||||
QueryWrapper<OperatorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OperatorEntity::getTaskId, taskEntity.getId())
|
||||
.eq(OperatorEntity::getCompletion, 0)
|
||||
.ne(OperatorEntity::getStatus, OperatorStateEnum.Futility.getCode())
|
||||
.isNull(OperatorEntity::getHandleStatus).isNotNull(OperatorEntity::getDuedate);
|
||||
List<OperatorEntity> operatorList = operatorService.list(queryWrapper);
|
||||
if (!operatorList.isEmpty()) {
|
||||
model.setHasPressBtn(true);
|
||||
}
|
||||
}
|
||||
// 撤回
|
||||
if (null == revokeEntity) {
|
||||
flowModel.setFlag(1);
|
||||
if (this.checkRecall(flowModel)) {
|
||||
model.setHasRecallLaunchBtn(true);
|
||||
}
|
||||
}
|
||||
// 撤销,全局属性开启 且 同意状态的任务才能撤销 且不是子流程
|
||||
if (global.getHasRevoke() && Objects.equals(taskEntity.getStatus(), TaskStatusEnum.PASSED.getCode())
|
||||
&& Objects.equals(taskEntity.getParentId(), "0")) {
|
||||
Boolean isExist = revokeService.checkExist(taskEntity.getId());
|
||||
if (null == revokeEntity && isExist) {
|
||||
model.setHasRevokeBtn(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "1": // 待签事宜
|
||||
if (Objects.equals(taskEntity.getStatus(), TaskStatusEnum.PAUSED.getCode())) {
|
||||
break;
|
||||
}
|
||||
model.setHasSignBtn(true);
|
||||
if (null != operatorEntity) {
|
||||
model.setProxyMark(!ObjectUtil.equals(operatorEntity.getHandleId(), userId));
|
||||
NodeModel nodeModel = nodes.get(operatorEntity.getNodeCode());
|
||||
if (this.checkViewStartForm(global, nodeModel)) {
|
||||
model.setHasViewStartFormBtn(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "2": // 待办事宜
|
||||
if (Objects.equals(taskEntity.getStatus(), TaskStatusEnum.PAUSED.getCode())) {
|
||||
break;
|
||||
}
|
||||
if (global.getHasSignFor()) {
|
||||
model.setHasReduceSignBtn(true);
|
||||
}
|
||||
model.setHasTransactBtn(true);
|
||||
if (null != operatorEntity) {
|
||||
NodeModel nodeModel = nodes.get(operatorEntity.getNodeCode());
|
||||
if (this.checkViewStartForm(global, nodeModel)) {
|
||||
model.setHasViewStartFormBtn(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "3": // 在办事宜
|
||||
if (Objects.equals(taskEntity.getStatus(), TaskStatusEnum.PAUSED.getCode())) {
|
||||
break;
|
||||
}
|
||||
if (null == operatorEntity) {
|
||||
break;
|
||||
}
|
||||
// 待办的opType传的也是3,所以待办的代理标识需要再在办判断
|
||||
model.setProxyMark(!ObjectUtil.equals(operatorEntity.getHandleId(), userId));
|
||||
if (null != revokeEntity) {
|
||||
model.setHasAuditBtn(true);
|
||||
model.setHasRejectBtn(true);
|
||||
break;
|
||||
}
|
||||
NodeModel nodeModel = nodes.get(operatorEntity.getNodeCode());
|
||||
if (null == nodeModel) {
|
||||
break;
|
||||
}
|
||||
if (this.checkViewStartForm(global, nodeModel)) {
|
||||
model.setHasViewStartFormBtn(true);
|
||||
}
|
||||
// 协办状态的经办 只有协办保存按钮
|
||||
if (OperatorStateEnum.Assist.getCode().equals(operatorEntity.getStatus())) {
|
||||
model.setHasAssistSaveBtn(true);
|
||||
break;
|
||||
}
|
||||
// 打印
|
||||
flowMethod.setNodeModel(nodeModel);
|
||||
model.setHasPrintBtn(this.checkPrint(flowMethod));
|
||||
if (nodeModel.getHasAuditBtn()) {
|
||||
model.setHasAuditBtn(true);
|
||||
}
|
||||
if (nodeModel.getHasRejectBtn() && ObjectUtil.equals(operatorEntity.getIsProcessing(), 0)) {
|
||||
model.setHasRejectBtn(true);
|
||||
}
|
||||
if (nodeModel.getHasBackBtn() && taskEntity.getRejectDataId() == null) {
|
||||
model.setHasBackBtn(true);
|
||||
}
|
||||
if (nodeModel.getHasSaveAuditBtn()) {
|
||||
model.setHasSaveAuditBtn(true);
|
||||
}
|
||||
List<Integer> operatorState = ImmutableList.of(OperatorStateEnum.AddSign.getCode(),
|
||||
OperatorStateEnum.Transfer.getCode());
|
||||
if (nodeModel.getHasFreeApproverBtn()) {
|
||||
if (!ObjectUtil.equals(operatorEntity.getStatus(), OperatorStateEnum.Transfer.getCode())) {
|
||||
model.setHasFreeApproverBtn(this.checkAddSign(operatorEntity, null, false));
|
||||
}
|
||||
}
|
||||
if (nodeModel.getHasTransferBtn()) {
|
||||
if (!operatorState.contains(operatorEntity.getStatus())
|
||||
&& ObjectUtil.equals(operatorEntity.getParentId(), "0")) {
|
||||
model.setHasTransferBtn(true);
|
||||
}
|
||||
}
|
||||
if (nodeModel.getHasAssistBtn()) {
|
||||
model.setHasAssistBtn(true);
|
||||
}
|
||||
break;
|
||||
case "4": // 已办事宜
|
||||
if (null == operatorEntity || operatorEntity.getId() == null) {
|
||||
break;
|
||||
}
|
||||
// 减签
|
||||
NodeModel node = nodes.get(operatorEntity.getNodeCode());
|
||||
// 节点属性开启、经办存在加签信息、记录是加签操作
|
||||
if (node != null) {
|
||||
if (null != recordEntity) {
|
||||
if (node.getHasReduceApproverBtn() && null != operatorEntity.getHandleParameter()
|
||||
&& recordEntity.getHandleType().equals(RecordEnum.addSign.getCode())) {
|
||||
QueryWrapper<OperatorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OperatorEntity::getTaskId, operatorEntity.getTaskId())
|
||||
.eq(OperatorEntity::getParentId, operatorEntity.getId())
|
||||
.ne(OperatorEntity::getStatus, OperatorStateEnum.Futility.getCode())
|
||||
.ne(OperatorEntity::getStatus, OperatorStateEnum.Assist.getCode())
|
||||
.eq(OperatorEntity::getCompletion, 0).isNull(OperatorEntity::getHandleStatus);
|
||||
List<OperatorEntity> list = operatorService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
model.setHasReduceApproverBtn(true);
|
||||
}
|
||||
}
|
||||
// 审批撤回
|
||||
List<Integer> handleTypes = ImmutableList.of(RecordEnum.audit.getCode(),
|
||||
RecordEnum.reject.getCode());
|
||||
if (handleTypes.contains(recordEntity.getHandleType())) {
|
||||
flowModel.setFlag(2);
|
||||
if (this.checkRecall(flowModel)) {
|
||||
model.setHasRecallAuditBtn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
flowMethod.setNodeModel(node);
|
||||
// 打印
|
||||
model.setHasPrintBtn(this.checkPrint(flowMethod));
|
||||
if (this.checkViewStartForm(global, node)) {
|
||||
model.setHasViewStartFormBtn(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "5": // 抄送事宜
|
||||
if (null != operatorEntity) {
|
||||
NodeModel node1 = nodes.get(operatorEntity.getNodeCode());
|
||||
if (this.checkViewStartForm(global, node1)) {
|
||||
model.setHasViewStartFormBtn(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "6": // 流程监控
|
||||
if (!userInfo.getIsAdministrator()) {
|
||||
List<String> organizeUserList = serviceUtil.getOrganizeUserList("edit");
|
||||
if (!organizeUserList.contains(taskEntity.getCreatorUserId())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 终止状态下只有复活
|
||||
if (ObjectUtil.equals(taskEntity.getStatus(), TaskStatusEnum.CANCEL.getCode())
|
||||
&& ObjectUtil.equals(taskEntity.getParentId(), "0")
|
||||
&& ObjectUtil.equals(template.getStatus(), 1)) {
|
||||
List<TriggerRecordEntity> triggerRecordList = triggerRecordService
|
||||
.getListByTaskId(taskEntity.getId());
|
||||
long count = triggerRecordList.stream().filter(e -> ObjectUtil.equals(e.getStatus(), 1)).count();
|
||||
if (count == 0) {
|
||||
model.setHasActivateBtn(true);
|
||||
}
|
||||
}
|
||||
// 挂起状态下只有恢复
|
||||
if (ObjectUtil.equals(taskEntity.getStatus(), TaskStatusEnum.PAUSED.getCode())) {
|
||||
if (!ObjectUtil.equals(taskEntity.getIsRestore(), 1)) {
|
||||
model.setHasRebootBtn(true);
|
||||
}
|
||||
}
|
||||
// 运行状态下,终止、挂起
|
||||
if (ObjectUtil.equals(taskEntity.getStatus(), TaskStatusEnum.RUNNING.getCode())) {
|
||||
// 子流程不允许终止
|
||||
if (ObjectUtil.equals(taskEntity.getParentId(), "0")) {
|
||||
model.setHasCancelBtn(true);
|
||||
}
|
||||
model.setHasPauseBtn(true);
|
||||
if (this.checkAssign(taskEntity, nodes)) {
|
||||
model.setHasAssignBtn(true);
|
||||
}
|
||||
}
|
||||
// 归档按钮
|
||||
FileConfig config = global.getFileConfig();
|
||||
if (config.getOn() && StringUtil.isNotBlank(config.getTemplateId())) {
|
||||
if (ObjectUtil.isNotEmpty(taskEntity.getEndTime())
|
||||
|| ObjectUtil.equals(taskEntity.getStatus(), TaskStatusEnum.CANCEL.getCode())) {
|
||||
if (serviceUtil.checkFlowFile(taskEntity.getId())) {
|
||||
model.setHasFileBtn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
// 判断指派,当前节点全是子流程,就隐藏
|
||||
public boolean checkAssign(TaskEntity taskEntity, Map<String, NodeModel> nodes) {
|
||||
String currentNodeCode = taskEntity.getCurrentNodeCode();
|
||||
if (StringUtil.isNotBlank(currentNodeCode)) {
|
||||
List<String> currentNodeList = Arrays.stream(currentNodeCode.split(",")).collect(Collectors.toList());
|
||||
for (String nodeCode : currentNodeList) {
|
||||
NodeModel nodeModel = nodes.get(nodeCode);
|
||||
if (null != nodeModel && !Objects.equals(nodeModel.getType(), NodeEnum.subFlow.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 委托发起按钮
|
||||
public boolean checkDelegateSubmit(String userId, TemplateEntity template) {
|
||||
List<DelegateEntity> delegateList = delegateService.getByToUserId(userId, 0);
|
||||
if (CollectionUtil.isNotEmpty(delegateList) && ObjectUtil.equals(template.getStatus(), 1)) {
|
||||
for (DelegateEntity delegateEntity : delegateList) {
|
||||
String flowId = delegateEntity.getFlowId();
|
||||
if (StringUtil.isNotBlank(flowId)) {
|
||||
if (flowId.contains(template.getId())) {
|
||||
if (ObjectUtil.equals(template.getVisibleType(), 1)) {
|
||||
return true;
|
||||
}
|
||||
List<String> launchPermission = serviceUtil.getLaunchPermission(delegateEntity.getUserId());
|
||||
if (launchPermission.contains(template.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 全部流程
|
||||
if (ObjectUtil.equals(template.getVisibleType(), 1)) {
|
||||
return true;
|
||||
}
|
||||
List<String> launchPermission = serviceUtil.getLaunchPermission(delegateEntity.getUserId());
|
||||
if (launchPermission.contains(template.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看发起表单
|
||||
*/
|
||||
public boolean checkViewStartForm(NodeModel global, NodeModel nodeModel) {
|
||||
if (null != nodeModel) {
|
||||
if (global.getHasAloneConfigureForms() && StringUtil.isNotBlank(nodeModel.getFormId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断撤回
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
public boolean checkRecall(FlowModel flowModel) throws WorkFlowException {
|
||||
String deploymentId = flowModel.getDeploymentId();
|
||||
String currentNodeCode = flowModel.getNodeEntity().getNodeCode();
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
RecordEntity recordEntity = flowModel.getRecordEntity();
|
||||
Map<String, NodeModel> nodes = flowModel.getNodes();
|
||||
// 判断撤回的标识 1.发起撤回 2.审批撤回
|
||||
int flag = flowModel.getFlag();
|
||||
boolean isException = flowModel.getIsException();
|
||||
|
||||
NodeModel global = nodes.get(NodeEnum.global.getType());
|
||||
Integer recallRule = global.getRecallRule();
|
||||
|
||||
// 全局撤回配置为1 直接不允许撤回 (流程撤回规则 1: 不允许撤回 2: 发起节点允许撤回 3:所有节点允许撤回)
|
||||
if (recallRule == null || recallRule == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 不是进行中的任务、存在退回冻结数据
|
||||
if (!Objects.equals(TaskStatusEnum.RUNNING.getCode(), taskEntity.getStatus())
|
||||
|| null != taskEntity.getRejectDataId()) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF036.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// 经办未审批 说明是已撤回的,不允许撤回
|
||||
OperatorEntity operator = operatorService.getInfo(recordEntity.getOperatorId());
|
||||
if (null != operator) {
|
||||
if (!ObjectUtil.equals(operator.getParentId(), "0")) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF077.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// 判断依次审批
|
||||
boolean inTurn = this.checkInTurn(operator, isException);
|
||||
if (!inTurn && !isException) {
|
||||
return false;
|
||||
}
|
||||
if (operator.getHandleStatus() == null) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF006.get());
|
||||
}
|
||||
return false;
|
||||
} else if (null == operator.getHandleTime()) {
|
||||
// 后加签的同意未真正审批,不允许撤回
|
||||
List<OperatorEntity> childList = operatorUtil.getChildList(operator.getId());
|
||||
if (CollectionUtil.isNotEmpty(childList)) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF006.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 发起撤回的校验
|
||||
QueryWrapper<RecordEntity> recordWrapper = new QueryWrapper<>();
|
||||
recordWrapper.lambda().eq(RecordEntity::getTaskId, taskEntity.getId())
|
||||
.and(t -> t.ne(RecordEntity::getStatus, -1).or().eq(RecordEntity::getHandleType,
|
||||
RecordEnum.back.getCode()));
|
||||
List<RecordEntity> recordList = recordService.list(recordWrapper);
|
||||
if (CollectionUtil.isNotEmpty(recordList)) {
|
||||
RecordEntity submit = recordList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getHandleType(), RecordEnum.submit.getCode())).findFirst()
|
||||
.orElse(null);
|
||||
if (null != submit) {
|
||||
recordList = recordList.stream()
|
||||
.filter(e -> !ObjectUtil.equals(e.getNodeCode(), submit.getNodeCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (!recordList.isEmpty()) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF006.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取节点的下一级节点,判断撤回
|
||||
NextOrPrevFo fo = new NextOrPrevFo();
|
||||
fo.setDeploymentId(deploymentId);
|
||||
fo.setTaskKey(currentNodeCode);
|
||||
List<FlowableNodeModel> nextModels = flowAbleUrl.getNext(fo);
|
||||
List<String> nextCodes = nextModels.stream().map(FlowableNodeModel::getId).collect(Collectors.toList());
|
||||
// 审批撤回需要用到下一级节点
|
||||
flowModel.setNextCodes(nextCodes);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(nextCodes)) {
|
||||
QueryWrapper<TaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TaskEntity::getParentId, taskEntity.getId())
|
||||
.in(TaskEntity::getSubCode, nextCodes);
|
||||
List<TaskEntity> list = taskService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
// 异步子流程,不允许撤回
|
||||
long asyncCount = list.stream().filter(e -> Objects.equals(e.getIsAsync(), FlowNature.ChildAsync))
|
||||
.count();
|
||||
if (asyncCount > 0) {
|
||||
return false;
|
||||
}
|
||||
long count = list.stream()
|
||||
.filter(e -> !Objects.equals(e.getStatus(), TaskStatusEnum.TO_BE_SUBMIT.getCode())).count();
|
||||
if (count > 0) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF036.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag == 2 && recallRule == 2) {
|
||||
return false;
|
||||
}
|
||||
if (CollectionUtil.isEmpty(nextCodes)) {
|
||||
return true;
|
||||
}
|
||||
// 存在已办理的经办,撤回后可以重新提交(下个审批节点只进行了签收 此时还可以撤回)
|
||||
QueryWrapper<OperatorEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(OperatorEntity::getTaskId, taskEntity.getId());
|
||||
if (CollectionUtil.isNotEmpty(nextCodes)) {
|
||||
wrapper.lambda().in(OperatorEntity::getNodeCode, nextCodes);
|
||||
}
|
||||
wrapper.lambda().orderByDesc(OperatorEntity::getCreatorTime);
|
||||
List<OperatorEntity> list = operatorService.list(wrapper);
|
||||
boolean mark = this.checkDraftAndRecord(list);
|
||||
if (mark) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF077.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 依次审批的撤回判断
|
||||
public boolean checkInTurn(OperatorEntity operator, boolean isException) throws WorkFlowException {
|
||||
if (StringUtil.isNotBlank(operator.getHandleAll())) {
|
||||
List<String> handleIds = Arrays.stream(operator.getHandleAll().split(",")).collect(Collectors.toList());
|
||||
int index = handleIds.indexOf(operator.getHandleId());
|
||||
if (index != -1 && index < handleIds.size() - 1) {
|
||||
String nextHandleId = handleIds.get(index + 1);
|
||||
QueryWrapper<OperatorEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(OperatorEntity::getHandleId, nextHandleId)
|
||||
.eq(OperatorEntity::getParentId, operator.getParentId())
|
||||
.eq(OperatorEntity::getNodeId, operator.getNodeId())
|
||||
.orderByDesc(OperatorEntity::getCreatorTime);
|
||||
List<OperatorEntity> list = operatorService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
OperatorEntity nextOperator = list.get(0);
|
||||
if (StringUtil.isNotEmpty(nextOperator.getDraftData())) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF036.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
QueryWrapper<RecordEntity> recordWrapper = new QueryWrapper<>();
|
||||
recordWrapper.lambda().eq(RecordEntity::getOperatorId, nextOperator.getId())
|
||||
.ne(RecordEntity::getStatus, -1);
|
||||
List<RecordEntity> recordList = recordService.list(recordWrapper);
|
||||
if (CollectionUtil.isNotEmpty(recordList)) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF036.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkDraftAndRecord(List<OperatorEntity> list) {
|
||||
return this.checkDraftAndRecord(list, false);
|
||||
}
|
||||
|
||||
// 判断草稿、操作记录
|
||||
public boolean checkDraftAndRecord(List<OperatorEntity> list, boolean filterAddSign) {
|
||||
list = list.stream().filter(e -> !ObjectUtil.equals(e.getStatus(), -1)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return false;
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(list)) {
|
||||
// // 回流的处理
|
||||
// OperatorEntity first = list.get(0);
|
||||
// list = list.stream().filter(e -> ObjectUtil.equals(first.getNodeId(),
|
||||
// e.getNodeId())).collect(Collectors.toList());
|
||||
// }
|
||||
// 只要有操作就不让撤回,草稿数据(暂存)
|
||||
long draftCount = list.stream().filter(e -> StringUtil.isNotEmpty(e.getDraftData())).count();
|
||||
boolean mark = false;
|
||||
// 不存在草稿数据,继续根据记录判断
|
||||
if (draftCount == 0) {
|
||||
List<String> collect = list.stream().map(OperatorEntity::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(collect)) {
|
||||
QueryWrapper<RecordEntity> recordWrapper = new QueryWrapper<>();
|
||||
recordWrapper.lambda().in(RecordEntity::getOperatorId, collect).ne(RecordEntity::getStatus, -1);
|
||||
List<RecordEntity> recordList = recordService.list(recordWrapper);
|
||||
if (filterAddSign) {
|
||||
List<Integer> status = ImmutableList.of(RecordEnum.addSign.getCode(),
|
||||
RecordEnum.subtractSign.getCode());
|
||||
recordList = recordList.stream().filter(e -> !status.contains(e.getHandleType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
mark = !recordList.isEmpty();
|
||||
}
|
||||
} else {
|
||||
mark = true;
|
||||
}
|
||||
return mark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断打印
|
||||
*/
|
||||
public boolean checkPrint(FlowMethod flowMethod) {
|
||||
NodeModel nodeModel = flowMethod.getNodeModel();
|
||||
TaskEntity taskEntity = flowMethod.getTaskEntity();
|
||||
Map<String, Object> formData = flowMethod.getFormData();
|
||||
List<TaskNodeModel> nodeList = flowMethod.getPrintNodeList();
|
||||
|
||||
// 发起除了草稿状态都显示
|
||||
if (Objects.equals(taskEntity.getStatus(), TaskStatusEnum.TO_BE_SUBMIT.getCode())) {
|
||||
return false;
|
||||
}
|
||||
PrintConfig printConfig = nodeModel.getPrintConfig();
|
||||
if (printConfig.getOn()) {
|
||||
// 打印没有选择模版,按钮不显示
|
||||
if (CollectionUtil.isEmpty(printConfig.getPrintIds())) {
|
||||
return false;
|
||||
}
|
||||
switch (printConfig.getConditionType()) {
|
||||
case 1:
|
||||
// 不限制
|
||||
return true;
|
||||
case 2:
|
||||
// 节点结束
|
||||
// 开始节点直接返回true,除草稿状态
|
||||
if (nodeModel.getType().equals(NodeEnum.start.getType())
|
||||
&& !taskEntity.getStatus().equals(TaskStatusEnum.TO_BE_SUBMIT.getCode())) {
|
||||
return true;
|
||||
}
|
||||
TaskNodeModel taskNode = nodeList.stream()
|
||||
.filter(e -> e.getNodeCode().equals(nodeModel.getNodeId())).findFirst().orElse(null);
|
||||
if (null != taskNode && taskNode.getType().equals("0")) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// 流程结束
|
||||
ImmutableList<Integer> status = ImmutableList.of(TaskStatusEnum.PASSED.getCode(),
|
||||
TaskStatusEnum.REJECTED.getCode());
|
||||
if (status.contains(taskEntity.getStatus())) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// 条件设置
|
||||
List<ProperCond> conditions = printConfig.getConditions();
|
||||
String matchLogic = printConfig.getMatchLogic();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
flowMethod.setUserInfo(userInfo);
|
||||
flowMethod.setUserEntity(serviceUtil.getUserInfo(userInfo.getUserId()));
|
||||
flowMethod.setConditions(conditions);
|
||||
flowMethod.setMatchLogic(matchLogic);
|
||||
if (FlowJsonUtil.nodeConditionDecide(flowMethod)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断加签
|
||||
*/
|
||||
public void checkAddSign(OperatorEntity operator, AddSignModel parameter) throws WorkFlowException {
|
||||
this.checkAddSign(operator, parameter, true);
|
||||
}
|
||||
|
||||
public boolean checkAddSign(OperatorEntity operator, AddSignModel parameter, Boolean isException)
|
||||
throws WorkFlowException {
|
||||
int level = 1;
|
||||
if (!ObjectUtil.equals(operator.getParentId(), "0")) {
|
||||
OperatorEntity parent = operatorService.getById(operator.getParentId());
|
||||
if (null != parent) {
|
||||
String handleParameter = parent.getHandleParameter() == null ? operator.getHandleParameter()
|
||||
: parent.getHandleParameter();
|
||||
AddSignModel jsonToBean = JsonUtil.getJsonToBean(handleParameter, AddSignModel.class);
|
||||
level = jsonToBean.getLevel() + 1;
|
||||
}
|
||||
}
|
||||
SysConfigModel sysConfig = serviceUtil.getSysConfig();
|
||||
Integer addSignLevel = sysConfig.getAddSignLevel();
|
||||
if (level > addSignLevel) {
|
||||
if (isException) {
|
||||
throw new WorkFlowException(MsgCode.WF143.get());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (null != parameter) {
|
||||
parameter.setLevel(level);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.CirculateEntity;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateNodeEntity;
|
||||
import com.yunzhupaas.flowable.enums.RecordEnum;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.CirculateService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.entity.UserRelationEntity;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/4/29 下午3:12
|
||||
*/
|
||||
@Component
|
||||
public class CirculateUtil {
|
||||
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private TaskUtil taskUtil;
|
||||
@Autowired
|
||||
private CirculateService circulateService;
|
||||
|
||||
public List<CirculateEntity> circulateList(FlowMethod flowMethod) throws WorkFlowException {
|
||||
FlowModel flowModel = flowMethod.getFlowModel();
|
||||
List<CirculateEntity> circulateList = new ArrayList<>();
|
||||
TaskEntity task = flowMethod.getTaskEntity();
|
||||
OperatorEntity operator = flowMethod.getOperatorEntity();
|
||||
TemplateNodeEntity nodeEntity = flowMethod.getNodeEntity();
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(nodeEntity.getNodeJson(), NodeModel.class);
|
||||
List<String> userIdAll = new ArrayList<>();
|
||||
//附加规则
|
||||
if (!ObjectUtil.equals(flowMethod.getType(), RecordEnum.reject.getCode())) {
|
||||
List<String> all = taskUtil.getSub(nodeModel.getCirculateUser());
|
||||
userIdAll = serviceUtil.getUserListAll(all);
|
||||
taskUtil.rule(userIdAll, task.getId(), nodeModel.getExtraCopyRule());
|
||||
}
|
||||
//指定传阅人
|
||||
userIdAll.addAll(Arrays.asList(StringUtil.isNotEmpty(flowModel.getCopyIds()) ? flowModel.getCopyIds().split(",") : new String[]{}));
|
||||
//抄送自己
|
||||
if (nodeModel.getIsInitiatorCopy()) {
|
||||
userIdAll.add(task.getCreatorUserId());
|
||||
}
|
||||
//抄送表单变量
|
||||
if (nodeModel.getIsFormFieldCopy()) {
|
||||
flowMethod.setIsAssign(false);
|
||||
flowMethod.setIsData(true);
|
||||
Map<String, Object> dataAll = taskUtil.createOrUpdate(flowMethod);
|
||||
Object data = dataAll.get(nodeModel.getCopyFormField() + FlowNature.FORM_FIELD_SUFFIX);
|
||||
if (data != null) {
|
||||
List<String> list = new ArrayList<>();
|
||||
try {
|
||||
list.addAll(JsonUtil.getJsonToList(String.valueOf(data), String.class));
|
||||
} catch (Exception e) {}
|
||||
if (data instanceof List) {
|
||||
list.addAll((List) data);
|
||||
} else {
|
||||
list.addAll(Arrays.asList(String.valueOf(data).split(",")));
|
||||
}
|
||||
List<String> id = new ArrayList<>();
|
||||
for (String s : list) {
|
||||
id.add(s.split("--")[0]);
|
||||
}
|
||||
List<UserRelationEntity> listByObjectIdAll = serviceUtil.getListByObjectIdAll(id);
|
||||
List<String> userPosition = listByObjectIdAll.stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
|
||||
List<String> handleIdAll = new ArrayList<>();
|
||||
handleIdAll.addAll(userPosition);
|
||||
handleIdAll.addAll(id);
|
||||
userIdAll.addAll(handleIdAll);
|
||||
}
|
||||
}
|
||||
//获取最新用户
|
||||
List<UserEntity> userList = serviceUtil.getUserName(userIdAll, true);
|
||||
for (UserEntity userEntity : userList) {
|
||||
CirculateEntity circulate = new CirculateEntity();
|
||||
circulate.setId(RandomUtil.uuId());
|
||||
circulate.setUserId(userEntity.getId());
|
||||
circulate.setNodeCode(nodeModel.getNodeId());
|
||||
circulate.setNodeName(nodeModel.getNodeName());
|
||||
circulate.setTaskId(task.getId());
|
||||
circulate.setCirculateRead(0);
|
||||
circulate.setOperatorId(operator.getId());
|
||||
circulate.setNodeId(operator.getNodeId());
|
||||
circulate.setCreatorTime(new Date());
|
||||
circulateList.add(circulate);
|
||||
}
|
||||
circulateService.saveBatch(circulateList);
|
||||
return circulateList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.DivideRuleEnum;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowAbleUrl;
|
||||
import com.yunzhupaas.flowable.model.flowable.OutgoingFlowsFo;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.ProperCond;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/19 15:14
|
||||
*/
|
||||
@Component
|
||||
public class ConditionService {
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private FlowAbleUrl flowAbleUrl;
|
||||
|
||||
// 处理选择分支的条件
|
||||
public Map<String, Boolean> getForBranch(FlowMethod flowMethod, List<String> branchList) throws WorkFlowException {
|
||||
Map<String, Boolean> resMap = new HashMap<>();
|
||||
|
||||
String deploymentId = flowMethod.getDeploymentId();
|
||||
String nodeCode = flowMethod.getNodeCode();
|
||||
Map<String, NodeModel> nodes = flowMethod.getNodes();
|
||||
NodeModel global = nodes.get(NodeEnum.global.getType());
|
||||
List<String> connectList = global.getConnectList();
|
||||
List<String> typeList = ImmutableList.of(NodeEnum.trigger.getType());
|
||||
|
||||
OutgoingFlowsFo flowsFo = new OutgoingFlowsFo();
|
||||
flowsFo.setDeploymentId(deploymentId);
|
||||
flowsFo.setTaskKey(nodeCode);
|
||||
List<String> outgoingFlows = flowAbleUrl.getOutgoingFlows(flowsFo);
|
||||
|
||||
for (String flow : outgoingFlows) {
|
||||
resMap.put(flow, false);
|
||||
if (!connectList.contains(flow)) {
|
||||
// 不存在connectList中,说明是隐藏的线,默认给true
|
||||
resMap.put(flow, true);
|
||||
continue;
|
||||
}
|
||||
List<String> nodeKey = flowAbleUrl.getTaskKeyAfterFlow(deploymentId, flow);
|
||||
if (CollectionUtil.isNotEmpty(nodeKey)) {
|
||||
NodeModel nodeModel = nodes.get(nodeKey.get(0));
|
||||
if (null != nodeModel && typeList.contains(nodeModel.getType())) {
|
||||
resMap.put(flow, true);
|
||||
} else if (branchList.contains(nodeKey.get(0))) {
|
||||
resMap.put(flow, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理条件
|
||||
*/
|
||||
public Map<String, Boolean> handleCondition(FlowMethod flowMethod) throws WorkFlowException {
|
||||
String deploymentId = flowMethod.getDeploymentId();
|
||||
String nodeCode = flowMethod.getNodeCode();
|
||||
// 获取节点的出线
|
||||
OutgoingFlowsFo flowsFo = new OutgoingFlowsFo();
|
||||
flowsFo.setDeploymentId(deploymentId);
|
||||
flowsFo.setTaskKey(nodeCode);
|
||||
List<String> outgoingFlows = flowAbleUrl.getOutgoingFlows(flowsFo);
|
||||
|
||||
Map<String, Boolean> resMap = new HashMap<>();
|
||||
flowMethod.setResMap(resMap);
|
||||
flowMethod.setOutgoingFlows(outgoingFlows);
|
||||
// 判断条件
|
||||
getConditionResult(flowMethod);
|
||||
return resMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取条件结果
|
||||
*/
|
||||
public void getConditionResult(FlowMethod flowMethod) {
|
||||
List<String> outgoingFlows = flowMethod.getOutgoingFlows();
|
||||
Map<String, Boolean> resMap = flowMethod.getResMap();
|
||||
Map<String, NodeModel> nodes = flowMethod.getNodes();
|
||||
String nodeCode = flowMethod.getNodeCode();
|
||||
TaskEntity taskEntity = flowMethod.getTaskEntity();
|
||||
if (CollectionUtil.isNotEmpty(outgoingFlows)) {
|
||||
|
||||
Set<String> userList = new HashSet<>();
|
||||
userList.add(UserProvider.getLoginUserId());
|
||||
|
||||
if (taskEntity != null) {
|
||||
userList.add(taskEntity.getCreatorUserId());
|
||||
if (StringUtil.isNotEmpty(taskEntity.getDelegateUserId())) {
|
||||
userList.add(taskEntity.getDelegateUserId());
|
||||
}
|
||||
}
|
||||
|
||||
List<UserEntity> userName = serviceUtil.getUserName(new ArrayList<>(userList));
|
||||
UserEntity createUser = null;
|
||||
UserEntity delegate = null;
|
||||
if (taskEntity != null) {
|
||||
createUser = userName.stream().filter(e -> Objects.equals(e.getId(), taskEntity.getCreatorUserId()))
|
||||
.findFirst().orElse(null);
|
||||
if (StringUtil.isNotEmpty(taskEntity.getDelegateUserId())) {
|
||||
delegate = userName.stream().filter(e -> Objects.equals(e.getId(), taskEntity.getDelegateUserId()))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置条件判断 所需参数
|
||||
UserEntity userEntity = userName.stream()
|
||||
.filter(e -> Objects.equals(e.getId(), UserProvider.getLoginUserId())).findFirst().orElse(null);
|
||||
flowMethod.setUserEntity(userEntity);
|
||||
if (flowMethod.getUserInfo() == null) {
|
||||
flowMethod.setUserInfo(UserProvider.getUser());
|
||||
}
|
||||
flowMethod.setCreateUser(createUser);
|
||||
flowMethod.setDelegate(delegate);
|
||||
|
||||
NodeModel currentNodeModel = nodes.get(nodeCode);
|
||||
flowMethod.setNodeModel(currentNodeModel);
|
||||
if (StringUtil.equals(currentNodeModel.getDivideRule(), DivideRuleEnum.PARALLEL.getType())) {
|
||||
// 并行,全都为true
|
||||
for (String key : outgoingFlows) {
|
||||
resMap.put(key, true);
|
||||
}
|
||||
}
|
||||
// else if (StringUtil.equals(currentNodeModel.getDivideRule(),
|
||||
// DivideRuleEnum.EXCLUSIVE.getType())) {
|
||||
// // 排他,获取到第一条为true的结果,其余默认为false
|
||||
// for (String key : outgoingFlows) {
|
||||
// // 获取出线节点 判断条件,没有设置条件的默认true
|
||||
// NodeModel nodeModel = nodes.get(key);
|
||||
// boolean res = true;
|
||||
// if (null != nodeModel) {
|
||||
// List<ProperCond> conditions = nodeModel.getConditions();
|
||||
// if (CollectionUtil.isNotEmpty(conditions)) {
|
||||
// flowMethod.setConditions(conditions);
|
||||
// flowMethod.setMatchLogic(nodeModel.getMatchLogic());
|
||||
// res = FlowJsonUtil.nodeConditionDecide(flowMethod);
|
||||
// }
|
||||
// conditionResMap.put(key, res);
|
||||
// }
|
||||
// resMap.put(key, res);
|
||||
// }
|
||||
// }
|
||||
else {
|
||||
for (String key : outgoingFlows) {
|
||||
// 获取出线节点 判断条件,没有设置条件的默认true
|
||||
NodeModel nodeModel = nodes.get(key);
|
||||
boolean res = true;
|
||||
if (null != nodeModel) {
|
||||
List<ProperCond> conditions = nodeModel.getConditions();
|
||||
if (CollectionUtil.isNotEmpty(conditions)) {
|
||||
flowMethod.setConditions(conditions);
|
||||
flowMethod.setMatchLogic(nodeModel.getMatchLogic());
|
||||
res = FlowJsonUtil.nodeConditionDecide(flowMethod);
|
||||
}
|
||||
}
|
||||
resMap.put(key, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理条件
|
||||
public boolean hasCondition(FlowMethod flowMethod) {
|
||||
TaskEntity taskEntity = flowMethod.getTaskEntity();
|
||||
UserEntity createUser = null;
|
||||
UserEntity delegate = null;
|
||||
if (taskEntity != null) {
|
||||
createUser = serviceUtil.getUserInfo(taskEntity.getCreatorUserId());
|
||||
delegate = StringUtil.isNotEmpty(taskEntity.getDelegateUserId())
|
||||
? serviceUtil.getUserInfo(taskEntity.getDelegateUserId())
|
||||
: null;
|
||||
}
|
||||
flowMethod.setCreateUser(createUser);
|
||||
flowMethod.setDelegate(delegate);
|
||||
UserEntity userEntity = serviceUtil.getUserInfo(UserProvider.getLoginUserId());
|
||||
flowMethod.setUserEntity(userEntity);
|
||||
flowMethod.setUserInfo(UserProvider.getUser());
|
||||
return FlowJsonUtil.nodeConditionDecide(flowMethod);
|
||||
}
|
||||
|
||||
public void checkCondition(Map<String, Boolean> resMap, Map<String, NodeModel> nodes) throws WorkFlowException {
|
||||
if (CollectionUtil.isEmpty(nodes)) {
|
||||
return;
|
||||
}
|
||||
NodeModel global = nodes.get(NodeEnum.global.getType());
|
||||
if (null == global) {
|
||||
throw new WorkFlowException(MsgCode.WF076.get());
|
||||
}
|
||||
List<String> connectList = global.getConnectList();
|
||||
long count = resMap.values().stream().filter(t -> Objects.equals(t, true)).count();
|
||||
Set<String> set = resMap.keySet();
|
||||
|
||||
if (count == resMap.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(connectList)) {
|
||||
int c = 0;
|
||||
for (String key : set) {
|
||||
if (connectList.contains(key) && resMap.get(key)) {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
if (c < 1) {
|
||||
throw new WorkFlowException(MsgCode.WF075.get());
|
||||
}
|
||||
} else {
|
||||
if (count < 1) {
|
||||
throw new WorkFlowException(MsgCode.WF075.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.util.SentMessageUtil;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.OperatorStateEnum;
|
||||
import com.yunzhupaas.flowable.model.message.DelegateModel;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.ExecuteAsyncModel;
|
||||
import com.yunzhupaas.flowable.model.trigger.ExecuteModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowConstant;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.model.util.SystemAuditModel;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.message.model.SentMessageForm;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/8/26 16:56
|
||||
*/
|
||||
@Component
|
||||
public class FlowAsyncUtil {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private SentMessageUtil sentMessageUtil;
|
||||
@Autowired
|
||||
private TriggerUtil triggerUtil;
|
||||
@Autowired
|
||||
private OperatorService operatorService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private OperatorUtil operatorUtil;
|
||||
|
||||
// --------------------------------------委托消息------------------------------------------------------
|
||||
@Async
|
||||
public void delegateMsg(DelegateModel flowDelegate) {
|
||||
List<String> toUserIds = flowDelegate.getToUserIds();
|
||||
if (!toUserIds.isEmpty()) {
|
||||
UserInfo userInfo = flowDelegate.getUserInfo();
|
||||
TaskEntity flowTask = flowDelegate.getFlowTask();
|
||||
Map<String, String> contentMsg = new HashMap<>();
|
||||
Boolean delegate = flowDelegate.getDelegate();
|
||||
boolean approve = flowDelegate.getApprove();
|
||||
if (approve) {
|
||||
SentMessageForm flowMsgModel = new SentMessageForm();
|
||||
flowMsgModel.setToUserIds(toUserIds);
|
||||
flowMsgModel.setUserInfo(flowDelegate.getUserInfo());
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
parameterMap.put(FlowConstant.MANDATOR, userInfo.getUserName());
|
||||
UserEntity mandatary = StringUtil.isNotEmpty(flowTask.getDelegateUserId())
|
||||
? serviceUtil.getUserInfo(flowTask.getDelegateUserId())
|
||||
: null;
|
||||
parameterMap.put(FlowConstant.MANDATARY, mandatary != null ? mandatary.getRealName() : "");
|
||||
parameterMap.put(FlowConstant.TITLE, delegate ? "委托" : "代理");
|
||||
flowMsgModel.setParameterMap(parameterMap);
|
||||
// 委托/代理确认通知
|
||||
Integer ack = flowDelegate.getAck();
|
||||
// 1.委托设置 2.委托给我
|
||||
Integer type = flowDelegate.getType();
|
||||
String templateId = FlowNature.EndMsg.equals(type) ? "PZXTLG021"
|
||||
: ObjectUtil.equals(ack, 1) ? "PZXTLG020" : "PZXTLG019";
|
||||
flowMsgModel.setTemplateId(templateId);
|
||||
|
||||
Integer delegateType = FlowNature.EndMsg.equals(type) ? 0 : delegate ? 2 : 4;
|
||||
contentMsg.put("type", delegateType + "");
|
||||
|
||||
flowMsgModel.setContentMsg(contentMsg);
|
||||
flowMsgModel.setFlowType(2);
|
||||
flowMsgModel.setType(2);
|
||||
List<SentMessageForm> messageListAll = new ArrayList<>();
|
||||
messageListAll.add(flowMsgModel);
|
||||
serviceUtil.sendDelegateMsg(messageListAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------发送消息------------------------------
|
||||
@Async
|
||||
public void sendMessage(List<SentMessageForm> messageListAll) {
|
||||
for (SentMessageForm messageForm : messageListAll) {
|
||||
if (messageForm.isSysMessage()) {
|
||||
sentMessageUtil.sendMessage(messageForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void execute(List<ExecuteAsyncModel> list) throws Exception {
|
||||
for (ExecuteAsyncModel asyncModel : list) {
|
||||
FlowModel flowModel = asyncModel.getFlowModel();
|
||||
ExecuteModel model = asyncModel.getModel();
|
||||
Boolean sync = asyncModel.getSync();
|
||||
List<OperatorEntity> operatorList = asyncModel.getOperatorList();
|
||||
List<SystemAuditModel> systemList = asyncModel.getSystemList();
|
||||
List<TaskEntity> subTaskList = asyncModel.getSubTaskList();
|
||||
this.execute(model, sync, operatorList, subTaskList, systemList, flowModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void execute(ExecuteModel model, Boolean isAsync, List<OperatorEntity> operatorList,
|
||||
List<TaskEntity> subTaskList, List<SystemAuditModel> systemList, FlowModel flowModel) throws Exception {
|
||||
try {
|
||||
triggerUtil.execute(model);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 终止流程
|
||||
if (isAsync) {
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
taskService.cancel(taskEntity.getId(), flowModel, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// try {
|
||||
// System.out.println("==================================================1");
|
||||
// Thread.sleep(20000);
|
||||
// System.out.println("==================================================2");
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
if (isAsync) {
|
||||
if (CollectionUtil.isNotEmpty(operatorList)) {
|
||||
for (OperatorEntity operator : operatorList) {
|
||||
operator.setStatus(OperatorStateEnum.Runing.getCode());
|
||||
}
|
||||
operatorService.updateBatchById(operatorList);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(subTaskList)) {
|
||||
for (TaskEntity taskEntity : subTaskList) {
|
||||
Integer hisStatus = taskEntity.getHisStatus();
|
||||
taskEntity.setStatus(hisStatus);
|
||||
}
|
||||
taskService.updateBatchById(subTaskList);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(systemList)) {
|
||||
for (SystemAuditModel systemAuditModel : systemList) {
|
||||
try {
|
||||
operatorUtil.autoAudit(systemAuditModel.getOperator(), systemAuditModel.getFlowModel());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
operatorUtil.autoAudit(flowModel, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,492 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.emnus.SearchMethodEnum;
|
||||
import com.yunzhupaas.emnus.TemplateEnum;
|
||||
import com.yunzhupaas.flowable.entity.RecordEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.templatejson.FlowParamModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.GroupsModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.ProperCond;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.TemplateJsonModel;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.visiual.YunzhupaasKeyConsts;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/18 20:22
|
||||
*/
|
||||
|
||||
public class FlowJsonUtil {
|
||||
|
||||
/**
|
||||
* 节点条件判断
|
||||
**/
|
||||
public static boolean nodeConditionDecide(FlowMethod flowMethod) {
|
||||
List<ProperCond> conditionList = flowMethod.getConditions();
|
||||
String matchLogic = flowMethod.getMatchLogic();
|
||||
boolean flag = false;
|
||||
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
||||
ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("js");
|
||||
Map<String, Object> map = flowMethod.getFormData();
|
||||
List<String> expressionAll = new ArrayList<>();
|
||||
StringBuilder condition = new StringBuilder();
|
||||
for (int k = 0; k < conditionList.size(); k++) {
|
||||
StringBuilder expression = new StringBuilder();
|
||||
expression.append("(");
|
||||
ProperCond properCond = conditionList.get(k);
|
||||
String logic = properCond.getLogic();
|
||||
List<GroupsModel> groups = properCond.getGroups();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
GroupsModel groupsModel = groups.get(i);
|
||||
String contain = "!=-1";
|
||||
String field = groupsModel.getField();
|
||||
String yunzhupaasKey = groupsModel.getYunzhupaasKey();
|
||||
int fieldType = groupsModel.getFieldType();
|
||||
Object form = fieldType == 1 ? formValue(flowMethod, yunzhupaasKey, map.get(field))
|
||||
: formula(groupsModel, map);
|
||||
Object formValue = form;
|
||||
String symbol = groupsModel.getSymbol();
|
||||
boolean include = ("like".equals(symbol) || "notLike".equals(symbol));
|
||||
if ("<>".equals(symbol)) {
|
||||
symbol = "!=";
|
||||
}
|
||||
int fieldValueType = groupsModel.getFieldValueType();
|
||||
String valueYunzhupaasKey = StringUtil.isNotEmpty(groupsModel.getFieldValueYunzhupaasKey())
|
||||
? groupsModel.getFieldValueYunzhupaasKey()
|
||||
: yunzhupaasKey;
|
||||
Object filedData = groupsModel.getFieldValue();
|
||||
|
||||
Object value;
|
||||
if (fieldValueType == 3 || fieldValueType == 4) {
|
||||
|
||||
TemplateJsonModel templateJsonModel = new TemplateJsonModel();
|
||||
templateJsonModel.setField(groupsModel.getField());
|
||||
templateJsonModel.setSourceType(fieldValueType == 3 ? 4 : TemplateEnum.Field.getCode());
|
||||
templateJsonModel.setMsgTemplateId(groupsModel.getField());
|
||||
templateJsonModel.setRelationField(String.valueOf(groupsModel.getFieldValue()));
|
||||
|
||||
MsgUtil msgUtil = new MsgUtil();
|
||||
TaskEntity flowTaskEntity = flowMethod.getTaskEntity();
|
||||
|
||||
Map<String, Object> mapData = new HashMap<>();
|
||||
if (null != flowTaskEntity) {
|
||||
if (StringUtil.isNotEmpty(flowTaskEntity.getGlobalParameter())) {
|
||||
mapData = JsonUtil.stringToMap(flowTaskEntity.getGlobalParameter());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isEmpty(mapData)) {
|
||||
NodeModel global = flowMethod.getNodes().get(NodeEnum.global.getType());
|
||||
if (null != global) {
|
||||
List<FlowParamModel> paramModelList = global.getGlobalParameterList();
|
||||
for (FlowParamModel model : paramModelList) {
|
||||
mapData.put(model.getFieldName(), model.getDefaultValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<TemplateJsonModel> list = new ArrayList<>();
|
||||
list.add(templateJsonModel);
|
||||
|
||||
RecordEntity record = new RecordEntity();
|
||||
record.setNodeCode(flowMethod.getNodeCode());
|
||||
UserEntity createUser = flowMethod.getCreateUser();
|
||||
UserEntity delegate = flowMethod.getDelegate();
|
||||
Map<String, String> resMap = msgUtil.parameterMap(mapData, list, record, flowTaskEntity, createUser,
|
||||
delegate);
|
||||
value = resMap.get(field);
|
||||
if (value != null) {
|
||||
value = "'" + value + "'";
|
||||
}
|
||||
} else {
|
||||
value = fieldValueType == 2 ? filedValue(flowMethod, filedData, valueYunzhupaasKey, form)
|
||||
: filedData(flowMethod, filedData, valueYunzhupaasKey, form);
|
||||
}
|
||||
Object fieldValue = value;
|
||||
String pression = formValue + symbol + fieldValue;
|
||||
// 比较的处理
|
||||
if ("<=".equals(symbol) || "<".equals(symbol) || ">".equals(symbol) || ">=".equals(symbol)) {
|
||||
try {
|
||||
String formValueStr = formValue.toString();
|
||||
if (formValueStr.startsWith("'") && formValueStr.endsWith("'")) {
|
||||
formValueStr = formValueStr.substring(1, formValueStr.length() - 1);
|
||||
}
|
||||
fieldValue = fieldValue == null ? "" : fieldValue;
|
||||
String fieldValueStr = fieldValue.toString();
|
||||
if (fieldValueStr.startsWith("'") && fieldValueStr.endsWith("'")) {
|
||||
fieldValueStr = fieldValueStr.substring(1, fieldValueStr.length() - 1);
|
||||
}
|
||||
BigDecimal a = new BigDecimal(formValueStr);
|
||||
BigDecimal b = new BigDecimal(fieldValueStr);
|
||||
boolean res = false;
|
||||
if ("<=".equals(symbol)) {
|
||||
res = a.compareTo(b) <= 0;
|
||||
} else if ("<".equals(symbol)) {
|
||||
res = a.compareTo(b) < 0;
|
||||
} else if (">".equals(symbol)) {
|
||||
res = a.compareTo(b) > 0;
|
||||
} else if (">=".equals(symbol)) {
|
||||
res = a.compareTo(b) >= 0;
|
||||
}
|
||||
pression = res + "";
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
pression = "false";
|
||||
}
|
||||
}
|
||||
if (include) {
|
||||
if ("notLike".equals(symbol)) {
|
||||
contain = "==-1";
|
||||
}
|
||||
symbol = ".indexOf";
|
||||
if (!(formValue instanceof CharSequence)) {
|
||||
formValue = "'" + formValue + "'";
|
||||
}
|
||||
if (!(fieldValue instanceof CharSequence)) {
|
||||
fieldValue = "'" + fieldValue + "'";
|
||||
}
|
||||
pression = formValue + ".toString()" + symbol + "(" + fieldValue + ")" + contain;
|
||||
}
|
||||
if (ObjectUtil.equals(symbol, "null")) {
|
||||
pression = "(" + formValue + " == null || " + formValue + " == '')";
|
||||
}
|
||||
if (ObjectUtil.equals(symbol, "notNull")) {
|
||||
pression = "(" + formValue + " != null && " + formValue + " != '')";
|
||||
}
|
||||
expression.append(pression);
|
||||
if (!StringUtils.isEmpty(logic) && i != groups.size() - 1) {
|
||||
expression.append(" " + search(logic) + " ");
|
||||
}
|
||||
}
|
||||
expression.append(")");
|
||||
expressionAll.add(expression.toString());
|
||||
}
|
||||
for (int i = 0; i < expressionAll.size(); i++) {
|
||||
String script = expressionAll.get(i);
|
||||
String search = i != expressionAll.size() - 1 ? search(matchLogic) : "";
|
||||
condition.append(script + " " + search + " ");
|
||||
}
|
||||
try {
|
||||
flag = (Boolean) scriptEngine.eval(condition.toString());
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件表达式
|
||||
*
|
||||
* @param logic
|
||||
*/
|
||||
private static String search(String logic) {
|
||||
return SearchMethodEnum.And.getSymbol().equalsIgnoreCase(logic) ? "&&" : "||";
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件数据修改
|
||||
*
|
||||
* @param flowMethod
|
||||
* @param value
|
||||
*/
|
||||
private static Object filedValue(FlowMethod flowMethod, Object value, String yunzhupaasKey, Object form) {
|
||||
UserInfo userInfo = flowMethod.getUserInfo();
|
||||
if ("currentUser".equals(value)) {
|
||||
value = userInfo.getUserId();
|
||||
}
|
||||
try {
|
||||
try {
|
||||
List<List<String>> dataAll = JsonUtil.getJsonToBean(value, List.class);
|
||||
List<String> id = new ArrayList<>();
|
||||
for (List<String> data : dataAll) {
|
||||
id.addAll(data);
|
||||
}
|
||||
value = String.join(",", id);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
List<String> id = new ArrayList<>();
|
||||
List<String> dataAll = JsonUtil.getJsonToList(value, String.class);
|
||||
if (YunzhupaasKeyConsts.CURRORGANIZE.equals(yunzhupaasKey)) {
|
||||
value = dataAll.stream().filter(t -> ("'" + t + "'").equals(form)).findFirst().orElse(null);
|
||||
} else {
|
||||
for (String data : dataAll) {
|
||||
id.add(data);
|
||||
}
|
||||
value = String.join(",", id);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
if (value instanceof CharSequence) {
|
||||
value = "'" + value + "'";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件数据修改
|
||||
*
|
||||
* @param flowMethod
|
||||
* @param value
|
||||
*/
|
||||
private static Object filedData(FlowMethod flowMethod, Object value, String yunzhupaasKey, Object form) {
|
||||
Map<String, Object> map = flowMethod.getFormData();
|
||||
value = map.get(value);
|
||||
UserEntity userEntity = flowMethod.getUserEntity();
|
||||
TaskEntity taskEntity = flowMethod.getTaskEntity();
|
||||
try {
|
||||
try {
|
||||
List<List<String>> dataAll = JsonUtil.getJsonToBean(value, List.class);
|
||||
List<String> id = new ArrayList<>();
|
||||
for (List<String> data : dataAll) {
|
||||
id.addAll(data);
|
||||
}
|
||||
value = String.join(",", id);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
List<String> id = new ArrayList<>();
|
||||
List<String> dataAll = JsonUtil.getJsonToList(value, String.class);
|
||||
if (YunzhupaasKeyConsts.CURRORGANIZE.equals(yunzhupaasKey)
|
||||
|| YunzhupaasKeyConsts.COMSELECT.equals(yunzhupaasKey)) {
|
||||
value = dataAll.stream().filter(t -> ("'" + t + "'").equals(form)).findFirst().orElse(null);
|
||||
} else {
|
||||
for (String data : dataAll) {
|
||||
id.add(data);
|
||||
}
|
||||
value = String.join(",", id);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
|
||||
}
|
||||
}
|
||||
if (YunzhupaasKeyConsts.CREATETIME.equals(yunzhupaasKey)) {
|
||||
Date creatorTime = taskEntity.getCreatorTime();
|
||||
value = null == creatorTime ? null : creatorTime.getTime();
|
||||
} else if (YunzhupaasKeyConsts.CREATEUSER.equals(yunzhupaasKey)) {
|
||||
value = taskEntity.getCreatorUserId();
|
||||
} else if (YunzhupaasKeyConsts.CURRORGANIZE.equals(yunzhupaasKey)) {
|
||||
value = userEntity.getOrganizeId();
|
||||
} else if (YunzhupaasKeyConsts.CURRPOSITION.equals(yunzhupaasKey)) {
|
||||
value = userEntity.getPositionId();
|
||||
} else if (YunzhupaasKeyConsts.MODIFYTIME.equals(yunzhupaasKey)) {
|
||||
Date lastModifyTime = taskEntity.getLastModifyTime();
|
||||
value = null == lastModifyTime ? null : lastModifyTime.getTime();
|
||||
} else if (YunzhupaasKeyConsts.MODIFYUSER.equals(yunzhupaasKey)) {
|
||||
value = taskEntity.getLastModifyUserId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
if (value instanceof CharSequence) {
|
||||
value = "'" + value + "'";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据修改
|
||||
*
|
||||
* @param form
|
||||
*/
|
||||
private static Object formValue(FlowMethod flowMethod, String yunzhupaasKey, Object form) {
|
||||
Object result = form;
|
||||
UserEntity userEntity = flowMethod.getUserEntity();
|
||||
TaskEntity flowTaskEntity = flowMethod.getTaskEntity();
|
||||
try {
|
||||
try {
|
||||
List<List<String>> dataAll = JsonUtil.getJsonToBean(form, List.class);
|
||||
List<String> id = new ArrayList<>();
|
||||
for (List<String> data : dataAll) {
|
||||
id.addAll(data);
|
||||
}
|
||||
result = String.join(",", id);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
List<String> id = new ArrayList<>();
|
||||
List<String> dataAll = JsonUtil.getJsonToList(form, String.class);
|
||||
for (String data : dataAll) {
|
||||
id.add(data);
|
||||
}
|
||||
result = String.join(",", id);
|
||||
} catch (Exception e1) {
|
||||
}
|
||||
}
|
||||
if (YunzhupaasKeyConsts.CREATETIME.equals(yunzhupaasKey)) {
|
||||
Date creatorTime = flowTaskEntity.getCreatorTime();
|
||||
result = null == creatorTime ? null : creatorTime.getTime();
|
||||
} else if (YunzhupaasKeyConsts.CREATEUSER.equals(yunzhupaasKey)) {
|
||||
result = StringUtil.isNotEmpty(flowTaskEntity.getDelegateUserId()) ? flowTaskEntity.getDelegateUserId()
|
||||
: flowTaskEntity.getCreatorUserId();
|
||||
} else if (YunzhupaasKeyConsts.CURRORGANIZE.equals(yunzhupaasKey)) {
|
||||
result = userEntity.getOrganizeId();
|
||||
} else if (YunzhupaasKeyConsts.CURRPOSITION.equals(yunzhupaasKey)) {
|
||||
result = userEntity.getPositionId();
|
||||
} else if (YunzhupaasKeyConsts.MODIFYTIME.equals(yunzhupaasKey)) {
|
||||
Date lastModifyTime = flowTaskEntity.getLastModifyTime();
|
||||
result = null == lastModifyTime ? null : lastModifyTime.getTime();
|
||||
} else if (YunzhupaasKeyConsts.MODIFYUSER.equals(yunzhupaasKey)) {
|
||||
result = flowTaskEntity.getLastModifyUserId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (result instanceof CharSequence) {
|
||||
result = "'" + result + "'";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表达式
|
||||
*/
|
||||
private static Object formula(GroupsModel properCond, Map<String, Object> data) {
|
||||
String result = null;
|
||||
try {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("function getNum(val) {\n" +
|
||||
" return isNaN(val) ? 0 : Number(val)\n" +
|
||||
"};\n" +
|
||||
"// 求和\n" +
|
||||
"function SUM() {\n" +
|
||||
" var value = 0\n" +
|
||||
" for (var i = 0; i < arguments.length; i++) {\n" +
|
||||
" value += getNum(arguments[i])\n" +
|
||||
" }\n" +
|
||||
" return value\n" +
|
||||
"};\n" +
|
||||
"// 求差\n" +
|
||||
"function SUBTRACT(num1, num2) {\n" +
|
||||
" return getNum(num1) - getNum(num2)\n" +
|
||||
"};\n" +
|
||||
"// 相乘\n" +
|
||||
"function PRODUCT() {\n" +
|
||||
" var value = 1\n" +
|
||||
" for (var i = 0; i < arguments.length; i++) {\n" +
|
||||
" value = value * getNum(arguments[i])\n" +
|
||||
" }\n" +
|
||||
" return value\n" +
|
||||
"};\n" +
|
||||
"// 相除\n" +
|
||||
"function DIVIDE(num1, num2) {\n" +
|
||||
" return getNum(num1) / (getNum(num2) === 0 ? 1 : getNum(num2))\n" +
|
||||
"};\n" +
|
||||
"// 获取参数的数量\n" +
|
||||
"function COUNT() {\n" +
|
||||
" var value = 0\n" +
|
||||
" for (var i = 0; i < arguments.length; i++) {\n" +
|
||||
" value ++\n" +
|
||||
" }\n" +
|
||||
" return value\n" +
|
||||
"};\n");
|
||||
String field = field(properCond.getField(), data, null);
|
||||
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
||||
ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("js");
|
||||
String eval = builder.toString() + " var result = " + field + ";";
|
||||
scriptEngine.eval(eval);
|
||||
double d = (double) scriptEngine.get("result");
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
nf.setRoundingMode(RoundingMode.UP);
|
||||
result = nf.format(d);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换文本值
|
||||
*
|
||||
* @param content
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static String field(String content, Map<String, Object> data, String type) {
|
||||
String pattern = "[{]([^}]+)[}]";
|
||||
Pattern patternList = Pattern.compile(pattern);
|
||||
Matcher matcher = patternList.matcher(content);
|
||||
Map<String, List<String>> parameterMap = data(matcher, data);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (StringUtils.isNotEmpty(type)) {
|
||||
Map<String, String> datas = new HashMap<>();
|
||||
for (String key : parameterMap.keySet()) {
|
||||
datas.put(key, data.get(key) != null ? String.valueOf(data.get(key)) : "");
|
||||
}
|
||||
result.putAll(datas);
|
||||
} else {
|
||||
Map<String, Object> dataAll = new HashMap<>();
|
||||
for (String key : parameterMap.keySet()) {
|
||||
StringJoiner joiner = new StringJoiner(",");
|
||||
List<String> list = parameterMap.get(key);
|
||||
for (String id : list) {
|
||||
joiner.add("'" + id + "'");
|
||||
}
|
||||
String value = joiner.toString();
|
||||
if (list.size() > 1) {
|
||||
value = "SUM(" + joiner.toString() + ")";
|
||||
}
|
||||
dataAll.put(key, value);
|
||||
}
|
||||
result.putAll(dataAll);
|
||||
}
|
||||
StringSubstitutor strSubstitutor = new StringSubstitutor(result, "{", "}");
|
||||
String field = strSubstitutor.replace(content);
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* 赋值
|
||||
*/
|
||||
private static Map<String, List<String>> data(Matcher matcher, Map<String, Object> dataAll) {
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
Map<String, String> keyAll = new HashMap<>();
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group().replaceAll("\\{", "").replaceAll("}", "");
|
||||
keyAll.put(group, group);
|
||||
}
|
||||
for (String id : keyAll.keySet()) {
|
||||
List<String> valueData = new ArrayList<>();
|
||||
String valueAll[] = id.split("-");
|
||||
String key = valueAll[0];
|
||||
Object childDataAll = dataAll.get(key) != null ? dataAll.get(key) : "";
|
||||
if (valueAll.length > 1) {
|
||||
String data = valueAll[1];
|
||||
if (childDataAll instanceof List) {
|
||||
List<Map<String, Object>> childData = (List<Map<String, Object>>) childDataAll;
|
||||
for (Map<String, Object> childDatum : childData) {
|
||||
Object childDatas = childDatum.get(data);
|
||||
valueData.add(childDatas + "");
|
||||
}
|
||||
}
|
||||
} else if (valueAll.length == 1) {
|
||||
valueData.add(childDataAll + "");
|
||||
}
|
||||
map.put(id, valueData);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,727 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.model.systemconfig.SysConfigModel;
|
||||
import com.yunzhupaas.emnus.TemplateEnum;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.model.message.ContModel;
|
||||
import com.yunzhupaas.flowable.model.message.DelegateModel;
|
||||
import com.yunzhupaas.flowable.model.message.FlowEventModel;
|
||||
import com.yunzhupaas.flowable.model.message.FlowMsgModel;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.*;
|
||||
import com.yunzhupaas.flowable.model.util.FlowConstant;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.DelegateService;
|
||||
import com.yunzhupaas.message.model.SentMessageForm;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.DateUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2022/3/30 11:45
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MsgUtil {
|
||||
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private DelegateService delegateService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private FlowAsyncUtil flowAsyncUtil;
|
||||
|
||||
public Map<String, Object> infoData(String formId, String taskId, Map<String, Map<String, Object>> allData) throws WorkFlowException {
|
||||
Map<String, Object> dataAll = allData.get(taskId + "_yunzhupaas_" + formId) != null ? allData.get(taskId + "_yunzhupaas_" + formId) : serviceUtil.infoData(formId, taskId);
|
||||
return dataAll;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param flowMsgModel
|
||||
*/
|
||||
public void message(FlowMsgModel flowMsgModel) throws WorkFlowException {
|
||||
List<SentMessageForm> messageListAll = new ArrayList<>();
|
||||
TaskEntity task = flowMsgModel.getTaskEntity();
|
||||
String taskId = task.getId();
|
||||
UserEntity user = StringUtil.isNotEmpty(task.getCreatorUserId()) ? serviceUtil.getUserInfo(task.getCreatorUserId()) : null;
|
||||
flowMsgModel.setCreateUser(user);
|
||||
UserEntity delegate = StringUtil.isNotEmpty(task.getDelegateUserId()) ? serviceUtil.getUserInfo(task.getDelegateUserId()) : null;
|
||||
flowMsgModel.setDelegate(delegate);
|
||||
Map<String, Map<String, Object>> formData = flowMsgModel.getFormData();
|
||||
String nodeCode = flowMsgModel.getNodeCode();
|
||||
List<TemplateNodeEntity> nodeList = flowMsgModel.getNodeList();
|
||||
List<OperatorEntity> operatorList = flowMsgModel.getOperatorList();
|
||||
List<CirculateEntity> circulateList = flowMsgModel.getCirculateList();
|
||||
TemplateNodeEntity startNodeEntity = nodeList.stream().filter(t -> FlowNature.NodeStart.equals(t.getNodeType())).findFirst().orElse(null);
|
||||
String nodeJson = startNodeEntity != null ? startNodeEntity.getNodeJson() : "{}";
|
||||
NodeModel startNode = JsonUtil.getJsonToBean(nodeJson, NodeModel.class);
|
||||
//同意
|
||||
if (flowMsgModel.getApprove()) {
|
||||
MsgConfig msgConfig = startNode.getApproveMsgConfig();
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(nodeCode)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getApproveMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC002");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
flowMsgModel.setOpType(FlowNature.LaunchDetail);
|
||||
Map<String, Object> data = this.infoData(startNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
List<OperatorEntity> taskOperatorList = new ArrayList() {{
|
||||
OperatorEntity operatorEntity = new OperatorEntity();
|
||||
operatorEntity.setTaskId(task.getId());
|
||||
operatorEntity.setHandleId(task.getCreatorUserId());
|
||||
add(operatorEntity);
|
||||
}};
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
// 拒绝
|
||||
if (flowMsgModel.getReject()) {
|
||||
MsgConfig msgConfig = startNode.getRejectMsgConfig();
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(nodeCode)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getRejectMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC018");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
flowMsgModel.setOpType(FlowNature.LaunchDetail);
|
||||
Map<String, Object> data = this.infoData(startNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
List<OperatorEntity> taskOperatorList = new ArrayList() {{
|
||||
OperatorEntity operatorEntity = new OperatorEntity();
|
||||
operatorEntity.setTaskId(task.getId());
|
||||
operatorEntity.setHandleId(task.getCreatorUserId());
|
||||
add(operatorEntity);
|
||||
}};
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
//等待
|
||||
if (flowMsgModel.getWait()) {
|
||||
MsgConfig taskMsgConfig = startNode.getWaitMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
if (flowMsgModel.getTransfer()) {
|
||||
taskMsgConfig.setMsgId("PZXTLC006");
|
||||
} else if (flowMsgModel.getAssign()) {
|
||||
taskMsgConfig.setMsgId("PZXTLC005");
|
||||
} else if (flowMsgModel.getPress()) {
|
||||
taskMsgConfig.setMsgId("PZXTLC004");
|
||||
} else {
|
||||
taskMsgConfig.setMsgId("PZXTLC001");
|
||||
}
|
||||
}
|
||||
Map<String, List<OperatorEntity>> operatorMap = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : operatorMap.keySet()) {
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = operatorMap.get(key);
|
||||
flowMsgModel.setOpType(FlowNature.WaitSign);
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
// 获取表单数据
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
for (OperatorEntity operator : taskOperatorList) {
|
||||
List<SentMessageForm> delegationMsg = delegationMsg(operator, msgModel);
|
||||
messageListAll.addAll(delegationMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
//结束
|
||||
if (flowMsgModel.getEnd()) {
|
||||
MsgConfig taskMsgConfig = startNode.getEndMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC010");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
flowMsgModel.setOpType(FlowNature.LaunchDetail);
|
||||
Map<String, Object> data = this.infoData(startNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
List<OperatorEntity> taskOperatorList = new ArrayList() {{
|
||||
OperatorEntity operatorEntity = new OperatorEntity();
|
||||
operatorEntity.setTaskId(task.getId());
|
||||
operatorEntity.setHandleId(task.getCreatorUserId());
|
||||
add(operatorEntity);
|
||||
}};
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
//退回
|
||||
if (flowMsgModel.getBack()) {
|
||||
MsgConfig msgConfig = startNode.getBackMsgConfig();
|
||||
Map<String, List<OperatorEntity>> operatorMap = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : operatorMap.keySet()) {
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(nodeCode)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getBackMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC003");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = operatorMap.get(key);
|
||||
if (ObjectUtil.equals(flowMsgModel.getWait(), true)) {
|
||||
flowMsgModel.setOpType(FlowNature.WaitSign);
|
||||
}
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
for (OperatorEntity operator : taskOperatorList) {
|
||||
List<SentMessageForm> delegationMsg = delegationMsg(operator, msgModel);
|
||||
messageListAll.addAll(delegationMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
//抄送
|
||||
if (flowMsgModel.getCopy()) {
|
||||
MsgConfig msgConfig = startNode.getCopyMsgConfig();
|
||||
Map<String, List<CirculateEntity>> circulateMap = circulateList.stream().collect(Collectors.groupingBy(CirculateEntity::getNodeCode));
|
||||
for (String key : circulateMap.keySet()) {
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getCopyMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC007");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = new ArrayList<>();
|
||||
for (CirculateEntity circulateEntity : circulateMap.get(key)) {
|
||||
OperatorEntity operatorEntity = JsonUtil.getJsonToBean(circulateEntity, OperatorEntity.class);
|
||||
operatorEntity.setHandleId(circulateEntity.getUserId());
|
||||
taskOperatorList.add(operatorEntity);
|
||||
}
|
||||
flowMsgModel.setOpType(FlowNature.Circulate);
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
}
|
||||
//子流程
|
||||
if (flowMsgModel.getLaunch()) {
|
||||
MsgConfig msgConfig = startNode.getLaunchMsgConfig();
|
||||
Map<String, List<OperatorEntity>> operatorMap = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : operatorMap.keySet()) {
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getLaunchMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC011");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = operatorMap.get(key);
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
flowMsgModel.setOpType(taskChildNode.getAutoSubmit().equals(1) ? FlowNature.LaunchDetail : FlowNature.LaunchCreate);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
}
|
||||
//发起人
|
||||
if (flowMsgModel.getStart()) {
|
||||
MsgConfig msgConfig = startNode.getBackMsgConfig();
|
||||
if (msgConfig.getOn() == 3) {
|
||||
msgConfig.setMsgId("PZXTLC003");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
flowMsgModel.setOpType(FlowNature.LaunchDetail);
|
||||
Map<String, Object> data = this.infoData(startNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
List<OperatorEntity> meOperatorList = new ArrayList() {{
|
||||
OperatorEntity operatorEntity = new OperatorEntity();
|
||||
operatorEntity.setTaskId(taskId);
|
||||
operatorEntity.setHandleId(task.getCreatorUserId());
|
||||
add(operatorEntity);
|
||||
}};
|
||||
FlowMsgModel msgModel = messageModel(meOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
//超时
|
||||
if (flowMsgModel.getOvertime()) {
|
||||
MsgConfig msgConfig = startNode.getOverTimeMsgConfig();
|
||||
Map<String, List<OperatorEntity>> operatorMap = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : operatorMap.keySet()) {
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getOverTimeMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC009");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = operatorMap.get(key);
|
||||
flowMsgModel.setOpType(FlowNature.WaitSign);
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
for (OperatorEntity operator : taskOperatorList) {
|
||||
List<SentMessageForm> delegationMsg = delegationMsg(operator, flowMsgModel);
|
||||
messageListAll.addAll(delegationMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
//提醒
|
||||
if (flowMsgModel.getNotice()) {
|
||||
MsgConfig msgConfig = startNode.getNoticeMsgConfig();
|
||||
Map<String, List<OperatorEntity>> operatorMap = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : operatorMap.keySet()) {
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
NodeModel taskChildNode = JsonUtil.getJsonToBean(taskNode.getNodeJson(), NodeModel.class);
|
||||
MsgConfig taskMsgConfig = taskChildNode.getNoticeMsgConfig();
|
||||
if (taskMsgConfig.getOn() == 2) {
|
||||
taskMsgConfig = msgConfig;
|
||||
}
|
||||
if (taskMsgConfig.getOn() == 3) {
|
||||
taskMsgConfig.setMsgId("PZXTLC008");
|
||||
}
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = operatorMap.get(key);
|
||||
flowMsgModel.setOpType(FlowNature.WaitSign);
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(taskMsgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
for (OperatorEntity operator : taskOperatorList) {
|
||||
List<SentMessageForm> delegationMsg = delegationMsg(operator, msgModel);
|
||||
messageListAll.addAll(delegationMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
//评论
|
||||
if (flowMsgModel.getComment()) {
|
||||
MsgConfig msgConfig = startNode.getCommentMsgConfig();
|
||||
if (msgConfig.getOn() == 3) {
|
||||
msgConfig.setMsgId("PZXTLC017");
|
||||
}
|
||||
Map<String, List<OperatorEntity>> operatorMap = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : operatorMap.keySet()) {
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = operatorMap.get(key);
|
||||
flowMsgModel.setOpType(FlowNature.Circulate);
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(msgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
//抄送
|
||||
Map<String, List<CirculateEntity>> circulateMap = circulateList.stream().collect(Collectors.groupingBy(CirculateEntity::getNodeCode));
|
||||
for (String key : circulateMap.keySet()) {
|
||||
TemplateNodeEntity taskNode = nodeList.stream().filter(t -> t.getNodeCode().equals(key)).findFirst().orElse(null);
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
List<OperatorEntity> taskOperatorList = new ArrayList<>();
|
||||
for (CirculateEntity circulateEntity : circulateMap.get(key)) {
|
||||
OperatorEntity operatorEntity = JsonUtil.getJsonToBean(circulateEntity, OperatorEntity.class);
|
||||
operatorEntity.setHandleId(circulateEntity.getUserId());
|
||||
taskOperatorList.add(operatorEntity);
|
||||
}
|
||||
flowMsgModel.setOpType(FlowNature.Circulate);
|
||||
Map<String, Object> data = this.infoData(taskNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
flowMsgModel.setMsgConfig(msgConfig);
|
||||
FlowMsgModel msgModel = messageModel(taskOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
if (flowMsgModel.getStartHandId()) {
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
flowMsgModel.setOpType(FlowNature.LaunchDetail);
|
||||
Map<String, Object> data = this.infoData(startNode.getFormId(), taskId, formData);
|
||||
flowMsgModel.setData(data);
|
||||
List<OperatorEntity> meOperatorList = new ArrayList() {{
|
||||
OperatorEntity operatorEntity = new OperatorEntity();
|
||||
operatorEntity.setTaskId(task.getId());
|
||||
operatorEntity.setHandleId(task.getCreatorUserId());
|
||||
add(operatorEntity);
|
||||
}};
|
||||
FlowMsgModel msgModel = messageModel(meOperatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
messageListAll.addAll(messageList);
|
||||
}
|
||||
}
|
||||
for (SentMessageForm sentMessageForm : messageListAll) {
|
||||
sentMessageForm.setFlowName(task.getFullName());
|
||||
sentMessageForm.setUserName(user != null ? user.getRealName() : "");
|
||||
}
|
||||
serviceUtil.sendMessage(messageListAll);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装接口数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> parameterMap(Map<String, Object> data, List<TemplateJsonModel> templateJsonModelList, RecordEntity record, TaskEntity task) {
|
||||
List<String> creator = ImmutableList.of(
|
||||
FlowConstant.LAUNCH_USER_NAME,
|
||||
FlowConstant.CREATORUSERNAME,
|
||||
FlowConstant.MANDATOR
|
||||
);
|
||||
List<String> mandatary = ImmutableList.of(FlowConstant.MANDATARY);
|
||||
List<TemplateJsonModel> templateList = templateJsonModelList.stream().filter(e -> Objects.equals(e.getSourceType(), TemplateEnum.System.getCode())).collect(Collectors.toList());
|
||||
boolean isCreator = templateList.stream().anyMatch(e -> creator.contains(e.getRelationField()));
|
||||
UserEntity createUser = null;
|
||||
if (isCreator) {
|
||||
createUser = serviceUtil.getUserInfo(task.getCreatorUserId());
|
||||
}
|
||||
boolean isMandatary = templateList.stream().anyMatch(e -> mandatary.contains(e.getRelationField()));
|
||||
UserEntity delegate = null;
|
||||
if (isMandatary) {
|
||||
delegate = StringUtil.isNotEmpty(task.getDelegateUserId()) ? serviceUtil.getUserInfo(task.getDelegateUserId()) : null;
|
||||
}
|
||||
return parameterMap(data, templateJsonModelList, record, task, createUser, delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装接口数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> parameterMap(Map<String, Object> data, List<TemplateJsonModel> templateJsonModelList, RecordEntity record, TaskEntity task, UserEntity createUser, UserEntity delegate) {
|
||||
Map<String, String> parameterMap = new HashMap<>();
|
||||
for (TemplateJsonModel templateJsonModel : templateJsonModelList) {
|
||||
String fieldId = templateJsonModel.getField();
|
||||
String msgTemplateId = templateJsonModel.getMsgTemplateId();
|
||||
String relationField = templateJsonModel.getRelationField();
|
||||
String dataValue = data.get(relationField) != null ? String.valueOf(data.get(relationField)) : null;
|
||||
String dataFieldValue = relationField;
|
||||
String dataJson = Objects.equals(TemplateEnum.Field.getCode(), templateJsonModel.getSourceType()) ? dataValue : dataFieldValue;
|
||||
FlowEventModel eventModel = FlowEventModel.builder().data(data).dataJson(dataJson).record(record).templateJson(templateJsonModel).taskEntity(task).createUser(createUser).delegate(delegate).build();
|
||||
dataJson = data(eventModel);
|
||||
parameterMap.put(StringUtil.isNotEmpty(msgTemplateId) ? msgTemplateId : "" + fieldId, dataJson);
|
||||
}
|
||||
return parameterMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private String data(FlowEventModel eventModel) {
|
||||
RecordEntity record = eventModel.getRecord();
|
||||
TemplateJsonModel templateJson = eventModel.getTemplateJson();
|
||||
String relationField = StringUtil.isNotEmpty(templateJson.getRelationField()) ? templateJson.getRelationField() : "";
|
||||
List<Integer> typeList = ImmutableList.of(TemplateEnum.Field.getCode(), TemplateEnum.System.getCode());
|
||||
boolean isType = typeList.contains(templateJson.getSourceType());
|
||||
String dataJson = eventModel.getDataJson();
|
||||
Map<String, Object> data = eventModel.getData();
|
||||
UserInfo userInfo = UserProvider.getUser();
|
||||
String userId = userInfo.getUserId();
|
||||
String userName = userInfo.getUserName() != null ? userInfo.getUserName() : "";
|
||||
String value = dataJson;
|
||||
TaskEntity taskEntity = eventModel.getTaskEntity();
|
||||
if (isType) {
|
||||
switch (relationField) {
|
||||
case FlowConstant.FLOW_ID:
|
||||
value = taskEntity.getFlowId();
|
||||
break;
|
||||
case FlowConstant.TASK_ID:
|
||||
value = taskEntity.getId();
|
||||
break;
|
||||
case FlowConstant.TASK_NODE_ID:
|
||||
value = record.getNodeCode();
|
||||
break;
|
||||
case FlowConstant.FLOW_FULL_NAME:
|
||||
value = taskEntity.getFlowName();
|
||||
break;
|
||||
case FlowConstant.TASK_FULL_NAME:
|
||||
value = taskEntity.getFullName();
|
||||
break;
|
||||
case FlowConstant.LAUNCH_USER_ID:
|
||||
value = taskEntity.getCreatorUserId();
|
||||
break;
|
||||
case FlowConstant.LAUNCH_USER_NAME:
|
||||
case FlowConstant.CREATORUSERNAME:
|
||||
case FlowConstant.MANDATOR:
|
||||
// UserEntity createUser = StringUtil.isNotBlank(taskEntity.getCreatorUserId()) ? serviceUtil.getUserInfo(taskEntity.getCreatorUserId()) : null;
|
||||
UserEntity createUser = eventModel.getCreateUser();
|
||||
value = createUser != null ? createUser.getRealName() : "";
|
||||
break;
|
||||
case FlowConstant.FLOW_OPERATOR_USER_ID:
|
||||
value = userId;
|
||||
break;
|
||||
case FlowConstant.FLOW_OPERATOR_USER_NAME:
|
||||
value = userName;
|
||||
break;
|
||||
case FlowConstant.SENDTIME:
|
||||
value = DateUtil.getNow();
|
||||
break;
|
||||
case FlowConstant.MANDATARY:
|
||||
// UserEntity delegate = StringUtil.isNotBlank(taskEntity.getDelegateUserId()) ? serviceUtil.getUserInfo(taskEntity.getDelegateUserId()) : null;
|
||||
UserEntity delegate = eventModel.getDelegate();
|
||||
value = delegate != null ? delegate.getRealName() : "";
|
||||
break;
|
||||
default:
|
||||
String[] model = StringUtil.isNotEmpty(relationField) ? relationField.split("-") : new String[]{};
|
||||
if (model.length > 1) {
|
||||
Object dataList = data.get(model[0]);
|
||||
if (dataList instanceof List) {
|
||||
List<Map<String, Object>> listAll = (List<Map<String, Object>>) dataList;
|
||||
List<Object> list = new ArrayList<>();
|
||||
for (Map<String, Object> objectMap : listAll) {
|
||||
list.add(objectMap.get(model[1]));
|
||||
}
|
||||
value = String.valueOf(list);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private void setMessageList(List<SentMessageForm> messageList, FlowMsgModel flowMsgModel) {
|
||||
HashMap<String, Object> data = new HashMap<>(flowMsgModel.getData());
|
||||
MsgConfig msgConfig = flowMsgModel.getMsgConfig() != null ? flowMsgModel.getMsgConfig() : new MsgConfig();
|
||||
List<String> userList = flowMsgModel.getUserList();
|
||||
UserInfo userInfo = flowMsgModel.getFlowModel().getUserInfo();
|
||||
TaskEntity task = flowMsgModel.getTaskEntity();
|
||||
UserEntity createUser = flowMsgModel.getCreateUser();
|
||||
UserEntity delegate = flowMsgModel.getDelegate();
|
||||
if (!userList.isEmpty()) {
|
||||
String templateId = msgConfig.getOn() == 0 ? "0" : msgConfig.getMsgId();
|
||||
boolean sysMessage = msgConfig.getOn() != 0;
|
||||
//解析发送配置json,获取消息模板参数
|
||||
List<TemplateJsonModel> templateJson = new ArrayList<>();
|
||||
for (SendConfigJson configJson : msgConfig.getTemplateJson()) {
|
||||
List<TemplateJsonModel> paramJson = configJson.getParamJson();
|
||||
templateJson.addAll(paramJson);
|
||||
List<String> list = ImmutableList.of(FlowConstant.MANDATOR, FlowConstant.MANDATARY, FlowConstant.CREATORUSERNAME, FlowConstant.SENDTIME);
|
||||
for (String field : list) {
|
||||
TemplateJsonModel jsonModel = new TemplateJsonModel();
|
||||
jsonModel.setMsgTemplateId(configJson.getId());
|
||||
jsonModel.setRelationField(field);
|
||||
jsonModel.setField(field);
|
||||
jsonModel.setSourceType(TemplateEnum.System.getCode());
|
||||
templateJson.add(jsonModel);
|
||||
}
|
||||
}
|
||||
SentMessageForm sentMessageForm = new SentMessageForm();
|
||||
sentMessageForm.setSysMessage(sysMessage);
|
||||
sentMessageForm.setTemplateId(templateId);
|
||||
sentMessageForm.setToUserIds(userList);
|
||||
Map<String, Object> parameterMap = new HashMap<>();
|
||||
RecordEntity record = new RecordEntity();
|
||||
record.setNodeCode(flowMsgModel.getNodeCode());
|
||||
for (TemplateJsonModel templateJsonModel : templateJson) {
|
||||
String fieldId = templateJsonModel.getField();
|
||||
String msgTemplateId = templateJsonModel.getMsgTemplateId();
|
||||
String relationField = templateJsonModel.getRelationField();
|
||||
String dataValue = data.get(relationField) != null ? String.valueOf(data.get(relationField)) : "";
|
||||
String dataFieldValue = relationField;
|
||||
String dataJson = Objects.equals(TemplateEnum.Field.getCode(), templateJsonModel.getSourceType()) ? dataValue : dataFieldValue;
|
||||
FlowEventModel eventModel = FlowEventModel.builder().data(data).dataJson(dataJson).record(record).templateJson(templateJsonModel)
|
||||
.taskEntity(task).createUser(createUser).delegate(delegate).build();
|
||||
dataJson = data(eventModel);
|
||||
parameterMap.put(msgTemplateId + fieldId, dataJson);
|
||||
}
|
||||
data.putAll(parameterMap);
|
||||
sentMessageForm.setUserInfo(userInfo);
|
||||
sentMessageForm.setParameterMap(data);
|
||||
sentMessageForm.setContentMsg(flowMsgModel.getContMsg());
|
||||
sentMessageForm.setTitle(task.getFullName());
|
||||
messageList.add(sentMessageForm);
|
||||
}
|
||||
}
|
||||
|
||||
private FlowMsgModel messageModel(List<OperatorEntity> taskOperatorList, FlowMsgModel flowMsgModel) {
|
||||
FlowMsgModel msgModel = JsonUtil.getJsonToBean(flowMsgModel, FlowMsgModel.class);
|
||||
List<String> userList = new ArrayList<>();
|
||||
TaskEntity task = flowMsgModel.getTaskEntity();
|
||||
Map<String, String> contMsg = new HashMap<>();
|
||||
for (OperatorEntity taskOperator : taskOperatorList) {
|
||||
ContModel contModel = new ContModel();
|
||||
contModel.setFlowId(task.getFlowId());
|
||||
contModel.setOperatorId(taskOperator.getId());
|
||||
contModel.setTaskId(task.getId());
|
||||
contModel.setOpType(flowMsgModel.getOpType());
|
||||
if (StringUtil.equals(flowMsgModel.getOpType(), FlowNature.WaitSign)) {
|
||||
if (null == taskOperator.getSignTime() && null == taskOperator.getStartHandleTime() && null == taskOperator.getHandleStatus()) {
|
||||
contModel.setOpType(FlowNature.WaitSign);
|
||||
} else if (null != taskOperator.getSignTime() && null == taskOperator.getStartHandleTime() && null == taskOperator.getHandleStatus()) {
|
||||
contModel.setOpType(FlowNature.Todo);
|
||||
} else if (null != taskOperator.getSignTime() && null != taskOperator.getStartHandleTime() && null == taskOperator.getHandleStatus()) {
|
||||
contModel.setOpType(FlowNature.Doing);
|
||||
}
|
||||
}
|
||||
contMsg.put(taskOperator.getHandleId(), JsonUtil.getObjectToString(contModel));
|
||||
userList.add(taskOperator.getHandleId());
|
||||
}
|
||||
msgModel.setUserList(userList);
|
||||
msgModel.setContMsg(contMsg);
|
||||
return msgModel;
|
||||
}
|
||||
|
||||
private List<SentMessageForm> delegationMsg(OperatorEntity operator, FlowMsgModel flowMsgModel) {
|
||||
List<SentMessageForm> messageList = new ArrayList<>();
|
||||
TaskEntity task = flowMsgModel.getTaskEntity();
|
||||
if (task != null) {
|
||||
// 获取委托人
|
||||
List<String> userList = delegateService.getToUser(operator.getHandleId(), task.getFlowId());
|
||||
List<OperatorEntity> operatorList = new ArrayList<>();
|
||||
for (String user : userList) {
|
||||
OperatorEntity delegate = JsonUtil.getJsonToBean(operator, OperatorEntity.class);
|
||||
delegate.setHandleId(user);
|
||||
operatorList.add(delegate);
|
||||
FlowMsgModel msgModel = messageModel(operatorList, flowMsgModel);
|
||||
setMessageList(messageList, msgModel);
|
||||
}
|
||||
}
|
||||
return messageList;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------委托消息------------------------------------------------------
|
||||
public void delegateMsg(DelegateModel flowDelegate) {
|
||||
SysConfigModel sysConfig = serviceUtil.getSysConfig();
|
||||
Integer ack = flowDelegate.getDelegate() ? sysConfig.getDelegateAck() : sysConfig.getProxyAck();
|
||||
flowDelegate.setAck(ack);
|
||||
flowAsyncUtil.delegateMsg(flowDelegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程事件
|
||||
*
|
||||
* @param status 事件状态 1.发起 2.结束 3.发起撤回 4同意 5拒绝 6节点撤回 7 超时 8提醒 9退回
|
||||
* @param nodeModel 节点数据
|
||||
* @param record 审批数据
|
||||
*/
|
||||
public void event(Integer status, NodeModel nodeModel, RecordEntity record, FlowModel flowModel) {
|
||||
if (nodeModel != null) {
|
||||
boolean on = false;
|
||||
String interId = "";
|
||||
List<TemplateJsonModel> templateJsonModelList = new ArrayList<>();
|
||||
FuncConfig config = null;
|
||||
switch (status) {
|
||||
case 1:
|
||||
config = nodeModel.getInitFuncConfig();
|
||||
break;
|
||||
case 2:
|
||||
config = nodeModel.getEndFuncConfig();
|
||||
break;
|
||||
case 3:
|
||||
config = nodeModel.getFlowRecallFuncConfig();
|
||||
break;
|
||||
case 4:
|
||||
config = nodeModel.getApproveFuncConfig();
|
||||
break;
|
||||
case 5:
|
||||
config = nodeModel.getRejectFuncConfig();
|
||||
break;
|
||||
case 6:
|
||||
config = nodeModel.getRecallFuncConfig();
|
||||
break;
|
||||
case 7:
|
||||
config = nodeModel.getOvertimeFuncConfig();
|
||||
break;
|
||||
case 8:
|
||||
config = nodeModel.getNoticeFuncConfig();
|
||||
break;
|
||||
case 9:
|
||||
config = nodeModel.getBackFuncConfig();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (config != null) {
|
||||
on = config.getOn();
|
||||
interId = config.getInterfaceId();
|
||||
templateJsonModelList = config.getTemplateJson();
|
||||
}
|
||||
if (on && StringUtil.isNotEmpty(interId)) {
|
||||
Map<String, Object> data = flowModel.getFormData();
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
// UserEntity createUser = null;
|
||||
// UserEntity delegate = null;
|
||||
// if (taskEntity != null) {
|
||||
// createUser = serviceUtil.getUserInfo(taskEntity.getCreatorUserId());
|
||||
// delegate = StringUtil.isNotEmpty(taskEntity.getDelegateUserId()) ? serviceUtil.getUserInfo(taskEntity.getDelegateUserId()) : null;
|
||||
// }
|
||||
Map<String, String> parameterMap = parameterMap(data, templateJsonModelList, record, taskEntity);
|
||||
ActionResult result = serviceUtil.infoToId(interId, parameterMap);
|
||||
if (null == result || Objects.equals(400, result.getCode())) {
|
||||
log.error("接口调用失败: {}", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 接口调用的参数需转为字符串
|
||||
public Map<String, String> intefaceParameterMap(Map<String, Object> data, List<TemplateJsonModel> templateJsonModelList, RecordEntity record, TaskEntity task, UserEntity createUser, UserEntity delegate) {
|
||||
Map<String, String> parameterMap = new HashMap<>();
|
||||
for (TemplateJsonModel templateJsonModel : templateJsonModelList) {
|
||||
String fieldId = templateJsonModel.getField();
|
||||
String msgTemplateId = templateJsonModel.getMsgTemplateId();
|
||||
String relationField = templateJsonModel.getRelationField();
|
||||
String dataValue = data.get(relationField) != null ? JsonUtil.getObjectToString(data.get(relationField)) : null;
|
||||
String dataFieldValue = relationField;
|
||||
String dataJson = Objects.equals(TemplateEnum.Field.getCode(), templateJsonModel.getSourceType()) ? dataValue : dataFieldValue;
|
||||
FlowEventModel eventModel = FlowEventModel.builder().data(data).dataJson(dataJson).record(record).templateJson(templateJsonModel).taskEntity(task).createUser(createUser).delegate(delegate).build();
|
||||
dataJson = data(eventModel);
|
||||
parameterMap.put(StringUtil.isNotEmpty(msgTemplateId) ? msgTemplateId : "" + fieldId, dataJson);
|
||||
}
|
||||
return parameterMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.enums.DivideRuleEnum;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.enums.OperatorStateEnum;
|
||||
import com.yunzhupaas.flowable.enums.TaskStatusEnum;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowAbleUrl;
|
||||
import com.yunzhupaas.flowable.model.flowable.FlowableHistoricModel;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.TaskNodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.AuxiliaryInfo;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.AuxiliaryInfoConfig;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.flowable.service.RevokeService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.flowable.service.TriggerRecordService;
|
||||
import com.yunzhupaas.model.document.FlowFileModel;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.UserProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/29 10:29
|
||||
*/
|
||||
@Component
|
||||
public class NodeUtil {
|
||||
@Autowired
|
||||
private FlowAbleUrl flowAbleUrl;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private TaskUtil taskUtil;
|
||||
@Autowired
|
||||
private OperatorService operatorService;
|
||||
@Autowired
|
||||
private OperatorUtil operatorUtil;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private RevokeService revokeService;
|
||||
@Autowired
|
||||
private TriggerRecordService triggerRecordService;
|
||||
|
||||
public List<TaskNodeModel> getNodeList(FlowModel flowModel) throws WorkFlowException {
|
||||
List<TaskNodeModel> nodeList = new ArrayList<>();
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
// 终止后 任务详情的流程图,需全部置灰
|
||||
if (ObjectUtil.equals(TaskStatusEnum.CANCEL.getCode(), taskEntity.getStatus())) {
|
||||
return nodeList;
|
||||
}
|
||||
List<TemplateNodeEntity> nodeEntities = flowModel.getNodeEntityList();
|
||||
// 当前节点
|
||||
String currentNodeCode = StringUtil.isNotEmpty(taskEntity.getCurrentNodeCode())
|
||||
? taskEntity.getCurrentNodeCode()
|
||||
: "";
|
||||
List<String> currentNodes = new ArrayList<>(Arrays.asList(currentNodeCode.split(",")));
|
||||
// 未经过的节点
|
||||
List<String> tobePass = flowAbleUrl.getTobePass(taskEntity.getInstanceId());
|
||||
if (currentNodeCode.equals(FlowNature.END_CODE)) {
|
||||
currentNodes = nodeEntities.stream()
|
||||
.filter(t -> NodeEnum.end.getType().equals(t.getNodeType())).map(TemplateNodeEntity::getNodeCode)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// 经过的节点
|
||||
FlowMethod flowMethod = new FlowMethod();
|
||||
flowMethod.setTobePass(tobePass);
|
||||
flowMethod.setCurrentNodes(currentNodes);
|
||||
flowMethod.setTaskId(taskEntity.getId());
|
||||
flowMethod.setTaskEntity(taskEntity);
|
||||
flowMethod.setNodeEntityList(nodeEntities);
|
||||
List<String> passed = this.getPassed(flowMethod);
|
||||
TemplateNodeEntity start = nodeEntities.stream().filter(e -> e.getNodeType().equals(NodeEnum.start.getType()))
|
||||
.findFirst().orElse(null);
|
||||
if (start != null) {
|
||||
passed.add(start.getNodeCode());
|
||||
}
|
||||
|
||||
List<TriggerRecordEntity> triggerRecordList = triggerRecordService.getListByTaskId(taskEntity.getId());
|
||||
|
||||
List<String> typeList = ImmutableList.of(NodeEnum.global.getType(), NodeEnum.connect.getType(), "confluence",
|
||||
"gateway");
|
||||
List<String> divideList = Arrays.stream(DivideRuleEnum.values()).map(DivideRuleEnum::getType)
|
||||
.collect(Collectors.toList());
|
||||
divideList.addAll(typeList);
|
||||
|
||||
flowMethod.setFlowModel(flowModel);
|
||||
flowMethod.setErrorRule(false);
|
||||
flowMethod.setExtraRule(true);
|
||||
|
||||
// 节点 (-1没有经过,0.经过 1.当前 2.未经过)
|
||||
for (TemplateNodeEntity node : nodeEntities) {
|
||||
String nodeCode = node.getNodeCode();
|
||||
// 跳过全局节点、连接线
|
||||
if (divideList.contains(node.getNodeType())) {
|
||||
continue;
|
||||
}
|
||||
TaskNodeModel model = JsonUtil.getJsonToBean(node, TaskNodeModel.class);
|
||||
// 节点名称
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(node.getNodeJson(), NodeModel.class);
|
||||
model.setNodeName(nodeModel.getNodeName());
|
||||
if (CollectionUtil.isNotEmpty(currentNodes)) {
|
||||
if (currentNodes.contains(nodeCode)) {
|
||||
model.setType("1");
|
||||
if (NodeEnum.end.getType().equals(node.getNodeType())) {
|
||||
model.setType("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(passed)) {
|
||||
if (passed.contains(nodeCode)) {
|
||||
model.setType("0");
|
||||
}
|
||||
}
|
||||
TriggerRecordEntity triggerRecord = triggerRecordList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getNodeCode(), nodeModel.getNodeId())).findFirst().orElse(null);
|
||||
if (null != triggerRecord) {
|
||||
String type = "1";
|
||||
if (ObjectUtil.equals(triggerRecord.getStatus(), 0)) {
|
||||
type = "0";
|
||||
} else if (ObjectUtil.equals(triggerRecord.getStatus(), 1)) {
|
||||
type = "3";
|
||||
}
|
||||
model.setType(type);
|
||||
}
|
||||
|
||||
List<String> userNameList = new ArrayList<>();
|
||||
|
||||
if (StringUtil.equals(node.getNodeType(), NodeEnum.start.getType())) {
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(taskEntity.getCreatorUserId());
|
||||
List<UserEntity> users = serviceUtil.getUserName(userIds);
|
||||
UserEntity user = users.get(0);
|
||||
userNameList.add(user.getRealName() + "/" + user.getAccount());
|
||||
if (!TaskStatusEnum.TO_BE_SUBMIT.getCode().equals(taskEntity.getStatus())) {
|
||||
model.setType("0");
|
||||
}
|
||||
} else if (StringUtil.equals(node.getNodeType(), NodeEnum.subFlow.getType())) {
|
||||
QueryWrapper<TaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(TaskEntity::getParentId, taskEntity.getId()).eq(TaskEntity::getSubCode,
|
||||
node.getNodeCode());
|
||||
List<TaskEntity> list = taskService.list(queryWrapper);
|
||||
List<String> userIds;
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
userIds = list.stream().map(TaskEntity::getCreatorUserId).collect(Collectors.toList());
|
||||
} else {
|
||||
flowMethod.setNodeEntity(node);
|
||||
userIds = taskUtil.userListAll(flowMethod);
|
||||
}
|
||||
List<UserEntity> users = serviceUtil.getUserName(userIds);
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
for (UserEntity user : users) {
|
||||
userNameList.add(user.getRealName() + "/" + user.getAccount());
|
||||
}
|
||||
}
|
||||
} else if (StringUtil.equals(node.getNodeType(), NodeEnum.approver.getType())
|
||||
|| StringUtil.equals(node.getNodeType(), NodeEnum.processing.getType())) {
|
||||
List<String> userIds;
|
||||
List<OperatorEntity> operatorList = operatorUtil.getByNodeCode(taskEntity.getId(), node.getNodeCode());
|
||||
|
||||
Integer counterSign = nodeModel.getCounterSign();
|
||||
|
||||
// 获取生成经办的人
|
||||
List<Integer> statusList = ImmutableList.of(OperatorStateEnum.Revoke.getCode(),
|
||||
OperatorStateEnum.AddSign.getCode(), OperatorStateEnum.Assist.getCode());
|
||||
List<OperatorEntity> list = operatorList.stream()
|
||||
.filter(e -> !statusList.contains(e.getStatus()) && ObjectUtil.equals(e.getParentId(), "0"))
|
||||
.collect(Collectors.toList());
|
||||
userIds = list.stream().map(OperatorEntity::getHandleId).collect(Collectors.toList());
|
||||
// 依次审批
|
||||
if (counterSign.equals(FlowNature.ImproperApprover)) {
|
||||
OperatorEntity last = list.stream().filter(e -> e.getCompletion().equals(0)).findFirst()
|
||||
.orElse(null);
|
||||
if (null != last && StringUtil.isNotBlank(last.getHandleAll())) {
|
||||
String[] split = last.getHandleAll().split(",");
|
||||
userIds = Arrays.stream(split).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
// 经办处理人的id为0,为系统自动通过
|
||||
if (userIds.contains(FlowNature.SYSTEM_CODE)) {
|
||||
// model.setUserName(FlowNature.SYSTEM_NAME);
|
||||
nodeList.add(model);
|
||||
continue;
|
||||
}
|
||||
if (CollectionUtil.isEmpty(userIds)) {
|
||||
flowMethod.setNodeEntity(node);
|
||||
userIds = taskUtil.userListAll(flowMethod);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(userIds)) {
|
||||
nodeList.add(model);
|
||||
continue;
|
||||
}
|
||||
userIds = userIds.stream().distinct().sorted().collect(Collectors.toList());
|
||||
List<UserEntity> users = serviceUtil.getUserName(userIds);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(users)) {
|
||||
for (String userId : userIds) {
|
||||
UserEntity user = users.stream().filter(e -> e.getId().equals(userId)).findFirst().orElse(null);
|
||||
if (null != user) {
|
||||
userNameList.add(user.getRealName() + "/" + user.getAccount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
model.setUserName(String.join(",", userNameList));
|
||||
nodeList.add(model);
|
||||
}
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 经过的节点
|
||||
*/
|
||||
public List<String> getPassed(FlowMethod flowMethod) {
|
||||
List<String> tobePass = flowMethod.getTobePass();
|
||||
List<String> currentNodes = flowMethod.getCurrentNodes();
|
||||
TaskEntity taskEntity = flowMethod.getTaskEntity();
|
||||
String taskId = flowMethod.getTaskId();
|
||||
List<TemplateNodeEntity> nodeEntityList = flowMethod.getNodeEntityList();
|
||||
List<String> resList = new ArrayList<>();
|
||||
|
||||
QueryWrapper<OperatorEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(OperatorEntity::getTaskId, taskId).ne(OperatorEntity::getStatus,
|
||||
OperatorStateEnum.Futility.getCode());
|
||||
List<OperatorEntity> operatorList = operatorService.list(wrapper);
|
||||
if (CollectionUtil.isNotEmpty(operatorList)) {
|
||||
List<String> nodeCodes = operatorList.stream().map(OperatorEntity::getNodeCode)
|
||||
.filter(e -> !currentNodes.contains(e)).collect(Collectors.toList());
|
||||
resList.addAll(nodeCodes);
|
||||
}
|
||||
|
||||
RevokeEntity revokeEntity = revokeService.getRevokeTask(taskEntity.getId());
|
||||
if (null != revokeEntity) {
|
||||
taskId = revokeEntity.getTaskId();
|
||||
}
|
||||
if (!ObjectUtil.equals(TaskStatusEnum.BACKED.getCode(), taskEntity.getStatus())) {
|
||||
QueryWrapper<TaskEntity> taskWrapper = new QueryWrapper<>();
|
||||
taskWrapper.lambda().eq(TaskEntity::getParentId, taskId);
|
||||
List<TaskEntity> subFlowList = taskService.list(taskWrapper);
|
||||
List<String> historic = new ArrayList<>();
|
||||
try {
|
||||
historic = flowAbleUrl.getHistoric(taskEntity.getInstanceId()).stream()
|
||||
.map(FlowableHistoricModel::getCode).collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(subFlowList)) {
|
||||
List<String> subCodes = subFlowList.stream().map(TaskEntity::getSubCode)
|
||||
.filter(e -> !currentNodes.contains(e) && !tobePass.contains(e))
|
||||
.collect(Collectors.toList());
|
||||
if (null != revokeEntity) {
|
||||
subCodes = subCodes.stream().filter(historic::contains).collect(Collectors.toList());
|
||||
}
|
||||
resList.addAll(subCodes);
|
||||
}
|
||||
// 撤销会跳过办理节点
|
||||
if (null != revokeEntity) {
|
||||
List<String> finalHistoric = historic;
|
||||
List<String> processingList = nodeEntityList.stream()
|
||||
.filter(e -> ObjectUtil.equals(e.getNodeType(), NodeEnum.processing.getType())
|
||||
&& !currentNodes.contains(e.getNodeCode()) && finalHistoric.contains(e.getNodeCode()))
|
||||
.map(TemplateNodeEntity::getNodeCode).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(processingList)) {
|
||||
resList.addAll(processingList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resList.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 辅助信息 添加归档文件信息
|
||||
*/
|
||||
public void setFlowFile(NodeModel currentNode, TaskEntity taskEntity, Map<String, Object> nodeProperties) {
|
||||
List<AuxiliaryInfo> auxiliaryList = currentNode.getAuxiliaryInfo();
|
||||
if (auxiliaryList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
long count = auxiliaryList.stream().filter(e -> ObjectUtil.equals(e.getConfig().getOn(), 0)).count();
|
||||
if (count == auxiliaryList.size()) {
|
||||
nodeProperties.put("auxiliaryInfo", null);
|
||||
return;
|
||||
}
|
||||
AuxiliaryInfo auxiliary = auxiliaryList.stream().filter(e -> ObjectUtil.equals(e.getId(), 3)).findFirst()
|
||||
.orElse(null);
|
||||
if (null == auxiliary) {
|
||||
return;
|
||||
}
|
||||
AuxiliaryInfoConfig auxiliaryConfig = auxiliary.getConfig();
|
||||
if (!ObjectUtil.equals(auxiliaryConfig.getOn(), 1)) {
|
||||
return;
|
||||
}
|
||||
String templateId = taskEntity.getTemplateId();
|
||||
FlowFileModel flowFileModel = FlowFileModel.builder().templateId(templateId)
|
||||
.userId(UserProvider.getLoginUserId())
|
||||
.dataRange(auxiliaryConfig.getDataRange()).build();
|
||||
List<Map<String, Object>> flowFile = serviceUtil.getFlowFile(flowFileModel);
|
||||
if (CollectionUtil.isEmpty(flowFile)) {
|
||||
return;
|
||||
}
|
||||
Object auxiliaryInfo = nodeProperties.get("auxiliaryInfo");
|
||||
if (auxiliaryInfo instanceof List) {
|
||||
List<Map<String, Object>> list = (List<Map<String, Object>>) auxiliaryInfo;
|
||||
for (Map<String, Object> map : list) {
|
||||
if (ObjectUtil.equals(map.get("id"), 3)) {
|
||||
Map<String, Object> config = (Map<String, Object>) map.get("config");
|
||||
config.put("fileList", flowFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,105 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
import com.yunzhupaas.flowable.enums.OperatorStateEnum;
|
||||
import com.yunzhupaas.flowable.model.message.FlowMsgModel;
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.flowable.service.TaskService;
|
||||
import com.yunzhupaas.flowable.service.TemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/23 上午10:33
|
||||
*/
|
||||
@Component
|
||||
public class OverTimeUtil {
|
||||
@Autowired
|
||||
private MsgUtil msgUtil;
|
||||
@Autowired
|
||||
private TaskUtil taskUtil;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private OperatorService operatorService;
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
public void overMsg(FlowTimeModel flowTimeModel) throws WorkFlowException {
|
||||
TaskEntity task = taskService.getInfo(flowTimeModel.getTaskId());
|
||||
//暂停,是跳过
|
||||
if (task == null) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
boolean isSuccess = false;
|
||||
try {
|
||||
taskUtil.isSuspend(task);
|
||||
} catch (Exception e) {
|
||||
isSuccess = true;
|
||||
}
|
||||
if (!isSuccess) {
|
||||
// 判断是否下架
|
||||
TemplateEntity template = templateService.getById(task.getTemplateId());
|
||||
if (null != template && !ObjectUtil.equals(template.getStatus(), 1)) {
|
||||
isSuccess = true;
|
||||
}
|
||||
}
|
||||
if (isSuccess) {
|
||||
if (flowTimeModel.getOverTime()) {
|
||||
flowTimeModel.setNum(flowTimeModel.getNum() + 1);
|
||||
flowTimeModel.setTransferNum(flowTimeModel.getTransferNum() + 1);
|
||||
}
|
||||
flowTimeModel.setIsPause(true);
|
||||
return;
|
||||
}
|
||||
taskUtil.isCancel(task);
|
||||
OperatorEntity operator = operatorService.getById(flowTimeModel.getOperatorId());
|
||||
if (operator == null || ObjectUtil.equals(operator.getStatus(), OperatorStateEnum.Futility.getCode())) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
if (operator.getHandleStatus() != null) {
|
||||
throw new WorkFlowException(MsgCode.WF031.get());
|
||||
}
|
||||
// complete为1的经办,不执行(加签、指派、转办、驳回、撤回、变更、复活流程,该节点的限时提醒规则重新生效)
|
||||
if (operator.getCompletion().equals(1)) {
|
||||
throw new WorkFlowException(MsgCode.FA001.get());
|
||||
}
|
||||
if (flowTimeModel.getOverTime()) {
|
||||
if (operator.getDuedate() == null) {
|
||||
operator.setDuedate(new Date());
|
||||
operatorService.updateById(operator);
|
||||
}
|
||||
}
|
||||
List<OperatorEntity> list = new ArrayList<>();
|
||||
list.add(operator);
|
||||
FlowMsgModel msgModel = new FlowMsgModel();
|
||||
msgModel.setFlowModel(flowTimeModel.getFlowModel());
|
||||
msgModel.setTaskEntity(task);
|
||||
msgModel.setNodeList(flowTimeModel.getFlowModel().getNodeEntityList());
|
||||
msgModel.setNodeCode(operator.getNodeCode());
|
||||
msgModel.setOperatorList(list);
|
||||
msgModel.setNotice(!flowTimeModel.getOverTime());
|
||||
msgModel.setOvertime(flowTimeModel.getOverTime());
|
||||
msgModel.setWait(false);
|
||||
msgUtil.message(msgModel);
|
||||
if (flowTimeModel.getOverTime()) {
|
||||
flowTimeModel.setNum(flowTimeModel.getNum() + 1);
|
||||
flowTimeModel.setTransferNum(flowTimeModel.getTransferNum() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,443 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.flowable.entity.*;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.enums.OperatorStateEnum;
|
||||
import com.yunzhupaas.flowable.enums.RecordEnum;
|
||||
import com.yunzhupaas.flowable.enums.TaskStatusEnum;
|
||||
import com.yunzhupaas.flowable.model.record.ProgressModel;
|
||||
import com.yunzhupaas.flowable.model.record.RecordVo;
|
||||
import com.yunzhupaas.flowable.model.record.UserItem;
|
||||
import com.yunzhupaas.flowable.model.task.FlowMethod;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.flowable.service.NodeRecordService;
|
||||
import com.yunzhupaas.flowable.service.OperatorService;
|
||||
import com.yunzhupaas.flowable.service.RecordService;
|
||||
import com.yunzhupaas.flowable.service.TriggerTaskService;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2024/4/26 17:05
|
||||
*/
|
||||
@Component
|
||||
public class RecordUtil {
|
||||
@Autowired
|
||||
private RecordService recordService;
|
||||
@Autowired
|
||||
private ServiceUtil serviceUtil;
|
||||
@Autowired
|
||||
private OperatorUtil operatorUtil;
|
||||
@Autowired
|
||||
private OperatorService operatorService;
|
||||
@Autowired
|
||||
private NodeRecordService nodeRecordService;
|
||||
@Autowired
|
||||
private TriggerTaskService triggerTaskService;
|
||||
|
||||
// 根据经办主键获取转审/转办记录
|
||||
public RecordEntity getTransferRecord(String operatorId) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RecordEntity::getOperatorId, operatorId)
|
||||
.in(RecordEntity::getHandleType, RecordEnum.transfer.getCode(), RecordEnum.transferProcessing.getCode())
|
||||
.orderByDesc(RecordEntity::getHandleTime);
|
||||
queryWrapper.lambda().select(RecordEntity::getId, RecordEntity::getHandleId);
|
||||
List<RecordEntity> list = recordService.page(new Page<>(1, 1, false), queryWrapper).getRecords();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
return list.get(0);
|
||||
}
|
||||
return new RecordEntity();
|
||||
}
|
||||
|
||||
// 获取节点记录
|
||||
public List<NodeRecordEntity> getNodeRecord(String taskId) {
|
||||
QueryWrapper<NodeRecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(NodeRecordEntity::getTaskId, taskId).ne(NodeRecordEntity::getNodeStatus, 5)
|
||||
.orderByDesc(NodeRecordEntity::getCreatorTime);
|
||||
List<NodeRecordEntity> list = nodeRecordService.list(queryWrapper);
|
||||
return CollectionUtil.isNotEmpty(list) ? list : new ArrayList<>();
|
||||
}
|
||||
|
||||
// 根据任务主键、节点id 获取记录
|
||||
public List<RecordEntity> getList(String taskId, String nodeId) {
|
||||
QueryWrapper<RecordEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(RecordEntity::getTaskId, taskId).eq(RecordEntity::getNodeId, nodeId)
|
||||
.orderByDesc(RecordEntity::getHandleTime);
|
||||
return recordService.list(wrapper);
|
||||
}
|
||||
|
||||
public List<RecordEntity> getList(String taskId) {
|
||||
QueryWrapper<RecordEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(RecordEntity::getTaskId, taskId).orderByAsc(RecordEntity::getHandleTime);
|
||||
return recordService.list(wrapper);
|
||||
}
|
||||
|
||||
public void updateRecords(List<RecordEntity> recordList) {
|
||||
if (CollectionUtil.isNotEmpty(recordList)) {
|
||||
recordService.updateBatchById(recordList);
|
||||
}
|
||||
}
|
||||
|
||||
// 将经办相关的记录作废
|
||||
public void invalid(List<OperatorEntity> operatorList) {
|
||||
List<String> opIds = operatorList.stream().map(OperatorEntity::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(opIds)) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().in(RecordEntity::getOperatorId, opIds);
|
||||
List<RecordEntity> list = recordService.list(queryWrapper);
|
||||
for (RecordEntity record : list) {
|
||||
record.setStatus(-1);
|
||||
}
|
||||
recordService.updateBatchById(list);
|
||||
}
|
||||
}
|
||||
|
||||
// 作废加签记录
|
||||
public void invalidAddSignRecord(OperatorEntity operator) {
|
||||
if (null != operator && null != operator.getId()) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RecordEntity::getOperatorId, operator.getId()).eq(RecordEntity::getHandleType,
|
||||
RecordEnum.addSign.getCode());
|
||||
List<RecordEntity> list = recordService.list(queryWrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (RecordEntity record : list) {
|
||||
record.setStatus(-1);
|
||||
}
|
||||
recordService.updateBatchById(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建记录
|
||||
*/
|
||||
public void createRecord(FlowMethod flowMethod) {
|
||||
FlowModel flowModel = flowMethod.getFlowModel();
|
||||
String userId = flowMethod.getUserId();
|
||||
OperatorEntity operator = flowMethod.getOperatorEntity();
|
||||
Integer type = flowMethod.getType();
|
||||
String handId = flowMethod.getHandId();
|
||||
|
||||
// 已存在同意操作的记录(说明是后加签默认同意,无需再次保存)
|
||||
if (ObjectUtil.equals(RecordEnum.audit.getCode(), type)) {
|
||||
QueryWrapper<RecordEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(RecordEntity::getOperatorId, operator.getId())
|
||||
.eq(RecordEntity::getHandleType, type)
|
||||
.ne(RecordEntity::getStatus, -1);
|
||||
if (recordService.count(queryWrapper) > 0)
|
||||
return;
|
||||
}
|
||||
|
||||
RecordEntity entity = new RecordEntity();
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setHandleId(handId);
|
||||
if (null != operator) {
|
||||
if (StringUtil.isBlank(handId)) {
|
||||
if (ObjectUtil.equals(operator.getHandleId(), FlowNature.SYSTEM_CODE)) {
|
||||
entity.setHandleId(FlowNature.SYSTEM_CODE);
|
||||
} else {
|
||||
entity.setHandleId(operator.getHandleId());
|
||||
}
|
||||
}
|
||||
if (StringUtil.isBlank(entity.getHandleId())) {
|
||||
String loginUserId = UserProvider.getLoginUserId();
|
||||
entity.setHandleId(loginUserId);
|
||||
}
|
||||
entity.setNodeId(operator.getNodeId());
|
||||
entity.setNodeCode(operator.getNodeCode());
|
||||
entity.setNodeName(operator.getNodeName());
|
||||
entity.setTaskId(operator.getTaskId());
|
||||
entity.setOperatorId(operator.getId());
|
||||
entity.setHandleType(operator.getHandleStatus());
|
||||
entity.setHandleTime(operator.getHandleTime() == null ? new Date() : operator.getHandleTime());
|
||||
entity.setCreatorTime(operator.getCreatorTime() == null ? new Date() : operator.getCreatorTime());
|
||||
}
|
||||
entity.setHandleOpinion(flowModel.getHandleOpinion());
|
||||
entity.setHandleUserId(userId);
|
||||
entity.setSignImg(flowModel.getSignImg());
|
||||
if (CollectionUtil.isNotEmpty(flowModel.getFileList())) {
|
||||
entity.setFileList(JsonUtil.getObjectToString(flowModel.getFileList()));
|
||||
}
|
||||
// 拓展字段
|
||||
List<Map> expandField = flowModel.getApprovalField();
|
||||
if (CollectionUtil.isNotEmpty(expandField)) {
|
||||
String str = JsonUtil.getObjectToString(expandField);
|
||||
entity.setExpandField(str);
|
||||
}
|
||||
entity.setHandleType(type);
|
||||
entity.setStatus(0);
|
||||
|
||||
recordService.save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流转记录
|
||||
*
|
||||
* @param records 流转记录集合
|
||||
*/
|
||||
public List<RecordVo> getRecordList(List<RecordEntity> records) {
|
||||
List<RecordVo> vos = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(records)) {
|
||||
List<UserEntity> userList = serviceUtil
|
||||
.getUserName(records.stream().map(RecordEntity::getHandleId).collect(Collectors.toList()));
|
||||
for (RecordEntity record : records) {
|
||||
RecordVo vo = JsonUtil.getJsonToBean(record, RecordVo.class);
|
||||
UserEntity userEntity = userList.stream().filter(t -> t.getId().equals(record.getHandleId()))
|
||||
.findFirst().orElse(null);
|
||||
vo.setUserName(userEntity != null ? userEntity.getRealName() + "/" + userEntity.getAccount() : "");
|
||||
if (userEntity != null) {
|
||||
vo.setHeadIcon(UploaderUtil.uploaderImg(userEntity.getHeadIcon()));
|
||||
}
|
||||
// 设置流转操作人
|
||||
String handleUserId = record.getHandleUserId();
|
||||
if (StringUtil.isNotEmpty(handleUserId)) {
|
||||
List<String> userIds = Arrays.stream(handleUserId.split(",")).collect(Collectors.toList());
|
||||
List<UserEntity> handleUserList = serviceUtil.getUserName(userIds);
|
||||
List<String> handleUserName = new ArrayList<>();
|
||||
for (String userId : userIds) {
|
||||
UserEntity user = handleUserList.stream().filter(t -> t.getId().equals(userId)).findFirst()
|
||||
.orElse(null);
|
||||
if (null != user) {
|
||||
handleUserName.add(user.getRealName() + "/" + user.getAccount());
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(handleUserName)) {
|
||||
vo.setHandleUserName(String.join(",", handleUserName));
|
||||
}
|
||||
}
|
||||
if (record.getExpandField() != null) {
|
||||
List<Map> expandField = JsonUtil.getJsonToList(record.getExpandField(), Map.class);
|
||||
vo.setApprovalField(expandField);
|
||||
}
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进度
|
||||
*
|
||||
* @param flowModel 参数
|
||||
*/
|
||||
public List<ProgressModel> getProgressList(FlowModel flowModel) throws WorkFlowException {
|
||||
List<ProgressModel> progressList = new ArrayList<>();
|
||||
TaskEntity taskEntity = flowModel.getTaskEntity();
|
||||
List<TemplateNodeEntity> nodeEntities = flowModel.getNodeEntityList();
|
||||
|
||||
List<NodeRecordEntity> nodeRecordList = nodeRecordService.getList(taskEntity.getId());
|
||||
|
||||
List<OperatorEntity> operatorList = operatorService.getList(taskEntity.getId());
|
||||
List<RecordEntity> recordList = recordService.getList(taskEntity.getId());
|
||||
|
||||
List<String> userIds = new ArrayList<>();
|
||||
List<String> operatorUserIds = operatorList.stream().map(OperatorEntity::getHandleId)
|
||||
.collect(Collectors.toList());
|
||||
List<String> recordUserIds = recordList.stream().map(RecordEntity::getHandleId).collect(Collectors.toList());
|
||||
userIds.addAll(operatorUserIds);
|
||||
userIds.addAll(recordUserIds);
|
||||
userIds = userIds.stream().distinct().collect(Collectors.toList());
|
||||
|
||||
List<UserEntity> users = serviceUtil.getUserName(userIds, false);
|
||||
|
||||
for (NodeRecordEntity nodeRecord : nodeRecordList) {
|
||||
|
||||
TemplateNodeEntity nodeEntity = nodeEntities.stream()
|
||||
.filter(e -> e.getNodeCode().equals(nodeRecord.getNodeCode())).findFirst().orElse(null);
|
||||
if (null == nodeEntity) {
|
||||
continue;
|
||||
}
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(nodeEntity.getNodeJson(), NodeModel.class);
|
||||
if (nodeModel.getType().equals(NodeEnum.subFlow.getType())) {
|
||||
continue;
|
||||
}
|
||||
ProgressModel model = new ProgressModel();
|
||||
model.setId(RandomUtil.uuId());
|
||||
model.setStartTime(nodeRecord.getCreatorTime().getTime());
|
||||
model.setNodeId(nodeRecord.getNodeId());
|
||||
model.setNodeCode(nodeRecord.getNodeCode());
|
||||
model.setNodeName(nodeRecord.getNodeName());
|
||||
model.setNodeType(NodeEnum.approver.getType());
|
||||
model.setNodeStatus(nodeRecord.getNodeStatus());
|
||||
if (nodeModel.getType().equals(NodeEnum.start.getType())) {
|
||||
model.setNodeType(NodeEnum.start.getType());
|
||||
progressList.add(model);
|
||||
continue;
|
||||
}
|
||||
|
||||
model.setCounterSign(nodeModel.getCounterSign());
|
||||
|
||||
List<RecordEntity> records = recordList.stream()
|
||||
.filter(e -> Objects.equals(e.getNodeCode(), nodeModel.getNodeId())
|
||||
&& Objects.equals(e.getNodeId(), nodeRecord.getNodeId()))
|
||||
.sorted(Comparator.comparing(RecordEntity::getHandleTime).reversed()).collect(Collectors.toList());
|
||||
|
||||
model.setApproverCount(CollectionUtil.isNotEmpty(records) ? records.size() : 0);
|
||||
|
||||
List<UserItem> items = new ArrayList<>();
|
||||
for (int i = 0; i < records.size(); i++) {
|
||||
UserItem item = new UserItem();
|
||||
RecordEntity record = records.get(i);
|
||||
UserEntity user = users.stream().filter(e -> ObjectUtil.equals(record.getHandleId(), e.getId()))
|
||||
.findFirst().orElse(null);
|
||||
if (user != null) {
|
||||
item.setHeadIcon(UploaderUtil.uploaderImg(user.getHeadIcon()));
|
||||
item.setUserId(user.getId());
|
||||
item.setUserName(user.getRealName());
|
||||
} else {
|
||||
item.setHeadIcon(UploaderUtil.uploaderImg(FlowNature.SYSTEM_HEAD_ICON));
|
||||
item.setUserId(FlowNature.SYSTEM_CODE);
|
||||
item.setUserName(FlowNature.SYSTEM_NAME);
|
||||
}
|
||||
item.setHandleType(record.getHandleType());
|
||||
items.add(item);
|
||||
if (i == 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
model.setApprover(items);
|
||||
// 判断是否存在任务流程
|
||||
model.setShowTaskFlow(triggerTaskService.existTriggerTask(taskEntity.getId(), model.getNodeId()));
|
||||
progressList.add(model);
|
||||
}
|
||||
|
||||
// 当前节点
|
||||
List<Integer> status = ImmutableList.of(TaskStatusEnum.RECALL.getCode(), TaskStatusEnum.BACKED.getCode(),
|
||||
TaskStatusEnum.CANCEL.getCode());
|
||||
if (taskEntity.getEndTime() == null && !status.contains(taskEntity.getStatus())) {
|
||||
String currentNodeCode = taskEntity.getCurrentNodeCode();
|
||||
if (StringUtil.isNotBlank(currentNodeCode)) {
|
||||
List<String> currentCodeList = Arrays.stream(currentNodeCode.split(",")).collect(Collectors.toList());
|
||||
|
||||
for (int i = 0; i < currentCodeList.size(); i++) {
|
||||
String nodeCode = currentCodeList.get(i);
|
||||
|
||||
TemplateNodeEntity nodeEntity = nodeEntities.stream().filter(e -> e.getNodeCode().equals(nodeCode))
|
||||
.findFirst().orElse(null);
|
||||
if (null == nodeEntity) {
|
||||
continue;
|
||||
}
|
||||
NodeModel nodeModel = JsonUtil.getJsonToBean(nodeEntity.getNodeJson(), NodeModel.class);
|
||||
if (nodeModel.getType().equals(NodeEnum.subFlow.getType())) {
|
||||
continue;
|
||||
}
|
||||
boolean isProcessing = ObjectUtil.equals(nodeEntity.getNodeType(), NodeEnum.processing.getType());
|
||||
ProgressModel model = new ProgressModel();
|
||||
model.setId(RandomUtil.uuId());
|
||||
|
||||
model.setNodeCode(nodeCode);
|
||||
model.setNodeName(nodeModel.getNodeName());
|
||||
model.setNodeType(isProcessing ? NodeEnum.processing.getType() : NodeEnum.approver.getType());
|
||||
model.setNodeStatus(isProcessing ? 8 : 4);
|
||||
model.setCounterSign(nodeModel.getCounterSign());
|
||||
|
||||
List<OperatorEntity> operators = operatorList.stream()
|
||||
.filter(e -> Objects.equals(e.getNodeCode(), nodeModel.getNodeId())
|
||||
&& !(ObjectUtil.equals(e.getCompletion(), 1) && null == e.getHandleTime()
|
||||
&& !ObjectUtil.equals(e.getParentId(), "0"))
|
||||
&& !Objects.equals(e.getStatus(), OperatorStateEnum.Assist.getCode())
|
||||
&& !Objects.equals(e.getStatus(), OperatorStateEnum.Futility.getCode()))
|
||||
.sorted(Comparator.comparing(OperatorEntity::getCreatorTime, Comparator.reverseOrder())
|
||||
.thenComparing(OperatorEntity::getCompletion))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
String nodeId;
|
||||
if (CollectionUtil.isNotEmpty(operators)) {
|
||||
OperatorEntity operator = operators.get(0);
|
||||
nodeId = operator.getNodeId();
|
||||
model.setStartTime(operators.get(0).getCreatorTime().getTime());
|
||||
operators = operators.stream().filter(e -> ObjectUtil.equals(e.getNodeId(), nodeId))
|
||||
.collect(Collectors.toList());
|
||||
// 触发节点选择同步,变更为等待中状态
|
||||
if (ObjectUtil.equals(operator.getStatus(), OperatorStateEnum.Waiting.getCode())) {
|
||||
model.setNodeStatus(7);
|
||||
}
|
||||
} else {
|
||||
nodeId = "";
|
||||
}
|
||||
model.setNodeId(nodeId);
|
||||
model.setApproverCount(CollectionUtil.isNotEmpty(operators) ? operators.size() : 0);
|
||||
|
||||
List<RecordEntity> records = recordList.stream()
|
||||
.filter(e -> Objects.equals(e.getNodeCode(), nodeModel.getNodeId()))
|
||||
.sorted(Comparator.comparing(RecordEntity::getHandleTime).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<UserItem> items = new ArrayList<>();
|
||||
for (int j = 0; j < operators.size(); j++) {
|
||||
OperatorEntity operator = operators.get(j);
|
||||
UserItem item = new UserItem();
|
||||
UserEntity user = users.stream()
|
||||
.filter(e -> ObjectUtil.equals(operator.getHandleId(), e.getId())).findFirst()
|
||||
.orElse(null);
|
||||
if (user != null) {
|
||||
item.setHeadIcon(UploaderUtil.uploaderImg(user.getHeadIcon()));
|
||||
item.setUserId(user.getId());
|
||||
item.setUserName(user.getRealName());
|
||||
} else {
|
||||
if (ObjectUtil.equals(operator.getHandleId(), FlowNature.SYSTEM_CODE)) {
|
||||
item.setHeadIcon(FlowNature.SYSTEM_HEAD_ICON);
|
||||
item.setUserName(FlowNature.SYSTEM_NAME);
|
||||
item.setUserId(FlowNature.SYSTEM_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
if (null != operator.getHandleStatus() && null != operator.getHandleTime()) {
|
||||
item.setHandleType(operator.getHandleStatus());
|
||||
} else {
|
||||
RecordEntity record = records.stream()
|
||||
.sorted(Comparator.comparing(RecordEntity::getId).reversed())
|
||||
.filter(e -> ObjectUtil.equals(e.getOperatorId(), operator.getId())
|
||||
&& ObjectUtil.equals(e.getNodeId(), operator.getNodeId())
|
||||
&& !ObjectUtil.equals(e.getStatus(), -1)
|
||||
&& !ObjectUtil.equals(e.getHandleType(), RecordEnum.back.getCode()))
|
||||
.findFirst().orElse(null);
|
||||
if (null != record) {
|
||||
item.setHandleType(record.getHandleType());
|
||||
} else {
|
||||
// -1.待审 -2.未审 -3.待办理 -4.未办理(暂未用到)
|
||||
item.setHandleType(isProcessing ? -3 : -1);
|
||||
}
|
||||
}
|
||||
items.add(item);
|
||||
}
|
||||
// items =
|
||||
// items.stream().sorted(Comparator.comparing(UserItem::getHandleType)).collect(Collectors.toList());
|
||||
if (items.size() > 4) {
|
||||
items = items.subList(0, 4);
|
||||
}
|
||||
model.setApprover(items);
|
||||
progressList.add(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加结束节点
|
||||
if (taskEntity.getEndTime() != null) {
|
||||
ProgressModel model = new ProgressModel();
|
||||
model.setId(RandomUtil.uuId());
|
||||
model.setStartTime(taskEntity.getEndTime().getTime());
|
||||
model.setNodeType(NodeEnum.end.getType());
|
||||
model.setNodeName("结束");
|
||||
progressList.add(model);
|
||||
}
|
||||
return progressList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.data.redis.core.script.RedisScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 类的描述
|
||||
*
|
||||
* @author YUNZHUPAASYUNZHUPAAS开发组
|
||||
* @version 5.0.x
|
||||
* @since 2025/1/9 14:19
|
||||
*/
|
||||
@Component
|
||||
public class RedisLock {
|
||||
private static final String LOCK_KEY_PREFIX = "workflow-lock:";
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
private String getLockKey(String lockName) {
|
||||
return LOCK_KEY_PREFIX + lockName;
|
||||
}
|
||||
|
||||
// false表示设置失败
|
||||
public boolean lock(String lockName, String lockValue, long expireTime, TimeUnit unit) {
|
||||
Boolean result = redisTemplate.opsForValue().setIfAbsent(getLockKey(lockName), lockValue,
|
||||
unit.toSeconds(expireTime), TimeUnit.SECONDS);
|
||||
return result != null && result;
|
||||
}
|
||||
|
||||
public boolean unlock(String lockName, String lockValue) {
|
||||
String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
|
||||
RedisScript<Long> redisScript = new DefaultRedisScript<>(script, Long.class);
|
||||
Long result = redisTemplate.execute(redisScript, Collections.singletonList(getLockKey(lockName)),
|
||||
Collections.singletonList(lockValue));
|
||||
return result != null && result > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,515 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.entity.DataInterfaceEntity;
|
||||
import com.yunzhupaas.base.entity.DictionaryDataEntity;
|
||||
import com.yunzhupaas.base.entity.VisualdevEntity;
|
||||
import com.yunzhupaas.base.model.VisualDevJsonModel;
|
||||
import com.yunzhupaas.base.model.flow.DataModel;
|
||||
import com.yunzhupaas.base.model.flow.FlowFormDataModel;
|
||||
import com.yunzhupaas.base.model.schedule.ScheduleNewCrForm;
|
||||
import com.yunzhupaas.base.model.systemconfig.SysConfigModel;
|
||||
import com.yunzhupaas.base.service.*;
|
||||
import com.yunzhupaas.base.util.SentMessageUtil;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.emnus.ModuleTypeEnum;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.extend.service.DocumentApi;
|
||||
import com.yunzhupaas.flowable.entity.TemplateEntity;
|
||||
import com.yunzhupaas.flowable.model.template.TemplateExportModel;
|
||||
import com.yunzhupaas.flowable.model.util.FlowContextHolder;
|
||||
import com.yunzhupaas.flowable.model.util.FlowNature;
|
||||
import com.yunzhupaas.message.model.SentMessageForm;
|
||||
import com.yunzhupaas.message.service.SendMessageConfigService;
|
||||
import com.yunzhupaas.model.document.FlowFileModel;
|
||||
import com.yunzhupaas.model.login.UserSystemVO;
|
||||
import com.yunzhupaas.onlinedev.model.PaginationModel;
|
||||
import com.yunzhupaas.base.model.OnlineImport.VisualdevModelDataInfoVO;
|
||||
import com.yunzhupaas.onlinedev.model.VisualParamModel;
|
||||
import com.yunzhupaas.permission.constant.AuthorizeConst;
|
||||
import com.yunzhupaas.permission.entity.*;
|
||||
import com.yunzhupaas.permission.model.organizeadministrator.OrganizeAdministratorModel;
|
||||
import com.yunzhupaas.permission.model.user.UserIdListVo;
|
||||
import com.yunzhupaas.permission.service.*;
|
||||
import com.yunzhupaas.util.DataFileExport;
|
||||
import com.yunzhupaas.util.GeneraterSwapUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.enums.DictionaryDataEnum;
|
||||
import com.yunzhupaas.visual.service.VisualdevApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.yunzhupaas.util.Constants.ADMIN_KEY;
|
||||
|
||||
@Component
|
||||
public class ServiceUtil {
|
||||
@Autowired
|
||||
private DictionaryDataService dictionaryDataService;
|
||||
@Autowired
|
||||
private UserRelationService userRelationService;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private OrganizeService organizeService;
|
||||
@Autowired
|
||||
private OrganizeAdministratorService organizeAdministratorService;
|
||||
@Autowired
|
||||
private PositionService positionService;
|
||||
@Autowired
|
||||
private BillRuleService billRuleService;
|
||||
@Autowired
|
||||
private DataInterfaceService dataInterfaceService;
|
||||
@Autowired
|
||||
private SentMessageUtil sentMessageUtil;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private FlowAsyncUtil flowAsyncUtil;
|
||||
@Autowired
|
||||
private SendMessageConfigService sendMessageConfigService;
|
||||
@Autowired
|
||||
private DataFileExport fileExport;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private CommonWordsService commonWordsService;
|
||||
@Autowired
|
||||
private SignService signService;
|
||||
|
||||
@Autowired
|
||||
private PermissionGroupService permissionGroupService;
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Autowired
|
||||
private VisualdevApi visualdevApi;
|
||||
@Autowired
|
||||
private DocumentApi documentApi;
|
||||
@Autowired
|
||||
private GeneraterSwapUtil generaterSwapUtil;
|
||||
@Autowired
|
||||
private SystemConfigApi systemConfigApi;
|
||||
@Autowired
|
||||
private ScheduleNewApi scheduleNewApi;
|
||||
|
||||
// 创建日程
|
||||
public void createSchedule(ScheduleNewCrForm fo) throws WorkFlowException {
|
||||
ActionResult result = scheduleNewApi.create(fo);
|
||||
if (result.getCode() != 200) {
|
||||
throw new WorkFlowException(result.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
// 获取系统配置
|
||||
public SysConfigModel getSysConfig() {
|
||||
ActionResult<SysConfigModel> actionResult = systemConfigApi.list();
|
||||
return actionResult.getData();
|
||||
}
|
||||
|
||||
// 获取系统配置,流程签收
|
||||
public Boolean getFlowSign() {
|
||||
ActionResult<SysConfigModel> actionResult = systemConfigApi.list();
|
||||
SysConfigModel data = actionResult.getData();
|
||||
return data.getFlowSign() == 0;
|
||||
}
|
||||
|
||||
// 获取系统配置,流程办理
|
||||
public Boolean getFlowTodo() {
|
||||
ActionResult<SysConfigModel> actionResult = systemConfigApi.list();
|
||||
SysConfigModel data = actionResult.getData();
|
||||
return data.getFlowTodo() == 0;
|
||||
}
|
||||
|
||||
// 流水号
|
||||
public String getBillNumber() {
|
||||
return generaterSwapUtil.getBillNumber(FlowNature.REVOKE_BILL_CODE, false);
|
||||
}
|
||||
|
||||
// -------------------------------签名-----------------------------
|
||||
public void updateSign(String signId, String signImg) {
|
||||
SignEntity signEntity = signService.getById(signId);
|
||||
if (null != signEntity) {
|
||||
signService.updateDefault(signId);
|
||||
} else {
|
||||
signEntity = new SignEntity();
|
||||
signEntity.setIsDefault(1);
|
||||
signEntity.setSignImg(signImg);
|
||||
signService.create(signEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------常用语-----------------------------
|
||||
public void addCommonWordsNum(String handleOpinion) {
|
||||
commonWordsService.addCommonWordsNum(handleOpinion);
|
||||
}
|
||||
|
||||
// -------------------------------文件-----------------------------
|
||||
// 判断是否存在归档文件,不存在为true
|
||||
public Boolean checkFlowFile(String taskId) {
|
||||
return documentApi.checkFlowFile(taskId);
|
||||
}
|
||||
|
||||
// 获取归档文件
|
||||
public List<Map<String, Object>> getFlowFile(FlowFileModel model) {
|
||||
return documentApi.getFlowFile(model);
|
||||
}
|
||||
|
||||
// -------------------------------发起权限-----------------------------
|
||||
public List<String> getLaunchPermission(String userId) {
|
||||
List<String> resList = new ArrayList<>();
|
||||
List<PermissionGroupEntity> groups = permissionGroupService.getPermissionGroupByUserId(userId, null, false, null);
|
||||
if (CollectionUtil.isNotEmpty(groups)) {
|
||||
List<String> objectIds = groups.stream().map(PermissionGroupEntity::getId).collect(Collectors.toList());
|
||||
resList = authorizeService.getListByObjectId(objectIds)
|
||||
.stream().filter(t -> AuthorizeConst.FLOW.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
// true是普通用户
|
||||
public boolean isCommonUser(String userId) {
|
||||
List<UserSystemVO> userStanding = authorizeService.getUserStanding(false, userId);
|
||||
return userStanding.stream().anyMatch(t -> "3".equals(t.getId()));
|
||||
}
|
||||
|
||||
// true是分管
|
||||
public boolean isOrgAdmin(String userId) {
|
||||
List<UserSystemVO> userStanding = authorizeService.getUserStanding(true, userId);
|
||||
return userStanding.stream().anyMatch(t -> "2".equals(t.getId()));
|
||||
}
|
||||
|
||||
// 获取流程有发起权限的人员
|
||||
public List<UserEntity> getLaunchUserByTemplateId(TemplateEntity template, Pagination pagination) {
|
||||
if (ObjectUtil.equals(template.getVisibleType(), 1)) {
|
||||
// 公开直接返回用户分页
|
||||
return userService.getUserPage(pagination);
|
||||
}
|
||||
|
||||
// 根据流程主键、权限为流程类型 获取权限关联
|
||||
List<AuthorizeEntity> flowAuthList = authorizeService.getListByObjectAndItemIdAndType(template.getId(), AuthorizeConst.FLOW);
|
||||
// 获取权限组
|
||||
List<String> groupIds = flowAuthList.stream().map(AuthorizeEntity::getObjectId).collect(Collectors.toList());
|
||||
List<PermissionGroupEntity> permissionGroupList = permissionGroupService.list(true, groupIds);
|
||||
permissionGroupList = permissionGroupList.stream().filter(e -> ObjectUtil.equals(e.getEnabledMark(), 1)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(permissionGroupList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
for (PermissionGroupEntity permission : permissionGroupList) {
|
||||
if (permission.getType() != null && permission.getType().equals(1)) {
|
||||
// 自定义
|
||||
String permissionMember = permission.getPermissionMember();
|
||||
if (StringUtil.isNotEmpty(permissionMember)) {
|
||||
String[] split = permissionMember.split(",");
|
||||
userIdList.addAll(Arrays.stream(split).collect(Collectors.toList()));
|
||||
}
|
||||
} else {
|
||||
// 全部成员,直接分页返回
|
||||
List<UserEntity> userPage = userService.getUserPage(pagination);
|
||||
return userPage;
|
||||
}
|
||||
}
|
||||
List<String> userListAll = this.getUserListAll(userIdList);
|
||||
return this.getUserName(userListAll, pagination);
|
||||
}
|
||||
|
||||
//--------------------------------表单------------------------------
|
||||
public VisualdevEntity getFormInfo(String id) {
|
||||
return visualdevApi.getFormConfig(id);
|
||||
}
|
||||
|
||||
public List<VisualdevEntity> getFormList(List<String> formIds) {
|
||||
if (formIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return visualdevApi.getFormConfigList(formIds);
|
||||
}
|
||||
|
||||
public void saveOrUpdateFormData(FlowFormDataModel model) throws WorkFlowException {
|
||||
ActionResult actionResult = visualdevApi.saveOrUpdate(model);
|
||||
if (actionResult.getCode() != 200) {
|
||||
throw new WorkFlowException(actionResult.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteFormData(String formId, String id) throws Exception {
|
||||
if (StringUtil.isBlank(formId) || StringUtil.isBlank(id)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
visualdevApi.delete(formId, id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> infoData(String formId, String id) throws WorkFlowException {
|
||||
// 流程调用表单接口
|
||||
Map<String, Object> dataAll = new HashMap<>();
|
||||
if (StringUtil.isNotEmpty(formId) && StringUtil.isNotEmpty(id)) {
|
||||
ActionResult result = visualdevApi.info(formId, id);
|
||||
if (null != result && null != result.getData()) {
|
||||
dataAll = (Map<String, Object>) result.getData();
|
||||
}
|
||||
}
|
||||
return dataAll;
|
||||
}
|
||||
|
||||
public void handleFormData(String flowId, Boolean isTransfer) throws WorkFlowException {
|
||||
try {
|
||||
Map<String, Map<String, Object>> allData = FlowContextHolder.getAllData();
|
||||
Map<String, List<Map<String, Object>>> formOperates = FlowContextHolder.getFormOperates();
|
||||
List<String> writeIdList = FlowContextHolder.getWriteIdList();
|
||||
for (String key : writeIdList) {
|
||||
String[] idList = key.split("_yunzhupaas_");
|
||||
List<Map<String, Object>> operates = formOperates.get(key);
|
||||
Map<String, Object> formData = allData.get(key);
|
||||
formData = formData == null ? new HashMap<>() : formData;
|
||||
FlowFormDataModel formDataModel = FlowFormDataModel.builder().formId(idList[1]).id(idList[0]).map(formData).formOperates(operates)
|
||||
.flowId(flowId).isTransfer(isTransfer).build();
|
||||
this.saveOrUpdateFormData(formDataModel);
|
||||
}
|
||||
} catch (WorkFlowException e) {
|
||||
throw e;
|
||||
} finally {
|
||||
FlowContextHolder.clearAll();
|
||||
}
|
||||
}
|
||||
|
||||
public VisualdevModelDataInfoVO getEditDataInfo(String id, VisualdevEntity visualdevEntity) {
|
||||
return visualdevApi.getEditDataInfo(id, visualdevEntity);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getListWithTableList(VisualDevJsonModel visualDevJsonModel, PaginationModel pagination, UserInfo userInfo) {
|
||||
return visualdevApi.getListWithTableList(visualDevJsonModel, pagination, userInfo);
|
||||
}
|
||||
|
||||
public VisualdevEntity getReleaseInfo(String formId) {
|
||||
return visualdevApi.getReleaseInfo(formId);
|
||||
}
|
||||
|
||||
public DataModel visualCreate(VisualdevEntity visualdevEntity, Map<String, Object> data) throws Exception {
|
||||
VisualParamModel visualParamModel = VisualParamModel.builder().visualdevEntity(visualdevEntity).data(data).build();
|
||||
return visualdevApi.visualCreate(visualParamModel);
|
||||
}
|
||||
|
||||
public DataModel visualUpdate(VisualdevEntity visualdevEntity, Map<String, Object> data, String id) throws Exception {
|
||||
VisualParamModel visualParamModel = VisualParamModel.builder().visualdevEntity(visualdevEntity).data(data).id(id).onlyUpdate(true).build();
|
||||
return visualdevApi.visualUpdate(visualParamModel);
|
||||
}
|
||||
|
||||
public void visualDelete(VisualdevEntity visualdevEntity, List<Map<String, Object>> dataList) throws Exception {
|
||||
VisualParamModel visualParamModel = VisualParamModel.builder().visualdevEntity(visualdevEntity).dataList(dataList).build();
|
||||
visualdevApi.visualDelete(visualParamModel);
|
||||
}
|
||||
|
||||
public void deleteSubTable(FlowFormDataModel model) throws Exception {
|
||||
visualdevApi.deleteByTableName(model);
|
||||
}
|
||||
|
||||
//--------------------------------数据字典------------------------------
|
||||
public List<DictionaryDataEntity> getDiList() {
|
||||
List<DictionaryDataEntity> dictionList = dictionaryDataService.getListByTypeDataCode(DictionaryDataEnum.FLOWWOEK_ENGINE.getDictionaryTypeId());
|
||||
return dictionList;
|
||||
}
|
||||
|
||||
public List<DictionaryDataEntity> getDictionName(List<String> id) {
|
||||
List<DictionaryDataEntity> dictionList = dictionaryDataService.getDictionName(id);
|
||||
return dictionList;
|
||||
}
|
||||
|
||||
//--------------------------------用户关系表------------------------------
|
||||
public List<UserRelationEntity> getListByUserIdAll(List<String> id) {
|
||||
List<UserRelationEntity> list = userRelationService.getListByUserIdAll(id).stream().filter(t -> StringUtil.isNotEmpty(t.getObjectId())).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserRelationEntity> getListByObjectIdAll(List<String> id) {
|
||||
List<UserRelationEntity> list = userRelationService.getListByObjectIdAll(id);
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getAdmin() {
|
||||
UserEntity admin = userService.getUserByAccount(ADMIN_KEY);
|
||||
return admin.getId();
|
||||
}
|
||||
|
||||
//--------------------------------用户------------------------------
|
||||
public List<UserEntity> getUserByAccount(List<String> accountList) {
|
||||
List<UserEntity> list = new ArrayList<>();
|
||||
if (CollectionUtil.isEmpty(accountList)) {
|
||||
return list;
|
||||
}
|
||||
for (String account : accountList) {
|
||||
UserEntity user = userService.getUserByAccount(account);
|
||||
if (null != user) {
|
||||
list.add(user);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserEntity> getUserName(List<String> id) {
|
||||
List<UserEntity> list = getUserName(id, false);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserEntity> getListByManagerId(String managerId) {
|
||||
List<UserEntity> list = StringUtil.isNotEmpty(managerId) ? userService.getListByManagerId(managerId, null) : new ArrayList<>();
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserEntity> getUserName(List<String> id, boolean enableMark) {
|
||||
List<UserEntity> list = userService.getUserName(id);
|
||||
if (enableMark) list = list.stream().filter(t -> t.getEnabledMark() == 1).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserEntity> getUserName(List<String> id, Pagination pagination) {
|
||||
List<UserEntity> list = userService.getUserName(id, pagination);
|
||||
return list;
|
||||
}
|
||||
|
||||
public UserEntity getUserInfo(String id) {
|
||||
UserEntity entity = null;
|
||||
if (StringUtil.isNotEmpty(id)) {
|
||||
entity = id.equalsIgnoreCase(ADMIN_KEY) ? userService.getUserByAccount(id) : userService.getInfo(id);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<String> getUserListAll(List<String> idList) {
|
||||
List<String> userIdList = userService.getUserIdList(idList, null);
|
||||
return userIdList;
|
||||
}
|
||||
|
||||
public List<UserEntity> getAdminList() {
|
||||
return userService.getAdminList();
|
||||
}
|
||||
|
||||
public List<String> getOrganizeUserList(String type) {
|
||||
OrganizeAdministratorModel model = organizeAdministratorService.getOrganizeAdministratorList();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
map.put("select", model.getSelectList());
|
||||
map.put("add", model.getAddList());
|
||||
map.put("delete", model.getDeleteList());
|
||||
map.put("edit", model.getEditList());
|
||||
List<String> list = map.get(type) != null ? map.get(type) : new ArrayList<>();
|
||||
List<String> userList = userRelationService.getListByObjectIdAll(list).stream().map(UserRelationEntity::getUserId).collect(Collectors.toList());
|
||||
return userList;
|
||||
}
|
||||
|
||||
public List<UserIdListVo> getUserList(List<String> userIds, Pagination pagination, String type) {
|
||||
List<UserIdListVo> list = userService.getObjList(userIds, pagination, type);
|
||||
return list;
|
||||
}
|
||||
|
||||
//--------------------------------角色------------------------------
|
||||
public List<RoleEntity> getListByIds(List<String> id) {
|
||||
List<RoleEntity> list = roleService.getListByIds(id, null, false);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<RoleEntity> getCurRolesByOrgId(String orgId) {
|
||||
List<RoleEntity> curRolesByOrgId = roleService.getCurRolesByOrgId(orgId);
|
||||
return curRolesByOrgId;
|
||||
}
|
||||
|
||||
//--------------------------------组织------------------------------
|
||||
public List<OrganizeEntity> getOrganizeName(List<String> id) {
|
||||
List<OrganizeEntity> list = organizeService.getOrganizeName(id);
|
||||
return list;
|
||||
}
|
||||
|
||||
public OrganizeEntity getOrganizeInfo(String id) {
|
||||
OrganizeEntity entity = StringUtil.isNotEmpty(id) ? organizeService.getInfo(id) : null;
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<OrganizeEntity> getOrganizeId(String organizeId) {
|
||||
List<OrganizeEntity> organizeList = new ArrayList<>();
|
||||
organizeService.getOrganizeId(organizeId, organizeList);
|
||||
Collections.reverse(organizeList);
|
||||
return organizeList;
|
||||
}
|
||||
|
||||
public List<OrganizeEntity> getDepartmentAll(String organizeId) {
|
||||
List<OrganizeEntity> departmentAll = organizeService.getDepartmentAll(organizeId);
|
||||
return departmentAll;
|
||||
}
|
||||
|
||||
public List<String> getChildOrg(String id) {
|
||||
List<String> res = new ArrayList<>();
|
||||
// 获取 id 存在organizeIdTree中的组织
|
||||
List<OrganizeEntity> list = organizeService.getAllChild(id);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
for (OrganizeEntity entity : list) {
|
||||
res.add(entity.getId() + "--" + entity.getCategory());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<String> getUnderOrg(String orgId) {
|
||||
return organizeService.getUnderOrganizations(orgId, false);
|
||||
}
|
||||
|
||||
public List<String> getOrgUserList(String type) {
|
||||
return organizeAdministratorService.getOrganizeUserList(type);
|
||||
}
|
||||
|
||||
//--------------------------------岗位------------------------------
|
||||
public List<PositionEntity> getPositionName(List<String> id) {
|
||||
List<PositionEntity> list = positionService.getPositionName(id, false);
|
||||
return list;
|
||||
}
|
||||
|
||||
//--------------------------------远端------------------------------
|
||||
public ActionResult infoToId(String interId, Map<String, String> parameterMap) {
|
||||
return dataInterfaceService.infoToId(interId, null, parameterMap);
|
||||
}
|
||||
|
||||
public ActionResult infoToId(String interId, String tenantId, Map<String, String> parameterMap, String token) {
|
||||
return dataInterfaceService.infoToId(interId, tenantId, parameterMap, token, null, null, null, null);
|
||||
}
|
||||
|
||||
public List<DataInterfaceEntity> getInterfaceList(List<String> id) {
|
||||
return dataInterfaceService.getList(id);
|
||||
}
|
||||
|
||||
//--------------------------------发送消息------------------------------
|
||||
public void sendMessage(List<SentMessageForm> messageListAll) {
|
||||
flowAsyncUtil.sendMessage(messageListAll);
|
||||
}
|
||||
|
||||
public void updateSendConfigUsed(String id, List<String> idList) {
|
||||
sendMessageConfigService.updateUsed(id, idList);
|
||||
}
|
||||
|
||||
public List<String> sendDelegateMsg(List<SentMessageForm> messageListAll) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (SentMessageForm messageForm : messageListAll) {
|
||||
List<String> errList = sentMessageUtil.sendDelegateMsg(messageForm);
|
||||
list.addAll(errList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
//------------------------------导出-------------------------------
|
||||
public DownloadVO exportData(TemplateExportModel model) {
|
||||
DownloadVO downloadVO = fileExport.exportFile(model, configValueUtil.getTemporaryFilePath(), model.getTemplate().getFullName(), ModuleTypeEnum.FLOW_FLOWENGINE.getTableName());
|
||||
return downloadVO;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,184 @@
|
||||
package com.yunzhupaas.flowable.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.yunzhupaas.flowable.entity.OperatorEntity;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.flowable.enums.NodeEnum;
|
||||
import com.yunzhupaas.flowable.job.FlowJobUtil;
|
||||
import com.yunzhupaas.flowable.job.FlowTime;
|
||||
import com.yunzhupaas.flowable.model.task.FlowModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.NodeModel;
|
||||
import com.yunzhupaas.flowable.model.templatenode.nodejson.TimeConfig;
|
||||
import com.yunzhupaas.flowable.model.time.FlowTimeModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/22 下午7:22
|
||||
*/
|
||||
public class TimeUtil {
|
||||
|
||||
public static boolean test = false;
|
||||
|
||||
private static final SchedulerFactory schedulerFactory = new StdSchedulerFactory();
|
||||
|
||||
public static void addJob(String jobName, Integer time, Class<? extends Job> jobClass, JobDataMap jobDataMap, Date startDate, Date endDate) {
|
||||
if (jobDataMap == null) {
|
||||
jobDataMap = new JobDataMap();
|
||||
}
|
||||
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName).setJobData(jobDataMap).build();
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.forJob(jobDetail)
|
||||
.withIdentity(jobName)
|
||||
.withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInMinutes(test ? time : time * 60))
|
||||
.startAt(startDate == null ? new Date() : startDate)
|
||||
.endAt(endDate != null ? endDate : null)
|
||||
.build();
|
||||
try {
|
||||
//获取实例化的 Scheduler。
|
||||
Scheduler scheduler = getScheduler();
|
||||
//将任务及其触发器放入调度器
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
//调度器开始调度任务
|
||||
if (!scheduler.isShutdown()) {
|
||||
scheduler.start();
|
||||
}
|
||||
} catch (SchedulerException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private static Scheduler getScheduler() {
|
||||
try {
|
||||
return schedulerFactory.getScheduler();
|
||||
} catch (SchedulerException e) {
|
||||
e.getMessage();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void deleteJob(String jobName) {
|
||||
try {
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
||||
Scheduler scheduler = getScheduler();
|
||||
scheduler.pauseTrigger(triggerKey);
|
||||
scheduler.unscheduleJob(triggerKey);
|
||||
scheduler.deleteJob(JobKey.jobKey(jobName));
|
||||
} catch (SchedulerException e) {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public static void timeModel(List<OperatorEntity> operatorList, FlowModel flowModel, RedisUtil redisUtil) {
|
||||
FlowModel model = new FlowModel();
|
||||
model.setUserInfo(flowModel.getUserInfo());
|
||||
model.setNodeEntityList(flowModel.getNodeEntityList());
|
||||
model.setNodes(flowModel.getNodes());
|
||||
model.setDeploymentId(flowModel.getDeploymentId());
|
||||
model.setTaskEntity(flowModel.getTaskEntity());
|
||||
model.setFormData(flowModel.getFormData());
|
||||
List<FlowTimeModel> timeList = new ArrayList<>();
|
||||
TaskEntity task = flowModel.getTaskEntity();
|
||||
Map<String, NodeModel> nodes = flowModel.getNodes();
|
||||
Map<String, Object> formData = flowModel.getFormData();
|
||||
Map<String, List<OperatorEntity>> map = operatorList.stream().collect(Collectors.groupingBy(OperatorEntity::getNodeCode));
|
||||
for (String key : map.keySet()) {
|
||||
model.setNodeCode(key);
|
||||
NodeModel nodeModel = new NodeModel();
|
||||
NodeModel childNode = nodes.get(key);
|
||||
NodeModel startNode = nodes.values().stream().filter(e -> e.getType().equals(NodeEnum.start.getType())).findFirst().orElse(new NodeModel());
|
||||
List<OperatorEntity> operatorEntities = map.get(key);
|
||||
for (OperatorEntity entity : operatorEntities) {
|
||||
TimeConfig limit = childNode.getTimeLimitConfig();
|
||||
if (limit.getOn() == 2) {
|
||||
limit = startNode.getTimeLimitConfig();
|
||||
}
|
||||
nodeModel.setTimeLimitConfig(limit);
|
||||
boolean isOn = limit.getOn() != 0;
|
||||
if (isOn) {
|
||||
TimeConfig notice = childNode.getNoticeConfig();
|
||||
FlowTimeModel noticeModel = new FlowTimeModel();
|
||||
noticeModel.setOperatorId(entity.getId());
|
||||
noticeModel.setTaskId(entity.getTaskId());
|
||||
noticeModel.setFlowModel(model);
|
||||
if (notice.getOn() == 2) {
|
||||
notice = startNode.getNoticeConfig();
|
||||
}
|
||||
noticeModel.setOn(notice.getOn() != 0);
|
||||
nodeModel.setNoticeConfig(notice);
|
||||
FlowTimeModel overModel = new FlowTimeModel();
|
||||
overModel.setOperatorId(entity.getId());
|
||||
overModel.setTaskId(entity.getTaskId());
|
||||
overModel.setFlowModel(model);
|
||||
|
||||
TimeConfig overTime = childNode.getOverTimeConfig();
|
||||
if (overTime.getOn() == 2) {
|
||||
overTime = startNode.getOverTimeConfig();
|
||||
}
|
||||
overModel.setOn(overTime.getOn() != 0);
|
||||
nodeModel.setOverTimeConfig(overTime);
|
||||
Date date = null;
|
||||
if (limit.getNodeLimit() == 0) {
|
||||
date = entity.getCreatorTime();
|
||||
} else if (limit.getNodeLimit() == 1) {
|
||||
date = task.getStartTime();
|
||||
} else if (limit.getNodeLimit() == 2) {
|
||||
Object data = formData.get(limit.getFormField());
|
||||
try {
|
||||
date = new Date((Long) data);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
date = DateUtil.parse(String.valueOf(data));
|
||||
} catch (Exception e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (date == null) {
|
||||
// date = new Date();
|
||||
continue;
|
||||
}
|
||||
noticeModel.setStartDate(DateUtil.offsetMinute(date, test ? notice.getFirstOver() : notice.getFirstOver() * 60));
|
||||
noticeModel.setEndDate(DateUtil.offsetSecond(DateUtil.offsetMinute(date, test ? limit.getDuringDeal() : limit.getDuringDeal() * 60), 1));
|
||||
noticeModel.setChildNode(nodeModel);
|
||||
noticeModel.setDuring(notice.getOverTimeDuring());
|
||||
timeList.add(noticeModel);
|
||||
|
||||
overModel.setStartDate(DateUtil.offsetMinute(noticeModel.getEndDate(), test ? overTime.getFirstOver() : overTime.getFirstOver() * 60));
|
||||
overModel.setEndDate(null);
|
||||
overModel.setChildNode(nodeModel);
|
||||
overModel.setOverTime(true);
|
||||
overModel.setDuring(overTime.getOverTimeDuring());
|
||||
timeList.add(overModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FlowTimeModel timeModel : timeList) {
|
||||
Date date = new Date();
|
||||
if (timeModel.getEndDate() != null && timeModel.getEndDate().getTime() < date.getTime()) {
|
||||
continue;
|
||||
}
|
||||
if (timeModel.getOn()) {
|
||||
String uuid = RandomUtil.uuId();
|
||||
timeModel.setId(uuid);
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.putAll(JsonUtil.entityToMap(timeModel));
|
||||
FlowJobUtil.insertModel(timeModel, redisUtil);
|
||||
TimeUtil.addJob(uuid, timeModel.getDuring(), FlowTime.class, jobDataMap, timeModel.getStartDate(), timeModel.getEndDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user