初始代码
This commit is contained in:
21
yunzhupaas-visualdev/yunzhupaas-visualdev-integrate/pom.xml
Normal file
21
yunzhupaas-visualdev/yunzhupaas-visualdev-integrate/pom.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-integrate</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yunzhupaas-visualdev-integrate-entity</module>
|
||||
<module>yunzhupaas-visualdev-integrate-biz</module>
|
||||
<module>yunzhupaas-visualdev-integrate-controller</module>
|
||||
</modules>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev-integrate</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-integrate-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-integrate-entity</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-base-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-onlinedev-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-flowable-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yunzhupaas.integrate.config;
|
||||
|
||||
import com.yunzhupaas.integrate.job.IntegrateQueryJobUtil;
|
||||
import org.quartz.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class IntegrateConfig {
|
||||
|
||||
@Bean
|
||||
public JobDetail integrateJobDetail() {
|
||||
JobDetail JobDetail = JobBuilder.newJob(IntegrateQueryJobUtil.class)
|
||||
.storeDurably() //必须调用该方法,添加任务
|
||||
.build();
|
||||
return JobDetail;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Trigger integrateTrigger() {
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("* * * * * ?");
|
||||
Trigger trigger = TriggerBuilder.newTrigger()
|
||||
.forJob(integrateJobDetail())
|
||||
.withSchedule(cronScheduleBuilder) //对触发器配置任务
|
||||
.build();
|
||||
return trigger;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.yunzhupaas.integrate.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.integrate.job.Integrate;
|
||||
import com.yunzhupaas.integrate.job.IntegrateJobUtil;
|
||||
import com.yunzhupaas.integrate.job.QuartzUtil;
|
||||
import com.yunzhupaas.integrate.model.nodeJson.IntegrateModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class IntegrateListener implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
Set<String> keysList = redisTemplate.keys(IntegrateJobUtil.WORKTIMEOUT_REDIS_KEY + "_key*");
|
||||
for (String id : keysList) {
|
||||
redisTemplate.delete(id);
|
||||
}
|
||||
List<String> hashValues = redisUtil.getHashValues(IntegrateJobUtil.IDGENERATOR_REDIS_KEY);
|
||||
for (String value : hashValues) {
|
||||
IntegrateModel integrateModel = JsonUtil.getJsonToBean(value, IntegrateModel.class);
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.putAll(JsonUtil.entityToMap(integrateModel));
|
||||
Date startTime = new Date(integrateModel.getStartTime());
|
||||
Date endTime = ObjectUtil.isNotEmpty(integrateModel.getEndTime()) ? new Date(integrateModel.getEndTime()) : null;
|
||||
boolean isAdd = ObjectUtil.isNotEmpty(endTime) ? endTime.getTime() > System.currentTimeMillis() : true;
|
||||
if (isAdd) {
|
||||
QuartzUtil.addJob(integrateModel.getId(), integrateModel.getCron(), Integrate.class, jobDataMap, startTime, endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.yunzhupaas.integrate.job;
|
||||
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.exception.TenantInvalidException;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
import com.yunzhupaas.integrate.model.nodeJson.IntegrateModel;
|
||||
import com.yunzhupaas.integrate.service.IntegrateQueueService;
|
||||
import com.yunzhupaas.integrate.service.IntegrateService;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import com.yunzhupaas.util.context.SpringContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.*;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@DisallowConcurrentExecution
|
||||
public class Integrate extends QuartzJobBean {
|
||||
|
||||
|
||||
private static RedisUtil redisUtil;
|
||||
private static ConfigValueUtil configValueUtil;
|
||||
private static IntegrateService integrateService;
|
||||
private static IntegrateQueueService integrateQueueService;
|
||||
|
||||
static {
|
||||
redisUtil = SpringContext.getBean(RedisUtil.class);
|
||||
configValueUtil = SpringContext.getBean(ConfigValueUtil.class);
|
||||
integrateService = SpringContext.getBean(IntegrateService.class);
|
||||
integrateQueueService = SpringContext.getBean(IntegrateQueueService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
JobDetail jobDetail = context.getJobDetail();
|
||||
String jobName = jobDetail.getKey().getName();
|
||||
JobDataMap jobDataMap = jobDetail.getJobDataMap();
|
||||
IntegrateModel model = IntegrateJobUtil.getModel(JsonUtil.getJsonToBean(jobDataMap, IntegrateModel.class), redisUtil);
|
||||
boolean isModel = model == null;
|
||||
IntegrateModel integrateModel = isModel ? JsonUtil.getJsonToBean(jobDataMap, IntegrateModel.class) : model;
|
||||
if (integrateModel != null) {
|
||||
UserInfo userInfo = integrateModel.getUserInfo();
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
try {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}catch (TenantInvalidException e){
|
||||
// 租户无效 禁用调度, 删除任务
|
||||
log.error("Integrate, 租户无效, 删除任务:{}", userInfo.getTenantId());
|
||||
IntegrateJobUtil.removeModel(integrateModel, redisUtil);
|
||||
QuartzUtil.deleteJob(jobName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
IntegrateEntity info = integrateService.getInfo(integrateModel.getId());
|
||||
if (info != null) {
|
||||
integrateModel.setTime(System.currentTimeMillis());
|
||||
Integer num = integrateModel.getNum();
|
||||
Integer endTimeType = integrateModel.getEndTimeType();
|
||||
Integer endLimit = integrateModel.getEndLimit();
|
||||
boolean isNext = Objects.equals(endTimeType, 1) ? num + 1 <= endLimit : Objects.equals(endTimeType, 2) ? integrateModel.getTime() <= integrateModel.getEndTime() : true;
|
||||
integrateModel.setNum(++num);
|
||||
if (isNext) {
|
||||
IntegrateJobUtil.insertModel(integrateModel, redisUtil);
|
||||
IntegrateQueueEntity entity = new IntegrateQueueEntity();
|
||||
entity.setState(0);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setIntegrateId(integrateModel.getId());
|
||||
entity.setExecutionTime(new Date());
|
||||
entity.setFullName(info.getFullName());
|
||||
IntegrateModel integrate = new IntegrateModel();
|
||||
integrate.setId(entity.getId());
|
||||
integrate.setUserInfo(userInfo);
|
||||
IntegrateJobUtil.insertIntegrate(integrate,redisUtil);
|
||||
integrateQueueService.create(entity);
|
||||
} else {
|
||||
IntegrateJobUtil.removeModel(integrateModel, redisUtil);
|
||||
QuartzUtil.deleteJob(jobName);
|
||||
}
|
||||
} else {
|
||||
IntegrateJobUtil.removeModel(integrateModel, redisUtil);
|
||||
QuartzUtil.deleteJob(jobName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.yunzhupaas.integrate.job;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.integrate.model.nodeJson.IntegrateModel;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import com.yunzhupaas.util.RedisUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* @author 云筑产品开发平台组
|
||||
* @version V3.3.0 flowable
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date 2024/6/15 17:37
|
||||
*/
|
||||
@Slf4j
|
||||
public class IntegrateJobUtil {
|
||||
/**
|
||||
* 缓存key
|
||||
*/
|
||||
public static final String WORKTIMEOUT_REDIS_KEY = "idgenerator_IntegrateList";
|
||||
|
||||
/**
|
||||
* 缓存key
|
||||
*/
|
||||
public static final String IDGENERATOR_REDIS_KEY = "idgenerator_IntegrateModel";
|
||||
|
||||
/**
|
||||
* 缓存key
|
||||
*/
|
||||
public static final String IDGENERATORID_REDIS_KEY = "idgenerator_id";
|
||||
|
||||
public static IntegrateModel getModel(IntegrateModel model, RedisUtil redisUtil) {
|
||||
String id = model.getId();
|
||||
String hashValues = redisUtil.getHashValues(IDGENERATOR_REDIS_KEY, id);
|
||||
IntegrateModel integrateModel = StringUtil.isNotEmpty(hashValues) ? JsonUtil.getJsonToBean(hashValues, IntegrateModel.class) : null;
|
||||
return integrateModel;
|
||||
}
|
||||
|
||||
public static void insertModel(IntegrateModel model, RedisUtil redisUtil) {
|
||||
String integrateId = model.getId();
|
||||
redisUtil.insertHash(IDGENERATOR_REDIS_KEY, integrateId, JsonUtil.getObjectToString(model));
|
||||
insertTenant(model, redisUtil);
|
||||
}
|
||||
|
||||
public static void removeModel(IntegrateModel model, RedisUtil redisUtil) {
|
||||
redisUtil.removeHash(IDGENERATOR_REDIS_KEY, model.getId());
|
||||
}
|
||||
|
||||
public static void insertTenant(IntegrateModel model, RedisUtil redisUtil) {
|
||||
String tenantId = StringUtil.isNotEmpty(model.getUserInfo().getTenantId()) ? model.getUserInfo().getTenantId() : "yunzhupaas";
|
||||
UserInfo userInfo = model.getUserInfo();
|
||||
redisUtil.insertHash(WORKTIMEOUT_REDIS_KEY, tenantId, JsonUtil.getObjectToString(userInfo));
|
||||
}
|
||||
|
||||
public static void removeTenant(String tenantId, RedisUtil redisUtil) {
|
||||
tenantId = StringUtil.isNotEmpty(tenantId) ? tenantId : "com.yunzhupaas";
|
||||
redisUtil.removeHash(WORKTIMEOUT_REDIS_KEY, tenantId);
|
||||
}
|
||||
|
||||
public static boolean getIntegrate(IntegrateModel model, RedisUtil redisUtil){
|
||||
String value = redisUtil.getHashValues(IDGENERATORID_REDIS_KEY, model.getId());
|
||||
return ObjectUtil.isNotEmpty(value);
|
||||
}
|
||||
|
||||
public static void insertIntegrate(IntegrateModel model, RedisUtil redisUtil){
|
||||
redisUtil.insertHash(IDGENERATORID_REDIS_KEY, model.getId(), model.getId());
|
||||
}
|
||||
|
||||
public static void removeIntegrate(IntegrateModel model, RedisUtil redisUtil){
|
||||
redisUtil.removeHash(IDGENERATORID_REDIS_KEY, model.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.yunzhupaas.integrate.job;
|
||||
|
||||
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.exception.TenantInvalidException;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
import com.yunzhupaas.integrate.model.nodeJson.IntegrateModel;
|
||||
import com.yunzhupaas.integrate.service.IntegrateQueueService;
|
||||
import com.yunzhupaas.integrate.util.IntegrateHttpModel;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@DisallowConcurrentExecution
|
||||
public class IntegrateQueryJobUtil extends QuartzJobBean {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private IntegrateQueueService integrateQueueService;
|
||||
|
||||
public static Map<String, ScheduledFuture> futureList = new HashMap<>();
|
||||
|
||||
private static ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = null;
|
||||
|
||||
IntegrateQueryJobUtil(ThreadPoolTaskExecutor threadPoolTaskExecutor) {
|
||||
if(scheduledThreadPoolExecutor == null) {
|
||||
scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(20, threadPoolTaskExecutor.getThreadPoolExecutor().getThreadFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
List<String> hashValues = redisUtil.getHashValues(IntegrateJobUtil.WORKTIMEOUT_REDIS_KEY);
|
||||
for (String id : hashValues) {
|
||||
UserInfo userInfo = JsonUtil.getJsonToBean(id, UserInfo.class);
|
||||
String tenantId = StringUtil.isNotEmpty(userInfo.getTenantId()) ? userInfo.getTenantId() : "yunzhupaas";
|
||||
boolean useSuccess = redisTemplate.opsForValue().setIfAbsent(IntegrateJobUtil.WORKTIMEOUT_REDIS_KEY + "_key:" + tenantId, System.currentTimeMillis(), 3600, TimeUnit.SECONDS);
|
||||
if (!useSuccess) continue;
|
||||
if (futureList.get(tenantId) == null) {
|
||||
ScheduledFuture scheduledFuture = scheduledThreadPoolExecutor.scheduleAtFixedRate(new Task(userInfo), 0, 1, TimeUnit.SECONDS);
|
||||
futureList.put(tenantId, scheduledFuture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Task implements Runnable {
|
||||
private UserInfo userInfo;
|
||||
|
||||
public Task(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String tenantId = StringUtil.isNotEmpty(userInfo.getTenantId()) ? userInfo.getTenantId() : "yunzhupaas";
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
try {
|
||||
TenantDataSourceUtil.switchTenant(userInfo.getTenantId());
|
||||
}catch (TenantInvalidException e){
|
||||
// 租户无效 删除缓存, 删除任务
|
||||
log.error("Task, 租户无效, 删除任务:{}", userInfo.getTenantId());
|
||||
IntegrateJobUtil.removeTenant(userInfo.getTenantId(), redisUtil);
|
||||
ScheduledFuture scheduledFuture = futureList.get(userInfo.getTenantId());
|
||||
if(scheduledFuture != null) {
|
||||
scheduledFuture.cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IntegrateQueueEntity> list = integrateQueueService.getList();
|
||||
if (list.size() > 0) {
|
||||
String token = AuthUtil.loginTempUser(userInfo.getUserId(), userInfo.getTenantId(), true);
|
||||
String url = configValueUtil.getApiDomain() + "/api/visualdev/Integrate/executeQuery";
|
||||
for (IntegrateQueueEntity entity : list) {
|
||||
IntegrateModel model = new IntegrateModel();
|
||||
model.setUserInfo(userInfo);
|
||||
model.setId(entity.getId());
|
||||
boolean integrate = IntegrateJobUtil.getIntegrate(model, redisUtil);
|
||||
boolean useSuccess = redisTemplate.opsForValue().setIfAbsent(IntegrateJobUtil.WORKTIMEOUT_REDIS_KEY + "_key:" + entity.getId(), System.currentTimeMillis(), 3600, TimeUnit.SECONDS);
|
||||
if (integrate && useSuccess) {
|
||||
System.out.println("执行一组调度开始----------------------------");
|
||||
IntegrateHttpModel httpModel = new IntegrateHttpModel();
|
||||
httpModel.setUserInfo(UserProvider.getUser(token));
|
||||
httpModel.setId(entity.getId());
|
||||
HttpRequest request = HttpRequest.of(url).method(Method.POST).body(JsonUtil.getObjectToString(httpModel));
|
||||
request.header(Constants.AUTHORIZATION, token);
|
||||
request.execute().body();
|
||||
System.out.println("执行一组调度结束----------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
//删除
|
||||
redisTemplate.delete(IntegrateJobUtil.WORKTIMEOUT_REDIS_KEY + "_key:" + tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.yunzhupaas.integrate.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
public class QuartzUtil {
|
||||
|
||||
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) {
|
||||
log.error("删除调度失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isTriKey(String jobName) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
Scheduler sched = schedulerFactory.getScheduler();
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(jobName);
|
||||
CronTrigger trigger = (CronTrigger) sched.getTrigger(triggerKey);
|
||||
flag = trigger != null;
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yunzhupaas.integrate.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
|
||||
public interface IntegrateMapper extends SuperMapper<IntegrateEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yunzhupaas.integrate.mapper;
|
||||
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateNodeEntity;
|
||||
|
||||
public interface IntegrateNodeMapper extends SuperMapper<IntegrateNodeEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.yunzhupaas.integrate.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
|
||||
public interface IntegrateQueueMapper extends SuperMapper<IntegrateQueueEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.yunzhupaas.integrate.mapper;
|
||||
|
||||
import com.yunzhupaas.base.mapper.SuperMapper;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateTaskEntity;
|
||||
|
||||
public interface IntegrateTaskMapper extends SuperMapper<IntegrateTaskEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yunzhupaas.integrate.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateNodeEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IntegrateNodeService extends SuperService<IntegrateNodeEntity> {
|
||||
|
||||
List<IntegrateNodeEntity> getList(List<String> id,String nodeCode);
|
||||
|
||||
List<IntegrateNodeEntity> getList(List<String> id,String nodeCode, Integer isRetry);
|
||||
|
||||
IntegrateNodeEntity getInfo(String id);
|
||||
|
||||
void create(IntegrateNodeEntity entity);
|
||||
|
||||
void update(String id,String nodeCode);
|
||||
|
||||
Boolean update(String id, IntegrateNodeEntity entity);
|
||||
|
||||
void delete(IntegrateNodeEntity entity);
|
||||
|
||||
void delete(String id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yunzhupaas.integrate.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IntegrateQueueService extends SuperService<IntegrateQueueEntity> {
|
||||
|
||||
List<IntegrateQueueEntity> getList();
|
||||
|
||||
void create(IntegrateQueueEntity entity);
|
||||
|
||||
Boolean update(String id, IntegrateQueueEntity entity);
|
||||
|
||||
void delete(IntegrateQueueEntity entity);
|
||||
|
||||
void delete(String integrateId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yunzhupaas.integrate.service;
|
||||
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.model.integrate.IntegratePagination;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IntegrateService extends SuperService<IntegrateEntity> {
|
||||
|
||||
List<IntegrateEntity> getList(IntegratePagination pagination);
|
||||
|
||||
List<IntegrateEntity> getList(IntegratePagination pagination, boolean isPage);
|
||||
|
||||
IntegrateEntity getInfo(String id);
|
||||
|
||||
Boolean isExistByFullName(String fullName, String id);
|
||||
|
||||
Boolean isExistByEnCode(String encode, String id);
|
||||
|
||||
void create(IntegrateEntity entity);
|
||||
|
||||
ActionResult ImportData(IntegrateEntity entity, Integer type) throws WorkFlowException;
|
||||
|
||||
Boolean update(String id, IntegrateEntity entity,boolean state);
|
||||
|
||||
void delete(IntegrateEntity entity);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.yunzhupaas.integrate.service;
|
||||
|
||||
import com.yunzhupaas.base.service.SuperService;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateTaskEntity;
|
||||
import com.yunzhupaas.integrate.model.integrate.IntegratePageModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IntegrateTaskService extends SuperService<IntegrateTaskEntity> {
|
||||
|
||||
List<IntegrateTaskEntity> getList(IntegratePageModel pagination);
|
||||
|
||||
List<IntegrateTaskEntity> getList(List<String> id);
|
||||
|
||||
IntegrateTaskEntity getInfo(String id);
|
||||
|
||||
void create(IntegrateTaskEntity entity);
|
||||
|
||||
Boolean update(String id, IntegrateTaskEntity entity);
|
||||
|
||||
void delete(String id) ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.yunzhupaas.integrate.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateNodeEntity;
|
||||
import com.yunzhupaas.integrate.mapper.IntegrateNodeMapper;
|
||||
import com.yunzhupaas.integrate.service.IntegrateNodeService;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class IntegrateNodeServiceImpl extends SuperServiceImpl<IntegrateNodeMapper, IntegrateNodeEntity> implements IntegrateNodeService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<IntegrateNodeEntity> getList(List<String> id, String nodeCode) {
|
||||
return getList(id,nodeCode,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntegrateNodeEntity> getList(List<String> id, String nodeCode, Integer resultType) {
|
||||
List<IntegrateNodeEntity> list = new ArrayList<>();
|
||||
QueryWrapper<IntegrateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (id.size() > 0) {
|
||||
queryWrapper.lambda().in(IntegrateNodeEntity::getTaskId, id);
|
||||
if (StringUtil.isNotEmpty(nodeCode)) {
|
||||
queryWrapper.lambda().eq(IntegrateNodeEntity::getNodeCode, nodeCode);
|
||||
}
|
||||
if(ObjectUtil.isNotEmpty(resultType)){
|
||||
queryWrapper.lambda().eq(IntegrateNodeEntity::getResultType, resultType);
|
||||
}
|
||||
queryWrapper.lambda().orderByAsc(IntegrateNodeEntity::getSortCode);
|
||||
queryWrapper.lambda().orderByAsc(IntegrateNodeEntity::getStartTime);
|
||||
list.addAll(this.list(queryWrapper));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegrateNodeEntity getInfo(String id) {
|
||||
QueryWrapper<IntegrateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateNodeEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(IntegrateNodeEntity entity) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setIsRetry(1);
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
entity.setEnabledMark(1);
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String taskId, String nodeCode) {
|
||||
UpdateWrapper<IntegrateNodeEntity> queryWrapper = new UpdateWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateNodeEntity::getTaskId,taskId);
|
||||
queryWrapper.lambda().eq(IntegrateNodeEntity::getNodeCode,nodeCode);
|
||||
queryWrapper.lambda().set(IntegrateNodeEntity::getIsRetry,0);
|
||||
this.update(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(String id, IntegrateNodeEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(IntegrateNodeEntity entity) {
|
||||
if(entity!=null) {
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String taskId) {
|
||||
QueryWrapper<IntegrateNodeEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateNodeEntity::getTaskId,taskId);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yunzhupaas.integrate.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
import com.yunzhupaas.integrate.mapper.IntegrateQueueMapper;
|
||||
import com.yunzhupaas.integrate.service.IntegrateQueueService;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
import com.yunzhupaas.util.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class IntegrateQueueServiceImpl extends SuperServiceImpl<IntegrateQueueMapper, IntegrateQueueEntity> implements IntegrateQueueService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<IntegrateQueueEntity> getList() {
|
||||
QueryWrapper<IntegrateQueueEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().orderByAsc(IntegrateQueueEntity::getCreatorTime);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(IntegrateQueueEntity entity) {
|
||||
if(StringUtil.isEmpty(entity.getId())){
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setCreatorTime(new Date());
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(String id, IntegrateQueueEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setLastModifyTime(new Date());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(IntegrateQueueEntity entity) {
|
||||
if(entity!=null){
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String integrateId) {
|
||||
QueryWrapper<IntegrateQueueEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateQueueEntity::getIntegrateId,integrateId);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
package com.yunzhupaas.integrate.service.impl;
|
||||
|
||||
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.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.job.Integrate;
|
||||
import com.yunzhupaas.integrate.job.IntegrateJobUtil;
|
||||
import com.yunzhupaas.integrate.job.QuartzUtil;
|
||||
import com.yunzhupaas.integrate.mapper.IntegrateMapper;
|
||||
import com.yunzhupaas.integrate.model.childnode.IntegrateChildNode;
|
||||
import com.yunzhupaas.integrate.model.childnode.IntegrateProperties;
|
||||
import com.yunzhupaas.integrate.model.integrate.IntegratePagination;
|
||||
import com.yunzhupaas.integrate.model.nodeJson.IntegrateModel;
|
||||
import com.yunzhupaas.integrate.service.IntegrateQueueService;
|
||||
import com.yunzhupaas.integrate.service.IntegrateService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class IntegrateServiceImpl extends SuperServiceImpl<IntegrateMapper, IntegrateEntity> implements IntegrateService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private IntegrateQueueService integrateQueueService;
|
||||
|
||||
@Override
|
||||
public List<IntegrateEntity> getList(IntegratePagination pagination) {
|
||||
return getList(pagination, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntegrateEntity> getList(IntegratePagination pagination, boolean isPage) {
|
||||
QueryWrapper<IntegrateEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (StringUtil.isNotEmpty(pagination.getKeyword())) {
|
||||
queryWrapper.lambda().and(
|
||||
t -> t.like(IntegrateEntity::getFullName, pagination.getKeyword())
|
||||
.or().like(IntegrateEntity::getEnCode, pagination.getKeyword())
|
||||
);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getType())) {
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getType, pagination.getType());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getFormId())) {
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getFormId, pagination.getFormId());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getTrigger())) {
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getTriggerType, pagination.getTrigger());
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getEnabledMark())) {
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getEnabledMark, pagination.getEnabledMark());
|
||||
}
|
||||
//排序
|
||||
if (StringUtils.isEmpty(pagination.getSidx())) {
|
||||
queryWrapper.lambda().orderByDesc(IntegrateEntity::getCreatorTime);
|
||||
} else {
|
||||
queryWrapper = "asc".equals(pagination.getSort().toLowerCase()) ? queryWrapper.orderByAsc(pagination.getSidx()) : queryWrapper.orderByDesc(pagination.getSidx());
|
||||
}
|
||||
if (isPage) {
|
||||
Page<IntegrateEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<IntegrateEntity> userPage = page(page, queryWrapper);
|
||||
return pagination.setData(userPage.getRecords(), page.getTotal());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegrateEntity getInfo(String id) {
|
||||
QueryWrapper<IntegrateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExistByFullName(String fullName, String id) {
|
||||
QueryWrapper<IntegrateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getFullName, fullName);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(IntegrateEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isExistByEnCode(String encode, String id) {
|
||||
QueryWrapper<IntegrateEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateEntity::getEnCode, encode);
|
||||
if (!StringUtil.isEmpty(id)) {
|
||||
queryWrapper.lambda().ne(IntegrateEntity::getId, id);
|
||||
}
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(IntegrateEntity entity) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
formId(entity);
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DSTransactional
|
||||
public ActionResult ImportData(IntegrateEntity entity, Integer type) throws WorkFlowException {
|
||||
if (entity != null) {
|
||||
StringJoiner errList = new StringJoiner("、");
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
if (this.getInfo(entity.getId()) != null) {
|
||||
if (Objects.equals(type, 0)) {
|
||||
errList.add("ID");
|
||||
} else {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
}
|
||||
if (this.isExistByEnCode(entity.getEnCode(),null) ) {
|
||||
if (Objects.equals(type, 0)) {
|
||||
errList.add(MsgCode.IMP009.get());
|
||||
} else {
|
||||
entity.setEnCode(entity.getEnCode() + copyNum);
|
||||
}
|
||||
}
|
||||
if (this.isExistByFullName(entity.getFullName(), null) ) {
|
||||
if (Objects.equals(type, 0)) {
|
||||
errList.add(MsgCode.IMP008.get());
|
||||
} else {
|
||||
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
|
||||
}
|
||||
}
|
||||
if (Objects.equals(type, 0) && errList.length() > 0) {
|
||||
return ActionResult.fail(errList + MsgCode.IMP007.get());
|
||||
}
|
||||
try {
|
||||
this.setIgnoreLogicDelete().removeById(entity.getId());
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setCreatorUserId(UserProvider.getLoginUserId());
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setEnabledMark(0);
|
||||
this.setIgnoreLogicDelete().saveOrUpdate(entity);
|
||||
this.clearIgnoreLogicDelete();
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(MsgCode.IMP003.get(),e);
|
||||
}
|
||||
return ActionResult.success(MsgCode.IMP001.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.IMP006.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(String id, IntegrateEntity entity, boolean state) {
|
||||
entity.setId(id);
|
||||
IntegrateEntity info = getInfo(id);
|
||||
if (Objects.equals(entity.getEnabledMark(), 0) || !Objects.equals(info.getTemplateJson(), entity.getTemplateJson())) {
|
||||
deleteJob(entity);
|
||||
}
|
||||
if (ObjectUtil.isEmpty(entity.getEnabledMark())) {
|
||||
entity.setEnabledMark(info.getEnabledMark());
|
||||
}
|
||||
if (ObjectUtil.isEmpty(entity.getType())) {
|
||||
entity.setType(info.getType());
|
||||
}
|
||||
if ((!Objects.equals(info.getTemplateJson(), entity.getTemplateJson()) || state) && Objects.equals(entity.getEnabledMark(), 1)) {
|
||||
formId(entity);
|
||||
}
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(IntegrateEntity entity) {
|
||||
deleteJob(entity);
|
||||
this.removeById(entity.getId());
|
||||
}
|
||||
|
||||
private void formId(IntegrateEntity entity) {
|
||||
Integer enabledMark = entity.getEnabledMark();
|
||||
String templateJson = entity.getTemplateJson();
|
||||
if (StringUtil.isNotEmpty(templateJson)) {
|
||||
IntegrateChildNode childNode = JsonUtil.getJsonToBean(templateJson, IntegrateChildNode.class);
|
||||
IntegrateProperties properties = childNode.getProperties();
|
||||
String formId = properties.getFormId();
|
||||
entity.setFormId(formId);
|
||||
entity.setTriggerType(properties.getTriggerEvent());
|
||||
if (Objects.equals(enabledMark, 1)) {
|
||||
if (Objects.equals(entity.getType(), 2)) {
|
||||
IntegrateModel model = new IntegrateModel();
|
||||
model.setId(entity.getId());
|
||||
IntegrateJobUtil.removeModel(model, redisUtil);
|
||||
IntegrateModel integrateModel = JsonUtil.getJsonToBean(properties, IntegrateModel.class);
|
||||
integrateModel.setUserInfo(UserProvider.getUser());
|
||||
integrateModel.setId(entity.getId());
|
||||
integrateModel.setState(0);
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
Date startTime = ObjectUtil.isNotEmpty(properties.getStartTime()) ? new Date(properties.getStartTime()) : new Date();
|
||||
Date endTime = Objects.equals(properties.getEndTimeType(), 2) ? new Date(properties.getEndTime()) : null;
|
||||
integrateModel.setEndTime(endTime != null ? endTime.getTime() : null);
|
||||
integrateModel.setStartTime(startTime.getTime());
|
||||
jobDataMap.putAll(JsonUtil.entityToMap(integrateModel));
|
||||
redisUtil.removeHash(IntegrateJobUtil.IDGENERATOR_REDIS_KEY, entity.getId());
|
||||
boolean isAdd = ObjectUtil.isNotEmpty(endTime) ? endTime.getTime() > System.currentTimeMillis() : true;
|
||||
if (isAdd) {
|
||||
QuartzUtil.addJob(entity.getId(), properties.getCron(), Integrate.class, jobDataMap, startTime, endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteJob(IntegrateEntity entity) {
|
||||
QuartzUtil.deleteJob(entity.getId());
|
||||
integrateQueueService.delete(entity.getId());
|
||||
IntegrateModel model = new IntegrateModel();
|
||||
model.setId(entity.getId());
|
||||
IntegrateJobUtil.removeModel(model, redisUtil);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.yunzhupaas.integrate.service.impl;
|
||||
|
||||
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.yunzhupaas.base.service.SuperServiceImpl;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateTaskEntity;
|
||||
import com.yunzhupaas.integrate.mapper.IntegrateTaskMapper;
|
||||
import com.yunzhupaas.integrate.model.integrate.IntegratePageModel;
|
||||
import com.yunzhupaas.integrate.service.IntegrateNodeService;
|
||||
import com.yunzhupaas.integrate.service.IntegrateTaskService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class IntegrateTaskServiceImpl extends SuperServiceImpl<IntegrateTaskMapper, IntegrateTaskEntity> implements IntegrateTaskService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IntegrateNodeService integrateNodeService;
|
||||
|
||||
@Override
|
||||
public List<IntegrateTaskEntity> getList(IntegratePageModel pagination) {
|
||||
QueryWrapper<IntegrateTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateTaskEntity::getIntegrateId,pagination.getIntegrateId());
|
||||
//日期范围(近7天、近1月、近3月、自定义)
|
||||
String startTime = pagination.getStartTime() != null ? pagination.getStartTime() : null;
|
||||
String endTime = pagination.getEndTime() != null ? pagination.getEndTime() : null;
|
||||
if (!StringUtils.isEmpty(startTime) && !StringUtils.isEmpty(endTime)) {
|
||||
Date startTimes = new Date(Long.parseLong(startTime));
|
||||
Date endTimes = new Date(Long.parseLong(endTime));
|
||||
queryWrapper.lambda().ge(IntegrateTaskEntity::getExecutionTime, startTimes).le(IntegrateTaskEntity::getExecutionTime, endTimes);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(pagination.getResultType())) {
|
||||
queryWrapper.lambda().eq(IntegrateTaskEntity::getResultType, pagination.getResultType());
|
||||
}
|
||||
queryWrapper.lambda().orderByDesc(IntegrateTaskEntity::getExecutionTime);
|
||||
Page<IntegrateTaskEntity> page = new Page<>(pagination.getCurrentPage(), pagination.getPageSize());
|
||||
IPage<IntegrateTaskEntity> userPage = page(page, queryWrapper);
|
||||
return pagination.setData(userPage.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntegrateTaskEntity> getList(List<String> id) {
|
||||
List<IntegrateTaskEntity> list = new ArrayList<>();
|
||||
QueryWrapper<IntegrateTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
if (id.size() > 0) {
|
||||
queryWrapper.lambda().in(IntegrateTaskEntity::getIntegrateId, id);
|
||||
list.addAll(this.list(queryWrapper));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegrateTaskEntity getInfo(String id) {
|
||||
QueryWrapper<IntegrateTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateTaskEntity::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(IntegrateTaskEntity entity) {
|
||||
if (StringUtil.isEmpty(entity.getId())) {
|
||||
entity.setId(RandomUtil.uuId());
|
||||
}
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
entity.setEnabledMark(0);
|
||||
this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(String id, IntegrateTaskEntity entity) {
|
||||
entity.setId(id);
|
||||
entity.setLastModifyTime(new Date());
|
||||
entity.setLastModifyUserId(UserProvider.getUser().getUserId());
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
if(StringUtils.isNotEmpty(id)) {
|
||||
QueryWrapper<IntegrateTaskEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(IntegrateTaskEntity::getId, id);
|
||||
this.remove(queryWrapper);
|
||||
integrateNodeService.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yunzhupaas.integrate.util;
|
||||
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.base.model.OnlineImport.VisualdevModelDataInfoVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/7/13 上午9:44
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateHttpModel {
|
||||
private String id;
|
||||
public UserInfo userInfo;
|
||||
private List<VisualdevModelDataInfoVO> dataInfoVOList = new ArrayList<>();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev-integrate</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-integrate-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-visualdev-integrate-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,306 @@
|
||||
package com.yunzhupaas.integrate.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.emnus.ModuleTypeEnum;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
import com.yunzhupaas.integrate.job.IntegrateJobUtil;
|
||||
import com.yunzhupaas.integrate.model.integrate.*;
|
||||
import com.yunzhupaas.integrate.model.nodeJson.IntegrateModel;
|
||||
import com.yunzhupaas.integrate.service.IntegrateQueueService;
|
||||
import com.yunzhupaas.integrate.service.IntegrateService;
|
||||
import com.yunzhupaas.integrate.util.IntegrateHttpModel;
|
||||
import com.yunzhupaas.integrate.util.IntegrateUtil;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.permission.service.UserService;
|
||||
import com.yunzhupaas.util.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Tag(name = "集成助手", description = "Integrate")
|
||||
@RestController
|
||||
@RequestMapping("/api/visualdev/Integrate")
|
||||
public class IntegrateController extends SuperController<IntegrateService, IntegrateEntity> {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private DataFileExport fileExport;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private IntegrateService integrateService;
|
||||
@Autowired
|
||||
private IntegrateQueueService integrateQueueService;
|
||||
@Autowired
|
||||
private IntegrateUtil integrateUtil;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<IntegrateListVO>> list(IntegratePagination pagination) {
|
||||
List<IntegrateEntity> data = integrateService.getList(pagination);
|
||||
List<String> userId = data.stream().map(t -> t.getCreatorUserId()).collect(Collectors.toList());
|
||||
List<UserEntity> userEntities = userService.getUserName(userId);
|
||||
List<IntegrateListVO> resultList = new ArrayList<>();
|
||||
for (IntegrateEntity entity : data) {
|
||||
IntegrateListVO vo = JsonUtil.getJsonToBean(entity, IntegrateListVO.class);
|
||||
UserEntity creatorUser = userEntities.stream().filter(t -> t.getId().equals(entity.getCreatorUserId())).findFirst().orElse(null);
|
||||
vo.setCreatorUser(creatorUser != null ? creatorUser.getRealName() + "/" + creatorUser.getAccount() : "");
|
||||
resultList.add(vo);
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(resultList, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取信息")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult info(@PathVariable("id") String id) {
|
||||
IntegrateEntity entity = integrateService.getInfo(id);
|
||||
if (entity == null) {
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
IntegrateInfoVO vo = JsonUtil.getJsonToBean(entity, IntegrateInfoVO.class);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*
|
||||
* @param integrateCrForm 实体对象
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "添加")
|
||||
@Parameters({
|
||||
@Parameter(name = "integrateCrForm", description = "实体对象", required = true)
|
||||
})
|
||||
@PostMapping
|
||||
public ActionResult create(@RequestBody @Valid IntegrateCrForm integrateCrForm) {
|
||||
IntegrateEntity entity = JsonUtil.getJsonToBean(integrateCrForm, IntegrateEntity.class);
|
||||
if (integrateService.isExistByFullName(entity.getFullName(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (integrateService.isExistByEnCode(entity.getEnCode(), entity.getId())) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
String id = RandomUtil.uuId();
|
||||
entity.setId(id);
|
||||
integrateService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU001.get(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true),
|
||||
@Parameter(name = "integrateUpForm", description = "实体对象", required = true)
|
||||
})
|
||||
@PutMapping("/{id}")
|
||||
public ActionResult update(@PathVariable("id") String id, @RequestBody IntegrateUpForm integrateUpForm) {
|
||||
IntegrateEntity positionEntity = integrateService.getInfo(id);
|
||||
if (positionEntity == null) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
IntegrateEntity entity = JsonUtil.getJsonToBean(integrateUpForm, IntegrateEntity.class);
|
||||
if (integrateService.isExistByFullName(entity.getFullName(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST001.get());
|
||||
}
|
||||
if (integrateService.isExistByEnCode(entity.getEnCode(), id)) {
|
||||
return ActionResult.fail(MsgCode.EXIST002.get());
|
||||
}
|
||||
boolean flag = integrateService.update(id, entity,false);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true)
|
||||
})
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
IntegrateEntity entity = integrateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
integrateService.delete(entity);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制功能
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "复制功能")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@PostMapping("/{id}/Actions/Copy")
|
||||
public ActionResult copyInfo(@PathVariable("id") String id) throws Exception {
|
||||
IntegrateEntity entity = integrateService.getInfo(id);
|
||||
entity.setEnabledMark(0);
|
||||
String copyNum = UUID.randomUUID().toString().substring(0, 5);
|
||||
entity.setFullName(entity.getFullName() + ".副本" + copyNum);
|
||||
entity.setLastModifyTime(null);
|
||||
entity.setLastModifyUserId(null);
|
||||
entity.setId(RandomUtil.uuId());
|
||||
entity.setEnCode(entity.getEnCode() + copyNum);
|
||||
entity.setCreatorTime(new Date());
|
||||
entity.setEnabledMark(0);
|
||||
entity.setCreatorUserId(UserProvider.getUser().getUserId());
|
||||
integrateService.create(entity);
|
||||
return ActionResult.success(MsgCode.SU007.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新功能状态
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "更新功能状态")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键"),
|
||||
})
|
||||
@PutMapping("/{id}/Actions/State")
|
||||
public ActionResult update(@PathVariable("id") String id) {
|
||||
IntegrateEntity entity = integrateService.getInfo(id);
|
||||
if (entity != null) {
|
||||
if (entity.getEnabledMark() == null || "1".equals(String.valueOf(entity.getEnabledMark()))) {
|
||||
entity.setEnabledMark(0);
|
||||
} else {
|
||||
entity.setEnabledMark(1);
|
||||
}
|
||||
boolean flag = integrateService.update(entity.getId(), entity,true);
|
||||
if (flag == false) {
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出")
|
||||
@PostMapping("/{id}/Actions/Export")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true),
|
||||
})
|
||||
public ActionResult<DownloadVO> exportData(@PathVariable("id") String id) {
|
||||
IntegrateEntity entity = integrateService.getInfo(id);
|
||||
DownloadVO downloadVO = fileExport.exportFile(entity, configValueUtil.getTemporaryFilePath(), entity.getFullName(), ModuleTypeEnum.BASE_INTEGRATE.getTableName());
|
||||
return ActionResult.success(downloadVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入
|
||||
*
|
||||
* @param file 文件
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入")
|
||||
@PostMapping(value = "/Actions/Import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ActionResult ImportData(@RequestPart("file") MultipartFile file,@RequestParam("type") Integer type) throws WorkFlowException {
|
||||
//判断是否为.json结尾
|
||||
if (FileUtil.existsSuffix(file, ModuleTypeEnum.BASE_INTEGRATE.getTableName())) {
|
||||
return ActionResult.fail(MsgCode.IMP002.get());
|
||||
}
|
||||
try {
|
||||
String fileContent = FileUtil.getFileContent(file);
|
||||
IntegrateEntity entity = JsonUtil.getJsonToBean(fileContent, IntegrateEntity.class);
|
||||
return integrateService.ImportData(entity, type);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(MsgCode.IMP004.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 集成助手事件触发
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/execute")
|
||||
public ActionResult execute(@RequestBody IntegrateHttpModel model) {
|
||||
integrateUtil.integrates(model.getDataInfoVOList(),model.getUserInfo());
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 集成助手定时触发
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/executeQuery")
|
||||
public ActionResult executeQuery(@RequestBody IntegrateHttpModel model) {
|
||||
IntegrateModel integrateModel = JsonUtil.getJsonToBean(model, IntegrateModel.class);
|
||||
if(ObjectUtil.isNotEmpty(model.getId())){
|
||||
IntegrateQueueEntity entity = integrateQueueService.getById(model.getId());
|
||||
if(ObjectUtil.isNotEmpty(entity)) {
|
||||
integrateUtil.integrate(entity, model.getUserInfo());
|
||||
}
|
||||
}
|
||||
IntegrateJobUtil.removeIntegrate(integrateModel, redisUtil);
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.yunzhupaas.integrate.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.controller.SuperController;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateNodeEntity;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateQueueEntity;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateTaskEntity;
|
||||
import com.yunzhupaas.integrate.model.integratetask.IntegrateQueueListVO;
|
||||
import com.yunzhupaas.integrate.model.integratetask.IntegrateTaskInfo;
|
||||
import com.yunzhupaas.integrate.model.integratetask.IntegrateTaskListVO;
|
||||
import com.yunzhupaas.integrate.model.integrate.IntegratePageModel;
|
||||
import com.yunzhupaas.integrate.model.integratetask.IntegrateTaskModel;
|
||||
import com.yunzhupaas.integrate.service.IntegrateNodeService;
|
||||
import com.yunzhupaas.integrate.service.IntegrateQueueService;
|
||||
import com.yunzhupaas.integrate.service.IntegrateTaskService;
|
||||
import com.yunzhupaas.integrate.util.IntegrateUtil;
|
||||
import com.yunzhupaas.util.JsonUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "集成助手日志", description = "IntegrateTask")
|
||||
@RestController
|
||||
@RequestMapping("/api/visualdev/IntegrateTask")
|
||||
public class IntegrateTaskController extends SuperController<IntegrateTaskService, IntegrateTaskEntity> {
|
||||
|
||||
@Autowired
|
||||
private IntegrateTaskService integrateTaskService;
|
||||
@Autowired
|
||||
private IntegrateNodeService integrateNodeService;
|
||||
@Autowired
|
||||
private IntegrateUtil integrateUtil;
|
||||
@Autowired
|
||||
private IntegrateQueueService integrateQueueService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "日志列表")
|
||||
@GetMapping
|
||||
public ActionResult<PageListVO<IntegrateTaskListVO>> list(IntegratePageModel pagination) {
|
||||
List<IntegrateTaskEntity> data = integrateTaskService.getList(pagination);
|
||||
List<IntegrateTaskListVO> list = JsonUtil.getJsonToList(data, IntegrateTaskListVO.class);
|
||||
for (IntegrateTaskListVO taskListVO : list) {
|
||||
taskListVO.setIsRetry("0".equals(taskListVO.getParentId()) ? 0 : 1);
|
||||
}
|
||||
PaginationVO paginationVO = JsonUtil.getJsonToBean(pagination, PaginationVO.class);
|
||||
return ActionResult.page(list, paginationVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id 主键值
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键值", required = true)
|
||||
})
|
||||
@DeleteMapping("/{id}")
|
||||
public ActionResult delete(@PathVariable("id") String id) {
|
||||
integrateTaskService.delete(id);
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "执行列表")
|
||||
@GetMapping("/queueList")
|
||||
public ActionResult<List<IntegrateQueueListVO>> queueList() {
|
||||
List<IntegrateQueueEntity> list = integrateQueueService.getList();
|
||||
List<IntegrateQueueListVO> listVO = JsonUtil.getJsonToList(list, IntegrateQueueListVO.class);
|
||||
return ActionResult.success(listVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 日志列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "日志详情")
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult<IntegrateTaskInfo> list(@PathVariable("id") String id) {
|
||||
IntegrateTaskEntity taskEntity = integrateTaskService.getInfo(id);
|
||||
List<IntegrateNodeEntity> nodeList = integrateNodeService.getList(new ArrayList() {{
|
||||
add(id);
|
||||
}}, null);
|
||||
List<IntegrateTaskModel> list = JsonUtil.getJsonToList(nodeList, IntegrateTaskModel.class);
|
||||
for (IntegrateTaskModel taskModel : list) {
|
||||
boolean isType = "0".equals(taskModel.getParentId());
|
||||
taskModel.setType(isType ? 1 : 0);
|
||||
}
|
||||
IntegrateTaskInfo info = new IntegrateTaskInfo();
|
||||
info.setList(list);
|
||||
info.setData(taskEntity.getData());
|
||||
return ActionResult.success(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点重试
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "节点重试")
|
||||
@GetMapping(value = "/{id}/nodeRetry")
|
||||
public ActionResult taskNode(@PathVariable("id") String id, String nodeId) {
|
||||
IntegrateTaskEntity taskEntity = integrateTaskService.getInfo(id);
|
||||
if (taskEntity != null) {
|
||||
integrateUtil.integrate(id, taskEntity.getParentId(), nodeId);
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "重试")
|
||||
@PutMapping(value = "/{id}/retry")
|
||||
public ActionResult ImportData(@PathVariable("id") String id) {
|
||||
IntegrateTaskEntity taskEntity = integrateTaskService.getInfo(id);
|
||||
if (taskEntity != null) {
|
||||
integrateUtil.integrate(id, id, "0");
|
||||
return ActionResult.success(MsgCode.SU005.get());
|
||||
}
|
||||
return ActionResult.fail(MsgCode.FA007.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
package com.yunzhupaas.integrate.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.database.util.TenantDataSourceUtil;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.model.integrate.WebHookInfoVo;
|
||||
import com.yunzhupaas.integrate.service.IntegrateService;
|
||||
import com.yunzhupaas.integrate.util.IntegrateUtil;
|
||||
import com.yunzhupaas.util.*;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@Tag(name = "webhook触发", description = "WebHook")
|
||||
@RestController
|
||||
@RequestMapping("/api/visualdev/Hooks")
|
||||
public class WebHookController {
|
||||
|
||||
@Autowired
|
||||
private IntegrateService integrateService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Autowired
|
||||
private ConfigValueUtil configValueUtil;
|
||||
@Autowired
|
||||
private IntegrateUtil integrateUtil;
|
||||
|
||||
|
||||
private static final String WEBHOOK_RED_KEY = "webhookencode";
|
||||
|
||||
private static long DEFAULT_CACHE_TIME = 60 * 5;
|
||||
|
||||
@Operation(summary = "数据接收接口")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "base64转码id", required = true),
|
||||
@Parameter(name = "tenantId", description = "租户id", required = false)
|
||||
})
|
||||
@PostMapping("/{id}")
|
||||
@NoDataSourceBind
|
||||
public ActionResult webhookTrigger(@PathVariable("id") String id,
|
||||
@RequestParam(value = "tenantId", required = false) String tenantId,
|
||||
@RequestBody Map<String, Object> body) throws WorkFlowException {
|
||||
String idReal = new String(Base64.decodeBase64(id.getBytes(StandardCharsets.UTF_8)));
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
// 判断是不是从外面直接请求
|
||||
if (StringUtil.isNotEmpty(tenantId)) {
|
||||
//切换成租户库
|
||||
try {
|
||||
TenantDataSourceUtil.switchTenant(tenantId);
|
||||
} catch (Exception e) {
|
||||
return ActionResult.fail(MsgCode.LOG105.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
integrateUtil.integrate(idReal, tenantId, body);
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取webhookUrl")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "主键", required = true)
|
||||
})
|
||||
@GetMapping("/getUrl")
|
||||
public ActionResult getWebhookUrl(@RequestParam("id") String id) {
|
||||
String enCodeBase64 = new String(Base64.encodeBase64(id.getBytes(StandardCharsets.UTF_8)));
|
||||
String randomStr = UUID.randomUUID().toString().substring(0, 5);
|
||||
WebHookInfoVo vo = new WebHookInfoVo();
|
||||
vo.setEnCodeStr(enCodeBase64);
|
||||
vo.setRandomStr(randomStr);
|
||||
vo.setWebhookUrl("/api/visualdev/Hooks/" + enCodeBase64);
|
||||
vo.setRequestUrl("/api/visualdev/Hooks/" + enCodeBase64 + "/params/" + randomStr);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
@Operation(summary = "通过get接口获取参数")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "base64转码id", required = true),
|
||||
@Parameter(name = "randomStr", description = "获取webhookUrl提供的随机字符", required = true)
|
||||
})
|
||||
@GetMapping("/{id}/params/{randomStr}")
|
||||
@NoDataSourceBind
|
||||
public ActionResult getWebhookParams(@PathVariable("id") String id,
|
||||
@PathVariable("randomStr") String randomStr) throws WorkFlowException {
|
||||
insertRedis(id, randomStr, new HashMap<>());
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "通过post接口获取参数")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "base64转码id", required = true),
|
||||
@Parameter(name = "randomStr", description = "获取webhookUrl提供的随机字符", required = true)
|
||||
})
|
||||
@PostMapping("/{id}/params/{randomStr}")
|
||||
@NoDataSourceBind
|
||||
public ActionResult postWebhookParams(@PathVariable("id") String id,
|
||||
@PathVariable("randomStr") String randomStr,
|
||||
@RequestBody Map<String, Object> obj) throws WorkFlowException {
|
||||
insertRedis(id, randomStr, new HashMap<>(obj));
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 助手id查询信息,写入缓存
|
||||
*
|
||||
* @param id
|
||||
* @param randomStr
|
||||
* @param resultMap
|
||||
* @throws WorkFlowException
|
||||
*/
|
||||
private void insertRedis(String id, String randomStr, Map<String, Object> resultMap) throws WorkFlowException {
|
||||
String idReal = new String(Base64.decodeBase64(id.getBytes(StandardCharsets.UTF_8)));
|
||||
String key1 = WEBHOOK_RED_KEY + "_" + idReal + "_" + randomStr;
|
||||
if (!redisUtil.exists(key1)) {
|
||||
throw new WorkFlowException(MsgCode.VS016.get());
|
||||
}
|
||||
String tenantId = redisUtil.getString(key1).toString();
|
||||
|
||||
if (configValueUtil.isMultiTenancy()) {
|
||||
// 判断是不是从外面直接请求
|
||||
if (StringUtil.isNotEmpty(tenantId)) {
|
||||
//切换成租户库
|
||||
try {
|
||||
TenantDataSourceUtil.switchTenant(tenantId);
|
||||
} catch (Exception e) {
|
||||
throw new WorkFlowException(MsgCode.LOG105.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
IntegrateEntity entity = integrateService.getInfo(idReal);
|
||||
if (Objects.equals(entity.getEnabledMark(), 0)) {
|
||||
throw new WorkFlowException(MsgCode.VS017.get());
|
||||
}
|
||||
Map<String, Object> parameterMap = new HashMap<>(ServletUtil.getRequest().getParameterMap());
|
||||
for (String key : parameterMap.keySet()) {
|
||||
String[] parameterValues = ServletUtil.getRequest().getParameterValues(key);
|
||||
if (parameterValues.length == 1) {
|
||||
parameterMap.put(key, parameterValues[0]);
|
||||
} else {
|
||||
parameterMap.put(key, parameterValues);
|
||||
}
|
||||
}
|
||||
resultMap.putAll(parameterMap);
|
||||
if (resultMap.keySet().size() > 0) {
|
||||
redisUtil.insert(WEBHOOK_RED_KEY + "_" + randomStr, resultMap, DEFAULT_CACHE_TIME);
|
||||
redisUtil.remove(key1);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "请求参数添加触发接口")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "base64转码id", required = true),
|
||||
@Parameter(name = "randomStr", description = "获取webhookUrl提供的随机字符", required = true)
|
||||
})
|
||||
@GetMapping("/{id}/start/{randomStr}")
|
||||
public ActionResult start(@PathVariable("id") String id,
|
||||
@PathVariable("randomStr") String randomStr) {
|
||||
redisUtil.remove(WEBHOOK_RED_KEY + "_" + randomStr);
|
||||
redisUtil.insert(WEBHOOK_RED_KEY + "_" + id + "_" + randomStr, UserProvider.getUser().getTenantId(), DEFAULT_CACHE_TIME);
|
||||
return ActionResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取缓存的接口参数")
|
||||
@Parameters({
|
||||
@Parameter(name = "randomStr", description = "获取webhookUrl提供的随机字符", required = true)
|
||||
})
|
||||
@GetMapping("/getParams/{randomStr}")
|
||||
public ActionResult getRedisParams(@PathVariable("randomStr") String randomStr) {
|
||||
Map<String, Object> mapRedis = new HashMap<>();
|
||||
String key = WEBHOOK_RED_KEY + "_" + randomStr;
|
||||
if (redisUtil.exists(key)) {
|
||||
mapRedis = redisUtil.getMap(key);
|
||||
}
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (String redisKey : mapRedis.keySet()) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", redisKey);
|
||||
map.put("fullName", mapRedis.get(redisKey));
|
||||
list.add(map);
|
||||
}
|
||||
return ActionResult.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-visualdev-integrate</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-visualdev-integrate-entity</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-database</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.yunzhupaas.integrate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version V3.4.5
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @author 云筑产品开发平台组
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_integrate")
|
||||
public class IntegrateEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("F_FULL_NAME")
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@TableField("F_EN_CODE")
|
||||
private String enCode;
|
||||
|
||||
/**
|
||||
* 模板
|
||||
*/
|
||||
@TableField("F_TEMPLATE_JSON")
|
||||
private String templateJson;
|
||||
|
||||
/**
|
||||
* 类型(1-事件,2-定时 )
|
||||
*/
|
||||
@TableField("F_TYPE")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 开始表单id
|
||||
*/
|
||||
@TableField("F_FORM_ID")
|
||||
private String formId;
|
||||
|
||||
/**
|
||||
* 类型 (1.新增 2.修改 3.删除)
|
||||
*/
|
||||
@TableField("F_TRIGGER_TYPE")
|
||||
private Integer triggerType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.yunzhupaas.integrate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version V3.4.5
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @author 云筑产品开发平台组
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_integrate_node")
|
||||
public class IntegrateNodeEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 任务主键
|
||||
*/
|
||||
@TableField("F_TASK_ID")
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 节点编码
|
||||
*/
|
||||
@TableField("F_NODE_CODE")
|
||||
private String nodeCode;
|
||||
|
||||
/**
|
||||
* 节点编码
|
||||
*/
|
||||
@TableField("F_FORM_ID")
|
||||
private String formId;
|
||||
|
||||
/**
|
||||
* 节点类型
|
||||
*/
|
||||
@TableField("F_NODE_TYPE")
|
||||
private String nodeType;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
@TableField("F_NODE_NAME")
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 父节点id
|
||||
*/
|
||||
@TableField("F_PARENT_ID")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 节点属性Json
|
||||
*/
|
||||
@TableField("F_NODE_PROPERTY_JSON")
|
||||
private String nodePropertyJson;
|
||||
|
||||
/**
|
||||
* 下一节点
|
||||
*/
|
||||
@TableField("F_NODE_NEXT")
|
||||
private String nodeNext;
|
||||
|
||||
/**
|
||||
* 运行结果
|
||||
*/
|
||||
@TableField("F_RESULT_TYPE")
|
||||
private Integer resultType;
|
||||
|
||||
/**
|
||||
* 异常
|
||||
*/
|
||||
@TableField("F_ERROR_MSG")
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@TableField("f_start_time")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 能否重试
|
||||
*/
|
||||
@TableField("f_is_retry")
|
||||
private Integer isRetry;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@TableField("F_END_Time")
|
||||
private Date endTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yunzhupaas.integrate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version V3.4.5
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @author 云筑产品开发平台组
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_integrate_queue")
|
||||
public class IntegrateQueueEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@TableField("f_state")
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 集成主键
|
||||
*/
|
||||
@TableField("F_INTEGRATE_ID")
|
||||
private String integrateId;
|
||||
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
@TableField("F_EXECUTION_TIME")
|
||||
private Date executionTime;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("F_FULL_NAME")
|
||||
private String fullName;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.yunzhupaas.integrate.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.yunzhupaas.base.entity.SuperExtendEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version V3.4.5
|
||||
* @copyright 深圳市乐程软件有限公司(http://www.szlecheng.cn)
|
||||
* @author 云筑产品开发平台组
|
||||
*/
|
||||
@Data
|
||||
@TableName("base_integrate_task")
|
||||
public class IntegrateTaskEntity extends SuperExtendEntity.SuperExtendDEEntity<String> {
|
||||
|
||||
/**
|
||||
* 集成主键
|
||||
*/
|
||||
@TableField("F_INTEGRATE_ID")
|
||||
private String integrateId;
|
||||
|
||||
/**
|
||||
* 实例进程
|
||||
*/
|
||||
@TableField("F_PROCESS_ID")
|
||||
private String processId;
|
||||
|
||||
/**
|
||||
* 集成类型(1-事件,2-定时 )
|
||||
*/
|
||||
@TableField("F_TYPE")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 集成模板
|
||||
*/
|
||||
@TableField("F_TEMPLATE_JSON")
|
||||
private String templateJson;
|
||||
|
||||
|
||||
/**
|
||||
* 数据主键
|
||||
*/
|
||||
@TableField("F_DATA_ID")
|
||||
private String dataId;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
@TableField("F_DATA")
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* 父节点id
|
||||
*/
|
||||
@TableField("F_PARENT_ID")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 父节点时间
|
||||
*/
|
||||
@TableField("F_PARENT_TIME")
|
||||
private Date parentTime;
|
||||
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
@TableField("F_EXECUTION_TIME")
|
||||
private Date executionTime;
|
||||
|
||||
/**
|
||||
* 结果 (0.失败 1.成功)
|
||||
*/
|
||||
@TableField("F_RESULT_TYPE")
|
||||
private Integer resultType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.integrate.model.childnode;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateChildNode {
|
||||
private String type;
|
||||
private String content;
|
||||
private String nodeId;
|
||||
private String prevId;
|
||||
private IntegrateChildNode childNode;
|
||||
private IntegrateProperties properties = new IntegrateProperties();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yunzhupaas.integrate.model.childnode;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateMsgModel {
|
||||
//0.关闭 1.自定义 3.默认
|
||||
private Integer on = 0;
|
||||
private String msgId;
|
||||
private List<IntegrateTemplateModel> templateJson = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.integrate.model.childnode;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateParamModel {
|
||||
private String field;
|
||||
private String fieldName;
|
||||
private Boolean required = false;
|
||||
private String relationField;
|
||||
private String msgTemplateId;
|
||||
private Boolean isSubTable = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yunzhupaas.integrate.model.childnode;
|
||||
|
||||
import com.yunzhupaas.database.model.superQuery.SuperQueryJsonModel;
|
||||
import com.yunzhupaas.emnus.SearchMethodEnum;
|
||||
import com.yunzhupaas.model.visualJson.FieLdsModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateProperties {
|
||||
private String id;
|
||||
private String title;
|
||||
private String formId;
|
||||
private String flowId;
|
||||
private Integer formType = 1;
|
||||
private List<FieLdsModel> formFieldList = new ArrayList<>();
|
||||
private List<TransferModel> transferList = new ArrayList<>();
|
||||
private List<SuperQueryJsonModel> ruleList = new ArrayList<>();
|
||||
private Integer triggerEvent;
|
||||
//0.不新增 1.新增
|
||||
private Integer addRule = 0;
|
||||
//0-不更新 1-新增
|
||||
private Integer unFoundRule = 0;
|
||||
//0-删除未找到 1-删除已找到
|
||||
private Integer deleteRule = 0;
|
||||
private String ruleMatchLogic = SearchMethodEnum.And.getSymbol();
|
||||
|
||||
|
||||
private String msgId;
|
||||
private List<String> msgUserType = new ArrayList<>();
|
||||
private List<String> msgUserIds = new ArrayList<>();
|
||||
private List<IntegrateTemplateModel> templateJson = new ArrayList<>();
|
||||
private List<IntegrateTemplateModel> interfaceTemplateJson = new ArrayList<>();
|
||||
private IntegrateMsgModel startMsgConfig = new IntegrateMsgModel();
|
||||
private IntegrateMsgModel failMsgConfig= new IntegrateMsgModel();
|
||||
|
||||
|
||||
|
||||
private Long startTime;
|
||||
private String cron;
|
||||
private Integer endTimeType = 1;
|
||||
//次数
|
||||
private Integer endLimit = 1;
|
||||
//结束时间
|
||||
private Long endTime;
|
||||
//类型
|
||||
private Integer integrateType = 2;
|
||||
|
||||
private List<String> initiator;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yunzhupaas.integrate.model.childnode;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateTemplateModel {
|
||||
//远端接口
|
||||
private String field;
|
||||
private Boolean required = false;
|
||||
private Integer sourceType;
|
||||
private String relationField;
|
||||
|
||||
|
||||
//发送配置
|
||||
private String id;
|
||||
private String templateId;
|
||||
private String sendConfigId;
|
||||
private String msgTemplateName;
|
||||
private List<IntegrateParamModel> paramJson = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.integrate.model.childnode;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class TransferModel {
|
||||
private String targetField;
|
||||
private String targetFieldLabel;
|
||||
private Integer sourceType;
|
||||
private String sourceValue;
|
||||
private Boolean required = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateCrForm {
|
||||
@Schema(description = "说明")
|
||||
private String description;
|
||||
@Schema(description = "名称")
|
||||
private String fullName;
|
||||
@Schema(description = "编码")
|
||||
private String enCode;
|
||||
@Schema(description = "有效标志")
|
||||
private Integer enabledMark;
|
||||
@Schema(description = "json")
|
||||
private String templateJson;
|
||||
@Schema(description = "排序码")
|
||||
private long sortCode;
|
||||
@Schema(description = "类型")
|
||||
private Integer type;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateInfoVO {
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
@Schema(description = "说明")
|
||||
private String description;
|
||||
@Schema(description = "名称")
|
||||
private String fullName;
|
||||
@Schema(description = "编码")
|
||||
private String enCode;
|
||||
@Schema(description = "有效标志")
|
||||
private Integer enabledMark;
|
||||
@Schema(description = "排序码")
|
||||
private Long sortCode;
|
||||
@Schema(description = "类型")
|
||||
private Integer type;
|
||||
@Schema(description = "json")
|
||||
private String templateJson;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateListVO {
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "类型")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String fullName;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String enCode;
|
||||
|
||||
@Schema(description = "有效标志")
|
||||
private Integer enabledMark;
|
||||
|
||||
@Schema(description = "创建时间" )
|
||||
private Long creatorTime;
|
||||
|
||||
@Schema(description = "创建人" )
|
||||
private String creatorUser;
|
||||
|
||||
@Schema(description = "修改时间" )
|
||||
private Long lastModifyTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegratePageModel extends Pagination {
|
||||
@Schema(description = "开始时间")
|
||||
private String startTime;
|
||||
@Schema(description = "结束时间")
|
||||
private String endTime;
|
||||
@Schema(description = "集成助手主键")
|
||||
private String integrateId;
|
||||
@Schema(description = "结果")
|
||||
private Integer resultType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import com.yunzhupaas.base.Pagination;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegratePagination extends Pagination {
|
||||
private Integer type;
|
||||
private String formId;
|
||||
private Integer trigger;
|
||||
private Integer enabledMark;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateUpForm extends IntegrateCrForm{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.integrate.model.integrate;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WebHookInfoVo {
|
||||
@Schema(description = "系统生成数据接收接口")
|
||||
private String webhookUrl;
|
||||
@Schema(description = "系统生成参数接收接口")
|
||||
private String requestUrl;
|
||||
@Schema(description = "base64未转换16进制字符串")
|
||||
private String enCodeStr;
|
||||
@Schema(description = "随机字符")
|
||||
private String randomStr;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.integrate.model.integratetask;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateQueueListVO {
|
||||
private String fullName;
|
||||
private Integer state;
|
||||
private Long executionTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.integrate.model.integratetask;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateTaskInfo {
|
||||
private List<IntegrateTaskModel> list = new ArrayList<>();
|
||||
private String data;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yunzhupaas.integrate.model.integratetask;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateTaskListVO {
|
||||
private String id;
|
||||
private String processId;
|
||||
private String parentId;
|
||||
private Integer isRetry;
|
||||
private Long parentTime;
|
||||
private Long executionTime;
|
||||
private Integer resultType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yunzhupaas.integrate.model.integratetask;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateTaskModel {
|
||||
private String taskId;
|
||||
private String nodeCode;
|
||||
private String nodeType;
|
||||
private String nodeName;
|
||||
private Integer resultType;
|
||||
private String errorMsg;
|
||||
private Long startTime;
|
||||
private Long endTime;
|
||||
private String parentId;
|
||||
private Boolean isRetry;
|
||||
private Integer type;
|
||||
private String id;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.integrate.model.nodeJson;
|
||||
|
||||
import com.yunzhupaas.integrate.model.childnode.IntegrateProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateChildNodeList {
|
||||
private String nodeId;
|
||||
private String prevId;
|
||||
private String nextId;
|
||||
private String type;
|
||||
private Integer integrateType;
|
||||
private Date startTime = new Date();
|
||||
private Date endTime = new Date();
|
||||
private IntegrateProperties properties = new IntegrateProperties();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.integrate.model.nodeJson;
|
||||
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateEntity;
|
||||
import com.yunzhupaas.integrate.entity.IntegrateNodeEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class IntegrateChildNodeModel {
|
||||
private Map<String, Object> data = new HashMap<>();
|
||||
private List<Map<String, Object>> dataListAll = new ArrayList<>();
|
||||
private List<IntegrateNodeEntity> nodeList = new ArrayList<>();
|
||||
private String node;
|
||||
private IntegrateEntity entity;
|
||||
private String retryNodeCode;
|
||||
private UserInfo userInfo;
|
||||
private int num = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.integrate.model.nodeJson;
|
||||
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 版本: V3.0.0
|
||||
* 版权: 深圳市乐程软件有限公司
|
||||
* 作者: 管理员/admin
|
||||
* 日期: 2020-10-21 14:23:30
|
||||
*/
|
||||
@Data
|
||||
public class IntegrateModel {
|
||||
private UserInfo userInfo;
|
||||
private String id;
|
||||
private String cron;
|
||||
private Long startTime = System.currentTimeMillis();
|
||||
private Long endTime;
|
||||
private Integer endTimeType = 1;
|
||||
private Integer endLimit = 1;
|
||||
private Integer num = 0;
|
||||
private Integer state = 0;
|
||||
private Long time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user