Commit 7f22d73b by zhouhaibao

Merge branch 'v1.0.1'

# Conflicts:
#	.gitignore
#	platform-process-api/src/main/java/cn/com/glsx/process/modules/entity/SopTpl.java
#	pom.xml
2 parents a161660c 5b0f7fc7
Showing 196 changed files with 16898 additions and 374 deletions
<?xml version="1.0" encoding="UTF-8"?> <?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"> <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> <parent>
<groupId>cn.com.glsx</groupId> <groupId>cn.com.glsx</groupId>
<artifactId>platform-process-server</artifactId> <artifactId>platform-process-server</artifactId>
...@@ -22,6 +23,25 @@ ...@@ -22,6 +23,25 @@
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>rest-admin-feign</artifactId> <artifactId>rest-admin-feign</artifactId>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.2-jre</version>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>
package cn.com.glsx.process.api;
import cn.com.glsx.process.modules.model.SopInstDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.Map;
/**
* @author payu
*/
@FeignClient(name = "rest-admin", contextId = "sop-inst", path = "/api/sopInsts/", decode404 = true)
public interface SopInstFeignClient {
/**
* 一、FeignClients使用注意事项:
* 1. @EnableFeignClients 默认扫描 xxxxApplication启动入口 所在包路径下的 @FeignClient bean,若无法扫描到, 可以在使用Feign调用外部模块的api时候,
* 需要在引用服务中 xxxxApplication 中的 `@EnableFeignClients(basePackages = "cn.tendyron.customer")` 添加外部包需要扫描FeignClient的路径,否则无法注入bean
* 2. @FeignClient 声明的类,使用 spring.application.name 作为 name配置 @FeignClient(name="xxxx"),如果想保留 context-path , 则需要配置 path 属性 ,如:@FeignClient(name="xxxx" , path="xxxx(context-path)")
* 3. @FeignClient 接口对应的实现类,需要使用 @RestController注解 声明
* 4. mapper注解不支持 : @GetMapping,@PostMapping , 参数要加 @RequestParam(“xxx”)
* 5. FeignClient 调用,实质是httpClient调用 ,若我们暴露的接口api,声明了对应的 http mapper 信息,在调用方调用时候,通过代理 发起了 http请求,到服务提供方对应的http服务上去,所以在服务提供方的接口,可以使用 @RestController
* 来声明接口的 实现,否则调用方无法找到 http 对应的路径,会报404 ;
* 或者 根据 api 声明的http 信息,构建一个 Controller ,再来调用接口的实现类,但是这样不太方便;
* 6.FeignClient是一个“客户端”,它是用来发起请求的,不是提供服务的。
*
*
* 二、fallback 几种模式:
* 1.EchoCenterFeignServiceFallback.class 直接fallback,获取不到HTTP请求错误状态码和信息
* 2.EchoCenterFeignFactory.class 特定类型工厂模式
* 3.FunFallbackFactory 使用统一的工厂模式处理
*
*
* 三、性能问题
* 1.Feign是一个http请求调用的轻量级框架,基于http协议,性能不如rpc
* 2.可以为Feign配置连接池,配合使用okhttp等
*/
/**
* 测试Feign Get ,普通处理
* 注意: @RequestParam("xx") 注解一定要写,而且属性名xx不能省略
*/
/**
* 通过实例默认输入参数查询指定门店模板实例
*
* @param instParam
* @return
*/
@GetMapping("/getOneByCustomData")
SopInstDTO getOneByCustomData(Map<String, Object> instParam);
}
...@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/** /**
* @author payu * @author payu
*/ */
@FeignClient(name = "rest-admin", contextId = "usercenter", path = "/api/user/", decode404 = true) @FeignClient(name = "platform-process", contextId = "usercenter", path = "/api/user/", decode404 = true)
public interface UserCenterFeignClient { public interface UserCenterFeignClient {
/** /**
...@@ -42,7 +42,7 @@ public interface UserCenterFeignClient { ...@@ -42,7 +42,7 @@ public interface UserCenterFeignClient {
* 注意: @RequestParam("xx") 注解一定要写,而且属性名xx不能省略 * 注意: @RequestParam("xx") 注解一定要写,而且属性名xx不能省略
*/ */
@GetMapping("/echo") @GetMapping("/echo")
String echo(@RequestParam String message); String echo(@RequestParam("message") String message);
@GetMapping(value = "/info/{id}") @GetMapping(value = "/info/{id}")
UserDTO info(@PathVariable("id") Long id); UserDTO info(@PathVariable("id") Long id);
......
package cn.com.glsx.process.modules.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "job_manager")
public class JobManager {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "job_name")
private String jobName;
private String cron;
@Column(name = "class")
private String className;
private String parameters;
@Column(name = "share_total_count")
private Integer shareTotalCount;
@Column(name = "del_flag")
private Integer delFlag;
@Column(name = "create_time")
private Date createTime;
@Column(name = "update_time")
private Date updateTime;
/**
* @return id
*/
public Integer getId() {
return id;
}
/**
* @param id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return job_name
*/
public String getJobName() {
return jobName;
}
/**
* @param jobName
*/
public void setJobName(String jobName) {
this.jobName = jobName == null ? null : jobName.trim();
}
/**
* @return cron
*/
public String getCron() {
return cron;
}
/**
* @param cron
*/
public void setCron(String cron) {
this.cron = cron == null ? null : cron.trim();
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
/**
* @return parameters
*/
public String getParameters() {
return parameters;
}
/**
* @param parameters
*/
public void setParameters(String parameters) {
this.parameters = parameters == null ? null : parameters.trim();
}
/**
* @return share_total_count
*/
public Integer getShareTotalCount() {
return shareTotalCount;
}
/**
* @param shareTotalCount
*/
public void setShareTotalCount(Integer shareTotalCount) {
this.shareTotalCount = shareTotalCount;
}
/**
* @return del_flag
*/
public Integer getDelFlag() {
return delFlag;
}
/**
* @param delFlag
*/
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "sop_node_tpl")
public class NodeTpl {
/**
* 节点id
*/
@Id
@Column(name = "tpl_node_id")
private Integer tplNodeId;
/**
* 节点任务描述
*/
@Column(name = "node_name")
private String nodeName;
/**
* 节点类型:可扩展,包括:start,end,java,python,js,
*/
@Column(name = "node_type")
private String nodeType;
/**
* 节点标签:Java、Js脚本、Sql查询等
*/
@Column(name = "node_label")
private String nodeLabel;
/**
* Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
@Column(name = "node_show")
private String nodeShow;
/**
* 节点可见状态,复制时不可变
*/
@Column(name = "node_visible")
private Byte nodeVisible;
/**
* 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
@Column(name = "node_cron")
private String nodeCron;
/**
* 节点终止调度,为空则不执行过期操作
*/
@Column(name = "node_expire_cron")
private String nodeExpireCron;
/**
* 节点是否可以跳过,复制时不可变
*/
@Column(name = "node_skipable")
private Byte nodeSkipable;
/**
* 获取节点id
*
* @return tpl_node_id - 节点id
*/
public Integer getTplNodeId() {
return tplNodeId;
}
/**
* 设置节点id
*
* @param tplNodeId 节点id
*/
public void setTplNodeId(Integer tplNodeId) {
this.tplNodeId = tplNodeId;
}
/**
* 获取节点任务描述
*
* @return node_name - 节点任务描述
*/
public String getNodeName() {
return nodeName;
}
/**
* 设置节点任务描述
*
* @param nodeName 节点任务描述
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName == null ? null : nodeName.trim();
}
/**
* 获取节点类型:可扩展,包括:start,end,java,python,js,
*
* @return node_type - 节点类型:可扩展,包括:start,end,java,python,js,
*/
public String getNodeType() {
return nodeType;
}
/**
* 设置节点类型:可扩展,包括:start,end,java,python,js,
*
* @param nodeType 节点类型:可扩展,包括:start,end,java,python,js,
*/
public void setNodeType(String nodeType) {
this.nodeType = nodeType == null ? null : nodeType.trim();
}
/**
* 获取节点标签:Java、Js脚本、Sql查询等
*
* @return node_label - 节点标签:Java、Js脚本、Sql查询等
*/
public String getNodeLabel() {
return nodeLabel;
}
/**
* 设置节点标签:Java、Js脚本、Sql查询等
*
* @param nodeLabel 节点标签:Java、Js脚本、Sql查询等
*/
public void setNodeLabel(String nodeLabel) {
this.nodeLabel = nodeLabel == null ? null : nodeLabel.trim();
}
/**
* 获取Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @return node_show - Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public String getNodeShow() {
return nodeShow;
}
/**
* 设置Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @param nodeShow Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public void setNodeShow(String nodeShow) {
this.nodeShow = nodeShow == null ? null : nodeShow.trim();
}
/**
* 获取节点可见状态,复制时不可变
*
* @return node_visible - 节点可见状态,复制时不可变
*/
public Byte getNodeVisible() {
return nodeVisible;
}
/**
* 设置节点可见状态,复制时不可变
*
* @param nodeVisible 节点可见状态,复制时不可变
*/
public void setNodeVisible(Byte nodeVisible) {
this.nodeVisible = nodeVisible;
}
/**
* 获取调度表达式,为空则立即执行,执行前记得检查sop批次状态
*
* @return node_cron - 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
public String getNodeCron() {
return nodeCron;
}
/**
* 设置调度表达式,为空则立即执行,执行前记得检查sop批次状态
*
* @param nodeCron 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
public void setNodeCron(String nodeCron) {
this.nodeCron = nodeCron == null ? null : nodeCron.trim();
}
/**
* 获取节点终止调度,为空则不执行过期操作
*
* @return node_expire_cron - 节点终止调度,为空则不执行过期操作
*/
public String getNodeExpireCron() {
return nodeExpireCron;
}
/**
* 设置节点终止调度,为空则不执行过期操作
*
* @param nodeExpireCron 节点终止调度,为空则不执行过期操作
*/
public void setNodeExpireCron(String nodeExpireCron) {
this.nodeExpireCron = nodeExpireCron == null ? null : nodeExpireCron.trim();
}
/**
* 获取节点是否可以跳过,复制时不可变
*
* @return node_skipable - 节点是否可以跳过,复制时不可变
*/
public Byte getNodeSkipable() {
return nodeSkipable;
}
/**
* 设置节点是否可以跳过,复制时不可变
*
* @param nodeSkipable 节点是否可以跳过,复制时不可变
*/
public void setNodeSkipable(Byte nodeSkipable) {
this.nodeSkipable = nodeSkipable;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.*;
@Table(name = "sop_data_source")
public class SopDataSource {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
private Integer id;
/**
* 数据源类型 MYSQL,ORACLE,MSSQL,POSTGRESQL
*/
@Column(name = "db_type")
private String dbType;
/**
* ip地址
*/
@Column(name = "db_server")
private String dbServer;
/**
* 端口
*/
@Column(name = "db_port")
private Integer dbPort;
/**
* 账号
*/
@Column(name = "db_user_name")
private String dbUserName;
/**
* 密码
*/
@Column(name = "db_pwd")
private String dbPwd;
/**
* 数据源名称
*/
private String name;
@Column(name = "db_name")
private String dbName;
/**
* @return id
*/
public Integer getId() {
return id;
}
@Column(name = "data_source_id")
private String dataSourceId;
/**
* @param id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取数据源类型 MYSQL,ORACLE,MSSQL,POSTGRESQL
*
* @return db_type - 数据源类型 MYSQL,ORACLE,MSSQL,POSTGRESQL
*/
public String getDbType() {
return dbType;
}
/**
* 设置数据源类型 MYSQL,ORACLE,MSSQL,POSTGRESQL
*
* @param dbType 数据源类型 MYSQL,ORACLE,MSSQL,POSTGRESQL
*/
public void setDbType(String dbType) {
this.dbType = dbType == null ? null : dbType.trim();
}
/**
* 获取ip地址
*
* @return db_server - ip地址
*/
public String getDbServer() {
return dbServer;
}
/**
* 设置ip地址
*
* @param dbServer ip地址
*/
public void setDbServer(String dbServer) {
this.dbServer = dbServer == null ? null : dbServer.trim();
}
/**
* 获取账号
*
* @return db_user_name - 账号
*/
public String getDbUserName() {
return dbUserName;
}
/**
* 设置账号
*
* @param dbUserName 账号
*/
public void setDbUserName(String dbUserName) {
this.dbUserName = dbUserName == null ? null : dbUserName.trim();
}
/**
* 获取密码
*
* @return db_pwd - 密码
*/
public String getDbPwd() {
return dbPwd;
}
/**
* 设置密码
*
* @param dbPwd 密码
*/
public void setDbPwd(String dbPwd) {
this.dbPwd = dbPwd == null ? null : dbPwd.trim();
}
/**
* 获取数据源名称
*
* @return name - 数据源名称
*/
public String getName() {
return name;
}
/**
* 设置数据源名称
*
* @param name 数据源名称
*/
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
/**
* @return db_name
*/
public String getDbName() {
return dbName;
}
/**
* @param dbName
*/
public void setDbName(String dbName) {
this.dbName = dbName == null ? null : dbName.trim();
}
public Integer getDbPort() {
return dbPort;
}
public void setDbPort(Integer dbPort) {
this.dbPort = dbPort;
}
public String getDataSourceId() {
return dataSourceId;
}
public void setDataSourceId(String dataSourceId) {
this.dataSourceId = dataSourceId;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Table(name = "sop_inst")
public class SopInst {
/**
* 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
@Id
@Column(name = "inst_id")
private String instId;
/**
* 实例分组:当前场景下,分组id就是门店id
*/
@Column(name = "grant_id")
private Integer grantId;
/**
* 实例名
*/
@Column(name = "inst_name")
private String instName;
/**
* cron表达式,sop执行周期
*/
@Column(name = "inst_cron")
private String instCron;
/**
* sop简介
*/
@Column(name = "inst_remark")
private String instRemark;
@Column(name = "create_time")
private Date createTime;
@Column(name = "update_time")
private Date updateTime;
/**
* 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
@Column(name = "inst_status")
private Byte instStatus;
/**
* 实例默认输入参数
*/
@Column(name = "inst_param")
private String instParam;
/**
* 实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;
*/
@Column(name = "inst_snapshot")
private String instSnapshot;
/**
* sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
@Column(name = "expire_time")
private Date expireTime;
/**
* 当前生效的批次
*/
@Column(name = "batch_no")
private String batchNo;
/**
* 获取实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*
* @return inst_id - 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
public String getInstId() {
return instId;
}
/**
* 设置实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*
* @param instId 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
public void setInstId(String instId) {
this.instId = instId == null ? null : instId.trim();
}
/**
* 获取实例分组:当前场景下,分组id就是门店id
*
* @return grant_id - 实例分组:当前场景下,分组id就是门店id
*/
public Integer getGrantId() {
return grantId;
}
/**
* 设置实例分组:当前场景下,分组id就是门店id
*
* @param grantId 实例分组:当前场景下,分组id就是门店id
*/
public void setGrantId(Integer grantId) {
this.grantId = grantId;
}
/**
* 获取实例名
*
* @return inst_name - 实例名
*/
public String getInstName() {
return instName;
}
/**
* 设置实例名
*
* @param instName 实例名
*/
public void setInstName(String instName) {
this.instName = instName == null ? null : instName.trim();
}
/**
* 获取cron表达式,sop执行周期
*
* @return inst_cron - cron表达式,sop执行周期
*/
public String getInstCron() {
return instCron;
}
/**
* 设置cron表达式,sop执行周期
*
* @param instCron cron表达式,sop执行周期
*/
public void setInstCron(String instCron) {
this.instCron = instCron == null ? null : instCron.trim();
}
/**
* 获取sop简介
*
* @return inst_remark - sop简介
*/
public String getInstRemark() {
return instRemark;
}
/**
* 设置sop简介
*
* @param instRemark sop简介
*/
public void setInstRemark(String instRemark) {
this.instRemark = instRemark == null ? null : instRemark.trim();
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取启用状态:0,未启用;1,启用;-1,已删除/过期;
*
* @return inst_status - 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
public Byte getInstStatus() {
return instStatus;
}
/**
* 设置启用状态:0,未启用;1,启用;-1,已删除/过期;
*
* @param instStatus 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
public void setInstStatus(Byte instStatus) {
this.instStatus = instStatus;
}
/**
* 获取实例默认输入参数
*
* @return inst_param - 实例默认输入参数
*/
public String getInstParam() {
return instParam;
}
/**
* 设置实例默认输入参数
*
* @param instParam 实例默认输入参数
*/
public void setInstParam(String instParam) {
this.instParam = instParam == null ? null : instParam.trim();
}
/**
* 获取实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;
*
* @return inst_snapshot - 实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;
*/
public String getInstSnapshot() {
return instSnapshot;
}
/**
* 设置实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;
*
* @param instSnapshot 实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;
*/
public void setInstSnapshot(String instSnapshot) {
this.instSnapshot = instSnapshot == null ? null : instSnapshot.trim();
}
/**
* 获取sop有效期,每个sop都设置一个有效期,到期自动停止。
*
* @return expire_time - sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
public Date getExpireTime() {
return expireTime;
}
/**
* 设置sop有效期,每个sop都设置一个有效期,到期自动停止。
*
* @param expireTime sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
/**
* 获取当前生效的批次
*
* @return batch_no - 当前生效的批次
*/
public String getBatchNo() {
return batchNo;
}
/**
* 设置当前生效的批次
*
* @param batchNo 当前生效的批次
*/
public void setBatchNo(String batchNo) {
this.batchNo = batchNo == null ? null : batchNo.trim();
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "sop_inst_batch")
public class SopInstBatch {
@Id
@Column(name = "batch_no")
private String batchNo;
@Column(name = "inst_id")
private String instId;
/**
* 执行快照
*/
private String snapshot;
/**
* 批次启动时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 批次最后时间
*/
@Column(name = "update_time")
private Date updateTime;
/**
* @return batch_no
*/
public String getBatchNo() {
return batchNo;
}
/**
* @param batchNo
*/
public void setBatchNo(String batchNo) {
this.batchNo = batchNo == null ? null : batchNo.trim();
}
/**
* @return inst_id
*/
public String getInstId() {
return instId;
}
/**
* @param instId
*/
public void setInstId(String instId) {
this.instId = instId;
}
/**
* 获取执行快照
*
* @return snapshot - 执行快照
*/
public String getSnapshot() {
return snapshot;
}
/**
* 设置执行快照
*
* @param snapshot 执行快照
*/
public void setSnapshot(String snapshot) {
this.snapshot = snapshot == null ? null : snapshot.trim();
}
/**
* 获取批次启动时间
*
* @return create_time - 批次启动时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置批次启动时间
*
* @param createTime 批次启动时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取批次最后时间
*
* @return update_time - 批次最后时间
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* 设置批次最后时间
*
* @param updateTime 批次最后时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.*;
@Table(name = "sop_inst_link")
public class SopInstLink {
@Id
@Column(name = "link_id")
private Integer linkId;
@Column(name = "inst_id")
private String instId;
/**
* 节点任务名
*/
@Column(name = "source_id")
private Integer sourceId;
/**
* 节点任务名
*/
@Column(name = "target_id")
private Integer targetId;
/**
* @return link_id
*/
public Integer getLinkId() {
return linkId;
}
/**
* @param linkId
*/
public void setLinkId(Integer linkId) {
this.linkId = linkId;
}
/**
* @return inst_id
*/
public String getInstId() {
return instId;
}
/**
* @param instId
*/
public void setInstId(String instId) {
this.instId = instId == null ? null : instId.trim();
}
/**
* 获取节点任务名
*
* @return source_id - 节点任务名
*/
public Integer getSourceId() {
return sourceId;
}
/**
* 设置节点任务名
*
* @param sourceId 节点任务名
*/
public void setSourceId(Integer sourceId) {
this.sourceId = sourceId;
}
/**
* 获取节点任务名
*
* @return target_id - 节点任务名
*/
public Integer getTargetId() {
return targetId;
}
/**
* 设置节点任务名
*
* @param targetId 节点任务名
*/
public void setTargetId(Integer targetId) {
this.targetId = targetId;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
@Table(name = "sop_inst_node")
public class SopInstNode {
/**
* 实例节点id
*/
@Id
@Column(name = "inst_node_id")
private Integer instNodeId;
@Column(name = "inst_id")
private String instId;
/**
* 节点id
*/
@Column(name = "node_id")
private Integer nodeId;
/**
* 节点任务名
*/
@Column(name = "node_name")
private String nodeName;
/**
* 节点类型:可扩展,包括:start,end,java,python,js,
*/
@Column(name = "node_type")
private String nodeType;
/**
* 节点标签:Java、Js脚本、Sql查询等
*/
@Column(name = "node_label")
private String nodeLabel;
/**
* 节点的访问key
*/
@Column(name = "node_key")
private String nodeKey;
/**
* Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
@Column(name = "node_show")
private String nodeShow;
/**
* 输入参数格式:Json,开始节点的输入参数全局共用
*/
@Column(name = "node_param")
private String nodeParam;
/**
* 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
@Column(name = "node_content")
private String nodeContent;
/**
* 节点可见状态
*/
@Column(name = "node_visible")
private Byte nodeVisible;
/**
* 是否跳过节点
*/
@Column(name = "node_skip")
private Byte nodeSkip;
@Column(name = "node_async")
private Byte nodeAsync;
/**
* 节点调度表达式
*/
@Column(name = "node_cron")
private String nodeCron;
/**
* 节点终止调度
*/
@Column(name = "node_expire_cron")
private String nodeExpireCron;
/**
* 节点状态:0,停用;1,启用;
*/
@Column(name = "node_status")
private Integer nodeStatus;
/**
* 每日执行次数限制,0表示不限制。
*/
@Column(name = "daily_limit")
private Integer dailyLimit;
/**
* 每日执行次数限制,0表示不限制。
*/
@Column(name = "daily_count")
private Integer dailyCount = 0;
/**
* 每日任务过期时间,创建批次时重置,任务执行时检查。
*/
@Column(name = "daily_expire")
private Date dailyExpire;
@Transient
private List<SopInstNode> sopInstNodeList;
public List<SopInstNode> getSopInstNodeList() {
return sopInstNodeList;
}
public void setSopInstNodeList(List<SopInstNode> sopInstNodeList) {
this.sopInstNodeList = sopInstNodeList;
}
/**
* 获取实例节点id
*
* @return inst_node_id - 实例节点id
*/
public Integer getInstNodeId() {
return instNodeId;
}
/**
* 设置实例节点id
*
* @param instNodeId 实例节点id
*/
public void setInstNodeId(Integer instNodeId) {
this.instNodeId = instNodeId;
}
/**
* @return inst_id
*/
public String getInstId() {
return instId;
}
/**
* @param instId
*/
public void setInstId(String instId) {
this.instId = instId == null ? null : instId.trim();
}
/**
* 获取节点id
*
* @return node_id - 节点id
*/
public Integer getNodeId() {
return nodeId;
}
/**
* 设置节点id
*
* @param nodeId 节点id
*/
public void setNodeId(Integer nodeId) {
this.nodeId = nodeId;
}
/**
* 获取节点任务名
*
* @return node_name - 节点任务名
*/
public String getNodeName() {
return nodeName;
}
/**
* 设置节点任务名
*
* @param nodeName 节点任务名
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName == null ? null : nodeName.trim();
}
/**
* 获取节点类型:可扩展,包括:start,end,java,python,js,
*
* @return node_type - 节点类型:可扩展,包括:start,end,java,python,js,
*/
public String getNodeType() {
return nodeType;
}
/**
* 设置节点类型:可扩展,包括:start,end,java,python,js,
*
* @param nodeType 节点类型:可扩展,包括:start,end,java,python,js,
*/
public void setNodeType(String nodeType) {
this.nodeType = nodeType == null ? null : nodeType.trim();
}
/**
* 获取节点标签:Java、Js脚本、Sql查询等
*
* @return node_label - 节点标签:Java、Js脚本、Sql查询等
*/
public String getNodeLabel() {
return nodeLabel;
}
/**
* 设置节点标签:Java、Js脚本、Sql查询等
*
* @param nodeLabel 节点标签:Java、Js脚本、Sql查询等
*/
public void setNodeLabel(String nodeLabel) {
this.nodeLabel = nodeLabel == null ? null : nodeLabel.trim();
}
/**
* 获取节点的访问key
*
* @return node_key - 节点的访问key
*/
public String getNodeKey() {
return nodeKey;
}
/**
* 设置节点的访问key
*
* @param nodeKey 节点的访问key
*/
public void setNodeKey(String nodeKey) {
this.nodeKey = nodeKey == null ? null : nodeKey.trim();
}
/**
* 获取Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @return node_show - Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public String getNodeShow() {
return nodeShow;
}
/**
* 设置Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @param nodeShow Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public void setNodeShow(String nodeShow) {
this.nodeShow = nodeShow == null ? null : nodeShow.trim();
}
/**
* 获取输入参数格式:Json,开始节点的输入参数全局共用
*
* @return node_param - 输入参数格式:Json,开始节点的输入参数全局共用
*/
public String getNodeParam() {
return nodeParam;
}
/**
* 设置输入参数格式:Json,开始节点的输入参数全局共用
*
* @param nodeParam 输入参数格式:Json,开始节点的输入参数全局共用
*/
public void setNodeParam(String nodeParam) {
this.nodeParam = nodeParam == null ? null : nodeParam.trim();
}
/**
* 获取节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*
* @return node_content - 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
public String getNodeContent() {
return nodeContent;
}
/**
* 设置节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*
* @param nodeContent 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
public void setNodeContent(String nodeContent) {
this.nodeContent = nodeContent == null ? null : nodeContent.trim();
}
/**
* 获取节点可见状态
*
* @return node_visible - 节点可见状态
*/
public Byte getNodeVisible() {
return nodeVisible;
}
/**
* 设置节点可见状态
*
* @param nodeVisible 节点可见状态
*/
public void setNodeVisible(Byte nodeVisible) {
this.nodeVisible = nodeVisible;
}
/**
* 获取是否跳过节点
*
* @return node_skip - 是否跳过节点
*/
public Byte getNodeSkip() {
return nodeSkip;
}
/**
* 设置是否跳过节点
*
* @param nodeSkip 是否跳过节点
*/
public void setNodeSkip(Byte nodeSkip) {
this.nodeSkip = nodeSkip;
}
/**
* 获取节点调度表达式
*
* @return node_cron - 节点调度表达式
*/
public String getNodeCron() {
return nodeCron;
}
/**
* 设置节点调度表达式
*
* @param nodeCron 节点调度表达式
*/
public void setNodeCron(String nodeCron) {
this.nodeCron = nodeCron == null ? null : nodeCron.trim();
}
/**
* 获取节点终止调度
*
* @return node_expire_cron - 节点终止调度
*/
public String getNodeExpireCron() {
return nodeExpireCron;
}
/**
* 设置节点终止调度
*
* @param nodeExpireCron 节点终止调度
*/
public void setNodeExpireCron(String nodeExpireCron) {
this.nodeExpireCron = nodeExpireCron == null ? null : nodeExpireCron.trim();
}
/**
* 获取节点状态:0,停用;1,启用;
*
* @return node_status - 节点状态:0,停用;1,启用;
*/
public Integer getNodeStatus() {
return nodeStatus;
}
/**
* 设置节点状态:0,停用;1,启用;
*
* @param nodeStatus 节点状态:0,停用;1,启用;
*/
public void setNodeStatus(Integer nodeStatus) {
this.nodeStatus = nodeStatus;
}
public Byte getNodeAsync() {
return nodeAsync;
}
public void setNodeAsync(Byte nodeAsync) {
this.nodeAsync = nodeAsync;
}
public Integer getDailyLimit() {
return dailyLimit;
}
public void setDailyLimit(Integer dailyLimit) {
this.dailyLimit = dailyLimit;
}
public Integer getDailyCount() {
return dailyCount;
}
public void setDailyCount(Integer dailyCount) {
this.dailyCount = dailyCount;
}
public Date getDailyExpire() {
return dailyExpire;
}
public void setDailyExpire(Date dailyExpire) {
this.dailyExpire = dailyExpire;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sop_inst_node_batch")
public class SopInstNodeBatch {
@Id
@Column(name = "node_batch_no")
private String nodeBatchNo;
@Column(name = "inst_node_id")
private Integer instNodeId;
/**
* 批次
*/
@Column(name = "batch_no")
private String batchNo;
/**
* 执行快照
*/
private String snapshot;
@Column(name = "create_time")
private Date createTime;
@Column(name = "update_time")
private Date updateTime;
/**
* @return node_batch_no
*/
public String getNodeBatchNo() {
return nodeBatchNo;
}
/**
* @param nodeBatchNo
*/
public void setNodeBatchNo(String nodeBatchNo) {
this.nodeBatchNo = nodeBatchNo == null ? null : nodeBatchNo.trim();
}
/**
* @return inst_node_id
*/
public Integer getInstNodeId() {
return instNodeId;
}
/**
* @param instNodeId
*/
public void setInstNodeId(Integer instNodeId) {
this.instNodeId = instNodeId;
}
/**
* 获取批次
*
* @return batch_no - 批次
*/
public String getBatchNo() {
return batchNo;
}
/**
* 设置批次
*
* @param batchNo 批次
*/
public void setBatchNo(String batchNo) {
this.batchNo = batchNo == null ? null : batchNo.trim();
}
/**
* 获取执行快照
*
* @return snapshot - 执行快照
*/
public String getSnapshot() {
return snapshot;
}
/**
* 设置执行快照
*
* @param snapshot 执行快照
*/
public void setSnapshot(String snapshot) {
this.snapshot = snapshot == null ? null : snapshot.trim();
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.*;
@Table(name = "sop_node_tpl")
public class SopNodeTpl {
/**
* 节点id
*/
@Id
@Column(name = "tpl_node_id")
private Integer tplNodeId;
/**
* 节点任务描述
*/
@Column(name = "node_name")
private String nodeName;
/**
* 节点类型:可扩展,包括:start,end,java,python,js,
*/
@Column(name = "node_type")
private String nodeType;
/**
* 节点标签:Java、Js脚本、Sql查询等
*/
@Column(name = "node_label")
private String nodeLabel;
/**
* Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
@Column(name = "node_show")
private String nodeShow;
/**
* 输入参数格式:Json,开始节点的输入参数全局共用
*/
@Column(name = "node_param_def")
private String nodeParamDef;
/**
* 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
@Column(name = "node_content_def")
private String nodeContentDef;
/**
* 节点输出数据格式模板,主要用于后续节点参考
*/
@Column(name = "node_result_def")
private String nodeResultDef;
/**
* 节点可见状态,复制时不可变
*/
@Column(name = "node_visible")
private Byte nodeVisible;
/**
* 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
@Column(name = "node_cron")
private String nodeCron;
/**
* 节点终止调度,为空则不执行过期操作
*/
@Column(name = "node_expire_cron")
private String nodeExpireCron;
/**
* 节点是否可以跳过,复制时不可变
*/
@Column(name = "node_skipable")
private Byte nodeSkipable;
/**
* 获取节点id
*
* @return tpl_node_id - 节点id
*/
public Integer getTplNodeId() {
return tplNodeId;
}
/**
* 设置节点id
*
* @param tplNodeId 节点id
*/
public void setTplNodeId(Integer tplNodeId) {
this.tplNodeId = tplNodeId;
}
/**
* 获取节点任务描述
*
* @return node_name - 节点任务描述
*/
public String getNodeName() {
return nodeName;
}
/**
* 设置节点任务描述
*
* @param nodeName 节点任务描述
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName == null ? null : nodeName.trim();
}
/**
* 获取节点类型:可扩展,包括:start,end,java,python,js,
*
* @return node_type - 节点类型:可扩展,包括:start,end,java,python,js,
*/
public String getNodeType() {
return nodeType;
}
/**
* 设置节点类型:可扩展,包括:start,end,java,python,js,
*
* @param nodeType 节点类型:可扩展,包括:start,end,java,python,js,
*/
public void setNodeType(String nodeType) {
this.nodeType = nodeType == null ? null : nodeType.trim();
}
/**
* 获取节点标签:Java、Js脚本、Sql查询等
*
* @return node_label - 节点标签:Java、Js脚本、Sql查询等
*/
public String getNodeLabel() {
return nodeLabel;
}
/**
* 设置节点标签:Java、Js脚本、Sql查询等
*
* @param nodeLabel 节点标签:Java、Js脚本、Sql查询等
*/
public void setNodeLabel(String nodeLabel) {
this.nodeLabel = nodeLabel == null ? null : nodeLabel.trim();
}
/**
* 获取Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @return node_show - Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public String getNodeShow() {
return nodeShow;
}
/**
* 设置Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @param nodeShow Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public void setNodeShow(String nodeShow) {
this.nodeShow = nodeShow == null ? null : nodeShow.trim();
}
/**
* 获取输入参数格式:Json,开始节点的输入参数全局共用
*
* @return node_param_def - 输入参数格式:Json,开始节点的输入参数全局共用
*/
public String getNodeParamDef() {
return nodeParamDef;
}
/**
* 设置输入参数格式:Json,开始节点的输入参数全局共用
*
* @param nodeParamDef 输入参数格式:Json,开始节点的输入参数全局共用
*/
public void setNodeParamDef(String nodeParamDef) {
this.nodeParamDef = nodeParamDef == null ? null : nodeParamDef.trim();
}
/**
* 获取节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*
* @return node_content_def - 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
public String getNodeContentDef() {
return nodeContentDef;
}
/**
* 设置节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*
* @param nodeContentDef 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
public void setNodeContentDef(String nodeContentDef) {
this.nodeContentDef = nodeContentDef == null ? null : nodeContentDef.trim();
}
/**
* 获取节点输出数据格式模板,主要用于后续节点参考
*
* @return node_result_def - 节点输出数据格式模板,主要用于后续节点参考
*/
public String getNodeResultDef() {
return nodeResultDef;
}
/**
* 设置节点输出数据格式模板,主要用于后续节点参考
*
* @param nodeResultDef 节点输出数据格式模板,主要用于后续节点参考
*/
public void setNodeResultDef(String nodeResultDef) {
this.nodeResultDef = nodeResultDef == null ? null : nodeResultDef.trim();
}
/**
* 获取节点可见状态,复制时不可变
*
* @return node_visible - 节点可见状态,复制时不可变
*/
public Byte getNodeVisible() {
return nodeVisible;
}
/**
* 设置节点可见状态,复制时不可变
*
* @param nodeVisible 节点可见状态,复制时不可变
*/
public void setNodeVisible(Byte nodeVisible) {
this.nodeVisible = nodeVisible;
}
/**
* 获取调度表达式,为空则立即执行,执行前记得检查sop批次状态
*
* @return node_cron - 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
public String getNodeCron() {
return nodeCron;
}
/**
* 设置调度表达式,为空则立即执行,执行前记得检查sop批次状态
*
* @param nodeCron 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
public void setNodeCron(String nodeCron) {
this.nodeCron = nodeCron == null ? null : nodeCron.trim();
}
/**
* 获取节点终止调度,为空则不执行过期操作
*
* @return node_expire_cron - 节点终止调度,为空则不执行过期操作
*/
public String getNodeExpireCron() {
return nodeExpireCron;
}
/**
* 设置节点终止调度,为空则不执行过期操作
*
* @param nodeExpireCron 节点终止调度,为空则不执行过期操作
*/
public void setNodeExpireCron(String nodeExpireCron) {
this.nodeExpireCron = nodeExpireCron == null ? null : nodeExpireCron.trim();
}
/**
* 获取节点是否可以跳过,复制时不可变
*
* @return node_skipable - 节点是否可以跳过,复制时不可变
*/
public Byte getNodeSkipable() {
return nodeSkipable;
}
/**
* 设置节点是否可以跳过,复制时不可变
*
* @param nodeSkipable 节点是否可以跳过,复制时不可变
*/
public void setNodeSkipable(Byte nodeSkipable) {
this.nodeSkipable = nodeSkipable;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity; package cn.com.glsx.process.modules.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sop_tpl")
public class SopTpl { public class SopTpl {
/**
* 模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位
*/
@Id
@Column(name = "tpl_id")
private String tplId;
/**
* 模板名
*/
@Column(name = "tpl_name")
private String tplName;
/**
* cron表达式,sop执行周期
*/
@Column(name = "tpl_cron")
private String tplCron;
/**
* sop简介
*/
@Column(name = "tpl_remark")
private String tplRemark;
/**
* 启用状态:0,禁用;1,启用;
*/
@Column(name = "tpl_status")
private Byte tplStatus;
/**
* JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*/
@Column(name = "tpl_param_def")
private String tplParamDef;
@Column(name = "tpl_result_def")
private String tplResultDef;
/**
* 是否单实例模式:0,多实例;1,单实例;
*/
@Column(name = "tpl_singleton")
private Byte tplSingleton;
@Column(name = "create_time")
private Date createTime;
@Column(name = "update_time")
private Date updateTime;
/**
* 获取模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位
*
* @return tpl_id - 模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位
*/
public String getTplId() {
return tplId;
}
/**
* 设置模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位
*
* @param tplId 模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位
*/
public void setTplId(String tplId) {
this.tplId = tplId == null ? null : tplId.trim();
}
/**
* 获取模板名
*
* @return tpl_name - 模板名
*/
public String getTplName() {
return tplName;
}
/**
* 设置模板名
*
* @param tplName 模板名
*/
public void setTplName(String tplName) {
this.tplName = tplName == null ? null : tplName.trim();
}
/**
* 获取cron表达式,sop执行周期
*
* @return tpl_cron - cron表达式,sop执行周期
*/
public String getTplCron() {
return tplCron;
}
/**
* 设置cron表达式,sop执行周期
*
* @param tplCron cron表达式,sop执行周期
*/
public void setTplCron(String tplCron) {
this.tplCron = tplCron == null ? null : tplCron.trim();
}
/**
* 获取sop简介
*
* @return tpl_remark - sop简介
*/
public String getTplRemark() {
return tplRemark;
}
/**
* 设置sop简介
*
* @param tplRemark sop简介
*/
public void setTplRemark(String tplRemark) {
this.tplRemark = tplRemark == null ? null : tplRemark.trim();
}
/**
* 获取启用状态:0,禁用;1,启用;
*
* @return tpl_status - 启用状态:0,禁用;1,启用;
*/
public Byte getTplStatus() {
return tplStatus;
}
/**
* 设置启用状态:0,禁用;1,启用;
*
* @param tplStatus 启用状态:0,禁用;1,启用;
*/
public void setTplStatus(Byte tplStatus) {
this.tplStatus = tplStatus;
}
/**
* 获取JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*
* @return tpl_param_def - JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*/
public String getTplParamDef() {
return tplParamDef;
}
/**
* 设置JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*
* @param tplParamDef JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*/
public void setTplParamDef(String tplParamDef) {
this.tplParamDef = tplParamDef == null ? null : tplParamDef.trim();
}
/**
* @return tpl_result_def
*/
public String getTplResultDef() {
return tplResultDef;
}
/**
* @param tplResultDef
*/
public void setTplResultDef(String tplResultDef) {
this.tplResultDef = tplResultDef == null ? null : tplResultDef.trim();
}
/**
* 获取是否单实例模式:0,多实例;1,单实例;
*
* @return tpl_singleton - 是否单实例模式:0,多实例;1,单实例;
*/
public Byte getTplSingleton() {
return tplSingleton;
}
/**
* 设置是否单实例模式:0,多实例;1,单实例;
*
* @param tplSingleton 是否单实例模式:0,多实例;1,单实例;
*/
public void setTplSingleton(Byte tplSingleton) {
this.tplSingleton = tplSingleton;
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
} }
package cn.com.glsx.process.modules.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "sop_tpl_grant")
public class SopTplGrant {
/**
* 授权状态:0,未启用;1,启用;-1,删除;
*/
public static final Byte GRANT_STATUS_DELETED = -1;
public static final Byte GRANT_STATUS_NORMAL = 1;
/**
* 授权id
*/
@Id
@Column(name = "grant_id")
private Integer grantId;
/**
* 实例分组:当前场景下,分组id就是门店id
*/
@Column(name = "group_id")
private String groupId;
@Column(name = "group_name")
private String groupName;
/**
* 模板id
*/
@Column(name = "tpl_id")
private String tplId;
@Column(name = "create_time")
private Date createTime;
@Column(name = "update_time")
private Date updateTime;
/**
* 授权状态:0,未启用;1,启用;
*/
@Column(name = "grant_status")
private Byte grantStatus;
/**
* 获取授权id
*
* @return grant_id - 授权id
*/
public Integer getGrantId() {
return grantId;
}
/**
* 设置授权id
*
* @param grantId 授权id
*/
public void setGrantId(Integer grantId) {
this.grantId = grantId;
}
/**
* 获取实例分组:当前场景下,分组id就是门店id
*
* @return group_id - 实例分组:当前场景下,分组id就是门店id
*/
public String getGroupId() {
return groupId;
}
/**
* 设置实例分组:当前场景下,分组id就是门店id
*
* @param groupId 实例分组:当前场景下,分组id就是门店id
*/
public void setGroupId(String groupId) {
this.groupId = groupId == null ? null : groupId.trim();
}
/**
* @return group_name
*/
public String getGroupName() {
return groupName;
}
/**
* @param groupName
*/
public void setGroupName(String groupName) {
this.groupName = groupName == null ? null : groupName.trim();
}
/**
* 获取模板id
*
* @return tpl_id - 模板id
*/
public String getTplId() {
return tplId;
}
/**
* 设置模板id
*
* @param tplId 模板id
*/
public void setTplId(String tplId) {
this.tplId = tplId == null ? null : tplId.trim();
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取授权状态:0,未启用;1,启用;
*
* @return grant_status - 授权状态:0,未启用;1,启用;
*/
public Byte getGrantStatus() {
return grantStatus;
}
/**
* 设置授权状态:0,未启用;1,启用;
*
* @param grantStatus 授权状态:0,未启用;1,启用;
*/
public void setGrantStatus(Byte grantStatus) {
this.grantStatus = grantStatus;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.*;
@Table(name = "sop_tpl_link")
public class SopTplLink {
@Id
@Column(name = "link_id")
private Integer linkId;
@Column(name = "tpl_id")
private String tplId;
/**
* 任务节点链接起点
*/
@Column(name = "source_id")
private Integer sourceId;
/**
* 任务节点链接终点
*/
@Column(name = "target_id")
private Integer targetId;
/**
* @return link_id
*/
public Integer getLinkId() {
return linkId;
}
/**
* @param linkId
*/
public void setLinkId(Integer linkId) {
this.linkId = linkId;
}
/**
* @return tpl_id
*/
public String getTplId() {
return tplId;
}
/**
* @param tplId
*/
public void setTplId(String tplId) {
this.tplId = tplId == null ? null : tplId.trim();
}
/**
* 获取任务节点链接起点
*
* @return source_id - 任务节点链接起点
*/
public Integer getSourceId() {
return sourceId;
}
/**
* 设置任务节点链接起点
*
* @param sourceId 任务节点链接起点
*/
public void setSourceId(Integer sourceId) {
this.sourceId = sourceId;
}
/**
* 获取任务节点链接终点
*
* @return target_id - 任务节点链接终点
*/
public Integer getTargetId() {
return targetId;
}
/**
* 设置任务节点链接终点
*
* @param targetId 任务节点链接终点
*/
public void setTargetId(Integer targetId) {
this.targetId = targetId;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.entity;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "sop_tpl_node")
public class SopTplNode {
/**
* 节点id
*/
@Id
@Column(name = "id")
private Integer id;
@Column(name = "node_id")
private Integer nodeId;
/**
* sop模板代码
*/
@Column(name = "tpl_id")
private String tplId;
/**
* 节点任务描述
*/
@Column(name = "node_name")
private String nodeName;
/**
* 节点类型:可扩展,包括:start,end,java,python,js,
*/
@Column(name = "node_type")
private String nodeType;
/**
* 节点标签:Java、Js脚本、Sql查询等
*/
@Column(name = "node_label")
private String nodeLabel;
/**
* Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
@Column(name = "node_show")
private String nodeShow;
/**
* 输入参数格式:Json,开始节点的输入参数全局共用
*/
@Column(name = "node_param_def")
private String nodeParamDef;
/**
* 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
@Column(name = "node_content_def")
private String nodeContentDef;
/**
* 节点的访问key,复制时不可变
*/
@Column(name = "node_key")
private String nodeKey;
/**
* 节点输出数据格式模板,主要用于后续节点参考
*/
@Column(name = "node_result_def")
private String nodeResultDef;
/**
* 节点可见状态,复制时不可变
*/
@Column(name = "node_visible")
private Byte nodeVisible;
/**
* 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
@Column(name = "node_cron")
private String nodeCron;
/**
* 节点终止调度,为空则立即执行
*/
@Column(name = "node_expire_cron")
private String nodeExpireCron;
/**
* 节点是否可以跳过,复制时不可变
*/
@Column(name = "node_skipable")
private Byte nodeSkipable;
/**
* '节点是否异步执行。非异步执行则代表对前置节点有依赖
*/
@Column(name = "node_async")
private Byte nodeAsync;
/**
* 每日执行次数限制,0表示不限制。
*/
@Column(name = "daily_limit")
private Integer dailyLimit;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/**
* 获取节点id
*
* @return node_id - 节点id
*/
public Integer getNodeId() {
return nodeId;
}
/**
* 设置节点id
*
* @param nodeId 节点id
*/
public void setNodeId(Integer nodeId) {
this.nodeId = nodeId;
}
/**
* 获取sop模板代码
*
* @return tpl_id - sop模板代码
*/
public String getTplId() {
return tplId;
}
/**
* 设置sop模板代码
*
* @param tplId sop模板代码
*/
public void setTplId(String tplId) {
this.tplId = tplId == null ? null : tplId.trim();
}
/**
* 获取节点任务描述
*
* @return node_name - 节点任务描述
*/
public String getNodeName() {
return nodeName;
}
/**
* 设置节点任务描述
*
* @param nodeName 节点任务描述
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName == null ? null : nodeName.trim();
}
/**
* 获取节点类型:可扩展,包括:start,end,java,python,js,
*
* @return node_type - 节点类型:可扩展,包括:start,end,java,python,js,
*/
public String getNodeType() {
return nodeType;
}
/**
* 设置节点类型:可扩展,包括:start,end,java,python,js,
*
* @param nodeType 节点类型:可扩展,包括:start,end,java,python,js,
*/
public void setNodeType(String nodeType) {
this.nodeType = nodeType == null ? null : nodeType.trim();
}
/**
* 获取节点标签:Java、Js脚本、Sql查询等
*
* @return node_label - 节点标签:Java、Js脚本、Sql查询等
*/
public String getNodeLabel() {
return nodeLabel;
}
/**
* 设置节点标签:Java、Js脚本、Sql查询等
*
* @param nodeLabel 节点标签:Java、Js脚本、Sql查询等
*/
public void setNodeLabel(String nodeLabel) {
this.nodeLabel = nodeLabel == null ? null : nodeLabel.trim();
}
/**
* 获取Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @return node_show - Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public String getNodeShow() {
return nodeShow;
}
/**
* 设置Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*
* @param nodeShow Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/
public void setNodeShow(String nodeShow) {
this.nodeShow = nodeShow == null ? null : nodeShow.trim();
}
/**
* 获取输入参数格式:Json,开始节点的输入参数全局共用
*
* @return node_param_def - 输入参数格式:Json,开始节点的输入参数全局共用
*/
public String getNodeParamDef() {
return nodeParamDef;
}
/**
* 设置输入参数格式:Json,开始节点的输入参数全局共用
*
* @param nodeParamDef 输入参数格式:Json,开始节点的输入参数全局共用
*/
public void setNodeParamDef(String nodeParamDef) {
this.nodeParamDef = nodeParamDef == null ? null : nodeParamDef.trim();
}
/**
* 获取节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*
* @return node_content_def - 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
public String getNodeContentDef() {
return nodeContentDef;
}
/**
* 设置节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*
* @param nodeContentDef 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/
public void setNodeContentDef(String nodeContentDef) {
this.nodeContentDef = nodeContentDef == null ? null : nodeContentDef.trim();
}
/**
* 获取节点的访问key,复制时不可变
*
* @return node_key - 节点的访问key,复制时不可变
*/
public String getNodeKey() {
return nodeKey;
}
/**
* 设置节点的访问key,复制时不可变
*
* @param nodeKey 节点的访问key,复制时不可变
*/
public void setNodeKey(String nodeKey) {
this.nodeKey = nodeKey == null ? null : nodeKey.trim();
}
/**
* 获取节点输出数据格式模板,主要用于后续节点参考
*
* @return node_result_def - 节点输出数据格式模板,主要用于后续节点参考
*/
public String getNodeResultDef() {
return nodeResultDef;
}
/**
* 设置节点输出数据格式模板,主要用于后续节点参考
*
* @param nodeResultDef 节点输出数据格式模板,主要用于后续节点参考
*/
public void setNodeResultDef(String nodeResultDef) {
this.nodeResultDef = nodeResultDef == null ? null : nodeResultDef.trim();
}
/**
* 获取节点可见状态,复制时不可变
*
* @return node_visible - 节点可见状态,复制时不可变
*/
public Byte getNodeVisible() {
return nodeVisible;
}
/**
* 设置节点可见状态,复制时不可变
*
* @param nodeVisible 节点可见状态,复制时不可变
*/
public void setNodeVisible(Byte nodeVisible) {
this.nodeVisible = nodeVisible;
}
/**
* 获取调度表达式,为空则立即执行,执行前记得检查sop批次状态
*
* @return node_cron - 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
public String getNodeCron() {
return nodeCron;
}
/**
* 设置调度表达式,为空则立即执行,执行前记得检查sop批次状态
*
* @param nodeCron 调度表达式,为空则立即执行,执行前记得检查sop批次状态
*/
public void setNodeCron(String nodeCron) {
this.nodeCron = nodeCron == null ? null : nodeCron.trim();
}
/**
* 获取节点终止调度,为空则立即执行
*
* @return node_expire_cron - 节点终止调度,为空则立即执行
*/
public String getNodeExpireCron() {
return nodeExpireCron;
}
/**
* 设置节点终止调度,为空则立即执行
*
* @param nodeExpireCron 节点终止调度,为空则立即执行
*/
public void setNodeExpireCron(String nodeExpireCron) {
this.nodeExpireCron = nodeExpireCron == null ? null : nodeExpireCron.trim();
}
/**
* 获取节点是否可以跳过,复制时不可变
*
* @return node_skipable - 节点是否可以跳过,复制时不可变
*/
public Byte getNodeSkipable() {
return nodeSkipable;
}
/**
* 设置节点是否可以跳过,复制时不可变
*
* @param nodeSkipable 节点是否可以跳过,复制时不可变
*/
public void setNodeSkipable(Byte nodeSkipable) {
this.nodeSkipable = nodeSkipable;
}
public Byte getNodeAsync() {
return nodeAsync;
}
public void setNodeAsync(Byte nodeAsync) {
this.nodeAsync = nodeAsync;
}
public Integer getDailyLimit() {
return dailyLimit;
}
public void setDailyLimit(Integer dailyLimit) {
this.dailyLimit = dailyLimit;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.JobManager;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface JobManagerMapper extends CommonBaseMapper<JobManager> {
JobManager findByName(@Param("jobName") String jobName);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.NodeTpl;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface NodeTplMapper extends CommonBaseMapper<NodeTpl> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopDataSource;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SopDataSourceMapper extends CommonBaseMapper<SopDataSource> {
SopDataSource findByDataSourceId(@Param("dataSourceId") String dataSourceId);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SopInstBatchMapper extends CommonBaseMapper<SopInstBatch> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstLink;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SopInstLinkMapper extends CommonBaseMapper<SopInstLink> {
List<SopInstLink> findByInstId(@Param("instId") String instId);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.model.SopInstDTO;
import cn.com.glsx.process.modules.model.SopInstSearch;
@Mapper
public interface SopInstMapper extends CommonBaseMapper<SopInst> {
List<SopInst> selectByGroupId(SopInstSearch search);
/**
* 通过门店模板实例初始参数查询
*
* @param customData
* @return
*/
List<SopInst> selectByCustomData(@Param("customData") Map<String, Object> customData);
/**
* 更新门店模板实例默认参数的自定义参数
*
* @param instId
* @param customData
*/
void updateInstParamCustomData(@Param("instId") String instId, @Param("customData") Map<String, Object> customData);
/**
* 更新门店模板实例的状态
*
* @param instId
* @param status
*/
void updateInstStatus(@Param("instId") String instId, @Param("status") Byte status);
void updateInstBatchNo(@Param("instId") String instId, @Param("batchNo") String batchNo, @Param("snapshot") String snapshot);
/**
* 分页查询模板实例列表
*
* @param search
* @return
*/
List<SopInstDTO> page(SopInstSearch search);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SopInstNodeBatchMapper extends CommonBaseMapper<SopInstNodeBatch> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import cn.com.glsx.process.modules.entity.SopInstNode;
@Mapper
public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> {
List<SopInstNode> findByInstId(@Param("instId") String instId);
int resetInstNodeDailyCount(@Param("instId") String instId);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopNodeTpl;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SopNodeTplMapper extends CommonBaseMapper<SopNodeTpl> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopTplGrant;
import cn.com.glsx.process.modules.model.SopTplGrantSearch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SopTplGrantMapper extends CommonBaseMapper<SopTplGrant> {
int countByTplId(@Param("tplId") String tplId);
List<SopTplGrant> list(SopTplGrantSearch search);
void del(@Param("id") Integer id);
/**
* 统计所有状态的派发数量
*
* @param tplId
* @return
*/
int countAllByTplId(@Param("tplId") String tplId);
/**
* 根据模板id和门店id集合查询授权在用记录
*
* @param tplId 模板id
* @param groupIds 门店id集合
* @return
*/
List<SopTplGrant> selectInUseGrants(@Param("tplId") String tplId, @Param("groupIds") List<String> groupIds);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopTplLink;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SopTplLinkMapper extends CommonBaseMapper<SopTplLink> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopTpl;
import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.model.SopTplSearch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SopTplMapper extends CommonBaseMapper<SopTpl> {
List<SopTplDTO> page(SopTplSearch search);
SopTplDTO getById(@Param("tplId") String tplId);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopTplNode;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SopTplNodeMapper extends CommonBaseMapper<SopTplNode> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.model;
import cn.hutool.db.Page;
import lombok.Data;
@Data
public class SopCustomerSearch extends Page {
/**
* 组织ID
*/
private String orgId;
/**
* 客户oneID
*/
private String oneId;
/**
* 客户旅程id
*/
private String sopJourneyId;
/**
* 客户旅程阶段
*/
private String sopJourneyStage;
/**
* 客户手机号列表
*/
private String customerPhone;
/**
* 客户姓名
*/
private String customerName;
/**
* 客户微信昵称
*/
private String wechatNickname;
/**
* 客户旅程跟进人id
*/
private String sopFollowUpPersonId;
/**
* 客户旅程跟进人手机号
*/
private String sopFollowUpPersonPhone;
/**
* 进入sop旅程时间-开始
* yyyy-MM-dd HH:mm:ss
*/
private String sopJourneyEnterTimeBegin;
/**
* 进入sop旅程时间-结束
* yyyy-MM-dd HH:mm:ss
*/
private String sopJourneyEnterTimeEnd;
}
package cn.com.glsx.process.modules.model;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopTplGrant;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.List;
public class SopInstDTO {
/**
* 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
private String instId;
/**
* 模板id
*/
private String tplId;
/**
* 实例分组:当前场景下,分组id就是门店id
*/
private Integer grantId;
/**
* 实例名
*/
private String instName;
/**
* cron表达式,sop执行周期
*/
private String instCron;
/**
* sop简介
*/
private String instRemark;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
private Byte instStatus;
/**
* 实例默认输入参数
*/
private String instParam;
/**
* 实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;
*/
private String instSnapshot;
/**
* sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
private Date expireTime;
/**
* 当前生效的批次
*/
private String batchNo;
/**
* sop任务节点
*/
private List<SopInstNode> nodes;
/**
* sop任务节点连接
*/
private List<SopInstLink> links;
/**
* 用于下发门店时
*/
private List<SopTplGrant> sopTplGrants;
/**
* 授权关系(关联的门店)
*/
private SopTplGrant sopTplGrant;
/**
* 获取实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*
* @return inst_id - 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
public String getInstId() {
return instId;
}
/**
* 设置实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*
* @param instId 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
public void setInstId(String instId) {
this.instId = instId == null ? null : instId.trim();
}
public String getTplId() {
return tplId;
}
public void setTplId(String tplId) {
this.tplId = tplId;
}
/**
* 获取实例分组:当前场景下,分组id就是门店id
*
* @return grant_id - 实例分组:当前场景下,分组id就是门店id
*/
public Integer getGrantId() {
return grantId;
}
/**
* 设置实例分组:当前场景下,分组id就是门店id
*
* @param grantId 实例分组:当前场景下,分组id就是门店id
*/
public void setGrantId(Integer grantId) {
this.grantId = grantId;
}
/**
* 获取实例名
*
* @return inst_name - 实例名
*/
public String getInstName() {
return instName;
}
/**
* 设置实例名
*
* @param instName 实例名
*/
public void setInstName(String instName) {
this.instName = instName == null ? null : instName.trim();
}
/**
* 获取cron表达式,sop执行周期
*
* @return inst_cron - cron表达式,sop执行周期
*/
public String getInstCron() {
return instCron;
}
/**
* 设置cron表达式,sop执行周期
*
* @param instCron cron表达式,sop执行周期
*/
public void setInstCron(String instCron) {
this.instCron = instCron == null ? null : instCron.trim();
}
/**
* 获取sop简介
*
* @return inst_remark - sop简介
*/
public String getInstRemark() {
return instRemark;
}
/**
* 设置sop简介
*
* @param instRemark sop简介
*/
public void setInstRemark(String instRemark) {
this.instRemark = instRemark == null ? null : instRemark.trim();
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* 获取启用状态:0,未启用;1,启用;-1,已删除/过期;
*
* @return inst_status - 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
public Byte getInstStatus() {
return instStatus;
}
/**
* 设置启用状态:0,未启用;1,启用;-1,已删除/过期;
*
* @param instStatus 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
public void setInstStatus(Byte instStatus) {
this.instStatus = instStatus;
}
public String getInstParam() {
return instParam;
}
public void setInstParam(String instParam) {
this.instParam = instParam;
}
public String getInstSnapshot() {
return instSnapshot;
}
public void setInstSnapshot(String instSnapshot) {
this.instSnapshot = instSnapshot;
}
/**
* 获取sop有效期,每个sop都设置一个有效期,到期自动停止。
*
* @return expire_time - sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
public Date getExpireTime() {
return expireTime;
}
/**
* 设置sop有效期,每个sop都设置一个有效期,到期自动停止。
*
* @param expireTime sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
/**
* 获取当前生效的批次
*
* @return batch_no - 当前生效的批次
*/
public String getBatchNo() {
return batchNo;
}
/**
* 设置当前生效的批次
*
* @param batchNo 当前生效的批次
*/
public void setBatchNo(String batchNo) {
this.batchNo = batchNo == null ? null : batchNo.trim();
}
public List<SopInstNode> getNodes() {
return nodes;
}
public void setNodes(List<SopInstNode> nodes) {
this.nodes = nodes;
}
public List<SopInstLink> getLinks() {
return links;
}
public void setLinks(List<SopInstLink> links) {
this.links = links;
}
public List<SopTplGrant> getSopTplGrants() {
return sopTplGrants;
}
public void setSopTplGrants(List<SopTplGrant> sopTplGrants) {
this.sopTplGrants = sopTplGrants;
}
public SopTplGrant getSopTplGrant() {
return sopTplGrant;
}
public void setSopTplGrant(SopTplGrant sopTplGrant) {
this.sopTplGrant = sopTplGrant;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.model;
import cn.hutool.db.Page;
import javax.validation.constraints.NotEmpty;
import java.util.Date;
import java.util.List;
public class SopInstSearch extends Page {
/**
* 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
private String instId;
/**
* 实例分组:当前场景下,分组id就是门店id
*/
private Integer grantId;
/**
* 实例名
*/
private String instName;
/**
* cron表达式,sop执行周期
*/
private String instCron;
/**
* sop简介
*/
private String instRemark;
private Date createTime;
private Date updateTime;
/**
* 启用状态:0,未启用;1,启用;-1,已删除/过期;
*/
private List<Byte> instStatuses;
/**
* 实例默认输入参数
*/
private String instParam;
/**
* sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
private Date expireTime;
/**
* 当前生效的批次
*/
private String batchNo;
/**
* 分组id就是门店id
*/
@NotEmpty(message = "门店id不能为空!")
private String groupId;
/**
* 获取实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*
* @return inst_id - 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
public String getInstId() {
return instId;
}
/**
* 设置实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*
* @param instId 实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态
*/
public void setInstId(String instId) {
this.instId = instId == null ? null : instId.trim();
}
/**
* 获取实例分组:当前场景下,分组id就是门店id
*
* @return grant_id - 实例分组:当前场景下,分组id就是门店id
*/
public Integer getGrantId() {
return grantId;
}
/**
* 设置实例分组:当前场景下,分组id就是门店id
*
* @param grantId 实例分组:当前场景下,分组id就是门店id
*/
public void setGrantId(Integer grantId) {
this.grantId = grantId;
}
/**
* 获取实例名
*
* @return inst_name - 实例名
*/
public String getInstName() {
return instName;
}
/**
* 设置实例名
*
* @param instName 实例名
*/
public void setInstName(String instName) {
this.instName = instName == null ? null : instName.trim();
}
/**
* 获取cron表达式,sop执行周期
*
* @return inst_cron - cron表达式,sop执行周期
*/
public String getInstCron() {
return instCron;
}
/**
* 设置cron表达式,sop执行周期
*
* @param instCron cron表达式,sop执行周期
*/
public void setInstCron(String instCron) {
this.instCron = instCron == null ? null : instCron.trim();
}
/**
* 获取sop简介
*
* @return inst_remark - sop简介
*/
public String getInstRemark() {
return instRemark;
}
/**
* 设置sop简介
*
* @param instRemark sop简介
*/
public void setInstRemark(String instRemark) {
this.instRemark = instRemark == null ? null : instRemark.trim();
}
/**
* @return create_time
*/
public Date getCreateTime() {
return createTime;
}
/**
* @param createTime
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* @return update_time
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* @param updateTime
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public List<Byte> getInstStatuses() {
return instStatuses;
}
public void setInstStatuses(List<Byte> instStatuses) {
this.instStatuses = instStatuses;
}
public String getInstParam() {
return instParam;
}
public void setInstParam(String instParam) {
this.instParam = instParam;
}
/**
* 获取sop有效期,每个sop都设置一个有效期,到期自动停止。
*
* @return expire_time - sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
public Date getExpireTime() {
return expireTime;
}
/**
* 设置sop有效期,每个sop都设置一个有效期,到期自动停止。
*
* @param expireTime sop有效期,每个sop都设置一个有效期,到期自动停止。
*/
public void setExpireTime(Date expireTime) {
this.expireTime = expireTime;
}
/**
* 获取当前生效的批次
*
* @return batch_no - 当前生效的批次
*/
public String getBatchNo() {
return batchNo;
}
/**
* 设置当前生效的批次
*
* @param batchNo 当前生效的批次
*/
public void setBatchNo(String batchNo) {
this.batchNo = batchNo == null ? null : batchNo.trim();
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.model;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
/**
* 更新单个旅程客户数据数据体
*/
@Data
public class SopJourneyStageUpdate {
/**
* 组织ID/门店id/商户号
*/
@NotEmpty
private String orgId;
/**
* 客户旅程id
*/
@NotEmpty
private String sopJourneyId;
/**
* oneId
*/
@NotEmpty
private String oneId;
/**
* 目标客户旅程阶段
*/
@NotEmpty
private String sopJourneyStage;
/**
* 操作人/登陆的账号名称
*/
@NotEmpty
private String oprBy;
}
package cn.com.glsx.process.modules.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Sets;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.hutool.core.lang.Pair;
import lombok.Data;
@Data
public class SopStruct {
/** 模板,暂时不关注 */
// private SopTpl tpl;
/** 模板节点表,暂时不关注 */
// private Map<Integer, SopTplNode> tplNodeMap;
/** 模板节点连接关系: fromSet, toSet,暂时不关注 */
// private Map<Integer, Pair<Set<Integer>, Set<Integer>>> tplLinkMap;
/** 模板分配 */
// private SopTplGrant grant;
/** 模板实例 */
private SopInst inst;
/** 实例节点表 */
private Map<Integer, SopInstNode> instNodeMap;
/** 实例节点连接关系: fromSet, toSet */
private Map<Integer, Pair<Set<Integer>, Set<Integer>>> instLinkMap;
/** 实例当前批次 */
private SopInstBatch batch;
/** 实例节点当前批次 */
private SopInstNodeBatch nodeBatch;
/** 所有节点执行顺序 */
public List<Integer> getNodeSort() {
List<Integer> sort = new ArrayList<>();
Set<Integer> keys = Sets.newHashSet();
int i = 0;
while (keys.size() < instLinkMap.keySet().size()) {
Set<Integer> sets = instLinkMap.keySet();
for (Integer key : sets) {
i++;
Pair<Set<Integer>, Set<Integer>> pair = instLinkMap.get(key);
if (!keys.contains(key)) {
// 第一个节点:直接执行
if (pair.getKey().isEmpty()) {
keys.add(key);
sort.add(key);
continue;
}
// 非第一个节点:判断前置节点
if (keys.containsAll(pair.getKey())) {
keys.add(key);
sort.add(key);
continue;
}
} else {
// 进入后置节点
sets = pair.getValue();
continue;
}
}
if (i++ > 1000) {
throw new RuntimeException("Sop实例:【" + inst.getInstId() + "-" + inst.getInstName() + "】节点不闭环,请检查!");
}
}
return sort;
}
}
package cn.com.glsx.process.modules.model;
import cn.com.glsx.process.modules.entity.SopTplGrant;
import cn.com.glsx.process.modules.entity.SopTplLink;
import cn.com.glsx.process.modules.entity.SopTplNode;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SopTplDTO {
/**
* 模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位
*/
private String tplId;
/**
* 模板名
*/
private String tplName;
/**
* cron表达式,sop执行周期
*/
private String tplCron;
/**
* sop简介
*/
private String tplRemark;
/**
* 启用状态:0,禁用;1,启用;
*/
private Byte tplStatus;
/**
* JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*/
private String tplParamDef;
/**
* JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表
*/
private String tplResultDef;
/**
* 是否单实例模式:0,多实例;1,单实例;
*/
private Byte tplSingleton;
private Date createTime;
private Date updateTime;
/**
* 分发门店数
*/
private int grantCount;
/**
* sop任务节点
*/
private List<SopTplNode> nodes;
/**
* sop任务节点连接
*/
private List<SopTplLink> links;
/**
* 下发的门店列表(授权)
*/
private List<SopTplGrant> sopTplGrants;
public String getTplId() {
return tplId;
}
public void setTplId(String tplId) {
this.tplId = tplId;
}
public String getTplName() {
return tplName;
}
public void setTplName(String tplName) {
this.tplName = tplName;
}
public String getTplCron() {
return tplCron;
}
public void setTplCron(String tplCron) {
this.tplCron = tplCron;
}
public String getTplRemark() {
return tplRemark;
}
public void setTplRemark(String tplRemark) {
this.tplRemark = tplRemark;
}
public Byte getTplStatus() {
return tplStatus;
}
public void setTplStatus(Byte tplStatus) {
this.tplStatus = tplStatus;
}
public String getTplParamDef() {
return tplParamDef;
}
public void setTplParamDef(String tplParamDef) {
this.tplParamDef = tplParamDef;
}
public String getTplResultDef() {
return tplResultDef;
}
public void setTplResultDef(String tplResultDef) {
this.tplResultDef = tplResultDef;
}
public Byte getTplSingleton() {
return tplSingleton;
}
public void setTplSingleton(Byte tplSingleton) {
this.tplSingleton = tplSingleton;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public int getGrantCount() {
return grantCount;
}
public void setGrantCount(int grantCount) {
this.grantCount = grantCount;
}
public List<SopTplNode> getNodes() {
return nodes;
}
public void setNodes(List<SopTplNode> nodes) {
this.nodes = nodes;
}
public List<SopTplLink> getLinks() {
return links;
}
public void setLinks(List<SopTplLink> links) {
this.links = links;
}
public List<SopTplGrant> getSopTplGrants() {
return sopTplGrants;
}
public void setSopTplGrants(List<SopTplGrant> sopTplGrants) {
this.sopTplGrants = sopTplGrants;
}
}
package cn.com.glsx.process.modules.model;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.Date;
@Data
public class SopTplGrantSearch {
private Integer grantId;
/**
* 实例分组:当前场景下,分组id就是门店id
*/
private String groupId;
private String groupName;
/**
* 模板id
*/
@NotEmpty(message = "tplId参数不能为空!")
private String tplId;
private Date createTime;
private Date updateTime;
/**
* 授权状态:0,未启用;1,启用;-1,删除;
*/
private Byte grantStatus;
}
package cn.com.glsx.process.modules.model;
import cn.hutool.db.Page;
import lombok.Data;
@Data
public class SopTplSearch extends Page {
private String tplId;
private String tplName;
private Integer tplStatus;
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
* @ClassName: DatabaseTypeEnum
* @Description: TODO(支持的数据库)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午2:55:27
*/
public enum DatabaseTypeEnum {
MYSQL("MYSQL", "MYSQL", "com.mysql.jdbc.Driver"), ORACLE("ORACLE", "ORACLE", "oracle.jdbc.driver.OralceDriver"), MSSQL("MSSQL", "MSSQL",
"com.microsoft.sqlserver.jdbc.SQLServerDriver"), POSTGRESQL("POSTGRESQL", "POSTGRESQL", "org.postgresql.Driver");
private String name;
private String value;
private String driverClass;
private DatabaseTypeEnum(String name, String value, String driverClass) {
this.name = name;
this.value = value;
this.driverClass = driverClass;
}
public static DatabaseTypeEnum getDatabaseByName(String name) {
for (DatabaseTypeEnum c : DatabaseTypeEnum.values()) {
if (c.getName().equals(name)) {
return c;
}
}
return null;
}
public static String getValueByName(String name) {
for (DatabaseTypeEnum c : DatabaseTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (DatabaseTypeEnum c : DatabaseTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDriverClass() {
return driverClass;
}
public void setDriverClass(String driverClass) {
this.driverClass = driverClass;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: EletypeEnum
* @Description: TODO(所有流程控件)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午3:35:56
*
*/
public enum EletypeEnum {
// START("开始控件", "start", (new FlowStart()).getClass()), DATA("data控件", "data", (new FlowData()).getClass()),
// JSON("json控件", "json", (new FlowJson()).getClass()), GIT("git控件", "git", (new FlowGit()).getClass()),
// SFTP("sftp控件", "sftp", (new FlowSftp()).getClass()), TEXT("文本控件", "text", (new FlowText()).getClass()),
// SCRIPT("js脚本控件", "script", (new FlowScript()).getClass()), JAVA("java控件", "java", (new FlowJava()).getClass()),
// PYTHON("python控件", "python", (new FlowPython()).getClass()), LINUX("linux控件", "linux", (new FlowLinux()).getClass()),
// WONTON("混沌控件", "wonton", (new FlowWonton()).getClass()), SQLQUERY("sql查询控件", "sqlQuery", (new FlowSqlQuery()).getClass()),
// SQLEXECUTE("sql执行控件", "sqlExecute", (new FlowSqlExecute()).getClass()), LOOP("循环", "loop", (new FlowLoop()).getClass()),
// PROCESS("子流程", "process", (new FlowProcess()).getClass()), END("结束控件", "end", (new FlowEnd()).getClass()),
// DEMO("示例控件", "demo", (new FlowDemo()).getClass());
;
private String name;
private String value;
private Class<?> classes;
private EletypeEnum(String name, String value, Class<?> classes) {
this.name = name;
this.value = value;
this.classes = classes;
}
public static String getValueByName(String name) {
for (EletypeEnum c : EletypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (EletypeEnum c : EletypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public static Class<?> getClassByValue(String value) {
for (EletypeEnum c : EletypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.classes;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Class<?> getClasses() {
return classes;
}
public void setClasses(Class<?> classes) {
this.classes = classes;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum FlowGitModeEnum {
HTTP("HTTP方式", "http");
private String name;
private String value;
private FlowGitModeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (FlowGitModeEnum c : FlowGitModeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (FlowGitModeEnum c : FlowGitModeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum FlowLinuxConnModeEnum {
DEPENDENCY("关联服务器数据源", "dependency"), ASSIGN("指定连接参数", "assign");
private String name;
private String value;
private FlowLinuxConnModeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (FlowLinuxConnModeEnum c : FlowLinuxConnModeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (FlowLinuxConnModeEnum c : FlowLinuxConnModeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum FlowLoopTypeEnum {
COUNT("指定次数", "count"), EXPRES("条件表达式", "expres");
private String name;
private String value;
private FlowLoopTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (FlowLoopTypeEnum c : FlowLoopTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (FlowLoopTypeEnum c : FlowLoopTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum FlowTextOutModeEnum {
OVERRIDE("覆盖", "override"), APPEND("追加", "append");
private String name;
private String value;
private FlowTextOutModeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (FlowTextOutModeEnum c : FlowTextOutModeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (FlowTextOutModeEnum c : FlowTextOutModeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum FlowVarTypeEnum {
SYSTEM("系统类型", "system"), FLOW("流程类型", "flow");
private String name;
private String value;
private FlowVarTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (FlowVarTypeEnum c : FlowVarTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (FlowVarTypeEnum c : FlowVarTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: EletypeEnum
* @Description: TODO(所有流程控件)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午3:35:56
*
*/
public enum LogOutTypeEnum {
PARAM("参数", "param"), NORMAL("普通", "normal"), RESULT("运行值", "result"), TEXT("text", "text"), SSH("shell", "ssh");
private String name;
private String value;
private LogOutTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (LogOutTypeEnum c : LogOutTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (LogOutTypeEnum c : LogOutTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: LogTypeEnum
* @Description: TODO(工作台功能,控件台输出的日志类型)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午3:38:41
*
*/
public enum LogTypeEnum {
INFO("信息", "info"), ERROR("错误信息", "error"), SUCCESS("成功信息", "success");
/* 类型描述 */
private String name;
/* bootstrap-alert组件的样式类名和Message组件log类的方法名 */
private String value;
private LogTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (LogTypeEnum c : LogTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (LogTypeEnum c : LogTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: WsshCommandEnum
* @Description: TODO(mcg webSocket 指令)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2020年6月14日 下午20:24:45
*
*/
public enum McgWsOperationEnum {
INIT("初始化", "init");
private String name;
private String value;
private McgWsOperationEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (McgWsOperationEnum c : McgWsOperationEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (McgWsOperationEnum c : McgWsOperationEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: MessageTypeEnum
* @Description: TODO(消息类型,前端可根据类型进行展现)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午3:44:07
*
*/
public enum MessageTypeEnum {
SYSTEM("系统消息", "system"), FLOW("流程消息", "flow"), NOTIFY("通知", "notify"), WONTON("混沌工程", "notify");
private String name;
private String value;
private MessageTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (MessageTypeEnum c : MessageTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (MessageTypeEnum c : MessageTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: SeverTypeEnum
* @Description: TODO(支持的服务器操作系统)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年7月29日 下午12:52:20
*
*/
public enum SeverTypeEnum {
LINUX("LINUX", "LINUX", "linux系统"), UNIX("UNIX", "UNIX", "unxi系统");
private String name;
private String value;
private String desc;
private SeverTypeEnum(String name, String value, String desc) {
this.name = name;
this.value = value;
this.desc = desc;
}
public static SeverTypeEnum getSeverTypeByName(String name) {
for (SeverTypeEnum c : SeverTypeEnum.values()) {
if (c.getName().equals(name)) {
return c;
}
}
return null;
}
public static String getValueByName(String name) {
for (SeverTypeEnum c : SeverTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (SeverTypeEnum c : SeverTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum SftpOperationTypeEnum {
UPLOAD("上传", "upload"), DOWNLOAD("下载", "download") ;
private String name;
private String value;
private SftpOperationTypeEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (SftpOperationTypeEnum c : SftpOperationTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (SftpOperationTypeEnum c : SftpOperationTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopInstNodeSkipEnum {
FALSE("不跳过节点", (byte)0), TRUE("跳过节点", (byte)1);
private String name;
private byte value;
SopInstNodeSkipEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopInstNodeStatusEnum {
DELETED("停用", 0), NORMAL("启用", 1);
private String name;
private int value;
SopInstNodeStatusEnum(String name, int value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopInstStatusEnum {
DELETED("已删除", (byte)-1), UNUSED("未启用", (byte)0), NORMAL("启用", (byte)1);
private String name;
private Byte value;
private SopInstStatusEnum(String name, Byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Byte getValue() {
return value;
}
public void setValue(Byte value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopTplNodeSkipableEnum {
NO("不可跳过节点", (byte)0), YES("可跳过节点", (byte)1);
private String name;
private byte value;
SopTplNodeSkipableEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopTplSingletonEnum {
FALSE("多实例", (byte)0), TRUE("单实例", (byte)1);
private String name;
private byte value;
SopTplSingletonEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
public enum WontonStateEnum {
NORMAL("正常", "normal"), LOSED("失联", "losed");
private String name;
private String value;
private WontonStateEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (WontonStateEnum c : WontonStateEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (WontonStateEnum c : WontonStateEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.model.enums;
/**
*
* @ClassName: WsshCommandEnum
* @Description: TODO(web ssh 指令)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2020年6月14日 下午12:00:01
*
*/
public enum WsshOperationEnum {
INIT("初始化", "init"), SHELL("shell", "shell");
private String name;
private String value;
private WsshOperationEnum(String name, String value) {
this.name = name;
this.value = value;
}
public static String getValueByName(String name) {
for (WsshOperationEnum c : WsshOperationEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (WsshOperationEnum c : WsshOperationEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.24/lombok-1.18.24.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/mapstruct/mapstruct-processor/1.5.2.Final/mapstruct-processor-1.5.2.Final.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
...@@ -30,6 +30,12 @@ ...@@ -30,6 +30,12 @@
<dependency> <dependency>
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>rest-admin-dubbo</artifactId> <artifactId>rest-admin-dubbo</artifactId>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- local api --> <!-- local api -->
...@@ -50,9 +56,118 @@ ...@@ -50,9 +56,118 @@
<artifactId>rpc-scrm-proxy-api</artifactId> <artifactId>rpc-scrm-proxy-api</artifactId>
<version>3.7.0-SNAPSHOT</version> <version>3.7.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.0.1-atlassian-hosted</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>com.github.kuhn-he</groupId>
<artifactId>elastic-job-lite-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
<!-- xxl-job依赖,maven仓库有该依赖,不需要手动安装 -->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.6.11</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<!-- cdp 接口依赖 -->
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>platform-cdp-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--rabbitmq-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-office</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
...@@ -82,6 +197,7 @@ ...@@ -82,6 +197,7 @@
<skip>true</skip> <skip>true</skip>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
package cn.com.glsx; package cn.com.glsx;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import com.glsx.plat.context.EnableRestAdmin; import com.glsx.plat.context.EnableRestAdmin;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.TimeZone; import java.util.TimeZone;
...@@ -19,17 +24,25 @@ import static java.util.TimeZone.getTimeZone; ...@@ -19,17 +24,25 @@ import static java.util.TimeZone.getTimeZone;
@EnableDubbo @EnableDubbo
@EnableRestAdmin @EnableRestAdmin
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.com.glsx.*.api"}) @EnableFeignClients(basePackages = { "cn.com.glsx.*.api"})
@SpringBootApplication @SpringBootApplication
public class Application { @EnableAspectJAutoProxy
@EnableTransactionManagement
public class Application implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@PostConstruct @PostConstruct
void started() { void started() {
TimeZone.setDefault(getTimeZone(of("Asia/Shanghai"))); TimeZone.setDefault(getTimeZone(of("Asia/Shanghai")));
} }
@Override
public void run(String... args) throws Exception {
SopXxlJobUtil.initLoadJob();
}
} }
package cn.com.glsx.process.common.constant; package cn.com.glsx.process.common.constant;
import java.nio.charset.Charset;
import com.glsx.plat.core.constant.BasicConstants; import com.glsx.plat.core.constant.BasicConstants;
/** /**
...@@ -13,4 +15,15 @@ public final class Constants extends BasicConstants { ...@@ -13,4 +15,15 @@ public final class Constants extends BasicConstants {
public final static String SERVER_NAME = "glsx_rest_admin"; public final static String SERVER_NAME = "glsx_rest_admin";
public static final Charset CHARSET = Charset.forName("utf-8");
public static final String RES_SUCCESS = "SUCCESS";
public static final String RES_KEY = "code";
public static final String RES_DATE_KEY = "data";
public static final String RES_FAIL = "FAIL";
public static final String RES_FAIL_MESSAGE = "FAIL_MESSAGE";
} }
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.common.sysenum;
/**
*
* @ClassName: DatabaseTypeEnum
* @Description: TODO(支持的数据库)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午2:55:27
*
*/
public enum DatabaseTypeEnum {
MYSQL("MYSQL", "MYSQL", "com.mysql.jdbc.Driver"), ORACLE("ORACLE", "ORACLE", "oracle.jdbc.driver.OralceDriver"), MSSQL("MSSQL", "MSSQL", "com.microsoft.sqlserver.jdbc.SQLServerDriver"), POSTGRESQL("POSTGRESQL", "POSTGRESQL", "org.postgresql.Driver");
private String name;
private String value;
private String driverClass;
private DatabaseTypeEnum(String name, String value, String driverClass) {
this.name = name;
this.value = value;
this.driverClass = driverClass;
}
public static DatabaseTypeEnum getDatabaseByName(String name) {
for (DatabaseTypeEnum c : DatabaseTypeEnum.values()) {
if (c.getName().equals(name)) {
return c;
}
}
return null;
}
public static String getValueByName(String name) {
for (DatabaseTypeEnum c : DatabaseTypeEnum.values()) {
if (c.getName().equals(name)) {
return c.value;
}
}
return null;
}
public static String getNameByValue(String value) {
for (DatabaseTypeEnum c : DatabaseTypeEnum.values()) {
if (c.getValue().equals(value)) {
return c.name;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDriverClass() {
return driverClass;
}
public void setDriverClass(String driverClass) {
this.driverClass = driverClass;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.common.sysenum;
import com.glsx.plat.exception.SystemMessage;
/**
* 试驾服务错误码
*
* @author zhouhaibao
*/
public enum ResultEnum {
PARAM_ERROR(1001, "参数错误"),
FEIGN_REQUEST_ERROR(1002, "feign请求异常"),
DATA_HANDLE_ERROR(1003, "数据处理异常");
private final Integer code;
private final String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
ResultEnum(SystemMessage systemMessage) {
this.code = systemMessage.getCode();
this.message = systemMessage.getMsg();
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}
package cn.com.glsx.process.config; package cn.com.glsx.process.config;
import com.glsx.plat.context.properties.UploadProperties; import javax.annotation.Resource;
import com.glsx.plat.jwt.base.ComJwtUser;
import com.glsx.plat.web.interceptor.LogInterceptor;
import com.glsx.plat.web.interceptor.VisitInterceptor;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource; import com.glsx.plat.context.properties.UploadProperties;
import com.glsx.plat.jwt.base.ComJwtUser;
import com.glsx.plat.web.interceptor.LogInterceptor;
import com.glsx.plat.web.interceptor.VisitInterceptor;
/** /**
* @author liuyf * @author liuyf
...@@ -46,6 +47,7 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -46,6 +47,7 @@ public class WebConfig implements WebMvcConfigurer {
.addResourceLocations("classpath:/META-INF/resources/") .addResourceLocations("classpath:/META-INF/resources/")
.addResourceLocations("classpath:/resources/") .addResourceLocations("classpath:/resources/")
.addResourceLocations("classpath:/static/") .addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/templates/")
.addResourceLocations("classpath:/public/") .addResourceLocations("classpath:/public/")
.addResourceLocations("/dist/"); .addResourceLocations("/dist/");
//本地文件 //本地文件
...@@ -59,14 +61,16 @@ public class WebConfig implements WebMvcConfigurer { ...@@ -59,14 +61,16 @@ public class WebConfig implements WebMvcConfigurer {
//1.加入的顺序就是拦截器执行的顺序, //1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle //2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle //3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry.addInterceptor(visitInterceptor) //4.sop登录不拦截 TODO 所有请求暂时不校验登录
.addPathPatterns("/**") // registry.addInterceptor(visitInterceptor)
.excludePathPatterns("/") // .addPathPatterns("/**")
.excludePathPatterns("/login") // .excludePathPatterns("/")
.excludePathPatterns("/actuator/**") // .excludePathPatterns("/login")
.excludePathPatterns("/api/**") // .excludePathPatterns("/actuator/**")
.excludePathPatterns(uploadProperties.getFilepath()) // .excludePathPatterns("/api/**")
.excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html"); // .excludePathPatterns("/sop/**")
// .excludePathPatterns(uploadProperties.getFilepath())
// .excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html");
registry.addInterceptor(logInterceptor).addPathPatterns("/**"); registry.addInterceptor(logInterceptor).addPathPatterns("/**");
} }
......
package cn.com.glsx.process.exception;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import com.glsx.plat.exception.SystemMessage;
import lombok.Getter;
import lombok.Setter;
/**
* @author payu
*/
@Setter
@Getter
public class AdminException extends RuntimeException {
private int errorCode;
private String message;
public AdminException() {
}
public AdminException(String message) {
super(message);
this.errorCode = SystemMessage.FAILURE.getCode();
this.message = message;
}
public AdminException(int errorCode, String message) {
super(message);
this.errorCode = errorCode;
this.message = message;
}
public AdminException(ResultEnum resultEnum) {
this.errorCode = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public AdminException(Throwable cause) {
super(cause);
}
public AdminException(String message, Throwable cause) {
super(message, cause);
}
}
package cn.com.glsx.process.exception;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.glsx.plat.core.web.R;
import com.glsx.plat.exception.ExceptionLevel;
import com.glsx.plat.exception.GlobalRExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.BindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局异常处理
*
* @author payu
*/
@Slf4j
@RestControllerAdvice
public class AdminExceptionHandler extends GlobalRExceptionHandler {
@ExceptionHandler(AdminException.class)
public R handleAdminException(AdminException e) {
return R.error(e.getErrorCode(),e.getMessage());
}
/**
* Mybatis BindingException
*
* @param e
* @return
*/
@ExceptionHandler(BindingException.class)
public R handleBindingException(BindingException e) {
return R.error(e.getMessage());
}
@ExceptionHandler(ExcelDataConvertException.class)
public R handleExcelDataConvertException(ExcelDataConvertException e) {
return R.error(e.getMessage());
}
@Override
protected void saveException(Exception e, ExceptionLevel level) {
super.saveException(e, level);
}
}
package cn.com.glsx.process.job.elastic;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
@Configuration
public class DynamicConfig {
@Value("${elaticjob.zookeeper.dynamiczk}")
private String dynamiczk;
@Value("${elaticjob.zookeeper.namespace}")
private String dynamicnamespace;
@Bean
public ZookeeperConfiguration zookeeperConfiguration() {
return new ZookeeperConfiguration(dynamiczk, dynamicnamespace);
}
@Bean(initMethod = "init")
public ZookeeperRegistryCenter zookeeperRegistryCenter(ZookeeperConfiguration zookeeperConfiguration) {
return new ZookeeperRegistryCenter(zookeeperConfiguration);
}
@Bean
public ElasticJobListener elasticJobListener() {
return new ElasticJobListener(100, 100);
}
}
package cn.com.glsx.process.job.elastic;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
import com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.lite.internal.schedule.JobRegistry;
import com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController;
import com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;
import cn.com.glsx.process.modules.entity.JobManager;
import cn.com.glsx.process.modules.mapper.JobManagerMapper;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class DynamicTaskService {
@Autowired
private ZookeeperRegistryCenter zookeeperRegistryCenter;
@Resource
private ElasticJobListener elasticJobListener;
@Autowired
private JobManagerMapper jobManagerMapper;
private static LiteJobConfiguration.Builder simpleJobConfigBuilder(String jobName, Class<? extends SimpleJob> jobClass, int shardTotalCount,
String cron, String description, String param) {
return LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(
JobCoreConfiguration.newBuilder(jobName, cron, shardTotalCount).jobParameter(param).description(description).build(),
jobClass.getCanonicalName()));
}
/***
* 动态创建定时任务
*
* @param jobName:定时任务名称
* @param cron:表达式
* @param shardingTotalCount:分片数量
* @param instance:定时任务实例
* @param parameters:参数
*/
public void create(String jobName, String cron, int shardingTotalCount, SimpleJob instance, String description, String param) {
LiteJobConfiguration jobConfig = simpleJobConfigBuilder(jobName, instance.getClass(), shardingTotalCount, cron, description, param)
.overwrite(true).build();
new SpringJobScheduler(instance, zookeeperRegistryCenter, jobConfig, elasticJobListener).init();
log.info("【动态任务】{},创建:cron:{}, job:{}", jobName, cron, instance.getClass().getSimpleName());
}
/**
* 更新定时任务
*
* @param jobName
* @param cron
*/
public void updateJob(String jobName, String cron) {
JobScheduleController schedule = JobRegistry.getInstance().getJobScheduleController(jobName);
if (schedule == null) {
log.info("【动态任务】{},更新:cron:{},任务不存在!", jobName, cron);
} else {
schedule.rescheduleJob(cron);
log.info("【动态任务】{},更新:cron:{},成功!", jobName, cron);
}
}
/**
* 删除定时任务
*
* @param jobName
*/
public void removeJob(String jobName) {
JobScheduleController schedule = JobRegistry.getInstance().getJobScheduleController(jobName);
if (schedule == null) {
log.info("【动态任务】{},删除:任务不存在!", jobName);
} else {
schedule.shutdown();
log.info("【动态任务】{},删除:成功!", jobName);
}
}
/**
* 停止定时任务
*
* @param jobName
*/
public void stopJob(String jobName) {
JobScheduleController schedule = JobRegistry.getInstance().getJobScheduleController(jobName);
if (schedule == null) {
log.info("【动态任务】{},暂停:任务不存在!", jobName);
} else {
schedule.pauseJob();
log.info("【动态任务】{},暂停:成功!", jobName);
}
}
public boolean isJobStoped(String jobName) {
JobScheduleController schedule = JobRegistry.getInstance().getJobScheduleController(jobName);
if (schedule == null) {
log.info("【动态任务】{},状态:任务不存在!", jobName);
return true;
} else {
log.info("【动态任务】{},状态:{}!", jobName, schedule.isPaused());
return schedule.isPaused();
}
}
/**
* 扫描搜索下线的服务
*/
public void scanAddJob() {
List<JobManager> jobManagers = jobManagerMapper.selectAll();
if (CollectionUtils.isNotEmpty(jobManagers)) {
for (JobManager jobManager : jobManagers) {
String className = jobManager.getClassName();
try {
Class<?> aClass = Class.forName(className);
create(jobManager.getJobName(), jobManager.getCron(), jobManager.getShareTotalCount(), (SimpleJob) aClass.newInstance(), "",
jobManager.getParameters());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
}
}
package cn.com.glsx.process.job.elastic;
import com.dangdang.ddframe.job.executor.ShardingContexts;
import com.dangdang.ddframe.job.lite.api.listener.AbstractDistributeOnceElasticJobListener;
public class ElasticJobListener extends AbstractDistributeOnceElasticJobListener {
public ElasticJobListener(long startedTimeoutMilliseconds, long completedTimeoutMilliseconds) {
super(startedTimeoutMilliseconds,completedTimeoutMilliseconds);
}
@Override
public void doBeforeJobExecutedAtLastStarted(ShardingContexts shardingContexts) {
}
@Override
public void doAfterJobExecutedAtLastCompleted(ShardingContexts shardingContexts) {
}
}
package cn.com.glsx.process.job.elastic.impl;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
public class DynamicJob implements SimpleJob {
@Override
public void execute(ShardingContext shardingContext) {
// 参数
String JobParameter = shardingContext.getJobParameter();
System.out.println("---------DynamicJob-------------:" + JobParameter);
}
}
/*
package cn.com.glsx.process.job.elastic.impl;
import java.util.Date;
import java.util.Set;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.glsx.plat.context.utils.SpringUtils;
import cn.com.glsx.process.job.DynamicTaskService;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
*/
/**
* 各实例启动执行,创建批次号,按各节点生成动态任务。
*
* @author kome
* @date 2023年9月11日 下午2:34:52
*//*
@Slf4j
public class SopInstExecuteJob implements SimpleJob {
@Override
public void execute(ShardingContext shardingContext) {
// 参数
String instId = shardingContext.getJobParameter();
log.info("---------SopInstExecuteJob------------- instId:{}", instId);
SopService sopService = SpringUtils.getBean(SopService.class);
DynamicTaskService taskService = SpringUtils.getBean(DynamicTaskService.class);
SopStruct sop = sopService.loadSop(instId);
if (taskService.isJobStoped(SopInstLoadJob.jobName(sop.getInst()))) {
// TODO 停止sop所有子任务
return;
}
// TODO 创建所有节点任务
for (SopInstNode node : sop.getInstNodeMap().values()) {
// 前置节点,后置节点
Pair<Set<Integer>, Set<Integer>> linkPair = sop.getInstLinkMap().get(node.getNodeId());
boolean enabled = linkPair == null || linkPair.getKey().isEmpty();
SopInstNodeParam param = new SopInstNodeParam();
param.setInstNodeId(node.getInstNodeId());
param.setPreIds(linkPair.getKey());
String paramJson = JSONUtil.toJsonStr(param);
if (StrUtil.isNotBlank(node.getNodeCron())) {
// 按cron表达式执行
// taskService.create(SopInstLoadJob.jobName(sop.getInst(), node), node.getNodeCron(), new SopInstNodeJob(),
// sop.getInst().getInstName() + "-" + node.getNodeName(), paramJson, enabled);
} else {
//
// 立即执行: 1分钟后执行: 11 12 8 2 3 ? 2024
String cron = DateUtil.format(org.apache.commons.lang.time.DateUtils.addMinutes(new Date(), 1), "s m H d M ? yyyy");
// taskService.create(SopInstLoadJob.jobName(sop.getInst(), node), cron, new SopInstNodeJob(),
// sop.getInst().getInstName() + "-" + node.getNodeName(), paramJson, enabled);
}
}
}
}
*/
/*
package cn.com.glsx.process.job.elastic.impl;
import java.util.List;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.glsx.plat.context.utils.SpringUtils;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.service.SopService;
import lombok.extern.slf4j.Slf4j;
*/
/**
* 定时从db加载sop实例,并判断是否加入动态任务
*
* @author kome
* @date 2023年9月11日 下午2:34:52
*//*
@Slf4j
public class SopInstLoadJob implements SimpleJob {
@Override
public void execute(ShardingContext shardingContext) {
// 参数
String JobParameter = shardingContext.getJobParameter();
log.info("---------SopInstLoadJob-------------:" + JobParameter);
SopService sopService = SpringUtils.getBean(SopService.class);
// DynamicTaskService taskService = SpringUtils.getBean(DynamicTaskService.class);
List<SopInst> all = sopService.loadAllInst();
for (SopInst inst : all) {
if (inst.getInstStatus() == 1) {
// taskService.create(jobName(inst), inst.getInstCron(), 1, new SopInstExecuteJob(), inst.getInstName(), inst.getInstId());
} else {
// taskService.stopJob(inst.getInstName());
}
}
}
public static String jobName(SopInst inst) {
return inst.getInstId();
}
public static String jobName(SopInst inst, SopInstNode node) {
return inst.getInstId() + "-" + node.getNodeId();
}
}
*/
/*
package cn.com.glsx.process.job.elastic.impl;
import java.util.Date;
import java.util.Set;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.glsx.plat.context.utils.SpringUtils;
import cn.com.glsx.process.job.DynamicTaskService;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
*/
/**
* 各实例启动执行,创建批次号,按各节点生成动态任务。
*
* @author kome
* @date 2023年9月11日 下午2:34:52
*//*
@Slf4j
public class SopInstNodeJob implements SimpleJob {
@Override
public void execute(ShardingContext shardingContext) {
// 参数
String json = shardingContext.getJobParameter();
SopInstNodeParam param = JSONUtil.toBean(json, SopInstNodeParam.class);
log.info("---------SopInstNodeJob------------- param:{}", json);
SopService sopService = SpringUtils.getBean(SopService.class);
DynamicTaskService taskService = SpringUtils.getBean(DynamicTaskService.class);
SopStruct sop = sopService.loadSopByInstNodeId(param.getInstNodeId());
if (taskService.isJobStoped(SopInstLoadJob.jobName(sop.getInst()))) {
// TODO 停止sop所有子任务
return;
}
SopInstNode node = sop.getInstNodeMap().get(param.getInstNodeId());
handleNode(node);
triggerNext(sop, node, param);
}
public void triggerNext(SopStruct sop, SopInstNode node, SopInstNodeParam param) {
// 前置节点,后置节点
Pair<Set<Integer>, Set<Integer>> linkPair = sop.getInstLinkMap().get(node.getNodeId());
// TODO 加载后置节点对应的任务列表
boolean enabled = linkPair == null || linkPair.getKey().isEmpty();
param.setInstNodeId(node.getInstNodeId());
param.setPreIds(linkPair.getKey());
String paramJson = JSONUtil.toJsonStr(param);
String cron = DateUtil.format(org.apache.commons.lang.time.DateUtils.addMinutes(new Date(), 1), "s m H d M ? yyyy");
cron = StrUtil.isBlank(node.getNodeCron()) ? cron : node.getNodeCron();
DynamicTaskService taskService = SpringUtils.getBean(DynamicTaskService.class);
// 按cron表达式执行
// taskService.create(SopInstLoadJob.jobName(sop.getInst(), node), node.getNodeCron(), new SopInstNodeJob(),
// sop.getInst().getInstName() + "-" + node.getNodeName(), paramJson, enabled);
}
// 执行本节点
public void handleNode(SopInstNode node) {
}
}
*/
package cn.com.glsx.process.job.xxljob.core;
import cn.com.glsx.process.util.I18nUtil;
public enum ExecutorRouteStrategyEnum {
FIRST(I18nUtil.getString("jobconf_route_first")),
LAST(I18nUtil.getString("jobconf_route_last")),
ROUND(I18nUtil.getString("jobconf_route_round")),
RANDOM(I18nUtil.getString("jobconf_route_random")),
CONSISTENT_HASH(I18nUtil.getString("jobconf_route_consistenthash")),
LEAST_FREQUENTLY_USED(I18nUtil.getString("jobconf_route_lfu")),
LEAST_RECENTLY_USED(I18nUtil.getString("jobconf_route_lru")),
FAILOVER(I18nUtil.getString("jobconf_route_failover")),
BUSYOVER(I18nUtil.getString("jobconf_route_busyover")),
SHARDING_BROADCAST(I18nUtil.getString("jobconf_route_shard"));
ExecutorRouteStrategyEnum(String title) {
this.title = title;
}
private String title;
public String getTitle() {
return title;
}
public static ExecutorRouteStrategyEnum match(String name, ExecutorRouteStrategyEnum defaultItem){
if (name != null) {
for (ExecutorRouteStrategyEnum item: ExecutorRouteStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
}
return defaultItem;
}
}
package cn.com.glsx.process.job.xxljob.core;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
/**
* xxl-job config
*
* @author yazb
*/
@Configuration
public class FrameLessXxlJobConfig {
private Logger logger = LoggerFactory.getLogger(FrameLessXxlJobConfig.class);
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.appname}")
private String appname;
@Value("${xxl.job.executor.address}")
private String address;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean
public XxlJobSpringExecutor xxlJobExecutor() {
logger.info(">>>>>>>>>>> xxl-job config init. accessToken:{}", accessToken);
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppname(appname);
xxlJobSpringExecutor.setAddress(address);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
/**
* 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
* 1、引入依赖:
* <dependency>
* <groupId>org.springframework.cloud</groupId>
* <artifactId>spring-cloud-commons</artifactId>
* <version>${version}</version>
* </dependency>
* 2、配置文件,或者容器启动变量
* spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
* 3、获取IP
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
*/
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.job.xxljob.core;
import cn.com.glsx.process.util.I18nUtil;
/**
* @author xuxueli 2020-10-29 21:11:23
*/
public enum MisfireStrategyEnum {
/**
* do nothing
*/
DO_NOTHING(I18nUtil.getString("misfire_strategy_do_nothing")),
/**
* fire once now
*/
FIRE_ONCE_NOW(I18nUtil.getString("misfire_strategy_fire_once_now"));
private String title;
MisfireStrategyEnum(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public static MisfireStrategyEnum match(String name, MisfireStrategyEnum defaultItem){
for (MisfireStrategyEnum item: MisfireStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
return defaultItem;
}
}
package cn.com.glsx.process.job.xxljob.core;
import cn.com.glsx.process.util.I18nUtil;
/**
* @author xuxueli 2020-10-29 21:11:23
*/
public enum ScheduleTypeEnum {
NONE(I18nUtil.getString("schedule_type_none")),
/**
* schedule by cron
*/
CRON(I18nUtil.getString("schedule_type_cron")),
/**
* schedule by fixed rate (in seconds)
*/
FIX_RATE(I18nUtil.getString("schedule_type_fix_rate")),
/**
* schedule by fix delay (in seconds), after the last time
*/
/*FIX_DELAY(I18nUtil.getString("schedule_type_fix_delay"))*/;
private String title;
ScheduleTypeEnum(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public static ScheduleTypeEnum match(String name, ScheduleTypeEnum defaultItem){
for (ScheduleTypeEnum item: ScheduleTypeEnum.values()) {
if (item.name().equals(name)) {
return item;
}
}
return defaultItem;
}
}
package cn.com.glsx.process.job.xxljob.core;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import com.google.common.collect.Lists;
import com.xxl.job.core.context.XxlJobHelper;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SopXxlJobUtil {
public static final String SOP_LOAD_JOB_ID = "sopInstLoadJobHandler";
public static final String SOP_EXECUTE_JOB_ID = "sopInstExecuteJobHandler";
public static final String SOP_NODE_EXECUTE_JOB_ID = "sopNodeExecuteJobHandler";
public static void pauseSop(SopStruct sop) {
if (sop == null || sop.getInstNodeMap() == null) {
return;
}
String jobBusId = jobBusId(sop.getInst());
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
if (job == null) {
SopXxlJobUtil.log(log, "【{}】Sop任务不存在:{}", jobBusId, sop.getInst().getInstName());
} else if (job.getTriggerStatus() != 1) {
SopXxlJobUtil.log(log, "【{}】Sop任务已停止:{}", jobBusId, sop.getInst().getInstName());
} else {
String pause = XxlJobUtil.pause(jobBusId);
SopXxlJobUtil.log(log, "【{}】Sop任务停止:{} - {}", jobBusId, pause, sop.getInst().getInstName());
}
// 遍历node,停止任务
for (SopInstNode node : sop.getInstNodeMap().values()) {
pauseSopNode(sop, node);
}
}
public static void pauseSopNode(SopStruct sop, SopInstNode node) {
String jobBusId = jobBusId(sop.getInst(), node);
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
if (job != null && job.getTriggerStatus() == 1) {
String pause = XxlJobUtil.pause(jobBusId);
SopXxlJobUtil.log(log, "【{}】Sop任务节点停止:{} {}", jobBusId, job.getJobDesc(), pause);
}
}
public static void initLoadJob() {
XxlJobInfo job = XxlJobUtil.findByBusKey(SOP_LOAD_JOB_ID);
boolean exists = job != null;
if (job == null) {
job = new XxlJobInfo();
}
job.setJobDesc("加载所有SOP实例任务");
job.setScheduleConf("10 0 */2 * * ?");
job.setExecutorHandler(SOP_LOAD_JOB_ID);
job.setBusKey(SOP_LOAD_JOB_ID);
job.setTriggerStatus(1);
if (exists) {
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】任务更新,cron:{},result:{}", SOP_LOAD_JOB_ID, job.getScheduleConf(), update);
} else {
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】任务启动,cron:{},result:{}", SOP_LOAD_JOB_ID, job.getScheduleConf(), add);
}
}
public static void initSopJob(SopInst inst) {
String jobBusId = jobBusId(inst);
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
boolean exists = job != null;
if (job == null) {
job = new XxlJobInfo();
}
// 重建job
job.setExecutorParam(inst.getInstId());
job.setJobDesc(inst.getInstName());
job.setAuthor("admin");
job.setScheduleConf(inst.getInstCron());
job.setExecutorHandler(SopXxlJobUtil.SOP_EXECUTE_JOB_ID);
job.setBusKey(jobBusId);
job.setTriggerStatus(1);
if (exists) {
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】Sop任务更新,cron:{},result:{}", jobBusId, job.getScheduleConf(), update);
} else {
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】Sop任务启动,cron:{},result:{}", jobBusId, job.getScheduleConf(), add);
}
}
public static void initSopNodesJob(SopStruct sop) {
if (sop == null) {
return;
}
if (sop.getInst().getInstStatus() != 1) {
pauseSop(sop);
return;
}
int i = 0;
for (Integer nodeId : sop.getNodeSort()) {
SopInstNode node = sop.getInstNodeMap().get(nodeId);
if (node.getDailyExpire() != null && node.getDailyExpire().before(new Date())) {
node.setNodeStatus(-1);
continue;
}
initSopNodeJob(sop, node, i++);
}
}
public static void initSopNodeJob(SopStruct sop, SopInstNode node, int i) {
String jobBusId = jobBusId(sop.getInst(), node);
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
boolean exists = job != null;
if (job == null) {
job = new XxlJobInfo();
}
// 15 2/3 * * * ?
String cron = DateUtil.format(org.apache.commons.lang.time.DateUtils.addSeconds(new Date(), 20 + i * 6), "s m H d M ?");
if (StrUtil.isNotBlank(node.getNodeCron())) {
cron = node.getNodeCron();
}
// 前置节点,后置节点
Pair<Set<Integer>, Set<Integer>> linkPair = sop.getInstLinkMap().get(node.getNodeId());
SopInstNodeParam params = new SopInstNodeParam();
params.setInstId(node.getInstId());
params.setNodeId(node.getNodeId());
params.setPreIds(linkPair.getKey());
params.setNextIds(linkPair.getValue());
String paramJson = JSONUtil.toJsonStr(params);
// 重建job
job.setExecutorParam(paramJson);
job.setJobDesc(sop.getInst().getInstName() + "-" + node.getNodeName());
job.setAuthor("admin");
job.setScheduleConf(cron);
job.setExecutorHandler(SopXxlJobUtil.SOP_NODE_EXECUTE_JOB_ID);
job.setBusKey(jobBusId);
job.setTriggerStatus(1);
job.setExecutorRouteStrategy("RANDOM");
if (exists) {
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】Sop任务节点更新,cron:{},result:{}", jobBusId, job.getScheduleConf(), update);
} else {
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】Sop任务节点启动,cron:{},result:{}", jobBusId, job.getScheduleConf(), add);
}
}
public static void finishSopNodeJob(SopStruct sop, SopInstNode node) {
// 前置节点,后置节点
Pair<Set<Integer>, Set<Integer>> linkPair = sop.getInstLinkMap().get(node.getNodeId());
for (Integer nextId : linkPair.getValue()) {
try {
String jobBusId = jobBusId(sop.getInst(), sop.getInstNodeMap().get(nextId));
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
if (job != null) {
SopInstNodeParam params = JSONUtil.toBean(job.getExecutorParam(), SopInstNodeParam.class);
if (params != null) {
params.getFinishedIds().add(node.getNodeId());
job.setExecutorParam(JSONUtil.toJsonStr(params));
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】Sop任务节点更新,params:{},result:{}", jobBusId, params, update);
}
}
} catch (Exception e) {
log.warn("linkPair:{}", linkPair, e);
}
}
}
public static String triggerHidden(SopStruct sop) {
if (sop == null) {
return null;
}
List<String> list = Lists.newArrayList();
for (int nodeId : sop.getNodeSort()) {
SopInstNode node = sop.getInstNodeMap().get(nodeId);
if (node.getNodeVisible() == 1) {
continue;
}
// 隐藏任务执行:
String jobBusId = jobBusId(sop.getInst(), node);
XxlJobUtil.trigger(jobBusId);
log.info("【{}】手动触发隐藏任务:{} - {}", jobBusId, node.getNodeName(), node.getNodeCron());
list.add(node.getNodeName());
}
try {
Thread.sleep(2000); // 执行完任务后,稍等才去执行后续操作。
} catch (Exception e) {
}
return CollectionUtil.join(list, ",");
}
public static String jobBusId(SopInst inst) {
return inst.getInstId();
}
public static String jobBusId(SopInst inst, SopInstNode node) {
return inst.getInstId() + "-" + node.getNodeId();
}
// 日志相关
public static boolean log(Logger logger, String appendLogPattern, Object... appendLogArguments) {
logger.info(appendLogPattern, appendLogArguments);
return XxlJobHelper.log("\r\n\t" + appendLogPattern + "\r\n", appendLogArguments);
}
}
package cn.com.glsx.process.job.xxljob.core;
public class XxlJobInfo {
private int id; // 主键ID
private int jobGroup; // 执行器主键ID
private String jobDesc;
private String author; // 负责人
private String alarmEmail; // 报警邮件
private String scheduleType; // 调度类型
private String scheduleConf; // 调度配置,值含义取决于调度类型
private String misfireStrategy; // 调度过期策略 MisfireStrategyEnum
private String executorRouteStrategy; // 执行器路由策略
private String executorHandler; // 执行器,任务Handler名称
private String executorParam; // 执行器,任务参数
private String executorBlockStrategy; // 阻塞处理策略 ExecutorBlockStrategyEnum
private int executorTimeout; // 任务执行超时时间,单位秒
private int executorFailRetryCount; // 失败重试次数
private String glueType; // GLUE类型 #com.xxl.job.core.glue.GlueTypeEnum
private String glueSource; // GLUE源代码
private String glueRemark; // GLUE备注
// private Date glueUpdatetime; // GLUE更新时间
private String childJobId; // 子任务ID,多个逗号分隔
private int triggerStatus; // 调度状态:0-停止,1-运行
private long triggerLastTime; // 上次调度时间
private long triggerNextTime; // 下次调度时间
private String busKey; // 业务标识
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getJobGroup() {
return jobGroup;
}
public void setJobGroup(int jobGroup) {
this.jobGroup = jobGroup;
}
public String getJobDesc() {
return jobDesc;
}
public void setJobDesc(String jobDesc) {
this.jobDesc = jobDesc;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getAlarmEmail() {
return alarmEmail;
}
public void setAlarmEmail(String alarmEmail) {
this.alarmEmail = alarmEmail;
}
public String getScheduleType() {
return scheduleType;
}
public void setScheduleType(String scheduleType) {
this.scheduleType = scheduleType;
}
public String getScheduleConf() {
return scheduleConf;
}
public void setScheduleConf(String scheduleConf) {
this.scheduleConf = scheduleConf;
}
public String getMisfireStrategy() {
return misfireStrategy;
}
public void setMisfireStrategy(String misfireStrategy) {
this.misfireStrategy = misfireStrategy;
}
public String getExecutorRouteStrategy() {
return executorRouteStrategy;
}
public void setExecutorRouteStrategy(String executorRouteStrategy) {
this.executorRouteStrategy = executorRouteStrategy;
}
public String getExecutorHandler() {
return executorHandler;
}
public void setExecutorHandler(String executorHandler) {
this.executorHandler = executorHandler;
}
public String getExecutorParam() {
return executorParam;
}
public void setExecutorParam(String executorParam) {
this.executorParam = executorParam;
}
public String getExecutorBlockStrategy() {
return executorBlockStrategy;
}
public void setExecutorBlockStrategy(String executorBlockStrategy) {
this.executorBlockStrategy = executorBlockStrategy;
}
public int getExecutorTimeout() {
return executorTimeout;
}
public void setExecutorTimeout(int executorTimeout) {
this.executorTimeout = executorTimeout;
}
public int getExecutorFailRetryCount() {
return executorFailRetryCount;
}
public void setExecutorFailRetryCount(int executorFailRetryCount) {
this.executorFailRetryCount = executorFailRetryCount;
}
public String getGlueType() {
return glueType;
}
public void setGlueType(String glueType) {
this.glueType = glueType;
}
public String getGlueSource() {
return glueSource;
}
public void setGlueSource(String glueSource) {
this.glueSource = glueSource;
}
public String getGlueRemark() {
return glueRemark;
}
public void setGlueRemark(String glueRemark) {
this.glueRemark = glueRemark;
}
// public Date getGlueUpdatetime() {
// return glueUpdatetime;
// }
//
// public void setGlueUpdatetime(Date glueUpdatetime) {
// this.glueUpdatetime = glueUpdatetime;
// }
public String getChildJobId() {
return childJobId;
}
public void setChildJobId(String childJobId) {
this.childJobId = childJobId;
}
public int getTriggerStatus() {
return triggerStatus;
}
public void setTriggerStatus(int triggerStatus) {
this.triggerStatus = triggerStatus;
}
public long getTriggerLastTime() {
return triggerLastTime;
}
public void setTriggerLastTime(long triggerLastTime) {
this.triggerLastTime = triggerLastTime;
}
public long getTriggerNextTime() {
return triggerNextTime;
}
public void setTriggerNextTime(long triggerNextTime) {
this.triggerNextTime = triggerNextTime;
}
public String getBusKey() {
return busKey;
}
public void setBusKey(String busKey) {
this.busKey = busKey;
}
}
package cn.com.glsx.process.job.xxljob.core;
import java.io.IOException;
import java.net.HttpCookie;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.util.GsonTool;
import com.xxl.job.core.util.XxlJobRemotingUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
@Component
@Slf4j
public class XxlJobUtil {
public static final int SUCCESS_CODE = 200;
private static String adminAddresses;
private static String appname;
private static Integer groupId;
private static String accessToken;
private static String cookie = "";
@Value("${xxl.job.admin.addresses}")
public void setAdminAddresses(String adminAddresses) {
XxlJobUtil.adminAddresses = adminAddresses;
}
@Value("${xxl.job.accessToken}")
public void setAccessToken(String accessToken) {
XxlJobUtil.accessToken = accessToken;
}
@Value("${xxl.job.executor.appname}")
public void setAppname(String appname) {
XxlJobUtil.appname = appname;
}
@Value("${xxl.job.executor.groupId}")
public void setGroupId(Integer groupId) {
XxlJobUtil.groupId = groupId;
}
private static final String ADD_URL = "/jobinfo/postadd";
private static final String UPDATE_URL = "/jobinfo/postupdate";
private static final String REMOVE_URL = "/jobinfo/remove";
private static final String PAUSE_URL = "/jobinfo/stop";
private static final String START_URL = "/jobinfo/start";
private static final String ADD_AND_START_URL = "/jobinfo/trigger";
private static final String FINDBYBUSKEY = "/jobinfo/findByBusKey";
private static final String GET_GROUP_ID = "/jobgroup/pageList";
private static final String LOGIN = "/login";
/**
* 添加任务
*
* @param jobInfo 任务信息
* @return {@link String} 任务id
**/
public static String add(XxlJobInfo jobInfo) {
jobInfo.setJobGroup(groupId);
jobInfo.setAuthor("admin");
jobInfo.setGlueType("BEAN");
jobInfo.setExecutorBlockStrategy("SERIAL_EXECUTION");
jobInfo.setExecutorRouteStrategy("RANDOM");
jobInfo.setMisfireStrategy("DO_NOTHING");
jobInfo.setScheduleType(ScheduleTypeEnum.CRON.name());
return doPost(adminAddresses + ADD_URL, jobInfo, String.class);
}
/**
* 修改执行时间
*
* @return {@link String}
**/
public static String update(XxlJobInfo jobInfo) {
if (jobInfo.getId() == 0) {
XxlJobInfo byBusKey = findByBusKey(jobInfo.getBusKey());
if (byBusKey != null) {
jobInfo.setId(byBusKey.getId());
}
}
// jobInfo.setAddTime(null);
// jobInfo.setUpdateTime(null);
// jobInfo.setGlueUpdatetime(null);
return doPost(adminAddresses + UPDATE_URL, jobInfo, String.class);
}
/**
* 删除任务
*
* @param buskey 业务key
* @return {@link String}
**/
public static String remove(String buskey) {
XxlJobInfo byBusKey = findByBusKey(buskey);
if (byBusKey != null) {
return doPost(adminAddresses + REMOVE_URL + "?id=" + byBusKey.getId(), null, String.class);
}
return null;
}
/**
* 暂停任务
*
* @param buskey 业务key
* @return {@link String}
**/
public static String pause(String buskey) {
XxlJobInfo byBusKey = findByBusKey(buskey);
if (byBusKey != null) {
return doPost(adminAddresses + PAUSE_URL + "?id=" + byBusKey.getId(), null, String.class);
}
return null;
}
/**
* 开始任务
*
* @param buskey 业务key
* @return {@link String}
**/
public static String start(String buskey) {
XxlJobInfo byBusKey = findByBusKey(buskey);
if (byBusKey != null) {
return doPost(adminAddresses + START_URL + "?id=" + byBusKey.getId(), null, String.class);
}
return null;
}
/**
* 添加并启动
*
* @param buskey 业务key
* @return {@link String}
**/
public static String trigger(String buskey) {
XxlJobInfo byBusKey = findByBusKey(buskey);
if (byBusKey != null) {
return doPost(adminAddresses + ADD_AND_START_URL + "?id=" + byBusKey.getId(), null, String.class);
}
return null;
}
/**
* 根据业务id查询tigger
*
* @param busKey 任务信息
* @return {@link String}
**/
public static XxlJobInfo findByBusKey(String busKey) {
if (busKey == null) {
// return null;
throw new RuntimeException("busKey is null");
}
XxlJobInfo xxlJobInfo = doPost(adminAddresses + FINDBYBUSKEY + "?busKey=" + busKey + "&jobGroup=" + groupId, null, XxlJobInfo.class);
return xxlJobInfo;
}
/**
* 根据业务id查询jobGroup
*
* @return {@link String}
**/
@PostConstruct
public void findJobGroup() {
/*
* Map resmap = doPost(adminAddresses + GET_GROUP_ID + "?appname=" + appname, null, Map.class);
* System.out.println(resmap);
* Object data = resmap.get("data");
* if(data!=null){
* String jsonString = JSONObject.toJSONString(data);
* List<Map> maps = JSONObject.parseArray(jsonString, Map.class);
* if(CollectionUtils.isNotEmpty(maps)){
* Map map = maps.get(0);
* groupId= (Integer) map.get("id");
* }
* }
*/
}
public static <T> T doPost(String url, Object json, Class<T> clazz) {
log.info("请求url: {}, 请求参数: {} {} : {}", url, GsonTool.toJson(json), XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN, accessToken);
ReturnT<T> returnT = XxlJobRemotingUtil.postBody(url, accessToken, 30, json, clazz);
if (returnT.getCode() != SUCCESS_CODE) {
log.info(String.format("【xxl-job】接口调用失败,错误码:%s,原因:%s", returnT.getCode(), returnT.getMsg()));
}
return returnT.getContent();
}
/**
* 登录
*
* @param url
* @param userName
* @param password
* @return
* @throws HttpException
* @throws IOException
*/
public static String login(String userName, String password) {
HttpResponse rsp = HttpUtil.createGet(adminAddresses + "/api/jobinfo/login?userName=" + userName + "&password=" + password).execute();
List<HttpCookie> cookies = rsp.getCookies();
StringBuffer tmpcookies = new StringBuffer();
for (HttpCookie c : cookies) {
tmpcookies.append(c.toString() + ";");
}
cookie = tmpcookies.toString();
return cookie;
}
}
package cn.com.glsx.process.job.xxljob.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class SopInstExecuteJobHandler {
@Resource
private SopService sopService;
@XxlJob(SopXxlJobUtil.SOP_EXECUTE_JOB_ID)
public void handler(String param) throws Exception {
param = XxlJobHelper.getJobParam();
SopXxlJobUtil.log(log, "【执行Sop实例】{}", param);
String instId = param;
SopStruct sop = sopService.loadSop(instId);
// 创建执行批次
if (sop.getInst().getInstStatus() == 1) {
sopService.createBatch(sop);
}
// 创建所有节点任务
SopXxlJobUtil.initSopNodesJob(sop);
}
}
package cn.com.glsx.process.job.xxljob.impl;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.xxl.job.core.handler.annotation.XxlJob;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class SopInstLoadJobHandler {
@Resource
private SopService sopService;
@XxlJob(SopXxlJobUtil.SOP_LOAD_JOB_ID)
public void handler(String param) throws Exception {
// param = XxlJobHelper.getJobParam();
SopXxlJobUtil.log(log, "【加载Sop实例列表】{}", param);
List<SopInst> all = sopService.loadAllInst();
for (SopInst inst : all) {
// 过期机制
if (inst.getExpireTime() != null && inst.getExpireTime().before(new Date())) {
inst.setInstStatus((byte) -1);
}
if (inst.getInstStatus() == 1) {
// 启动sop任务
SopXxlJobUtil.initSopJob(inst);
} else {
// 停止实例任务以及所有子任务
SopStruct sop = sopService.loadSop(inst.getInstId());
SopXxlJobUtil.pauseSop(sop);
}
}
}
}
package cn.com.glsx.process.job.xxljob.impl;
import java.util.Date;
import java.util.Set;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.com.glsx.process.modules.sop.SopHelper;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory;
import cn.com.glsx.process.modules.sop.execute.SopNodeType;
import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class SopInstNodeExecuteJobHandler {
@Resource
private SopService sopService;
@XxlJob(SopXxlJobUtil.SOP_NODE_EXECUTE_JOB_ID)
public void handler(String param1) throws Exception {
String json = XxlJobHelper.getJobParam();
SopInstNodeParam param = JacksonUtils.fromJson(json, SopInstNodeParam.class);
SopXxlJobUtil.log(log, "【执行Sop节点】{}", param);
if (param == null) {
SopXxlJobUtil.log(log, "【执行Sop节点】任务启动参数为空!!!");
return;
}
SopStruct sop = sopService.loadSop(param.getInstId());
// 执行sop里面的instNodeId节点。
SopInstNode node = sop.getInstNodeMap().get(param.getNodeId());
boolean avaliable = checkPreIds(sop, node, param);
if (!avaliable) {
return;
}
SopXxlJobUtil.log(log, "【执行Sop节点】{}【{}:{}】 开始执行......", sop.getInst().getInstName(), node.getNodeId(), node.getNodeName());
// 节点执行
execute(sop, node);
// 记录节点执行结果
}
/**
* 检查本节点的前置任务是否完成,如果前置任务是异步任务,则忽略
*
* @param sop
* @param node
* @param param
* @return
*/
private boolean checkPreIds(SopStruct sop, SopInstNode node, SopInstNodeParam param) {
log.info("sop:{}", JacksonUtils.nodefaultMapper.toJson(sop));
log.info("node:{}", JacksonUtils.nodefaultMapper.toJson(node));
Pair<Set<Integer>, Set<Integer>> pair = sop.getInstLinkMap().get(node.getNodeId());
// 前置任务为空,直接执行
if (pair.getKey().isEmpty()) {
return true;
}
// 前置任务已完成,可以执行
if (param.getFinishedIds().containsAll(pair.getKey())) {
return true;
}
// 前置任务是异步任务,可以执行
for (Integer preId : pair.getKey()) {
SopInstNode preNode = sop.getInstNodeMap().get(preId);
if (preNode != null && preNode.getNodeAsync() != 1 && !param.getFinishedIds().contains(preId)) {
SopXxlJobUtil.log(log, "【执行Sop节点】【{}:{}】,存在前置任务未完成:【{}:{}】", sop.getInst().getInstId(), sop.getInst().getInstName(),
preNode.getInstId(), preNode.getNodeName());
return false;
}
}
return true;
}
/**
* 节点执行时,申请sop锁
*
* @param node 节点信息
* @param sop 执行器
*/
public void execute(SopStruct sop, SopInstNode node) {
SopNodeType type = SopNodeType.fromBusType(node.getNodeType());
SopNodeExecutor instance = SopNodeExecutorFactory.getInstance(type.getHanderImp(), SopNodeExecutor.class);
// 执行sop节点前,锁定sop
if (SopHelper.lockInst(sop.getInst())) {
try {
if (node.getNodeSkip() != 1) {
// 重新加载sop
sop = reloadAndCreateNodeBatch(sop, node);
node = sop.getInstNodeMap().get(node.getNodeId());
// 节点过期
if (node.getDailyExpire() != null && node.getDailyExpire().before(new Date())) {
node.setNodeStatus(-1);
SopXxlJobUtil.pauseSopNode(sop, node);
SopXxlJobUtil.log(log, "【执行Sop节点】【{}:{}】,节点dailyExpire已到期,停止执行!", sop.getInst().getInstId(), sop.getInst().getInstName());
return;
}
// 没超执行次数限制
if (node.getDailyLimit() == 0 || node.getDailyCount() < node.getDailyLimit()) {
// 预备执行参数
SnapshotStruct snapshotStruct = instance.prepare(sop, node);
// 执行sop节点
Object result = instance.execute(sop, node, snapshotStruct);
// 处理执行结果
snapshotStruct = instance.handleResult(sop, node, snapshotStruct, result);
// 保存快照
updateBatch(sop, node, snapshotStruct);
} else {
SopXxlJobUtil.log(log, "【执行Sop节点】【{}:{}】,执行次数超限!节点当日执行次数:{},当日限制次数:{}", sop.getInst().getInstId(),
sop.getInst().getInstName(), node.getDailyCount(), node.getDailyLimit());
}
} else {
SopXxlJobUtil.log(log, "【执行Sop节点】【{}:{}】,节点nodeSkip=1,跳过任务!", sop.getInst().getInstId(), sop.getInst().getInstName());
}
// 更新后续节点状态
updateNextNodes(sop, node);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
SopHelper.unlockInst(sop.getInst());
}
} else {
SopXxlJobUtil.log(log, "【执行Sop节点】【{}:{}】,申请实例锁失败,本次不执行!", sop.getInst().getInstId(), sop.getInst().getInstName());
return;
}
}
private void updateNextNodes(SopStruct sop, SopInstNode node) {
// TODO 是否需要触发后续任务
SopXxlJobUtil.finishSopNodeJob(sop, node);
}
private void updateBatch(SopStruct sop, SopInstNode node, SnapshotStruct result) {
String snapshot = JacksonUtils.nodefaultMapper.toJson(result);
// 刷新实例快照
SopInst inst = sop.getInst();
inst.setInstSnapshot(snapshot);
node.setDailyCount(ObjectUtil.defaultIfNull(node.getDailyCount(), 0) + 1);
SopXxlJobUtil.log(log, "【执行Sop节点】【{}:{}】,节点已执行次数:{}!", sop.getInst().getInstId(), sop.getInst().getInstName(), node.getDailyCount());
// 刷新实例批次快照
SopInstBatch batch = sop.getBatch();
if (batch != null) {
batch.setSnapshot(snapshot);
batch.setUpdateTime(new Date());
}
// 刷新实例节点批次快照
SopInstNodeBatch nodeBatch = sop.getNodeBatch();
if (nodeBatch != null) {
nodeBatch.setSnapshot(snapshot);
nodeBatch.setUpdateTime(new Date());
}
sopService.updateNodeBatch(inst, node, batch, nodeBatch);
}
private SopStruct reloadAndCreateNodeBatch(SopStruct sop, SopInstNode node) {
sop = sopService.loadSop(sop.getInst().getInstId());
// 创建节点执行批次
SopInstNodeBatch curBatch = sopService.createNodeBatch(sop.getInst(), node.getInstNodeId());
sop.setNodeBatch(curBatch);
return sop;
}
}
package cn.com.glsx.process.job.xxljob.param;
import java.util.Set;
import com.alibaba.nacos.shaded.com.google.common.collect.Sets;
import lombok.Data;
@Data
public class SopInstNodeParam {
/** 实例id */
private String instId;
/** 实例节点id */
private Integer nodeId;
/** 实例节点前置节点id */
private Set<Integer> preIds = Sets.newHashSet();
/** 已完成的前置节点,当所有前置节点已完成时,触发本任务 */
private Set<Integer> finishedIds = Sets.newHashSet();
/** 实例节点后置节点id,本节点任务完成时触发后续节点 */
private Set<Integer> nextIds = Sets.newHashSet();
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules; package cn.com.glsx.process.modules;
import cn.com.glsx.process.modules.service.UserDemoService; import javax.annotation.Resource;
import com.glsx.plat.core.web.R;
import com.glsx.plat.web.controller.AbstractController;
import cn.com.glsx.process.modules.entity.User;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.validation.BindException; import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import com.glsx.plat.core.web.R;
import com.glsx.plat.web.controller.AbstractController;
import cn.com.glsx.process.modules.entity.User;
import cn.com.glsx.process.modules.service.UserDemoService;
/** /**
* @author liuyf * @author liuyf
......
package cn.com.glsx.process.modules; package cn.com.glsx.process.modules;
import cn.com.glsx.process.modules.entity.User; import java.util.HashMap;
import cn.com.glsx.process.modules.service.UserDemoService; import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.common.annotation.SysLog; import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import cn.com.glsx.process.modules.entity.User;
import cn.com.glsx.process.modules.service.UserDemoService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author payu * @author payu
......
package cn.com.glsx.process.modules.api;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody;
import cn.com.glsx.process.api.SopInstFeignClient;
import cn.com.glsx.process.modules.model.SopInstDTO;
import cn.com.glsx.process.modules.service.SopInstService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
/**
* 微服务应用在网关中处理统一返回体
*
* @author payu
*/
@Slf4j
@Tag(name = "SOP门店模板实例开放接口")
@RestController
@RequestMapping(value = "/api/sopInsts")
@ResponseResultBody
public class SopInstApiController implements SopInstFeignClient {
@Resource
private SopInstService sopInstService;
@Operation(summary = "通过实例自定义唯一标识参数查询SOP实例", description = "通过实例自定义唯一标识参数查询SOP实例")
@GetMapping("/getOneByCustomData")
@Override
public SopInstDTO getOneByCustomData(@RequestParam Map<String, Object> customData) {
return sopInstService.getOneByCustomData(customData);
}
}
package cn.com.glsx.process.modules.api; package cn.com.glsx.process.modules.api;
import javax.annotation.Resource;
import cn.com.glsx.cdp.api.customer.CustomerSopJourneyFeignClient;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result;
import cn.com.glsx.echocenter.api.EchoCenterFeignClient;
import cn.com.glsx.process.api.UserCenterFeignClient; import cn.com.glsx.process.api.UserCenterFeignClient;
import cn.com.glsx.process.modules.converter.UserConverter; import cn.com.glsx.process.modules.converter.UserConverter;
import cn.com.glsx.process.modules.entity.User; import cn.com.glsx.process.modules.entity.User;
import cn.com.glsx.process.modules.model.UserDTO; import cn.com.glsx.process.modules.model.UserDTO;
import cn.com.glsx.process.modules.service.UserDemoService; import cn.com.glsx.process.modules.service.UserDemoService;
import cn.com.glsx.echocenter.api.EchoCenterFeignClient;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/** /**
* 微服务应用在网关中处理统一返回体 * 微服务应用在网关中处理统一返回体
...@@ -34,13 +44,19 @@ public class UserApiController implements UserCenterFeignClient { ...@@ -34,13 +44,19 @@ public class UserApiController implements UserCenterFeignClient {
@Resource @Resource
private EchoCenterFeignClient echoCenterFeignClient; private EchoCenterFeignClient echoCenterFeignClient;
@Resource
private CustomerSopJourneyFeignClient customerSopJourneyFeignClient;
@Operation(summary = "FeignClient调用") @Operation(summary = "FeignClient调用")
@Override @Override
@GetMapping("/echo") @GetMapping("/echo")
public String echo(@RequestParam String message) { public String echo(@RequestParam String message) {
String echo = echoCenterFeignClient.echo(message); CustomerSopJourneySearch customerSopJourneySearch = new CustomerSopJourneySearch();
return echo; customerSopJourneySearch.setPageNum(1);
customerSopJourneySearch.setPageSize(10);
Result<PageInfo<CustomerSopJourneyDTO>> pageInfoResult = customerSopJourneyFeignClient.pageCustomerSopJourney(customerSopJourneySearch);
return JSONObject.toJSONString(pageInfoResult);
} }
@Operation(summary = "本地调用") @Operation(summary = "本地调用")
......
package cn.com.glsx.process.modules.controller;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
/**
* @author kome
*/
@Slf4j
@Tag(name = "sop服务")
@RestController
@RequestMapping(value = "/sop/api")
@ResponseResultBody
public class SopController {
@Resource
private SopService sopService;
@Operation(summary = "查询实例")
@GetMapping(value = "/inst/{instId}")
public SopStruct inst(@PathVariable("instId") String instId) {
SopStruct sop = sopService.loadSop(instId);
return sop;
}
@Operation(summary = "刷新实例状态", description = "找出实例中所有隐藏且频繁执行的节点,手动执行一次")
@GetMapping(value = "/inst/refresh/{instId}")
public Result<String> stageTrigger(@PathVariable("instId") String instId) {
SopStruct sop = sopService.loadSop(instId);
String rs = SopXxlJobUtil.triggerHidden(sop);
return Result.success("已刷新:" + rs);
}
@Operation(summary = "从实例反推模板", description = "注意先把模板清理掉")
@GetMapping(value = "/inst/to/tpl/{instId}")
public Result<String> instToTpl(@PathVariable("instId") String instId) {
SopStruct sop = sopService.loadSop(instId);
sopService.generateTplFromInst(sop);
return Result.success("已生成模板!");
}
}
package cn.com.glsx.process.modules.controller;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.model.SopCustomerSearch;
import cn.com.glsx.process.modules.model.SopInstDTO;
import cn.com.glsx.process.modules.model.SopInstSearch;
import cn.com.glsx.process.modules.model.SopJourneyStageUpdate;
import cn.com.glsx.process.modules.service.SopInstService;
import cn.com.glsx.process.util.FileUploadServerData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "SOP门店模板实例开放接口")
@RestController
@RequestMapping(value = "/sop/api/sopInsts")
@ResponseResultBody
public class SopInstController extends BaseController {
@Resource
private SopInstService sopInstService;
@Operation(summary = "查询SOP模板实例分页列表", description = "查询SOP模板实例分页列表")
@GetMapping
public PageInfo<SopInstDTO> page(SopInstSearch search) {
return sopInstService.page(search);
}
@Operation(summary = "查询门店下SOP模板实例分页列表(门店下)", description = "查询门店下SOP模板实例分页列表(门店下)")
@GetMapping("/byGroupId")
public PageInfo<SopInst> selectByGroupId(@Validated SopInstSearch search) {
return sopInstService.selectByGroupId(search);
}
@Operation(summary = "查询模板实例客户分页列表", description = "查询模板实例客户分页列表")
@GetMapping("/customers")
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
return sopInstService.customers(search);
}
@Operation(summary = "单个更新旅程客户阶段", description = "单个更新旅程客户阶段")
@PostMapping("/customers/stageUpdate")
public Result<Boolean> stageUpdate(@Validated @RequestBody SopJourneyStageUpdate body) {
return sopInstService.stageUpdate(body);
}
@Operation(summary = "导出客户数据", description = "导出客户数据")
@GetMapping("/customers/export")
public FileUploadServerData customersExport(SopCustomerSearch search) {
return sopInstService.customersExport(search);
}
@Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息")
@GetMapping("/customers/detail")
public Result<CustomerSopJourneyDetailDTO> customerDetail(SopCustomerSearch search) {
return sopInstService.customerDetail(search);
}
@Operation(summary = "根据id查询SOP门店模板实例详情", description = "根据id查询SOP门店模板实例详情")
@GetMapping("/{instId}")
public SopInstDTO findById(@PathVariable("instId") String instId) {
return sopInstService.findById(instId);
}
@Operation(summary = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)", description = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)")
@PostMapping("/{instId}/instParam/customData")
public Result<String> updateInstParamCustomData(@PathVariable("instId") String instId, @RequestBody Map<String, Object> customData) {
return sopInstService.updateInstParamCustomData(instId, customData);
}
@Operation(summary = "更新SOP门店模板实例状态", description = "更新SOP门店模板实例状态")
@PostMapping("/{instId}/status")
public Result<String> updateInstStatus(@PathVariable("instId") String instId, @RequestBody Byte status) {
return sopInstService.updateInstStatus(instId, status);
}
@Operation(summary = "SOP模板批量下发门店", description = "SOP模板批量下发门店")
@PostMapping
public String add(@RequestBody SopInstDTO sopInstDTO) {
sopInstService.add(sopInstDTO);
return "success";
}
}
package cn.com.glsx.process.modules.controller;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody;
import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.entity.SopTpl;
import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.model.SopTplSearch;
import cn.com.glsx.process.modules.service.SopTplService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "SOP模板开放接口")
@RestController
@RequestMapping(value = "/sop/api/sopTpls")
@ResponseResultBody
public class SopTplController extends BaseController {
@Resource
private SopTplService sopTplService;
@Operation(summary = "SOP模板分页列表", description = "SOP模板分页列表")
@GetMapping
public PageInfo<SopTplDTO> page(SopTplSearch search) {
return sopTplService.page(search);
}
@Operation(summary = "SOP模板全部列表", description = "SOP模板全部列表")
@GetMapping("/list")
public List<SopTpl> list() {
return sopTplService.list();
}
@Operation(summary = "SOP模板详情", description = "SOP模板详情")
@GetMapping("/{tplId}")
public SopTplDTO getById(@PathVariable("tplId") String tplId) {
return sopTplService.getById(tplId);
}
}
package cn.com.glsx.process.modules.controller;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody;
import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.entity.SopTplGrant;
import cn.com.glsx.process.modules.model.SopTplGrantSearch;
import cn.com.glsx.process.modules.service.SopTplGrantService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "SOP模板授权门店接口")
@RestController
@RequestMapping(value = "/sop/api/sopTplGrants")
@ResponseResultBody
public class SopTplGrantController extends BaseController {
@Resource
private SopTplGrantService sopTplGrantService;
@Operation(summary = "分配门店列表", description = "分配门店列表")
@GetMapping("/list")
public List<SopTplGrant> list(@Validated SopTplGrantSearch search) {
return sopTplGrantService.list(search);
}
}
package cn.com.glsx.process.modules.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "动态任务(Demo)")
@RestController
@RequestMapping(value = "/sop/job")
@ResponseResultBody
public class TestJobController {
/* *//* @Autowired
private DynamicTaskService dynamicTaskAdd;
@GetMapping("/jobtest")
@Operation(summary = "动态任务添加", description = "动态任务添加")
public void addtest(@RequestParam("cron") String cron,@RequestParam("jobName") String jobName) {
// cron表达式
dynamicTaskAdd.create(jobName, cron, 1, new DynamicJob(), "test", "test");
}
@PostMapping("/jobtestupdate")
@Operation(summary = "动态任务更新", description = "动态任务更新")
public void updatetest(@RequestParam("cron") String cron, @RequestParam("jobName") String jobName) {
dynamicTaskAdd.updateJob(jobName, cron);
}*//*
@PostMapping("/jobtestdel")
@Operation(summary = "动态任务删除", description = "动态任务删除")
public void deltest(@RequestParam("jobName") String jobName) {
dynamicTaskAdd.removeJob(jobName);
}*/
}
package cn.com.glsx.process.modules.controller;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import com.glsx.plat.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.R;
import cn.com.glsx.process.job.xxljob.core.XxlJobInfo;
import cn.com.glsx.process.job.xxljob.core.XxlJobUtil;
import cn.com.glsx.process.modules.service.UserDemoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Tag(name = "xxljob动态任务(Demo)")
@RestController
@RequestMapping(value = "/sop/xxljob")
@ResponseResultBody
public class TestXXLJobController {
@Autowired
private UserDemoService userDemoService;
@GetMapping("/jobtest")
@Operation(summary = "动态任务添加", description = "动态任务添加")
public void addtest(@RequestParam("cron") String cron, @RequestParam("jobName") String jobName, @RequestParam("param") String param, @RequestParam("executorHandler") String executorHandler, @RequestParam("busKey") String busKey) {
// cron表达式
XxlJobInfo jobInfo = new XxlJobInfo();
jobInfo.setExecutorParam(param);
jobInfo.setJobDesc(jobName);
jobInfo.setAuthor("admin");
jobInfo.setScheduleConf(cron);
jobInfo.setExecutorHandler(executorHandler);
jobInfo.setBusKey(busKey);
XxlJobUtil.add(jobInfo);
}
@PostMapping("/jobtestupdate")
@Operation(summary = "动态任务更新", description = "动态任务更新")
public void updatetest(@RequestParam(value = "cron", required = false) String cron, @RequestParam("id") String id, @RequestParam(value = "executorParam", required = false) String executorParam, @RequestParam(value = "jobDesc", required = false) String jobDesc, @RequestParam(value = "triggerStatus", required = false) Integer triggerStatus) {
XxlJobInfo jobInfo = new XxlJobInfo();
jobInfo.setBusKey(id);
jobInfo.setScheduleConf(cron);
jobInfo.setJobDesc(jobDesc);
jobInfo.setExecutorParam(executorParam);
jobInfo.setTriggerStatus(triggerStatus);
XxlJobUtil.update(jobInfo);
}
@PostMapping("/jobtestdel")
@Operation(summary = "动态任务删除", description = "动态任务删除")
public void deltest(@RequestParam("id") String id) {
XxlJobUtil.remove(id);
}
@PostMapping("/pause")
@Operation(summary = "动态任务暂停", description = "动态任务暂停")
public void pause(@RequestParam("id") String id) {
XxlJobUtil.pause(id);
}
@PostMapping("/start")
@Operation(summary = "动态任务开启", description = "动态任务开启")
public void start(@RequestParam("id") String id) {
XxlJobUtil.start(id);
}
@PostMapping("/trigger")
@Operation(summary = "动态任务触发", description = "动态任务触发")
public void trigger(@RequestParam("id") String id) {
XxlJobUtil.trigger(id);
}
@PostMapping("/findBybusKey")
@Operation(summary = "任务查询", description = "动态任务触发")
public R findBybusKey(@RequestParam("busKey") String busKey) {
return R.ok().data(XxlJobUtil.findByBusKey(busKey));
}
@PostMapping("/testJava")
@Operation(summary = "测试java", description = "动态任务触发")
public R testJava(@RequestParam("busKey") String busKey) throws Exception {
if (true) {
throw new AdminException(ResultEnum.PARAM_ERROR);
}
return R.ok().data(userDemoService.testJava(busKey));
}
}
package cn.com.glsx.process.modules.controller; package cn.com.glsx.process.modules.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.context.utils.validator.AssertUtils;
import com.glsx.plat.core.annotation.ResponseResultBody;
import cn.com.glsx.process.modules.BaseController; import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.converter.UserConverter; import cn.com.glsx.process.modules.converter.UserConverter;
import cn.com.glsx.process.modules.entity.User; import cn.com.glsx.process.modules.entity.User;
...@@ -7,16 +21,9 @@ import cn.com.glsx.process.modules.model.UserBO; ...@@ -7,16 +21,9 @@ import cn.com.glsx.process.modules.model.UserBO;
import cn.com.glsx.process.modules.model.UserDTO; import cn.com.glsx.process.modules.model.UserDTO;
import cn.com.glsx.process.modules.model.UserSearch; import cn.com.glsx.process.modules.model.UserSearch;
import cn.com.glsx.process.modules.service.UserDemoService; import cn.com.glsx.process.modules.service.UserDemoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.context.utils.validator.AssertUtils;
import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/** /**
* 单体应用Controller处理统一返回体 * 单体应用Controller处理统一返回体
...@@ -26,7 +33,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -26,7 +33,7 @@ import org.springframework.web.bind.annotation.*;
@Slf4j @Slf4j
@Tag(name = "用户接口(Demo)") @Tag(name = "用户接口(Demo)")
@RestController @RestController
@RequestMapping(value = "/user") @RequestMapping(value = "/sop/user")
@ResponseResultBody @ResponseResultBody
public class UserController extends BaseController { public class UserController extends BaseController {
...@@ -62,9 +69,9 @@ public class UserController extends BaseController { ...@@ -62,9 +69,9 @@ public class UserController extends BaseController {
@Operation(summary = "用户详情", description = "查询用户详情") @Operation(summary = "用户详情", description = "查询用户详情")
@GetMapping(value = "/info/{id}") @GetMapping(value = "/info/{id}")
public UserDTO info(@PathVariable("id") Long id) { public UserDTO info(@PathVariable("id") Long id) {
User user = userDemoService.getById(id); /* User user = userDemoService.getById(id);
UserDTO userDTO = UserConverter.INSTANCE.do2dto(user); UserDTO userDTO = UserConverter.INSTANCE.do2dto(user);*/
return userDTO; return null;
} }
} }
package cn.com.glsx.process.modules.converter;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.model.SopInstDTO;
@Mapper
public interface SopInstConverter {
SopInstConverter INSTANCE = Mappers.getMapper(SopInstConverter.class);
SopInst do2do(SopInst sopInst);
SopInstDTO do2dto(SopInst sopInst);
}
package cn.com.glsx.process.modules.converter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopTpl;
import cn.com.glsx.process.modules.model.SopTplDTO;
@Mapper
public interface SopTplConverter {
SopTplConverter INSTANCE = Mappers.getMapper(SopTplConverter.class);
SopTplDTO do2dto(SopTpl sopTpl);
SopTpl dto2do(SopTplDTO sopTplDTO);
@Mappings({
@Mapping(source = "tplName", target = "instName"),
@Mapping(source = "tplCron", target = "instCron"),
@Mapping(source = "tplRemark", target = "instRemark"),
@Mapping(source = "tplParamDef", target = "instParam")})
SopInst do2inst(SopTpl sopTpl);
@Mappings({
@Mapping(source = "tplName", target = "instName"),
@Mapping(source = "tplCron", target = "instCron"),
@Mapping(source = "tplRemark", target = "instRemark"),
@Mapping(source = "tplParamDef", target = "instParam")})
SopInst dto2inst(SopTplDTO sopTplDTO);
}
package cn.com.glsx.process.modules.converter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.entity.SopTplLink;
@Mapper
public interface SopTplLinKConverter {
SopTplLinKConverter INSTANCE = Mappers.getMapper(SopTplLinKConverter.class);
@Mappings({@Mapping(ignore = true, source = "linkId", target = "linkId")})
SopInstLink tpl2inst(SopTplLink link);
}
package cn.com.glsx.process.modules.converter;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopTplNode;
@Mapper
public interface SopTplNodeConverter {
SopTplNodeConverter INSTANCE = Mappers.getMapper(SopTplNodeConverter.class);
@Mappings({
@Mapping(source = "nodeAsync", target = "nodeAsync"),
@Mapping(source = "nodeParamDef", target = "nodeParam"),
@Mapping(source = "nodeContentDef", target = "nodeContent")})
SopInstNode tpl2inst(SopTplNode node);
}
package cn.com.glsx.process.modules.converter; package cn.com.glsx.process.modules.converter;
import cn.com.glsx.process.modules.model.UserBO;
import cn.com.glsx.process.modules.model.UserDTO;
import cn.com.glsx.process.modules.entity.User;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import cn.com.glsx.process.modules.entity.User;
import cn.com.glsx.process.modules.model.UserBO;
import cn.com.glsx.process.modules.model.UserDTO;
/** /**
* 解耦dao与api的实体映射 * 解耦dao与api的实体映射
* 字段名不一样,用@Mapping来处理 * 字段名不一样,用@Mapping来处理
......
package cn.com.glsx.process.modules.handler;
import java.io.IOException;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonTypeHandler implements TypeHandler<Object> {
private static final ObjectMapper objectMapper = new ObjectMapper();
@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
try {
String json = objectMapper.writeValueAsString(parameter);
ps.setString(i, json);
} catch (IOException e) {
throw new SQLException(e);
}
}
@Override
public Object getResult(ResultSet rs, String columnName) throws SQLException {
String json = rs.getString(columnName);
return parseJson(json);
}
@Override
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
String json = rs.getString(columnIndex);
return parseJson(json);
}
@Override
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
String json = cs.getString(columnIndex);
return parseJson(json);
}
private Object parseJson(String json) throws SQLException {
try {
return objectMapper.readValue(json, Object.class);
} catch (IOException e) {
throw new SQLException(e);
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.model;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import java.util.Date;
import java.util.Objects;
/**
*
*/
public class SopCustomerExcelDTO {
@ExcelProperty("客户姓名")
private String customerName;
@ExcelProperty("客户电话")
private String customerPhone;
@ExcelProperty("微信昵称")
private String wechatNickname;
@ExcelProperty("旅程")
private String sopJourneyName;
@ExcelProperty("进入旅程时间")
private Date sopJourneyEnterTime;
@ExcelProperty("所处旅程天数")
private int sopJourneyDays;
@ExcelProperty("旅程阶段")
private String sopJourneyStage;
/**
* 进入当前sop旅程阶段时间
*/
@ExcelIgnore
private Date sopJourneyStageEnterTime;
@ExcelProperty("所处旅程阶段天数")
private int sopJourneyStageDays;
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getCustomerPhone() {
return customerPhone;
}
public void setCustomerPhone(String customerPhone) {
this.customerPhone = customerPhone;
}
public String getWechatNickname() {
return wechatNickname;
}
public void setWechatNickname(String wechatNickname) {
this.wechatNickname = wechatNickname;
}
public String getSopJourneyName() {
return sopJourneyName;
}
public void setSopJourneyName(String sopJourneyName) {
this.sopJourneyName = sopJourneyName;
}
public Date getSopJourneyEnterTime() {
return sopJourneyEnterTime;
}
public void setSopJourneyEnterTime(Date sopJourneyEnterTime) {
this.sopJourneyEnterTime = sopJourneyEnterTime;
}
public int getSopJourneyDays() {
if (Objects.isNull(sopJourneyEnterTime)) {
return 0;
}
Date now = new Date();
long nowTime = now.getTime();
long enterTime = sopJourneyEnterTime.getTime();
long num = nowTime - enterTime;
return (int) (num/24/60/60/1000);
}
public void setSopJourneyDays(int sopJourneyDays) {
this.sopJourneyDays = sopJourneyDays;
}
public String getSopJourneyStage() {
return sopJourneyStage;
}
public void setSopJourneyStage(String sopJourneyStage) {
this.sopJourneyStage = sopJourneyStage;
}
public Date getSopJourneyStageEnterTime() {
return sopJourneyStageEnterTime;
}
public void setSopJourneyStageEnterTime(Date sopJourneyStageEnterTime) {
this.sopJourneyStageEnterTime = sopJourneyStageEnterTime;
}
public int getSopJourneyStageDays() {
if (Objects.isNull(sopJourneyStageEnterTime)) {
return 0;
}
Date now = new Date();
long nowTime = now.getTime();
long enterTime = sopJourneyStageEnterTime.getTime();
long num = nowTime - enterTime;
return (int) (num/24/60/60/1000);
}
public void setSopJourneyStageDays(int sopJourneyStageDays) {
this.sopJourneyStageDays = sopJourneyStageDays;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.rabbitmq;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
/**
* 编写消息的生产者
*/
@Component
@Slf4j
public class MsgProducer implements RabbitTemplate.ConfirmCallback {
//由于rabbitTemplate的scope属性设置为ConfigurableBeanFactory.SCOPE_PROTOTYPE,所以不能自动注入
private RabbitTemplate rabbitTemplate;
/**
* 构造方法注入rabbitTemplate
*/
@Autowired
public MsgProducer(RabbitTemplate rabbitTemplate) {
this.rabbitTemplate = rabbitTemplate;
rabbitTemplate.setConfirmCallback(this); //rabbitTemplate如果为单例的话,那回调就是最后设置的内容
}
/**
* topic模式
*
* @param content
*/
public void topicSend(String exchange,String routingKey,Object content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
String contentJson = JSON.toJSONString(content);
log.info("消息id:{},推送数据到mq:{}",correlationId, contentJson);
rabbitTemplate.convertAndSend(exchange,routingKey, contentJson,correlationId);
}
/**
* topic模式
* 交换机使用本项目默认
*
* @param content
*/
public void topicSend(String routingKey,Object content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
String contentJson = JSON.toJSONString(content);
log.info("消息id:{},推送数据到mq:{}",correlationId, contentJson);
rabbitTemplate.convertAndSend(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS,routingKey, contentJson,correlationId);
}
/**
* 回调
*/
@Override
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
log.info(" 回调id:" + correlationData);
if (ack) {
log.info("交换机已收到id为:{}的消息",correlationData);
} else {
log.info("交换机已收到id为:{}的消息,原因:{}",correlationData, cause);
}
}
}
package cn.com.glsx.process.modules.rabbitmq;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
//声明topic交换机
@Bean
public TopicExchange topicExchange() {
//durable(true) 持久化,mq重启之后交换机还在
return ExchangeBuilder.topicExchange(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS).durable(true).build();
}
@Bean(name = "dataReportQueue")
public Queue dataReportQueue() {
return new Queue(RabbitMQConstants.DATA_REPORT_QUEUE_NAME, true);
}
@Bean(name = "dataReportTopicExchange")
public TopicExchange dataReportTopicExchange() {
return new TopicExchange(RabbitMQConstants.DATA_REPORT_EXCHANGE_NAME);
}
@Bean
public Binding bindingDataReport(@Qualifier("dataReportQueue") Queue dataReportQueue,
@Qualifier("dataReportTopicExchange") TopicExchange dataReportTopicExchange) {
return BindingBuilder.bind(dataReportQueue).to(dataReportTopicExchange).with(RabbitMQConstants.DATA_REPORT_TOPIC);
}
}
package cn.com.glsx.process.modules.rabbitmq;
public interface RabbitMQConstants {
String TOPIC_EXCHANGE_PLATFORM_PROCESS = "sop.platform-process";
String ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE = "sop_inst.inst_param.custom_data.update";
//上报给cdp的相关信息常量(cdp那边固定)
String DATA_REPORT_QUEUE_NAME = "dataReport_queue";
String DATA_REPORT_EXCHANGE_NAME = "dataReport_exchange";
String DATA_REPORT_TOPIC = "dataReport.#";
String DATA_REPORT_ROUTING_KEY = "dataReport.customer.event";
}
package cn.com.glsx.process.modules.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopDataSource;
import cn.com.glsx.process.modules.mapper.SopDataSourceMapper;
@Service
public class SopDataSourceService {
@Autowired
private SopDataSourceMapper sopDataSourceMapper;
public SopDataSource getById(Integer id){
return sopDataSourceMapper.selectByPrimaryKey(id);
};
public SopDataSource findByDataSourceId(String dataSourceId) {
return sopDataSourceMapper.findByDataSourceId(dataSourceId);
}
}
package cn.com.glsx.process.modules.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.mapper.SopInstBatchMapper;
@Service
public class SopInstBatchService {
@Autowired
private SopInstBatchMapper sopInstBatchMapper;
/**
* 根据id查询
*
* @param batchNo
* @return
*/
private SopInstBatch findById(String batchNo) {
return sopInstBatchMapper.selectByPrimaryKey(batchNo);
}
/**
* 保存
*
* @param sopInstBatch
* @return
*/
public int insert(SopInstBatch sopInstBatch) {
return sopInstBatchMapper.insertUseGeneratedKeys(sopInstBatch);
}
/**
* 更新
*
* @param sopInstBatch
* @return
*/
public boolean update(SopInstBatch sopInstBatch) {
int i = sopInstBatchMapper.updateByPrimaryKeySelective(sopInstBatch);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param batchNo
* @return
*/
public boolean delete(String batchNo) {
int i = sopInstBatchMapper.deleteByPrimaryKey(batchNo);
if (i > 0) {
return true;
}
return false;
}
}
package cn.com.glsx.process.modules.service;
import cn.com.glsx.process.modules.entity.SopInstNode;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.mapper.SopInstLinkMapper;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SopInstLinkService {
@Autowired
private SopInstLinkMapper sopInstMapper;
@Autowired
private SopInstNodeService sopInstNodeService;
/**
* 根据id查询
*
* @param linkId
* @return
*/
private SopInstLink findById(Integer linkId) {
return sopInstMapper.selectByPrimaryKey(linkId);
}
/**
* 保存
*
* @param sopInstLink
* @return
*/
public int insert(SopInstLink sopInstLink) {
return sopInstMapper.insertUseGeneratedKeys(sopInstLink);
}
/**
* 更新
*
* @param sopInstLink
* @return
*/
public boolean update(SopInstLink sopInstLink) {
int i = sopInstMapper.updateByPrimaryKeySelective(sopInstLink);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param linkId
* @return
*/
public boolean delete(Integer linkId) {
int i = sopInstMapper.deleteByPrimaryKey(linkId);
if (i > 0) {
return true;
}
return false;
}
/**
* 递归查询实例树结构
*
* @param instId
* @return
*/
public List<SopInstNode> findByInstId(String instId) {
List<SopInstLink> byInstId = sopInstMapper.findByInstId(instId);
List<SopInstNode> sopInstNodes = sopInstNodeService.findByInstId(instId);
List<SopInstNode> collected = sopInstNodes.stream().filter(index -> index.getNodeId().intValue() == 1).collect(Collectors.toList());
setchildren(collected, byInstId, sopInstNodes);
return collected;
}
private void setchildren(List<SopInstNode> sopInstNode, List<SopInstLink> byInstId, List<SopInstNode> sopInstNodes) {
for (SopInstNode instNode : sopInstNode) {
Integer nodeId = instNode.getNodeId();
List<Integer> collect = byInstId.stream().filter(index -> index.getSourceId().intValue() == nodeId).map(SopInstLink::getTargetId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
instNode.setSopInstNodeList(sopInstNodes.stream().filter(index -> collect.contains(index.getNodeId())).collect(Collectors.toList()));
setchildren(instNode.getSopInstNodeList(), byInstId, sopInstNodes);
}
continue;
}
}
}
package cn.com.glsx.process.modules.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.mapper.SopInstNodeBatchMapper;
@Service
public class SopInstNodeBatchService {
@Autowired
private SopInstNodeBatchMapper sopInstNodeBatchMapper;
/**
* 根据id查询
*
* @param nodeBatchNo
* @return
*/
private SopInstNodeBatch findById(String nodeBatchNo) {
return sopInstNodeBatchMapper.selectByPrimaryKey(nodeBatchNo);
}
/**
* 保存
*
* @param sopInstNodeBatch
* @return
*/
public int insert(SopInstNodeBatch sopInstNodeBatch) {
return sopInstNodeBatchMapper.insertUseGeneratedKeys(sopInstNodeBatch);
}
/**
* 更新
*
* @param sopInstNodeBatch
* @return
*/
public boolean update(SopInstNodeBatch sopInstNodeBatch) {
int i = sopInstNodeBatchMapper.updateByPrimaryKeySelective(sopInstNodeBatch);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param nodeBatchNo
* @return
*/
public boolean delete(String nodeBatchNo) {
int i = sopInstNodeBatchMapper.deleteByPrimaryKey(nodeBatchNo);
if (i > 0) {
return true;
}
return false;
}
}
package cn.com.glsx.process.modules.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.mapper.SopInstNodeMapper;
import java.util.List;
@Service
public class SopInstNodeService {
@Autowired
private SopInstNodeMapper sopInstNodeMapper;
/**
* 根据id查询
*
* @param instNodeId
* @return
*/
private SopInstNode findById(Integer instNodeId) {
return sopInstNodeMapper.selectByPrimaryKey(instNodeId);
}
/**
* 保存
*
* @param sopInstNode
* @return
*/
public int insert(SopInstNode sopInstNode) {
return sopInstNodeMapper.insertUseGeneratedKeys(sopInstNode);
}
/**
* 更新
*
* @param sopInstNode
* @return
*/
public boolean update(SopInstNode sopInstNode) {
int i = sopInstNodeMapper.updateByPrimaryKeySelective(sopInstNode);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param instNodeId
* @return
*/
public boolean delete(Integer instNodeId) {
int i = sopInstNodeMapper.deleteByPrimaryKey(instNodeId);
if (i > 0) {
return true;
}
return false;
}
public List<SopInstNode> findByInstId(String instId) {
return sopInstNodeMapper.findByInstId( instId);
}
}
package cn.com.glsx.process.modules.service;
import cn.com.glsx.cdp.api.customer.CustomerSopJourneyFeignClient;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDetailDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.cdp.modules.model.customer.ModifySopJourneyStageRequest;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.modules.converter.SopInstConverter;
import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.converter.SopTplLinKConverter;
import cn.com.glsx.process.modules.converter.SopTplNodeConverter;
import cn.com.glsx.process.modules.entity.*;
import cn.com.glsx.process.modules.mapper.*;
import cn.com.glsx.process.modules.model.*;
import cn.com.glsx.process.modules.model.enums.*;
import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
import cn.com.glsx.process.modules.rabbitmq.RabbitMQConstants;
import cn.com.glsx.process.util.FileUploadServerData;
import cn.com.glsx.process.util.FileUploadUtil;
import cn.com.glsx.process.util.SopTplParamHandler;
import cn.hutool.core.date.DatePattern;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.enums.SysConstants;
import com.glsx.plat.core.web.Result;
import com.glsx.plat.office.excel.EasyExcelUtils;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
import java.io.ByteArrayOutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class SopInstService {
@Autowired
private SopInstMapper sopInstMapper;
@Autowired
private SopInstLinkMapper sopInstLinkMapper;
@Autowired
private SopInstNodeMapper sopInstNodeMapper;
@Autowired
private SopTplMapper sopTplMapper;
@Autowired
private SopTplNodeMapper sopTplNodeMapper;
@Autowired
private SopTplLinkMapper sopTplLinkMapper;
@Autowired
private SopTplGrantMapper sopTplGrantMapper;
@Autowired
private CustomerSopJourneyFeignClient customerSopJourneyFeignClient;
@Autowired
private MsgProducer msgProducer;
/**
* 根据id查询
*
* @param instId
* @return
*/
public SopInstDTO findById(String instId) {
SopInst sopInst = sopInstMapper.selectByPrimaryKey(instId);
return getSopInstOtherInfo(sopInst);
}
/**
* 保存
*
* @param sopInst
* @return
*/
public int insert(SopInst sopInst) {
return sopInstMapper.insertUseGeneratedKeys(sopInst);
}
/**
* 更新
*
* @param sopInst
* @return
*/
public boolean update(SopInst sopInst) {
int i = sopInstMapper.updateByPrimaryKeySelective(sopInst);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param instId
* @return
*/
public boolean delete(String instId) {
int i = sopInstMapper.deleteByPrimaryKey(instId);
if (i > 0) {
return true;
}
return false;
}
/**
* 查询SOP门店模板实例分页列表
*
* @param search
* @return
*/
public PageInfo<SopInst> selectByGroupId(SopInstSearch search) {
//临时固定
search.setPageSize(1000);
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<SopInst> list = sopInstMapper.selectByGroupId(search);
return new PageInfo<>(list);
}
/**
* 通过实例默认输入参数查询指定门店模板实例
*
* @param customData
* @return
*/
public SopInstDTO getOneByCustomData(Map<String, Object> customData) {
List<SopInst> sopInsts = sopInstMapper.selectByCustomData(customData);
if (CollectionUtils.isEmpty(sopInsts)) {
return null;
}
if (sopInsts.size() > 1) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "根据查询条件找到多条记录,请检查参数是否有误!");
}
return getSopInstOtherInfo(sopInsts.get(0));
}
/**
* 补充门店旅程实例其它信息
*
* @param sopInst
* @return
*/
private SopInstDTO getSopInstOtherInfo(SopInst sopInst) {
if (sopInst == null) {
return null;
}
SopInstDTO sopInstDTO = SopInstConverter.INSTANCE.do2dto(sopInst);
String instId = sopInstDTO.getInstId();
List<SopInstNode> nodes = sopInstNodeMapper
.selectByExample(Example.builder(SopInstNode.class).where(Sqls.custom().andEqualTo("instId", instId)).build());
sopInstDTO.setNodes(nodes);
List<SopInstLink> links = sopInstLinkMapper
.selectByExample(Example.builder(SopInstLink.class).where(Sqls.custom().andEqualTo("instId", instId)).build());
sopInstDTO.setLinks(links);
return sopInstDTO;
}
/**
* 更新门店模板实例默认参数的自定义参数
*
* @param instId 实例id
* @param customData 自定义参数
* @return
*/
@Transactional
public Result<String> updateInstParamCustomData(String instId, Map<String, Object> customData) {
Result<String> result = Result.success("success");
SopInst sopInst = sopInstMapper.selectByPrimaryKey(instId);
if (sopInst == null || sopInst.getInstStatus().equals(SopInstStatusEnum.DELETED.getValue())) {
result = Result.failure();
result.setMessage("模板实例不存在或已关闭");
return result;
}
if (sopInst.getInstStatus().equals(SopInstStatusEnum.NORMAL.getValue())) {
result = Result.failure();
result.setMessage("模板实例已开启,此参数不允许再变更");
return result;
}
Object activityId = customData.get("activityId");
if (!Objects.isNull(activityId)) {
HashMap<String, Object> tMap = new HashMap<>();
tMap.put("activityId", activityId);
SopInstDTO existInst = getOneByCustomData(tMap);
if (Objects.nonNull(existInst)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), String.format("该活动已关联‘%s’实例,不能再关联", existInst.getInstName()));
}
}
sopInstMapper.updateInstParamCustomData(instId, customData);
//发送字段数据变更通知消息
customData.put("instId", instId);
msgProducer.topicSend(RabbitMQConstants.ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE, customData);
return result;
}
/**
* 更新SOP门店模板实例状态
*
* @param instId
* @param status
* @return
*/
@Transactional
public Result<String> updateInstStatus(String instId, Byte status) {
Result<String> result = Result.success("success");
SopInst sopInst = sopInstMapper.selectByPrimaryKey(instId);
if (sopInst == null || sopInst.getInstStatus().equals(SopInstStatusEnum.DELETED.getValue())) {
result = Result.failure();
result.setMessage("模板实例不存在或已关闭");
return result;
}
Byte instStatus = sopInst.getInstStatus();
if (instStatus.equals(SopInstStatusEnum.UNUSED.getValue())) {
if (!status.equals(SopInstStatusEnum.NORMAL.getValue())) {
result = Result.failure();
result.setMessage("参数错误,模板实例未开启,只能开启");
return result;
}
} else {
if (!status.equals(SopInstStatusEnum.DELETED.getValue())) {
result = Result.failure();
result.setMessage("参数错误,模板实例已开启,只能关闭");
return result;
}
}
sopInstMapper.updateInstStatus(instId, status);
return result;
}
/**
* 查询模板实例分页列表
*
* @param search
* @return
*/
public PageInfo<SopInstDTO> page(SopInstSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<SopInstDTO> list = sopInstMapper.page(search);
return new PageInfo<>(list);
}
/**
* 模板批量下发门店
*
* @param sopInstDTO
*/
@Transactional
public void add(SopInstDTO sopInstDTO) {
String tplId = sopInstDTO.getTplId();
SopTplDTO sopTplDTO = sopTplMapper.getById(tplId);
if (Objects.isNull(sopTplDTO)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "模板不存在!");
}
SopTplNode nodeQuery = new SopTplNode();
nodeQuery.setTplId(tplId);
List<SopTplNode> nodes = sopTplNodeMapper.select(nodeQuery);
SopTplLink linkQuery = new SopTplLink();
linkQuery.setTplId(tplId);
List<SopTplLink> links = sopTplLinkMapper.select(linkQuery);
List<SopTplGrant> sopTplGrants = sopInstDTO.getSopTplGrants();
if (CollectionUtils.isEmpty(sopTplGrants)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "请选择门店");
}
if (SopTplSingletonEnum.TRUE.getValue() == sopTplDTO.getTplSingleton()) {
List<String> groupIds = sopTplGrants.stream().map(sopTplGrant -> sopTplGrant.getGroupId()).collect(Collectors.toList());
List<SopTplGrant> grants = sopTplGrantMapper.selectInUseGrants(tplId, groupIds);
if (!CollectionUtils.isEmpty(grants)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), String.format("%s已存在该旅程,请确认后重新操作", grants.get(0).getGroupName()));
}
}
//新增派发门店记录
Date date = new Date();
sopTplGrants.forEach(sopTplGrant -> {
sopTplGrant.setTplId(tplId);
sopTplGrant.setGrantStatus(SopTplGrant.GRANT_STATUS_NORMAL);
sopTplGrant.setCreateTime(date);
sopTplGrant.setUpdateTime(date);
});
sopTplGrantMapper.insertList(sopTplGrants);
List<SopInstNode> nodesCustom = sopInstDTO.getNodes();
HashMap<Integer, SopInstNode> customNodesMap = new HashMap<>();
nodesCustom.forEach(sopInstNode -> customNodesMap.put(sopInstNode.getNodeId(), sopInstNode));
SopTplConverter sopTplConverter = SopTplConverter.INSTANCE;
SopTplLinKConverter sopTplLinKConverter = SopTplLinKConverter.INSTANCE;
SopTplNodeConverter sopTplNodeConverter = SopTplNodeConverter.INSTANCE;
for (SopTplGrant sopTplGrant : sopTplGrants) {
Integer grantId = sopTplGrant.getGrantId();
//克隆模板内容
SopInst sopInst = sopTplConverter.dto2inst(sopTplDTO);
sopInst.setInstName(String.format("%s-%s", sopTplGrant.getGroupName(), sopTplDTO.getTplName()));
sopInst.setInstId(tplId + grantId);
sopInst.setGrantId(grantId);
// 处理模板定义的初始化参数
sopInst.setInstParam(SopTplParamHandler.addMerchantId(SopTplParamHandler.extract(sopTplDTO.getTplParamDef()), sopTplGrant.getGroupId()) );
sopInst.setCreateTime(date);
sopInst.setUpdateTime(date);
sopInst.setInstStatus(SopInstStatusEnum.UNUSED.getValue());
sopInstMapper.insert(sopInst);
//克隆连接
String instId = sopInst.getInstId();
List<SopInstLink> sopInstLinks = new ArrayList<>();
links.forEach(sopTplLink -> {
SopInstLink sopInstLink = sopTplLinKConverter.tpl2inst(sopTplLink);
sopInstLink.setInstId(instId);
sopInstLinks.add(sopInstLink);
});
sopInstLinkMapper.insertList(sopInstLinks);
//克隆节点
List<SopInstNode> sopInstNodes = new ArrayList<>();
for (SopTplNode sopTplNode : nodes) {
SopInstNode sopInstNode = sopTplNodeConverter.tpl2inst(sopTplNode);
sopInstNode.setInstId(instId);
sopInstNode.setNodeStatus(SopInstNodeStatusEnum.NORMAL.getValue());
// 处理模板节点定义的初始化参数
sopInstNode.setNodeParam(SopTplParamHandler.extract(sopTplNode.getNodeParamDef()));
//页面选择是否跳过处理
SopInstNode sopInstNodeTemp = customNodesMap.get(sopInstNode.getNodeId());
if (!Objects.isNull(sopInstNodeTemp)
&& sopInstNodeTemp.getNodeSkip().equals(SopInstNodeSkipEnum.TRUE.getValue())
&& sopTplNode.getNodeSkipable().equals(SopTplNodeSkipableEnum.NO.getValue())) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), String.format("节点 %s 不可跳过", sopInstNode.getNodeName()));
}
sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp) ? sopInstNodeTemp.getNodeSkip() : SopInstNodeSkipEnum.FALSE.getValue());
sopInstNodes.add(sopInstNode);
}
sopInstNodeMapper.insertList(sopInstNodes);
}
}
/**
* 查询模板实例客户分页列表
*
* @param search
* @return
*/
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
String sopJourneyId = search.getSopJourneyId();
SopInst sopInst = sopInstMapper.selectByPrimaryKey(sopJourneyId);
if (Objects.isNull(sopInst)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "该模板实例不存在!");
}
SopTplGrant sopTplGrant = sopTplGrantMapper.selectByPrimaryKey(sopInst.getGrantId());
// 改converter转换
CustomerSopJourneySearch request = new CustomerSopJourneySearch();
request.setPageNum(search.getPageNumber());
request.setPageSize(search.getPageSize());
request.setOrgId(sopTplGrant.getGroupId());
request.setSopJourneyIds(Lists.newArrayList(sopJourneyId));
String sopJourneyStage = search.getSopJourneyStage();
request.setSopJourneyStages(StringUtils.hasLength(sopJourneyStage) ? Lists.newArrayList(sopJourneyStage) : null);
String customerPhone = search.getCustomerPhone();
request.setCustomerPhones(StringUtils.hasLength(customerPhone) ? Lists.newArrayList(customerPhone) : null);
request.setCustomerName(search.getCustomerName());
request.setWechatNickname(search.getWechatNickname());
String sopFollowUpPersonId = search.getSopFollowUpPersonId();
request.setSopFollowUpPersonIds(StringUtils.hasLength(sopFollowUpPersonId) ? Lists.newArrayList(sopFollowUpPersonId) : null);
request.setSopFollowUpPersonPhone(search.getSopFollowUpPersonPhone());
request.setSopJourneyEnterTimeBegin(search.getSopJourneyEnterTimeBegin());
request.setSopJourneyEnterTimeEnd(search.getSopJourneyEnterTimeEnd());
return customerSopJourneyFeignClient.pageCustomerSopJourney(request);
}
/**
* 查询模板实例客户详细信息
*
* @param search
* @return
*/
public Result<CustomerSopJourneyDetailDTO> customerDetail(SopCustomerSearch search) {
return customerSopJourneyFeignClient.detail(search.getOrgId(), search.getSopJourneyId(), search.getOneId());
}
/**
* 单个更新旅程客户阶段
*
* @param body
* @return
*/
public Result<Boolean> stageUpdate(SopJourneyStageUpdate body) {
String orgId = body.getOrgId();
String sopJourneyId = body.getSopJourneyId();
String oneId = body.getOneId();
Result<CustomerSopJourneyDetailDTO> detail = customerSopJourneyFeignClient.detail(orgId, sopJourneyId, oneId);
if (!SysConstants.ResultStatus.success.getCode().equals(detail.getCode())) {
throw new AdminException(ResultEnum.FEIGN_REQUEST_ERROR.getCode(), "查询客户信息异常");
}
CustomerSopJourneyDetailDTO customerDetail = detail.getData();
if (Objects.isNull(customerDetail)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "客户信息不存在");
}
ModifySopJourneyStageRequest request = new ModifySopJourneyStageRequest();
request.setOrgId(orgId);
request.setSopJourneyId(sopJourneyId);
request.setOneIds(Lists.newArrayList(oneId));
request.setSopJourneyStage(body.getSopJourneyStage());
request.setOprBy(body.getOprBy());
Result<Boolean> booleanResult = customerSopJourneyFeignClient.modifyStage(request);
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
HashMap<String, Object> mqMap = new HashMap<>();
mqMap.put("org_id", orgId);
mqMap.put("add_way", "SOP");
mqMap.put("customer_phone", customerDetail.getCustomerPhone());
mqMap.put("event_time", sdf.format(now));
mqMap.put("event_type", "MODIFY_SOP_JOURNEY_STAGE");
mqMap.put("platform", "WebPage");
mqMap.put("extra", body);
msgProducer.topicSend(RabbitMQConstants.DATA_REPORT_EXCHANGE_NAME, RabbitMQConstants.DATA_REPORT_ROUTING_KEY, Lists.newArrayList(mqMap));
return booleanResult;
}
public FileUploadServerData customersExport(SopCustomerSearch search) {
search.setPageSize(5000);
SopInst sopInst = sopInstMapper.selectByPrimaryKey(search.getSopJourneyId());
if (Objects.isNull(sopInst)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "模板实例不存在");
}
List<SopCustomerExcelDTO> data = new ArrayList<>();
List<CustomerSopJourneyDTO> customerSopJourneyDTOList = new ArrayList<>();
getCustomersForExcel(search, customerSopJourneyDTOList);
if (CollectionUtils.isEmpty(customerSopJourneyDTOList)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "当前数据列表为空,请重新选择");
}
customerSopJourneyDTOList.parallelStream().forEach(customerSopJourneyDTO -> {
SopCustomerExcelDTO sopCustomerExcelDTO = new SopCustomerExcelDTO();
sopCustomerExcelDTO.setCustomerName(customerSopJourneyDTO.getCustomerName());
sopCustomerExcelDTO.setCustomerPhone(customerSopJourneyDTO.getCustomerPhone());
sopCustomerExcelDTO.setWechatNickname(customerSopJourneyDTO.getWechatNickname());
sopCustomerExcelDTO.setSopJourneyName(sopInst.getInstName());
sopCustomerExcelDTO.setSopJourneyEnterTime(customerSopJourneyDTO.getSopJourneyEnterTime());
sopCustomerExcelDTO.setSopJourneyStage(customerSopJourneyDTO.getSopJourneyStage());
sopCustomerExcelDTO.setSopJourneyStageEnterTime(customerSopJourneyDTO.getSopJourneyStageEnterTime());
data.add(sopCustomerExcelDTO);
});
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcel(outputStream, data, "客户数据", SopCustomerExcelDTO.class);
byte[] bytes = outputStream.toByteArray();
Date now = new Date();
FileUploadServerData fileUploadServerData = FileUploadUtil.uploadToFileSystem(String.format("客户数据_%d", now.getTime()), bytes, "xlsx");
return fileUploadServerData;
} catch (Exception e) {
throw new AdminException(ResultEnum.DATA_HANDLE_ERROR.getCode(), "客户数据导出处理异常");
}
}
private void getCustomersForExcel(SopCustomerSearch search, List<CustomerSopJourneyDTO> customerSopJourneyDTOList) {
Result<PageInfo<CustomerSopJourneyDTO>> customersResult = customers(search);
if (!SysConstants.ResultStatus.success.getCode().equals(customersResult.getCode())) {
throw new AdminException(ResultEnum.FEIGN_REQUEST_ERROR.getCode(), "查询客户数据接口异常");
}
PageInfo<CustomerSopJourneyDTO> pageInfo = customersResult.getData();
List<CustomerSopJourneyDTO> list = pageInfo.getList();
if (CollectionUtils.isEmpty(list)) {
return;
}
customerSopJourneyDTOList.addAll(list);
if (search.getPageNumber() < pageInfo.getPages()) {
search.setPageNumber(search.getPageNumber() + 1);
getCustomersForExcel(search, customerSopJourneyDTOList);
}
}
}
package cn.com.glsx.process.modules.service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.quartz.CronExpression;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.nacos.shaded.com.google.common.collect.Maps;
import com.alibaba.nacos.shaded.com.google.common.collect.Sets;
import com.glsx.plat.common.utils.SnowFlake;
import com.google.common.collect.Lists;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.entity.SopTpl;
import cn.com.glsx.process.modules.entity.SopTplLink;
import cn.com.glsx.process.modules.entity.SopTplNode;
import cn.com.glsx.process.modules.mapper.SopInstBatchMapper;
import cn.com.glsx.process.modules.mapper.SopInstLinkMapper;
import cn.com.glsx.process.modules.mapper.SopInstMapper;
import cn.com.glsx.process.modules.mapper.SopInstNodeBatchMapper;
import cn.com.glsx.process.modules.mapper.SopInstNodeMapper;
import cn.com.glsx.process.modules.mapper.SopTplGrantMapper;
import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
import cn.com.glsx.process.modules.mapper.SopTplMapper;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;
/**
* SOP服务
*
* @author kome
* @date 2023年9月10日 下午5:05:24
*/
@Service
@Slf4j
public class SopService {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private SopTplMapper tplMapper;
@Resource
private SopTplNodeMapper tplNodeMapper;
@Resource
private SopTplLinkMapper tplLinkMapper;
@Resource
private SopTplGrantMapper grantMapper;
@Resource
private SopInstMapper instMapper;
@Resource
private SopInstNodeMapper instNodeMapper;
@Resource
private SopInstLinkMapper instLinkMapper;
@Resource
private SopInstBatchMapper instBatchMapper;
@Resource
private SopInstNodeBatchMapper instNodeBatchMapper;
/**
* 加载全部实例。根据实例状态创建或调整动态任务。
*
* @return
*/
public List<SopInst> loadAllInst() {
List<SopInst> all = instMapper.selectAll();
return all;
}
public SopStruct loadSopByInstNodeId(Integer instNodeId) {
SopInstNode instNode = instNodeMapper.selectByPrimaryKey(instNodeId);
return loadSop(instNode.getInstId());
}
public SopStruct loadSop(String instId) {
SopStruct sop = new SopStruct();
SopInst inst = instMapper.selectByPrimaryKey(instId);
sop.setInst(inst);
if (inst == null) {
log.warn("Sop实例不存在:{}", instId);
return null;
}
// 过期机制
if (inst.getExpireTime() != null && inst.getExpireTime().before(new Date())) {
inst.setInstStatus((byte) -1);
}
// SopTplGrant grant = grantMapper.selectByPrimaryKey(inst.getGrantId());
// sop.setGrant(grant);
// SopTpl tpl = tplMapper.selectByPrimaryKey(grant.getTplId());
// sop.setTpl(tpl);
// List<SopTplNode> tplNodes = tplNodeMapper
// .selectByExample(Example.builder(SopTplNode.class).where(Sqls.custom().andEqualTo("tplId", grant.getTplId())).build());
// Map<Integer, SopTplNode> tplNodeMap = tplNodes.stream().collect(Collectors.toMap(SopTplNode::getNodeId, obj -> obj, (key1, key2) -> key1));
// sop.setTplNodeMap(tplNodeMap);
List<SopInstNode> instNodes = instNodeMapper
.selectByExample(Example.builder(SopInstNode.class).where(Sqls.custom().andEqualTo("instId", inst.getInstId())).build());
Map<Integer, SopInstNode> instNodeMap = instNodes.stream()
.collect(Collectors.toMap(SopInstNode::getNodeId, obj -> obj, (key1, key2) -> key1));
sop.setInstNodeMap(instNodeMap);
List<SopInstLink> instLinks = instLinkMapper
.selectByExample(Example.builder(SopInstLink.class).where(Sqls.custom().andEqualTo("instId", inst.getInstId())).build());
Map<Integer, Pair<Set<Integer>, Set<Integer>>> linkMap = Maps.newHashMap();
for (SopInstLink sl : instLinks) {
// 找出每个节点的上下节点
Pair<Set<Integer>, Set<Integer>> src = linkMap.getOrDefault(sl.getSourceId(),
new Pair<Set<Integer>, Set<Integer>>(Sets.newHashSet(), Sets.newHashSet()));
Pair<Set<Integer>, Set<Integer>> tgt = linkMap.getOrDefault(sl.getTargetId(),
new Pair<Set<Integer>, Set<Integer>>(Sets.newHashSet(), Sets.newHashSet()));
linkMap.put(sl.getSourceId(), src);
linkMap.put(sl.getTargetId(), tgt);
src.getValue().add(sl.getTargetId());
tgt.getKey().add(sl.getSourceId());
}
sop.setInstLinkMap(linkMap);
if (StrUtil.isNotBlank(inst.getBatchNo())) {
SopInstBatch batch = instBatchMapper.selectByPrimaryKey(inst.getBatchNo());
sop.setBatch(batch);
}
return sop;
}
public SopInstBatch createBatch(SopStruct sop) {
SopInst sopInst = sop.getInst();
SopInstBatch batch = new SopInstBatch();
batch.setBatchNo(SnowFlake.nextSerialNumber());
batch.setCreateTime(new Date());
batch.setUpdateTime(new Date());
batch.setInstId(sopInst.getInstId());
SnapshotStruct ss = JacksonUtils.fromJson(StrUtil.blankToDefault(sopInst.getInstSnapshot(), "{}"), SnapshotStruct.class);
ss.getResultMap().clear();
batch.setSnapshot(JacksonUtils.toJson(ss));
instBatchMapper.insert(batch);
instMapper.updateInstBatchNo(sopInst.getInstId(), batch.getBatchNo(), batch.getSnapshot());
// 重置节点执行次数
instNodeMapper.resetInstNodeDailyCount(sopInst.getInstId());
for (SopInstNode node : sop.getInstNodeMap().values()) {
if (StrUtil.isBlank(node.getNodeExpireCron())) {
continue;
}
try {
Date expire = new CronExpression(node.getNodeExpireCron()).getNextValidTimeAfter(new Date());
node.setDailyExpire(expire);
instNodeMapper.updateByPrimaryKey(node);
} catch (Exception e) {
log.info("【{}】过期格式不对:{}", node.getNodeName(), node.getNodeExpireCron(), e);
}
}
sop.setBatch(batch);
return batch;
}
public SopInstNodeBatch createNodeBatch(SopInst sopInst, Integer instNodeId) {
SopInstNodeBatch curBatch = new SopInstNodeBatch();
curBatch.setBatchNo(sopInst.getBatchNo());
curBatch.setNodeBatchNo(SnowFlake.nextSerialNumber());
curBatch.setCreateTime(new Date());
curBatch.setUpdateTime(new Date());
curBatch.setInstNodeId(instNodeId);
curBatch.setSnapshot(StrUtil.blankToDefault(sopInst.getInstSnapshot(), "{}"));
instNodeBatchMapper.insert(curBatch);
return curBatch;
}
public void updateNodeBatch(SopInst sopInst, SopInstNode node, SopInstBatch batch, SopInstNodeBatch nodeBatch) {
if (nodeBatch != null) {
instNodeBatchMapper.updateByPrimaryKey(nodeBatch);
}
if (batch != null) {
instBatchMapper.updateByPrimaryKey(batch);
}
// 过期机制
if (sopInst.getExpireTime() != null && sopInst.getExpireTime().before(new Date())) {
sopInst.setInstStatus((byte) -1);
}
instMapper.updateByPrimaryKey(sopInst); // 更新快照
instNodeMapper.updateByPrimaryKey(node); // 更新执行次数
}
/** 从实例倒推出模板,主要用于开发阶段 */
@Transactional
public void generateTplFromInst(SopStruct sop) {
// 预备模板
SopTpl tpl = new SopTpl();
tpl.setCreateTime(new Date());
tpl.setTplCron(sop.getInst().getInstCron());
tpl.setTplId(StrUtil.sub(SnowFlake.nextSerialNumber(), 0, 8)); // 随机生成模板id
tpl.setTplName(sop.getInst().getInstName());
// 生成参数定义
tpl.setTplParamDef(parseDef(sop.getInst().getInstParam()));
tpl.setTplRemark("从实例自动产生模板:" + sop.getInst().getInstName());
tpl.setTplResultDef(sop.getInst().getInstSnapshot());
tpl.setTplSingleton((byte) 1);
tpl.setTplStatus((byte) 1);
tpl.setUpdateTime(new Date());
tplMapper.insert(tpl);
List<SopTplNode> nodes = Lists.newArrayList();
for (SopInstNode node : sop.getInstNodeMap().values()) {
SopTplNode tnode = new SopTplNode();
tnode.setDailyLimit(node.getDailyLimit());
tnode.setNodeAsync(node.getNodeAsync());
tnode.setNodeContentDef(node.getNodeContent());
tnode.setNodeCron(node.getNodeCron());
tnode.setNodeExpireCron(node.getNodeExpireCron());
tnode.setNodeId(node.getNodeId());
tnode.setNodeKey(node.getNodeKey());
tnode.setNodeLabel(node.getNodeLabel());
tnode.setNodeName(node.getNodeName());
tnode.setNodeParamDef(parseDef(node.getNodeParam()));
tnode.setNodeResultDef(node.getNodeContent());
tnode.setNodeShow(node.getNodeShow());
tnode.setNodeSkipable(node.getNodeSkip());
tnode.setNodeType(node.getNodeType());
tnode.setNodeVisible(node.getNodeVisible());
tnode.setTplId(tpl.getTplId());
nodes.add(tnode);
}
tplNodeMapper.insertList(nodes);
List<SopTplLink> links = Lists.newArrayList();
for (Entry<Integer, Pair<Set<Integer>, Set<Integer>>> entry : sop.getInstLinkMap().entrySet()) {
if (entry.getValue().getValue().isEmpty()) {
continue;
}
int sourceId = entry.getKey();
for (int targetId : entry.getValue().getValue()) {
SopTplLink link = new SopTplLink();
link.setSourceId(sourceId);
link.setTargetId(targetId);
link.setTplId(tpl.getTplId());
links.add(link);
}
}
tplLinkMapper.insertList(links);
}
/**
* <code>
{
"day": {
"paramName": "day",
"paramDesc": "有意向第?天",
"valueType": "Integer",
"defaultValue": "2",
"required": true
},
"textContent": {
"paramName": "textContent",
"paramDesc": "营销文案",
"valueType": "String",
"defaultValue": "尊敬的${userName},优惠券领取url.cn/c134dqwe",
"required": true
}
}
* </code>
*
* @param json
* @return
*/
private static String parseDef(String json) {
if (json == null || json.trim().length() < 1) {
return null;
}
JSONObject def = new JSONObject();
try {
JSONObject parse = JSONUtil.parseObj(json);
for (String key : parse.keySet()) {
Map<String, Object> map = Maps.newHashMap();
map.put("paramKey", key);
map.put("paramDesc", key);
Object value = parse.get(key);
String type = detectType(value);
map.put("valueType", type);
map.put("defaultValue", value);
map.put("required", true);
def.set(key, map);
}
} catch (Exception e) {
log.warn("json:{}", json, e);
}
return def.toString();
}
private static String detectType(Object value) {
String v = value.toString().trim();
if (NumberUtil.isNumber(v)) {
return "Number";
}
if (StrUtil.startWith(v, "{")) {
return "Map";
}
if (StrUtil.startWith(v, "[")) {
return "Array";
}
return "String";
}
}
package cn.com.glsx.process.modules.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import com.glsx.plat.exception.ResultException;
import com.glsx.plat.exception.SystemMessage;
import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.converter.SopTplLinKConverter;
import cn.com.glsx.process.modules.converter.SopTplNodeConverter;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstLink;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopTpl;
import cn.com.glsx.process.modules.entity.SopTplGrant;
import cn.com.glsx.process.modules.entity.SopTplLink;
import cn.com.glsx.process.modules.entity.SopTplNode;
import cn.com.glsx.process.modules.mapper.SopInstLinkMapper;
import cn.com.glsx.process.modules.mapper.SopInstMapper;
import cn.com.glsx.process.modules.mapper.SopInstNodeMapper;
import cn.com.glsx.process.modules.mapper.SopTplGrantMapper;
import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
import cn.com.glsx.process.modules.mapper.SopTplMapper;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
import cn.com.glsx.process.modules.model.SopTplGrantSearch;
import cn.com.glsx.process.modules.model.enums.SopInstStatusEnum;
@Service
public class SopTplGrantService {
@Resource
private SopTplGrantMapper sopTplGrantMapper;
@Resource
private SopInstMapper sopInstMapper;
@Resource
private SopInstLinkMapper sopInstLinkMapper;
@Resource
private SopInstNodeMapper sopInstNodeMapper;
@Resource
private SopTplMapper sopTplMapper;
@Resource
private SopTplNodeMapper sopTplNodeMapper;
@Resource
private SopTplLinkMapper sopTplLinkMapper;
public List<SopTplGrant> list(SopTplGrantSearch search) {
return sopTplGrantMapper.list(search);
}
@Transactional
public void del(Integer id) {
sopTplGrantMapper.del(id);
}
}
package cn.com.glsx.process.modules.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopTplLink;
import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
@Service
public class SopTplLinkService {
@Autowired
private SopTplLinkMapper sopTplLinkMapper;
/**
* 根据id查询
*
* @param linkId
* @return
*/
private SopTplLink findById(Integer linkId) {
return sopTplLinkMapper.selectByPrimaryKey(linkId);
}
/**
* 保存
*
* @param sopTplLink
* @return
*/
public int insert(SopTplLink sopTplLink) {
return sopTplLinkMapper.insertUseGeneratedKeys(sopTplLink);
}
/**
* 更新
*
* @param sopTplLink
* @return
*/
public boolean update(SopTplLink sopTplLink) {
int i = sopTplLinkMapper.updateByPrimaryKeySelective(sopTplLink);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param id
* @return
*/
public boolean delete(Integer id) {
int i = sopTplLinkMapper.deleteByPrimaryKey(id);
if (i > 0) {
return true;
}
return false;
}
}
package cn.com.glsx.process.modules.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopTplNode;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
@Service
public class SopTplNodeService {
@Autowired
private SopTplNodeMapper sopTplNodeMapper;
/**
* 根据id查询
*
* @param nodeId
* @return
*/
private SopTplNode findById(Integer nodeId) {
return sopTplNodeMapper.selectByPrimaryKey(nodeId);
}
/**
* 保存
*
* @param sopTplNode
* @return
*/
public int insert(SopTplNode sopTplNode) {
return sopTplNodeMapper.insertUseGeneratedKeys(sopTplNode);
}
/**
* 更新
*
* @param sopTplNode
* @return
*/
public boolean update(SopTplNode sopTplNode) {
int i = this.sopTplNodeMapper.updateByPrimaryKeySelective(sopTplNode);
if (i > 0) {
return true;
}
return false;
}
/**
* 根据id删除
*
* @param nodeId
* @return
*/
public boolean delete(Integer nodeId) {
int i = this.sopTplNodeMapper.deleteByPrimaryKey(nodeId);
if (i > 0) {
return true;
}
return false;
}
}
package cn.com.glsx.process.modules.service;
import java.util.List;
import java.util.Objects;
import javax.annotation.Resource;
import cn.com.glsx.process.modules.entity.SopTpl;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.com.glsx.process.modules.entity.SopTplLink;
import cn.com.glsx.process.modules.entity.SopTplNode;
import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
import cn.com.glsx.process.modules.mapper.SopTplMapper;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.model.SopTplSearch;
@Service
public class SopTplService {
@Resource
private SopTplMapper sopTplMapper;
@Resource
private SopTplNodeMapper sopTplNodeMapper;
@Resource
private SopTplLinkMapper sopTplLinkMapper;
public PageInfo<SopTplDTO> page(SopTplSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<SopTplDTO> list = sopTplMapper.page(search);
return new PageInfo<>(list);
}
/**
* 查询sop模板详情
*
* @param tplId
* @return
*/
public SopTplDTO getById(String tplId) {
SopTplDTO sopTplDTO = sopTplMapper.getById(tplId);
if (Objects.isNull(sopTplDTO)) {
return null;
}
SopTplNode nodeQuery = new SopTplNode();
nodeQuery.setTplId(tplId);
List<SopTplNode> nodes = sopTplNodeMapper.select(nodeQuery);
sopTplDTO.setNodes(nodes);
SopTplLink linkQuery = new SopTplLink();
linkQuery.setTplId(tplId);
List<SopTplLink> links = sopTplLinkMapper.select(linkQuery);
sopTplDTO.setLinks(links);
return sopTplDTO;
}
/**
* 查询所有模板
*
* @return
*/
public List<SopTpl> list() {
return sopTplMapper.selectAll();
}
}
package cn.com.glsx.process.modules.service; package cn.com.glsx.process.modules.service;
import cn.com.glsx.process.modules.converter.UserConverter; import java.util.ArrayList;
import cn.com.glsx.process.modules.entity.User; import java.util.Date;
import cn.com.glsx.process.modules.mapper.UserMapper; import java.util.List;
import cn.com.glsx.process.modules.model.UserDTO; import java.util.Map;
import cn.com.glsx.process.modules.model.UserSearch;
import javax.annotation.Resource;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.ObjectUtils; import com.glsx.plat.common.utils.ObjectUtils;
import com.glsx.plat.common.utils.SessionUtils;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.exception.ResultException; import com.glsx.plat.exception.ResultException;
import com.glsx.plat.exception.SystemMessage; import com.glsx.plat.exception.SystemMessage;
import com.glsx.plat.jwt.base.ComJwtUser; import com.glsx.plat.jwt.base.ComJwtUser;
import com.glsx.plat.jwt.util.JwtUtils; import com.glsx.plat.jwt.util.JwtUtils;
import com.glsx.plat.common.utils.SessionUtils;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource; import cn.com.glsx.process.job.xxljob.core.ExecutorRouteStrategyEnum;
import java.util.ArrayList; import cn.com.glsx.process.modules.converter.UserConverter;
import java.util.Date; import cn.com.glsx.process.modules.entity.User;
import java.util.List; import cn.com.glsx.process.modules.mapper.UserMapper;
import java.util.Map; import cn.com.glsx.process.modules.model.UserDTO;
import cn.com.glsx.process.modules.model.UserSearch;
import cn.com.glsx.process.modules.sop.execute.plugin.java.DynamicEngine;
import cn.com.glsx.process.redis.DistributedLockUtils;
import lombok.extern.slf4j.Slf4j;
/** /**
* @author liuyf * @author liuyf
...@@ -31,6 +40,7 @@ import java.util.Map; ...@@ -31,6 +40,7 @@ import java.util.Map;
* @date 2019年10月24日 下午2:37:40 * @date 2019年10月24日 下午2:37:40
*/ */
@Service @Service
@Slf4j
public class UserDemoService { public class UserDemoService {
@Resource @Resource
...@@ -130,4 +140,80 @@ public class UserDemoService { ...@@ -130,4 +140,80 @@ public class UserDemoService {
return user; return user;
} }
public void testRedis(User user) {
boolean b = DistributedLockUtils.lock(user.getAccount(), 1 * 1000);
if (b) {
try {
aa(user);
} catch (Exception e) {
//
} finally {
DistributedLockUtils.unlock(user.getAccount());
}
}
}
private void aa(User user) throws InterruptedException {
System.out.println(ExecutorRouteStrategyEnum.FIRST.name());
Thread.sleep(10 * 1000);
}
public Object testJava(String user) throws Exception {
DynamicEngine de = DynamicEngine.getInstance();
log.info("JAVA代码{}",user);
JSONObject jsonObject=new JSONObject();
jsonObject.put("merchantNo","44210895");
return de.execute("Controller", "import cn.com.glsx.process.modules.sop.SopHelper;\n" +
"import com.alibaba.fastjson.JSON;\n" +
"import com.alibaba.fastjson.JSONObject;\n" +
"import org.springframework.util.LinkedMultiValueMap;\n" +
"import org.springframework.util.MultiValueMap;\n" +
"\n" +
"\n" +
"/**\n" +
" * java执行器使用demo,rop请求,类名Controller,方法名execute\n" +
" * TODO 1.下发门店助手任务\n" +
" * TODO 2.查询到保日期\n" +
" */\n" +
"public class Controller {\n" +
"\n" +
" private final static String baseurl = \"http://rop-merchant.test.glsx.com.cn/rop-merchants/router\";\n" +
"\n" +
" private final static String method = \"merchants.api.open.findStaffListByMerchantNo\";\n" +
"\n" +
" public static JSON execute(JSON param) {\n" +
"\n" +
" // 将JSON字符串转换为Map\n" +
" // 将Map中的数据放入MultiValueMap中\n" +
" Object post = null;\n" +
" JSONObject jsonObject = (JSONObject) param;\n" +
" String nodeData = jsonObject.get(\"nodeData\") + \"\";\n" +
" String instSnapshot = jsonObject.get(\"instSnapshot\") + \"\";\n" +
"\n" +
" String sopId = jsonObject.get(\"sopId\") + \"\";\n" +
" String sopName = jsonObject.get(\"sopName\") + \"\";\n" +
" String nodeId = jsonObject.get(\"nodeId\") + \"\";\n" +
" String nodeName = jsonObject.get(\"nodeName\") + \"\";\n" +
"\n" +
" // TODO 组装任务需要的参数\n" +
"\n" +
" //\n" +
" MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();\n" +
" for (Object key : jsonObject.keySet()) {\n" +
" String keyString = (String) key;\n" +
" String value = (String) jsonObject.get(key);\n" +
" multiValueMap.add(keyString, value);\n" +
" }\n" +
" try {\n" +
" post = SopHelper.post(multiValueMap, Object.class, baseurl, method);\n" +
" } catch (Exception e) {\n" +
" throw new RuntimeException(e);\n" +
" }\n" +
" return (JSONObject) JSONObject.toJSON(post);\n" +
" }\n" +
"\n" +
"\n" +
"\n" +
"}", "execute", new Class[]{JSON.class}, new Object[]{jsonObject});
}
} }
package cn.com.glsx.process.modules.sop;
import lombok.Data;
import java.util.Date;
@Data
public class CustomerInfo {
private String orgId;
private String oneId;
private String customerName;
private String customerPhone;
private String sopJourneyId;
private Date sopJourneyEnterTime;
private String sopJourneyStage;
private Date sopJourneyStageEnterTime;
private String followStaffPhone;
private String messageContent;
private String messageId;
private String talkId;
private String vin;
private String arrivalDate;
}
package cn.com.glsx.process.modules.sop;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode;
import lombok.Data;
import java.util.Map;
@Data
public class SopExecutorResult {
private SopInst sopInst;
private SopInstNode sopInstNode;
private Map<String, Object> resultData;
public SopExecutorResult(SopInst sopInst, SopInstNode sopInstNode, Map<String, Object> resultData) {
this.sopInst = sopInst;
this.sopInstNode = sopInstNode;
this.resultData = resultData;
}
public SopExecutorResult() {
}
}
package cn.com.glsx.process.modules.sop;
import java.io.IOException;
import java.lang.reflect.Field;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.redis.DistributedLockUtils;
/**
* 封装部分操作,可以提供给Java执行器中的代码调用
*
* @author kome
* @date 2023年9月19日 下午4:35:12
*/
public class SopHelper {
private static final String SOP_INST_LOCK_NAMESPACE = "lock.sop.inst.";
private final static String appKey = "48e5e13229b82c1b4e6e8c96151f0637";
private final static String secret = "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b";
public static boolean lockInst(SopInst inst) {
String key = SOP_INST_LOCK_NAMESPACE + inst.getInstId();
return DistributedLockUtils.lock(key, 10 * 1000L, 3, 3 * 1000L);
}
public static void unlockInst(SopInst inst) {
String key = SOP_INST_LOCK_NAMESPACE + inst.getInstId();
DistributedLockUtils.unlock(key);
}
public static boolean diffDay(Date date, Integer diffdays) {
DateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
String end = dft.format(new Date());
String star = dft.format(date);
String[] star1 = star.split("-");
String[] end1 = end.split("-");
int days = 0;
if (Integer.parseInt(star1[0]) < Integer.parseInt(end1[0])) {
for (int i = Integer.parseInt(star1[0]); i < Integer.parseInt(end1[0]); i++) {
// 计算是否是瑞年
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
days += 366;
} else {
days += 365;
}
}
}
// 得到开始那一年已过去的日期
int starday = days(star1[0], star1[1], star1[2]);
// 得到结束那一年已过去的日期
int endday = days(end1[0], end1[1], end1[2]);
// 减去开始那一年已过去的日期,加上结束那一年已过去的日期
days = days - starday + endday;
return days == diffdays;
}
/**
* 获取构建的信息
*
* @param param 入参
* @return
*/
public static SopExecutorResult getExcustorParam(JSON param) {
JSONObject jsonObject = (JSONObject) param;
SopInst sopInst = (SopInst) jsonObject.get("sopInst");
SopInstNode sopInstNode = (SopInstNode) jsonObject.get("sopInstNode");
Map<String, Object> resultData = (Map<String, Object>) jsonObject.get("instSnapshot");
return new SopExecutorResult(sopInst, sopInstNode, resultData);
}
/**
* 获取匹配上的信息
*
* @param sopInstNode 节点信息
* @param resultData 上个节点返回的信息
* @return
*/
public static List<CustomerInfo> getMeetWithCustomer(SopInstNode sopInstNode, Map<String, Object> resultData) {
String nodeParam = sopInstNode.getNodeParam();
String key = "user" + getValueFromJsonString(nodeParam, "stageid");
// 拿到过滤出阶段的客户
List<CustomerInfo> customerInfoList = JSON.parseArray(JSON.toJSONString(resultData.get(key)), CustomerInfo.class);
String diffday = SopHelper.getValueFromJsonString(nodeParam, "day");
if (org.apache.commons.lang3.StringUtils.isEmpty(diffday)) {
return null;
}
if (CollectionUtils.isNotEmpty(customerInfoList)) {
// 距离旅程相差天数过滤
return customerInfoList.stream().filter(index -> SopHelper.diffDay(index.getSopJourneyStageEnterTime(), Integer.parseInt(diffday)))
.collect(Collectors.toList());
}
return null;
}
public static Map<String, Object> objectToMap(Object obj) {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
String fieldName = field.getName();
Object fieldValue = null;
try {
fieldValue = field.get(obj);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
map.put(fieldName, fieldValue);
}
return map;
}
public static String getValueFromJsonString(String jsonString, String objectName, String fieldName) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonString);
JsonNode objectNode = rootNode.get(objectName);
JsonNode fieldNode = objectNode.get(fieldName);
return fieldNode.asText();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String getValueFromJsonString(String jsonString, String objectName, String objectNameTwo, String fieldName) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonString);
JsonNode objectNode = rootNode.get(objectName);
JsonNode objectNodeTwo = objectNode.get(objectNameTwo);
JsonNode fieldNode = objectNodeTwo.get(fieldName);
return fieldNode.asText();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String getValueFromJsonString(String jsonString, String fieldName) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonString);
JsonNode fieldNode = rootNode.get(fieldName);
if (fieldNode != null) {
return fieldNode.asText();
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static <T> T post(MultiValueMap<String, String> paramsMap, Class<T> responseType, String baseurl, String method) throws Exception {
addBaseParam(paramsMap, method);
MultiValueMap<String, String> params = getSysParams();
params.putAll(paramsMap);
for (Map.Entry<String, String> entry : params.toSingleValueMap().entrySet()) {
if (StringUtils.isEmpty(entry.getValue())) {
params.remove(entry.getKey());
}
}
String sign = sign(params.toSingleValueMap(), secret);
params.add("sign", sign);
return new RestTemplate().postForObject(baseurl, params, responseType);
}
public static MultiValueMap<String, String> getSysParams() {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>(16);
params.add("appKey", appKey);
params.add("format", "json");
return params;
}
public static String sign(Map<String, String> paramValues, String secret) {
return sign(paramValues, (List) null, secret);
}
public static String sign(Map<String, String> paramValues, List<String> ignoreParamNames, String secret) {
try {
StringBuilder sb = new StringBuilder();
List<String> paramNames = new ArrayList(paramValues.size());
paramNames.addAll(paramValues.keySet());
Iterator var5;
String paramName;
if (ignoreParamNames != null && ignoreParamNames.size() > 0) {
var5 = ignoreParamNames.iterator();
while (var5.hasNext()) {
paramName = (String) var5.next();
paramNames.remove(paramName);
}
}
Collections.sort(paramNames);
sb.append(secret);
var5 = paramNames.iterator();
while (var5.hasNext()) {
paramName = (String) var5.next();
sb.append(paramName).append(paramValues.get(paramName));
}
sb.append(secret);
byte[] sha1Digest = getSHA1Digest(sb.toString());
return byte2hex(sha1Digest);
} catch (IOException var7) {
return null;
}
}
private static byte[] getSHA1Digest(String data) throws IOException {
Object var1 = null;
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] bytes = md.digest(data.getBytes("UTF-8"));
return bytes;
} catch (GeneralSecurityException var3) {
throw new IOException(var3);
}
}
private static String byte2hex(byte[] bytes) {
StringBuilder sign = new StringBuilder();
for (int i = 0; i < bytes.length; ++i) {
String hex = Integer.toHexString(bytes[i] & 255);
if (hex.length() == 1) {
sign.append("0");
}
sign.append(hex.toUpperCase());
}
return sign.toString();
}
private static void addBaseParam(MultiValueMap<String, String> paramsMap, String method) {
paramsMap.add("v", "1.0.0");
paramsMap.add("method", method);
paramsMap.add("name", "zhouhb");
}
public static int days(String year, String month, String day) {
int days = 0;
int nowyear = Integer.parseInt(year);
int[] monthday = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int[] monthday1 = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
boolean flag = true;
if (nowyear % 4 == 0 && nowyear % 100 != 0 || nowyear % 400 == 0) {
} else {
flag = false;
}
for (int i = 0; i < Integer.parseInt(month); i++) {
if (flag) {
days += monthday1[i];
} else {
days += monthday[i];
}
}
days += Integer.parseInt(day);
return days;
}
}
package cn.com.glsx.process.modules.sop.execute;
import java.io.Serializable;
import java.util.Map;
import com.google.common.collect.Maps;
import lombok.Getter;
/**
* node执行过程-快照管理
*
* @author kome
* @date 2023年9月19日 下午5:09:42
*/
@Getter
public class SnapshotStruct implements Serializable, Cloneable {
private static final long serialVersionUID = -1413400196758036960L;
/**
* Sop批次初始化参数表
*/
private Map<String, Object> initMap = Maps.newHashMap();
/**
* Sop各节点的输入参数表
*/
private Map<String, Object> paramMap = Maps.newHashMap();
/**
* Sop各节点的执行结果表
*/
private Map<String, Object> resultMap = Maps.newHashMap();
public Map<String, Object> toMap() {
Map<String, Object> map = Maps.newHashMap();
map.putAll(getInitMap());
map.putAll(getResultMap());
return map;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.util.FreemarkerUtil;
import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
public interface SopNodeExecutor {
Logger log = LoggerFactory.getLogger(SopNodeExecutor.class);
/**
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
*
* @param node
* @return
*/
default SnapshotStruct prepare(SopStruct sop, SopInstNode node) {
SnapshotStruct es = JacksonUtils.fromJson(sop.getInst().getInstSnapshot(), SnapshotStruct.class);
// 启动参数
if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) {
es.getInitMap().clear();
// 重新生成初始化参数
JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam());
es.getInitMap().putAll(paramObj);
}
es.getInitMap().put("instId", sop.getInst().getInstId());
SopXxlJobUtil.log(log, "【{}】Sop任务节点,初始化参数:{}", node.getNodeName(), JacksonUtils.nodefaultMapper.toJson(es.getInitMap()));
// 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeParam())) {
// 节点入参按freemarker语法替换
String source = FreemarkerUtil.processContent(node.getNodeParam(), es.toMap());
if (StrUtil.isNotEmpty(node.getNodeKey())) {
JSONObject nodeParamObj = JSONUtil.parseObj(source);
es.getParamMap().put(node.getNodeKey(), nodeParamObj);
} else {
log.warn("【{}】nodeKey 为空!!!", node.getInstId() + "-" + node.getNodeId());
}
}
SopXxlJobUtil.log(log, "【{}】Sop任务节点,节点参数:{}", node.getNodeName(), JacksonUtils.nodefaultMapper.toJson(es.getParamMap()));
return es;
}
/**
* SOP节点执行
*
* @param sop SOP
* @param node SOP节点
* @return 输出参数
* @throws Exception
*/
Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception;
/**
* 合并本节点执行结果到快照体中
*
* @param sop
* @param node
* @param snapshotStruct
* @param result
* @return
*/
default SnapshotStruct handleResult(SopStruct sop, SopInstNode node, SnapshotStruct es, Object result) {
SopXxlJobUtil.log(log, "【{}】Sop任务节点,节点执行结果:{}", node.getNodeName(), JacksonUtils.nodefaultMapper.toJson(result));
if (result == null) {
return es;
}
// 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeKey())) {
es.getResultMap().put(node.getNodeKey(), result);
} else {
log.warn("【{}】nodeKey 为空!!!", node.getInstId() + "-" + node.getNodeId());
}
return es;
}
}
package cn.com.glsx.process.modules.sop.execute;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
/**
* @Author zhouhb
* @Version 1.0
* @Description: 工厂方法
*/
@Service
public class SopNodeExecutorFactory implements ApplicationContextAware {
// ApplicationContext对象是Spring开源框架的上下文对象实例,在项目运行时自动装载Handler内的所有信息到内存。
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (SopNodeExecutorFactory.applicationContext == null) {
SopNodeExecutorFactory.applicationContext = applicationContext;
}
}
/**
* 获取service子类
*
* @param handerType
* @param requiredType
* @param <T>
* @return
*/
public static <T> T getInstance(String handerType, Class<T> requiredType) {
T bean = applicationContext.getBean(handerType, requiredType);
if (bean == null) {
throw new RuntimeException("未找到的Sop节点执行器:" + handerType);
}
return bean;
}
}
package cn.com.glsx.process.modules.sop.execute;
import cn.com.glsx.process.modules.sop.execute.executor.EndExecutor;
import cn.com.glsx.process.modules.sop.execute.executor.JavaExecutor;
import cn.com.glsx.process.modules.sop.execute.executor.SqlExecutor;
import cn.com.glsx.process.modules.sop.execute.executor.SqlQueryExecutor;
import cn.com.glsx.process.modules.sop.execute.executor.StartExecutor;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
/**
* @Author: zhouhb
* @Description: 执行器枚举
* @Version: 1.0
*/
@Getter
public enum SopNodeType {
/**
* 执行器枚举
*/
START("START", "startExecutor", StartExecutor.class),
JAVA("Java", "javaExecutor", JavaExecutor.class),
SQL_SEARCH("Sql查询", "sqlQueryExecutor", SqlQueryExecutor.class),
SQL_EXCUTE("Sql更新", "sqlExecutor", SqlExecutor.class),
END("END", "endExecutor", EndExecutor.class);
private String busType;
private String handerImp;
private Class<?> classes;
SopNodeType(String busType, String handerImp, Class<?> classes) {
this.busType = busType;
this.handerImp = handerImp;
this.classes = classes;
}
public String getBusType() {
return busType;
}
public String getHanderImp() {
return handerImp;
}
public static SopNodeType fromBusType(String busType) {
for (SopNodeType c : SopNodeType.values()) {
if (StrUtil.equalsAnyIgnoreCase(c.getBusType(), busType)) {
return c;
}
}
throw new RuntimeException("未找到的Sop节点类型:" + busType);
}
}
package cn.com.glsx.process.modules.sop.execute.executor;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class EndExecutor implements SopNodeExecutor {
@Override
public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.execute.executor;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.plugin.java.DynamicEngine;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class JavaExecutor implements SopNodeExecutor {
@Override
public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
Map<String, Object> resultMap = executeStruct.getResultMap();
try {
// 处理开始节点
String nodeContent = node.getNodeContent();
JSONObject paramMap = JSON.parseObject(nodeContent);
String javacode = paramMap.get("source") + "";
// java参数处理,执行java
DynamicEngine de = DynamicEngine.getInstance();
// 获取实例快照,传给处理器
SopInst inst = sop.getInst();
JSONObject jsonObject = new JSONObject();
// 实例信息
jsonObject.put("sopInst", inst);
// 节点信息
jsonObject.put("sopInstNode", node);
// 实例快照
jsonObject.put("instSnapshot", executeStruct.getResultMap());
Object instance = de.execute("Controller", javacode, "execute", new Class[] { JSON.class }, new Object[] { jsonObject });
// 处理返回结果
return instance;
} catch (Exception e) {
SopXxlJobUtil.log(log, "【{}】{}", getClass().getSimpleName(), e.getMessage(), e);
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.execute.executor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.entity.SopDataSource;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopDataSourceService;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopBizAdapter;
import cn.com.glsx.process.util.FreemarkerUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class SqlExecutor implements SopNodeExecutor {
@Autowired
private SopDataSourceService sopDataSourceService;
@Override
public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
try {
// 获取配置参数信息
String nodeContent = node.getNodeContent();
JSONObject paramMap = JSON.parseObject(nodeContent);
String sqlTemplate = paramMap.get("source") + "";
String dataSourceId = paramMap.get("dataSourceId") + "";
// 执行sql插件
SopDataSource byId = sopDataSourceService.findByDataSourceId(dataSourceId);
SopBizAdapter mcgBizAdapter = new FlowDataAdapterImpl(byId);
String sql = FreemarkerUtil.processContent(sqlTemplate, executeStruct.toMap());
int i = mcgBizAdapter.executeUpdate(sql);
return "更新成功条数" + i;
} catch (Exception e) {
SopXxlJobUtil.log(log, "【{}】{}", getClass().getSimpleName(), e.getMessage(), e);
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.execute.executor;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.modules.entity.SopDataSource;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopDataSourceService;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopBizAdapter;
import cn.com.glsx.process.util.FreemarkerUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class SqlQueryExecutor implements SopNodeExecutor {
@Autowired
private SopDataSourceService sopDataSourceService;
@Override
public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
try {
// 获取配置参数信息
String nodeContent = node.getNodeContent();
JSONObject paramMap = JSON.parseObject(nodeContent);
String sqlTemplate = paramMap.get("source") + "";
String dataSourceId = paramMap.get("dataSourceId") + "";
// 执行sql插件
SopDataSource byId = sopDataSourceService.findByDataSourceId(dataSourceId);
SopBizAdapter mcgBizAdapter = new FlowDataAdapterImpl(byId);
String sql = FreemarkerUtil.processContent(sqlTemplate, executeStruct.toMap());
List<Map<String, Object>> maps = mcgBizAdapter.tableQuery(sql);
// 处理执行结果
return maps;
} catch (Exception e) {
SopXxlJobUtil.log(log, "【{}】{}", getClass().getSimpleName(), e.getMessage(), e);
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.execute.executor;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
/**
* 开始节点:
* 1.从SopInst提取初始化参数;
* 2.记录开始节点快照,更新Sop快照;
* 3.更新触发后置任务;
*
* @author kome
* @date 2023年9月19日 下午5:42:59
*/
@Slf4j
@Service
public class StartExecutor implements SopNodeExecutor {
@Resource
private SopService sopService;
@Override
public SnapshotStruct prepare(SopStruct sop, SopInstNode node) {
SnapshotStruct ss = SopNodeExecutor.super.prepare(sop, node);
ss.getResultMap().clear();// 清空前批次结果
return ss;
}
@Override
public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
return null;
}
public static void main(String[] args) {
String json = "{\"merchantId\":{\"paramName\":\"merchantId\",\"paramDesc\":\"门店id,分配给门店时需要赋值\",\"valueType\":\"String\",\"defaultValue\":\"\",\"required\":true},\"stages\":{\"paramName\":\"stages\",\"paramDesc\":\"旅程阶段,值类型为Json\",\"valueType\":\"Json\",\"defaultValue\":{\"stage1\":{\"value\":\"潜客\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage2\":{\"value\":\"高意向\",\"editable\":true,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage3\":{\"value\":\"下单\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage4\":{\"value\":\"战败\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]}},\"required\":true},\"users\":{\"paramName\":\"users\",\"paramDesc\":\"通过膨胀金活动导入的用户信息\",\"valueType\":\"Json\",\"defaultValue\":{\"u0001\":{\"userId\":\"u0001\",\"userName\":\"张三\",\"followId\":\"跟进人id1\",\"textContent\":\"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"},\"u0002\":{\"userId\":\"u0002\",\"userName\":\"李四\",\"followId\":\"跟进人id2\",\"textContent\":\"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"}},\"required\":true}}";
JSONObject paramObj = JSONUtil.parseObj(json);
System.out.println(paramObj.get("merchantId"));
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractConnect {
private static Logger logger = LoggerFactory.getLogger(AbstractConnect.class);
public DbConnect dbConnect;
public AbstractConnect(DataSource dataSource) {
super();
initDbConnect(dataSource);
}
/**
* 初始化
*
* @see [类、类#方法、类#成员]
*/
private void initDbConnect(DataSource dataSource) {
if (dbConnect == null) {
dbConnect = new DbConnect(dataSource);
}
}
/**
* 带可变参数查询,返回执行结果
*
* @param sql
* 查询sql
* @param para
* 可变参数
* @return
* @throws SQLException
*/
public List<Map<String, Object>> querySql(String sql, Object... para) throws SQLException {
return dbConnect.querySql(sql, para);
}
/**
* 带可变参数查询,返回执行结果
*
* @param <T>
*
* @param sql
* 查询sql
* @param para
* 可变参数
* @return
* @throws SQLException
*/
@SuppressWarnings("unchecked")
public <T> List<T> executeQuery(T clazz, String sql, Object... para) throws SQLException {
return dbConnect.querySql(clazz, sql, para);
}
/**
* 带可变参数查询,返回long类型数据
*
* @param countSql
* 查询记录条数的sql
* @param para
* 可变参数
* @return
* @throws SQLException
* @throws SQLException
*/
public Long queryForLong(String countSql, Object... para) throws SQLException {
return dbConnect.queryForLong(countSql, para);
}
/**
* 带可变参数, 执行sql插入,返回新增记录的自增主键<BR>
* 注意: 若插入的表无自增主键则返回 0,异常的话则返回 null
*
* @param sql
* @param para
* @return
* @throws SQLException
* @see [类、类#方法、类#成员]
*/
public Long executeInsert(String sql, Object... para) throws SQLException {
return dbConnect.insertSql(sql, para);
}
/**
* 带可变参数, 执行sql,返回执行影响的记录条数
*
* @param sql
* 执行的sql 语句
* @param para
* 可变参数
* @return
* @throws SQLException
*/
public int executeUpdate(String sql, Object... para) throws SQLException {
int total=0;
String[] split = sql.split(";");
for (String s : split) {
if(StringUtils.isNotEmpty(s)) {
int i = dbConnect.executeUpdate(s, para);
total = total + i;
}
}
return total;
}
public boolean testConnect() {
boolean result = false;
try {
Connection connection = dbConnect.getDataSource().getConnection();
if (connection != null) {
DbUtils.closeQuietly(connection);
result = true;
}
} catch (SQLException e) {
logger.error("测试连接出错,异常信息:", e);
return result;
}
return result;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.dbutils.BasicRowProcessor;
import org.apache.commons.dbutils.BeanProcessor;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.GenerousBeanProcessor;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.RowProcessor;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* 带事务支持的数据库底层操作类
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DbConnect {
private static Logger logger = LoggerFactory.getLogger(DbConnect.class);
private DataSource dataSource;
private ThreadLocal<Connection> threadLocal = new ThreadLocal<Connection>();
public DbConnect(DataSource dataSource) {
this.dataSource = dataSource;
}
/**
* 创建数据库连接
*
* @return
* @see [类、类#方法、类#成员]
*/
public Connection getConnection() {
Connection connection = threadLocal.get();
try {
if (connection == null) {
connection = dataSource.getConnection();
threadLocal.set(connection);
}
} catch (SQLException e) {
logger.error("获取数据库连接失败,异常信息:", e.getMessage());
throw new RuntimeException("获取数据库连接失败.....");
}
return connection;
}
/**
* 带可变参数查询,返回执行结果
*
* @param sql 查询sql
* @param para 可变参数
* @return
*/
public List<Map<String, Object>> querySql(String sql, Object... para) throws SQLException {
logger.debug("查询Sql: {}, 查询参数: {}", sql, ToStringBuilder.reflectionToString(para));
QueryRunner runner = new QueryRunner();
Connection conn = null;
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
try {
conn = getConnection();
result = runner.query(conn, sql, new MapListHandler(), para);
} catch (SQLException e) {
logger.error("查询出错,异常信息: {}", e.getMessage());
throw e;
} finally {
if (conn != null && conn.getAutoCommit() == true) {
freeConnection();
}
}
return result;
}
/**
*
* @Title: querySql
* @Description: TODO(带可变参数查询,返回执行结果)
* @param: @param clazz 转换的对象实例
* @param: @param sql 查询sql语句
* @param: @param para 查询参数
* @param: @return
* @param: @throws SQLException
* @return: List
* @throws
*/
public <T> List querySql(T clazz, String sql, Object... para) throws SQLException {
logger.debug("查询Sql: {}, 查询参数: {}", sql, ToStringBuilder.reflectionToString(para));
QueryRunner runner = new QueryRunner();
Connection conn = null;
List<T> result = new ArrayList<T>();
try {
conn = getConnection();
// 下划线分隔的表字段名转换为实体bean驼峰命名属性
BeanProcessor bean = new GenerousBeanProcessor();
RowProcessor processor = new BasicRowProcessor(bean);
result = (List<T>) runner.query(conn, sql, new BeanListHandler((Class) clazz, processor), para);
} catch (SQLException e) {
logger.error("查询出错,异常信息: {}------", e.getMessage());
throw e;
} finally {
if (conn != null && conn.getAutoCommit() == true) {
freeConnection();
}
}
return result;
}
/**
*
* @Title: queryForLong
* @Description: TODO(带可变参数查询,返回long类型数据)
* @param: @param countSql 查询记录总条数
* @param: @param para 参数
* @param: @return
* @param: @throws SQLException
* @return: Long
* @throws
*/
public Long queryForLong(String countSql, Object... para) throws SQLException {
logger.debug("queryForLong: {}, para: {}", countSql, ToStringBuilder.reflectionToString(para));
QueryRunner runner = new QueryRunner();
Long number = null;
Connection conn = null;
try {
conn = getConnection();
number = runner.query(conn, countSql, new ScalarHandler<Long>(), para);
} catch (SQLException e) {
logger.error("------queryForLong error: {}------", e.getMessage());
throw e;
} finally {
if (conn != null && conn.getAutoCommit() == true) {
freeConnection();
}
}
return number;
}
/**
*
* @Title: executeUpdate
* @Description: TODO(带可变参数, 执行sql,返回执行影响的记录条数)
* @param: @param sql 执行的sql语句
* @param: @param para 参数
* @param: @return
* @param: @throws SQLException
* @return: int
* @throws
*/
public int executeUpdate(String sql, Object... para) throws SQLException {
logger.info("executeUpdate: {}, para: {}", sql, ToStringBuilder.reflectionToString(para));
QueryRunner runner = new QueryRunner();
Connection conn = null;
int count = 0;
try {
conn = getConnection();
count = runner.update(conn, sql, para);
} catch (SQLException e) {
logger.error("------executeUpdate error: {}------", e.getMessage());
throw e;
} finally {
if (conn != null && conn.getAutoCommit() == true) {
freeConnection();
}
}
return count;
}
/**
*
* @Title: insertSql
* @Description: TODO(带可变参数, 执行sql插入,返回新增记录的自增主键。注意: 若插入的表无自增主键则返回 0,异常的话则返回 null)
* @param: @param sql 执行的sql语句
* @param: @param para 参数
* @param: @return
* @param: @throws SQLException
* @return: Long
* @throws
*/
public Long insertSql(String sql, Object... para) throws SQLException {
logger.debug("InsertSql: {}, para: {}", sql, ToStringBuilder.reflectionToString(para));
QueryRunner runner = new QueryRunner();
Connection conn = null;
Long id = null;
try {
conn = getConnection();
id = (Long) runner.insert(conn, sql, new ScalarHandler<Object>(), para);
} catch (SQLException e) {
logger.error("------insertSql error: {}------", e.getMessage());
throw e;
} finally {
if (conn != null && conn.getAutoCommit() == true) {
freeConnection();
}
}
return id;
}
/**
*
* @Title: executeBatch
* @Description: TODO(批量更新)
* @param: @param sql 执行的sql语句
* @param: @param params 二维数组参数
* @param: @throws SQLException
* @return: void
* @throws
*/
public void executeBatch(String sql, Object[][] params) throws SQLException {
logger.debug("executeBatch: {}, params:{}", sql, ToStringBuilder.reflectionToString(params));
QueryRunner runner = new QueryRunner();
Connection conn = null;
try {
conn = getConnection();
runner.batch(conn, sql, params);
} catch (SQLException e) {
logger.error("------executeBatch Error:{}------", e.getMessage());
throw e;
} finally {
if (conn != null && conn.getAutoCommit() == true) {
freeConnection();
}
}
}
/**
*
* @Title: executeBatch
* @Description: TODO(批量更新)
* @param: @param sql 执行的sql语句
* @param: @param params 参数
* @param: @throws SQLException
* @return: void
* @throws
*/
public void executeBatch(String sql, List<Object[]> params) throws SQLException {
Object[][] paramArr = params.toArray(new Object[0][]);
executeBatch(sql, paramArr);
}
/**
*
* @Title: freeConnection
* @Description: TODO(释放数据库连接)
* @param:
* @return: void
* @throws
*/
public void freeConnection() {
logger.debug("------释放数据库连接------");
Connection conn = threadLocal.get();
if (conn != null) {
DbUtils.closeQuietly(conn);
threadLocal.remove(); // 解除当前线程上绑定conn
}
}
/**
*
* @Title: commit
* @Description: TODO(提交事务)
* @param:
* @return: void
* @throws
*/
public void commit() {
logger.debug("------提交事务-------");
try {
Connection conn = threadLocal.get();
if (conn != null) {
conn.commit();
}
} catch (SQLException e) {
logger.error("提交事务失败,异常信息:{}", e.getMessage());
}
}
/**
*
* @Title: rollback
* @Description: TODO(回滚事务)
* @param:
* @return: void
*/
public void rollback() {
logger.debug("------ 系统异常,回滚事务------");
try {
Connection conn = threadLocal.get();
if (conn != null) {
conn.rollback();
}
} catch (SQLException e) {
logger.error("回滚事务失败,异常信息:{}", e.getMessage());
}
}
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.postgresql.ds.PGPoolingDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
import com.mysql.cj.jdbc.MysqlDataSource;
import cn.com.glsx.process.common.sysenum.DatabaseTypeEnum;
import cn.com.glsx.process.modules.entity.SopDataSource;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.mssql.MssqlConnectImpl;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.mysql.MysqlConnectImpl;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.oracle.OracleConnectImpl;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.postgresql.PostgresqlConnectImpl;
import oracle.jdbc.pool.OracleDataSource;
public class FlowDataAdapterImpl implements SopBizAdapter {
private static Logger logger = LoggerFactory.getLogger(FlowDataAdapterImpl.class);
private SopConnect mcgConnect;
public FlowDataAdapterImpl(SopDataSource mcgDataSource) {
if(DatabaseTypeEnum.MYSQL.getValue().equals(mcgDataSource.getDbType())) {
MysqlDataSource mysqlDataSource = new MysqlDataSource();
mysqlDataSource.setServerName(mcgDataSource.getDbServer());
mysqlDataSource.setPort(mcgDataSource.getDbPort());
mysqlDataSource.setDatabaseName(mcgDataSource.getDbName());
try {
mysqlDataSource.setCharacterEncoding("UTF-8");
mysqlDataSource.setCharacterSetResults("UTF-8");
} catch (SQLException e) {
throw new RuntimeException(e);
}
mysqlDataSource.setUser(mcgDataSource.getDbUserName());
mysqlDataSource.setPassword(mcgDataSource.getDbPwd());
try {
mysqlDataSource.setConnectTimeout(3000);
} catch (SQLException e) {
logger.error("mysql数据源适配失败,异常信息:", e);
}
mcgConnect = new MysqlConnectImpl(mysqlDataSource);
} else if(DatabaseTypeEnum.ORACLE.getValue().equals(mcgDataSource.getDbType())) {
try {
OracleDataSource oracleDataSource = new OracleDataSource();
oracleDataSource.setDriverType("thin");
oracleDataSource.setNetworkProtocol("tcp");
oracleDataSource.setServerName(mcgDataSource.getDbServer());
oracleDataSource.setDatabaseName(mcgDataSource.getDbName());
oracleDataSource.setPortNumber(mcgDataSource.getDbPort());
oracleDataSource.setUser(mcgDataSource.getDbUserName());
oracleDataSource.setPassword(mcgDataSource.getDbPwd());
oracleDataSource.setLoginTimeout(3000);
mcgConnect = new OracleConnectImpl(oracleDataSource);
} catch (SQLException e) {
logger.error("oracle数据源适配失败,异常信息:", e);
}
} else if(DatabaseTypeEnum.MSSQL.getValue().equals(mcgDataSource.getDbType())) {
try {
SQLServerDataSource sqlServerDataSource = new SQLServerDataSource();
sqlServerDataSource.setDatabaseName(mcgDataSource.getDbName());
sqlServerDataSource.setUser(mcgDataSource.getDbUserName());
sqlServerDataSource.setPassword(mcgDataSource.getDbPwd());
sqlServerDataSource.setServerName(mcgDataSource.getDbServer());
sqlServerDataSource.setPortNumber(mcgDataSource.getDbPort());
sqlServerDataSource.setLoginTimeout(3000);
mcgConnect = new MssqlConnectImpl(sqlServerDataSource);
} catch (Exception e) {
logger.error("oracle数据源适配失败,异常信息:", e);
}
} else if(DatabaseTypeEnum.POSTGRESQL.getValue().equals(mcgDataSource.getDbType())) {
PGPoolingDataSource pgDataSource = new PGPoolingDataSource();
try {
pgDataSource.setDatabaseName(mcgDataSource.getDbName());
pgDataSource.setUser(mcgDataSource.getDbUserName());
pgDataSource.setPassword(mcgDataSource.getDbPwd());
pgDataSource.setPortNumber(mcgDataSource.getDbPort());
pgDataSource.setServerName(mcgDataSource.getDbServer());
pgDataSource.setLoginTimeout(3000);
} catch (SQLException e) {
logger.error("postgresql数据源适配失败,异常信息:", e);
}
mcgConnect = new PostgresqlConnectImpl(pgDataSource);
}
}
@Override
public List<Map<String, Object>> tableQuery(String sql, Object... para) throws SQLException {
return mcgConnect.querySql(sql, para);
}
@Override
public int executeUpdate(String sql, Object... para) throws SQLException {
return mcgConnect.executeUpdate(sql, para);
}
@Override
public boolean testConnect() {
boolean flag = false;
try {
flag = mcgConnect.testConnect();
} catch (Exception e) {
logger.error("数据连接测试失败,异常信息:", e);
}
return flag;
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
public interface SopBizAdapter {
boolean testConnect();
List<Map<String, Object>> tableQuery(String sql, Object... para) throws SQLException;
public int executeUpdate(String sql, Object... para) throws SQLException;
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
public interface SopConnect {
boolean testConnect();
List<Map<String, Object>> querySql(String sql, Object... para) throws SQLException;
int executeUpdate(String sql, Object... para) throws SQLException;
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class SopDataSource implements Serializable {
private static final long serialVersionUID = -7416980731775213841L;
@XmlElement
private String dataSourceId;
@XmlElement
private String name;
@XmlElement
private String dbType;
@XmlElement
private String dbServer;
@XmlElement
private Integer dbPort;
@XmlElement
private String dbName;
@XmlElement
private String dbUserName;
@XmlElement
private String dbPwd;
@XmlElement
private String note;
public String getDataSourceId() {
return dataSourceId;
}
public void setDataSourceId(String dataSourceId) {
this.dataSourceId = dataSourceId;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
public String getDbServer() {
return dbServer;
}
public void setDbServer(String dbServer) {
this.dbServer = dbServer;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getDbUserName() {
return dbUserName;
}
public void setDbUserName(String dbUserName) {
this.dbUserName = dbUserName;
}
public String getDbPwd() {
return dbPwd;
}
public void setDbPwd(String dbPwd) {
this.dbPwd = dbPwd;
}
public Integer getDbPort() {
return dbPort;
}
public void setDbPort(Integer dbPort) {
this.dbPort = dbPort;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn.mssql;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.AbstractConnect;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopConnect;
public class MssqlConnectImpl extends AbstractConnect implements SopConnect {
private static Logger logger = LoggerFactory.getLogger(MssqlConnectImpl.class);
public MssqlConnectImpl(DataSource dataSource) {
super(dataSource);
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn.mysql;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.AbstractConnect;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopConnect;
public class MysqlConnectImpl extends AbstractConnect implements SopConnect {
private static Logger logger = LoggerFactory.getLogger(MysqlConnectImpl.class);
public MysqlConnectImpl(DataSource dataSource) {
super(dataSource);
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn.oracle;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.AbstractConnect;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopConnect;
public class OracleConnectImpl extends AbstractConnect implements SopConnect {
private static Logger logger = LoggerFactory.getLogger(OracleConnectImpl.class);
public OracleConnectImpl(DataSource dataSource) {
super(dataSource);
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.dbconn.postgresql;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.AbstractConnect;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopConnect;
public class PostgresqlConnectImpl extends AbstractConnect implements SopConnect {
private static Logger logger = LoggerFactory.getLogger(PostgresqlConnectImpl.class);
public PostgresqlConnectImpl(DataSource dataSource) {
super(dataSource);
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.java;
import java.net.URI;
import javax.tools.SimpleJavaFileObject;
public class CharSequenceJavaFileObject extends SimpleJavaFileObject {
private CharSequence content;
public CharSequenceJavaFileObject(String className,
CharSequence content) {
super(URI.create("string:///" + className.replace('.', '/')
+ Kind.SOURCE.extension), Kind.SOURCE);
this.content = content;
}
@Override
public CharSequence getCharContent(
boolean ignoreEncodingErrors) {
return content;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.java;
import java.io.IOException;
import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
public class ClassFileManager extends ForwardingJavaFileManager {
public JavaClassObject getJavaClassObject() {
return jclassObject;
}
private JavaClassObject jclassObject;
public ClassFileManager(StandardJavaFileManager
standardManager) {
super(standardManager);
}
@Override
public JavaFileObject getJavaFileForOutput(Location location,
String className, JavaFileObject.Kind kind, FileObject sibling)
throws IOException {
jclassObject = new JavaClassObject(className, kind);
return jclassObject;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.java;
import java.net.URL;
import java.net.URLClassLoader;
public class DynamicClassLoader extends URLClassLoader {
public DynamicClassLoader(ClassLoader parent) {
super(new URL[0], parent);
}
public Class<?> findClassByClassName(String className) throws ClassNotFoundException {
return this.findClass(className);
}
public Class<?> loadClass(String fullName, JavaClassObject jco) {
byte[] classData = jco.getBytes();
return this.defineClass(fullName, classData, 0, classData.length);
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.java;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.ToolProvider;
import cn.com.glsx.process.common.constant.Constants;
public class DynamicEngine {
private static DynamicEngine ourInstance = new DynamicEngine();
public static DynamicEngine getInstance() {
return ourInstance;
}
private URLClassLoader parentClassLoader;
private String classpath;
private DynamicEngine() {
this.parentClassLoader = (URLClassLoader) this.getClass().getClassLoader();
this.buildClassPath();
}
private void buildClassPath() {
this.classpath = null;
StringBuilder sb = new StringBuilder();
for (URL url : this.parentClassLoader.getURLs()) {
String p = url.getFile();
sb.append(p).append(File.pathSeparator);
}
this.classpath = sb.toString();
}
/**
* 调用类方法
* @param cls 类
* @param methodName 方法名
* @param paramsCls 方法参数类型
* @param params 方法参数
* @return
* @throws SecurityException
* @throws NoSuchMethodException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws InvocationTargetException
* @throws IllegalArgumentException
*/
public Object invoke(Class<?> cls, String methodName, Class<?>[] paramsCls, Object[] params) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
Object result = null;
Method method = cls.getDeclaredMethod(methodName, paramsCls);
Object obj = cls.newInstance();
result = method.invoke(obj, params);
return result;
}
public Object execute(String fullClassName, String javaCode, String method, Class<?>[] paramsCls,Object[] params) throws Exception {
Object result = null;
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
ClassFileManager fileManager = new ClassFileManager(compiler.getStandardFileManager(diagnostics, null, null));
List<JavaFileObject> jfiles = new ArrayList<JavaFileObject>();
jfiles.add(new CharSequenceJavaFileObject(fullClassName, javaCode));
List<String> options = new ArrayList<String>();
options.add("-encoding");
options.add(Constants.CHARSET.toString());
options.add("-classpath");
options.add(this.classpath);
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, options, null, jfiles);
boolean success = task.call();
if (success) {
JavaClassObject jco = fileManager.getJavaClassObject();
DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(this.parentClassLoader);
Class<?> clazz = dynamicClassLoader.loadClass(fullClassName,jco);
result = invoke(clazz, method, paramsCls, params);
// instance = clazz.newInstance();
dynamicClassLoader.close();
} else {
StringBuilder error = new StringBuilder();
for (Diagnostic<?> diagnostic : diagnostics.getDiagnostics()) {
error.append(compilePrint(diagnostic));
}
throw new Exception(error.toString());
}
return result;
}
private String compilePrint(Diagnostic<?> diagnostic) {
StringBuilder res = new StringBuilder();
res.append("Code:[" + diagnostic.getCode() + "]\n");
res.append("Kind:[" + diagnostic.getKind() + "]\n");
res.append("Position:[" + diagnostic.getPosition() + "]\n");
res.append("Start Position:[" + diagnostic.getStartPosition() + "]\n");
res.append("End Position:[" + diagnostic.getEndPosition() + "]\n");
res.append("Source:[" + diagnostic.getSource() + "]\n");
res.append("Message:[" + diagnostic.getMessage(null) + "]\n");
res.append("LineNumber:[" + diagnostic.getLineNumber() + "]\n");
res.append("ColumnNumber:[" + diagnostic.getColumnNumber() + "]\n");
return res.toString();
}
}
\ No newline at end of file \ No newline at end of file
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.modules.sop.execute.plugin.java;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import javax.tools.SimpleJavaFileObject;
public class JavaClassObject extends SimpleJavaFileObject {
protected final ByteArrayOutputStream bos = new ByteArrayOutputStream();
public JavaClassObject(String name, Kind kind) {
super(URI.create("string:///" + name.replace('.', '/') + kind.extension), kind);
}
public byte[] getBytes() {
return bos.toByteArray();
}
@Override
public OutputStream openOutputStream() throws IOException {
return bos;
}
}
package cn.com.glsx.process.modules.sop.java.example;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.sop.CustomerInfo;
import cn.com.glsx.process.modules.sop.SopExecutorResult;
import cn.com.glsx.process.modules.sop.SopHelper;
/**
* java执行器使用demo,rop请求,类名Controller,方法名execute
* 1.下发门店助手任务
*/
public class ControllerDisTasksDemo {
private final static String baseurl = "http://scrm.dev.glsx.com.cn/rop-scrm-stoassistant/router";
private final static String method = "scrm.api.sop.marketing.task.customer";
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
Object post = null;
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
SopExecutorResult excustorParam = SopHelper.getExcustorParam(param);
Map<String, Object> resultData = excustorParam.getResultData();
SopInst sopInst = excustorParam.getSopInst();
SopInstNode sopInstNode = excustorParam.getSopInstNode();
String nodeParam = sopInstNode.getNodeParam();
List<CustomerInfo> customerInfoList = SopHelper.getMeetWithCustomer(sopInstNode, resultData);
// 营销的客户存在执行任务下发
if (CollectionUtils.isNotEmpty(customerInfoList)) {
String instSnapshot = sopInst.getInstSnapshot();
multiValueMap.add("requestList[0].activityId", SopHelper.getValueFromJsonString(instSnapshot, "initMap", "customData","activityId"));
multiValueMap.add("requestList[0].nodeId", sopInstNode.getNodeId() + "");
multiValueMap.add("requestList[0].nodeName", sopInstNode.getNodeName());
multiValueMap.add("requestList[0].stageId", SopHelper.getValueFromJsonString(nodeParam, "stage"));
multiValueMap.add("requestList[0].stageName", SopHelper.getValueFromJsonString(nodeParam, "stage"));
multiValueMap.add("requestList[0].sopId", sopInst.getInstId());
multiValueMap.add("requestList[0].enterJourneyDays",SopHelper.getValueFromJsonString(nodeParam, "day"));
multiValueMap.add("requestList[0].taskType", SopHelper.getValueFromJsonString(nodeParam, "taskType"));
for (int i = 0; i < customerInfoList.size(); i++) {
CustomerInfo customerInfo = customerInfoList.get(i);
multiValueMap.add("requestList[0].customerList[" + i + "].customerId", customerInfo.getOneId());
multiValueMap.add("requestList[0].customerList[" + i + "].followStaffPhone", customerInfo.getFollowStaffPhone());
multiValueMap.add("requestList[0].customerList[" + i + "].messageContent", customerInfo.getMessageContent());
if(customerInfo.getMessageId()!=null) {
multiValueMap.add("requestList[0].customerList[" + i + "].messageId", customerInfo.getMessageId());
}
if(customerInfo.getTalkId()!=null) {
multiValueMap.add("requestList[0].customerList[" + i + "].talkId", customerInfo.getTalkId());
}
}
try {
System.out.println("入参" + JSONObject.toJSONString(multiValueMap));
post = SopHelper.post(multiValueMap, Object.class, baseurl, method);
System.out.println("返回" + JSONObject.toJSONString(post));
} catch (Exception e) {
throw new RuntimeException(e);
}
return (JSONObject) JSONObject.toJSON(post);
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.java.example;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.sop.CustomerInfo;
import cn.com.glsx.process.modules.sop.SopExecutorResult;
import cn.com.glsx.process.modules.sop.SopHelper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* java执行器使用demo,rop请求,类名Controller,方法名execute
* 查询到保日期
*/
public class ControllerFoundInsDemo {
private final static String baseurl = "http://scrm.dev.glsx.com.cn/rop-scrm-marketing/router";
private final static String method = "marketing.api.supermarket.renewal.queryByVins";
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
List<CustomerInfo> result = new ArrayList<>();
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
SopExecutorResult excustorParam = SopHelper.getExcustorParam(param);
Map<String, Object> resultData = excustorParam.getResultData();
SopInstNode sopInstNode = excustorParam.getSopInstNode();
List<CustomerInfo> customerInfoList = SopHelper.getMeetWithCustomer(sopInstNode, resultData);
if (CollectionUtils.isNotEmpty(customerInfoList)) {
List<String> collect = customerInfoList.stream().filter(index -> StringUtils.isNotEmpty(index.getVin())).map(CustomerInfo::getVin).collect(Collectors.toList());
try {
multiValueMap.put("vins", collect);
Object post = SopHelper.post(multiValueMap, Object.class, baseurl, method);
JSONObject json = (JSONObject) JSONObject.toJSON(post);
Object data = json.get("data");
Map<String, Object> stringObjectMap = (Map<String, Object>) (data);
if (!stringObjectMap.isEmpty()) {
for (String key : stringObjectMap.keySet()) {
String s = stringObjectMap.get(key) + "";
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setVin(key);
if(stringObjectMap.get(key)!=null) {
customerInfo.setArrivalDate(DateFormatUtils.format(Long.parseLong(s), "yyyy-MM-dd HH:mm:ss"));
}
result.add(customerInfo);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return JSONArray.parseArray(JSONObject.toJSONString(result));
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.java.example;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* java执行器使用demo,http请求,类名Controller,方法名execute
* 隐藏任务跑sql
*
*/
public class ControllerHttpDemo {
private static String baseurl = "http://192.168.0.63:9823/process/sop/xxljob/testJava";
public static JSON execute(JSON param) {
System.out.println("测试java");
RestTemplate restTemplate = new RestTemplate();
Object o = restTemplate.postForObject(baseurl + "?busKey=" + 11, param, Object.class);
return (JSONObject) JSONObject.toJSON(o);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.java.example;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.sop.CustomerInfo;
import cn.com.glsx.process.modules.sop.SopExecutorResult;
import cn.com.glsx.process.modules.sop.SopHelper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* java执行器使用demo,http请求,类名Controller,方法名execute
* 筛选客户
*/
public class ControllerScreenPersonDemo {
public static JSON execute(JSON param) {
SopExecutorResult excustorParam = SopHelper.getExcustorParam(param);
SopInstNode sopInstNode = excustorParam.getSopInstNode();
String nodeParam = sopInstNode.getNodeParam();
String stage = SopHelper.getValueFromJsonString(nodeParam, "stage");
Map<String, Object> resultData = excustorParam.getResultData();
List<CustomerInfo> customerInfoList = JSON.parseArray(JSON.toJSONString(resultData.get("users")), CustomerInfo.class);
if (CollectionUtils.isNotEmpty(customerInfoList)) {
List<CustomerInfo> collect = customerInfoList.stream().filter(index -> stage.equals(index.getSopJourneyStage())).collect(Collectors.toList());
return (JSONArray) JSONObject.toJSON(collect);
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.java.example;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/**
* 续保旅程中,圈人节点,按输入参数中的标签来圈人
*
* @author kome
* @date 2023年9月21日 下午2:04:17
*/
public class ControllerXblcCustomerQuery {
private static String baseurl = "http://192.168.0.63:9823/process/sop/xxljob/testJava";
/**
* <code>
{
"merchantId": "M153312087",
"stages": {
...
},
"sopTag": "xblc" // select * from cdp_user where tag_xblc=1
}
* </code>
*
* @param param
* @return
*/
public static JSON execute(JSON param) {
// 走sql或http查询用户列表
RestTemplate restTemplate = new RestTemplate();
Object o = restTemplate.postForObject(baseurl + "?busKey=" + 11, param, Object.class);
return (JSONObject) JSONObject.toJSON(o);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.java.example;
import com.alibaba.fastjson.JSONObject;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
* java文件转化为可执行的节点内容
*
*/
public class JavaFileToString {
public static void main(String[] args) {
StringBuilder javaCodeBuilder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader("F:\\360MoveData\\Users\\11\\Desktop\\企微SAAS\\2023\\09\\sop\\platform-process-server\\platform-process\\src\\main\\java\\cn\\com\\glsx\\process\\modules\\sop\\java\\example\\ControllerHttpDemo.java"))) {
String line;
while (true) {
try {
if (!((line = reader.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
javaCodeBuilder.append(line).append(System.lineSeparator());
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
String javaCode = javaCodeBuilder.toString();
Map<String,String> stringMap=new HashMap<>();
stringMap.put("source",javaCode);
// 读取Java文件内容
System.out.println("转化后结果"+ JSONObject.toJSONString(stringMap));
}
}
package cn.com.glsx.process.redis;
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AopConfig {
@Value("@annotation(cn.com.glsx.process.redis.DistributedLock)")
private String point;
@Bean
@AutoConfigureOrder(value = 2)
public AspectJExpressionPointcutAdvisor aspectJExpressionPointcutAdvisor(){
AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
advisor.setAdvice(new DistributedLockInterceptor());
advisor.setExpression(point);
return advisor;
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.redis;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DistributedLock {
/**
* 分布式锁key
*/
String key() default "";
/**
* 过期时间 单位毫秒
*
* @return
*/
long expireTime();
}
package cn.com.glsx.process.redis;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import com.glsx.plat.context.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class DistributedLockInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
DistributedLock distributedLock = method.getAnnotation(DistributedLock.class);
if (distributedLock != null) {
String lockKey = distributedLock.key();
long expireTime = distributedLock.expireTime();
boolean locked = false;
try {
String lockName = parseKey(distributedLock.key(), invocation.getMethod(), invocation.getArguments());
log.info("拦截key{}",lockName);
locked = tryLock(lockKey, expireTime);
if (locked) {
return invocation.proceed();
} else {
throw new IllegalStateException("Failed to acquire distributed lock");
}
} finally {
if (locked) {
unlock(lockKey);
}
}
} else {
return invocation.proceed();
}
}
private boolean tryLock(String lockKey, long expireTime) {
// 使用Redis的SETNX命令来尝试获取锁
RedisTemplate restRedisTemplate = SpringUtils.getBean("restRedisTemplate");
Boolean result = restRedisTemplate.opsForValue().setIfAbsent(lockKey, "locked", expireTime, TimeUnit.MILLISECONDS);
return result != null && result;
}
private void unlock(String lockKey) {
RedisTemplate restRedisTemplate = SpringUtils.getBean("restRedisTemplate");
restRedisTemplate.delete(lockKey);
}
private String parseKey(String key, Method method, Object[] args) {
if (StringUtils.isEmpty(key)) {
return null;
}
if (key.indexOf("#") == -1) {
return key;
}
//获取被拦截方法参数名列表(使用Spring支持类库)
LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();
String[] paraNameArr = u.getParameterNames(method);
if (paraNameArr == null || paraNameArr.length == 0) {
return key;
}
//使用SPEL进行key的解析
ExpressionParser parser = new SpelExpressionParser();
//SPEL上下文
StandardEvaluationContext context = new StandardEvaluationContext();
//把方法参数放入SPEL上下文中
for (int i = 0; i < paraNameArr.length; i++) {
context.setVariable(paraNameArr[i], args[i]);
}
Expression e = parser.parseExpression(key);
return e.getValue(context, String.class);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.redis;
import java.util.concurrent.TimeUnit;
import org.springframework.data.redis.core.RedisTemplate;
import com.glsx.plat.context.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class DistributedLockUtils {
private static final int DEFAULT_RETRY_TIMES = 3 * 1000;
private static final long DEFAULT_RETRY_INTERVAL = 100 * 1000;
private static RedisTemplate redisTemplate;
public static RedisTemplate redisTemplate() {
if (redisTemplate == null) {
redisTemplate = SpringUtils.getBean("restRedisTemplate");
}
return redisTemplate;
}
/**
* 分布式锁不重试
*
* @param key 锁key
* @param expireTime 过期时间
* @return
*/
public static boolean lock(String key, long expireTime) {
RedisTemplate redisTemplate = redisTemplate();
log.info("锁获取{}", key);
Boolean locked = redisTemplate.opsForValue().setIfAbsent(key, System.currentTimeMillis(), expireTime, TimeUnit.MILLISECONDS);
log.info("锁获取结果{}", locked);
if (locked != null && locked) {
return true;
}
return false;
}
/**
* 重试分布式锁
*
* @param key 锁key
* @param expireTime 过期时间
* @param retryCount 重试次数
* @param retryTime 重试时间
* @return
*/
public static boolean lock(String key, long expireTime, Integer retryCount, Long retryTime) {
RedisTemplate redisTemplate = redisTemplate();
log.info("锁获取{}", key);
Boolean locked = redisTemplate.opsForValue().setIfAbsent(key, System.currentTimeMillis() + "", expireTime, TimeUnit.MILLISECONDS);
try {
if (locked != null && locked) {
return locked;
}
if (retryCount != null) {
locked = retryLock(key, expireTime, retryCount, retryTime);
}
return locked != null && locked;
} finally {
log.info("锁获取结果{}", locked);
}
}
/**
* 重试
*
* @param key 锁key
* @param expireTime 过期时间
* @param retryCount 重试次数
* @param retryTime 重试时间
* @return
*/
private static boolean retryLock(String key, long expireTime, Integer retryCount, Long retryTime) {
if (retryCount == null) {
retryCount = DEFAULT_RETRY_TIMES;
}
if (retryTime == null) {
retryTime = DEFAULT_RETRY_INTERVAL;
}
RedisTemplate redisTemplate = redisTemplate();
for (int i = 0; i < retryCount; i++) {
try {
Thread.sleep(retryTime);
log.info("重试锁获取{} retry:{}", key, i);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Boolean locked = redisTemplate.opsForValue().setIfAbsent(key, System.currentTimeMillis(), expireTime, TimeUnit.MILLISECONDS);
if (locked != null && locked) {
return true;
}
}
return false;
}
public static void unlock(String key) {
RedisTemplate<String, ?> redisTemplate = redisTemplate();
Object v = redisTemplate.opsForValue().get(key);
if (v != null) {
redisTemplate.delete(key);
log.info("锁释放{} time:{}", key, (System.currentTimeMillis() - Long.valueOf(v.toString())));
} else {
log.info("锁释放{}", key);
}
}
}
package cn.com.glsx.process.util;
import java.beans.PropertyDescriptor;
import java.util.Date;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.converters.DateConverter;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.FatalBeanException;
public class BeanUtilsEx extends BeanUtils {
private static final BeanUtilsBean beanUtilsBean;
static {
beanUtilsBean = new BeanUtilsBean();
beanUtilsBean.getConvertUtils().register(new DateConverter(null), Date.class);
}
public static void copyProperties(Object source, Object target) {
if (source == null || target == null) {
throw new IllegalArgumentException("Source and target objects must not be null");
}
Class<?> actualEditable = target.getClass();
if (target instanceof Class) {
actualEditable = (Class<?>) target;
}
PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable);
for (PropertyDescriptor targetPd : targetPds) {
if (targetPd.getWriteMethod() != null) {
PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName());
if (sourcePd != null && sourcePd.getReadMethod() != null) {
try {
Object value = sourcePd.getReadMethod().invoke(source);
if (value != null) {
beanUtilsBean.copyProperty(target, targetPd.getName(), value);
}
} catch (Throwable ex) {
throw new FatalBeanException("Could not copy properties", ex);
}
}
}
}
}
}
package cn.com.glsx.process.util;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
@SuppressWarnings("serial")
public class FileUploadServerData implements Serializable {
public static final int UPLOAD_SUCCSSS = 0; // "上传文件成功!",
public static final int UPLOAD_FAILURE = 1; // "上传文件失败!"),
//private static final int UPLOAD_TYPE_ERROR = 2; // "上传文件类型错误!"),
//private static final int UPLOAD_OVERSIZE = 3; // "上传文件过大!"),
//private static final int UPLOAD_ZEROSIZE = 4; // "上传文件为空!"),
//private static final int UPLOAD_NOTFOUND = 5; // "上传文件路径错误!")
private Integer status = 0;
private String message = "";
private String url = "";
private String systemSign;
private String filePath;
private String param1;
private String param2;
private String param3;
private String secureUrl;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getSystemSign() {
return systemSign;
}
public void setSystemSign(String systemSign) {
this.systemSign = systemSign;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getParam1() {
return param1;
}
public void setParam1(String param1) {
this.param1 = param1;
}
public String getParam2() {
return param2;
}
public void setParam2(String param2) {
this.param2 = param2;
}
public String getParam3() {
return param3;
}
public void setParam3(String param3) {
this.param3 = param3;
}
public String getSecureUrl() {
return secureUrl;
}
public void setSecureUrl(String secureUrl) {
this.secureUrl = secureUrl;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("{");
sb.append("status:" + this.status + ",");
sb.append("message:'" + this.message + "',");
sb.append("url:'" + this.url + "',");
sb.append("systemSign:'" + this.systemSign + "',");
sb.append("filePath:'" + this.filePath + "',");
sb.append("param1:'" + this.param1 + "',");
sb.append("param2:'" + this.param2 + "',");
sb.append("param3:'" + this.param3 + "'");
sb.append("secureUrl:'" + this.secureUrl + "'");
sb.append("}");
return sb.toString();
}
public FileUploadServerData() {
}
public FileUploadServerData(HttpServletRequest request) {
this.systemSign = request.getParameter("systemSign");
this.filePath = request.getParameter("filePath");
this.param1 = request.getParameter("param1");
this.param2 = request.getParameter("param2");
this.param3 = request.getParameter("param3");
}
}
package cn.com.glsx.process.util;
import org.apache.commons.codec.binary.Base64;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.List;
/**
* @author wangxw
* @version 1.0.0
* @ClassName FileUploadUtil.java
* @description: 文件上传操作类
* @createTime 2019年11月24日 14:29:00
*/
public class FileUploadUtil {
public static final String FILE_UPLOAD_URL = "http://gfs.glsx.com.cn/file/upstring";
private static final String FILE_ZIP_URL = "http://gfs.glsx.com.cn/file/zip";
private static final String FILE_UPLOAD_TEST_URL = "http://gfs.test.glsx.com.cn/file/upstring";
// blib 供应链
// biz 业务
private static final String dir_content = "biz";
/**
* 将文件上传至文件服务器
* @param uploadData
* @param fileType
* @return
*/
public static FileUploadServerData uploadToFileSystem(String fileName, byte[] uploadData, String fileType) {
RestTemplate restTemplate = new RestTemplate();
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
form.add("systemSign", dir_content);
form.add("param1", fileName);
form.add("files", fileType + "@" + Base64.encodeBase64String(uploadData));
// return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
return restTemplate.postForObject(FILE_UPLOAD_URL, form, FileUploadServerData.class);
}
}
package cn.com.glsx.process.util;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import com.google.common.collect.Sets;
import cn.hutool.json.JSONUtil;
import freemarker.cache.StringTemplateLoader;
import freemarker.core.Environment;
import freemarker.core.InvalidReferenceException;
import freemarker.core.NonSequenceOrCollectionException;
import freemarker.core.TemplateElement;
import freemarker.ext.beans.StringModel;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateCollectionModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateHashModelEx;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateModelIterator;
import freemarker.template.TemplateScalarModel;
import freemarker.template.TemplateSequenceModel;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FreemarkerUtil {
static Configuration configuration = new Configuration(Configuration.VERSION_2_3_31);
static {
configuration.setLogTemplateExceptions(false);
// configuration.setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);
}
public static Set<String> extractVariables(String templateContent) throws IOException, TemplateException {
Set<String> variables = new HashSet<>();
Template template = generateTemplate(templateContent);
StringWriter writer = new StringWriter();
Map<String, Object> dataModel = new HashMap<>();
template.process(dataModel, writer);
Environment environment = template.createProcessingEnvironment(dataModel, writer);
TemplateModel templateModel = environment.getDataModel();
extractVariablesFromTemplateModel(templateModel, variables);
return variables;
}
private static void extractVariablesFromTemplateModel(TemplateModel templateModel, Set<String> variables) throws TemplateModelException {
if (templateModel instanceof TemplateHashModelEx) {
TemplateHashModelEx hashModelEx = (TemplateHashModelEx) templateModel;
TemplateCollectionModel keys = hashModelEx.keys();
TemplateModelIterator keyIterator = keys.iterator();
while (keyIterator.hasNext()) {
TemplateModel key = keyIterator.next();
if (key instanceof TemplateScalarModel) {
String variable = ((TemplateScalarModel) key).getAsString();
variables.add(variable);
}
}
}
if (templateModel instanceof TemplateCollectionModel) {
TemplateCollectionModel hashModel = (TemplateCollectionModel) templateModel;
// TemplateCollectionModel values = hashModel.values();
TemplateModelIterator valueIterator = hashModel.iterator();
while (valueIterator.hasNext()) {
TemplateModel value = valueIterator.next();
extractVariablesFromTemplateModel(value, variables);
}
}
if (templateModel instanceof TemplateSequenceModel) {
TemplateSequenceModel sequenceModel = (TemplateSequenceModel) templateModel;
int size = sequenceModel.size();
for (int i = 0; i < size; i++) {
TemplateModel element = sequenceModel.get(i);
extractVariablesFromTemplateModel(element, variables);
}
}
}
/**
* Find all the variables used in the Freemarker Template
*
* @param templateName
* @return
*/
public static Set<String> getTemplateVariables(Template template) {
StringWriter stringWriter = new StringWriter();
Map<String, Object> dataModel = new HashMap<>();
boolean exceptionCaught;
do {
exceptionCaught = false;
try {
template.process(dataModel, stringWriter);
} catch (InvalidReferenceException e) {
exceptionCaught = true;
dataModel.put(e.getBlamedExpressionString(), "");
} catch (NonSequenceOrCollectionException e) {
} catch (Exception e) {
// throw new IllegalStateException("Failed to Load Template: " + template.getName(), e);
}
} while (exceptionCaught);
return dataModel.keySet();
}
private static Template getTemplate(String templateName) {
try {
return configuration.getTemplate(templateName);
} catch (IOException e) {
throw new IllegalStateException("Failed to Load Template: " + templateName, e);
}
}
private static Template generateTemplate(String templateContent) {
try {
StringTemplateLoader templateLoader = new StringTemplateLoader();
templateLoader.putTemplate("__testTemplate", templateContent);
configuration.setTemplateLoader(templateLoader);
Template template = configuration.getTemplate("__testTemplate");
return template;
} catch (IOException e) {
throw new IllegalStateException("Failed to generate Template: " + templateContent, e);
}
}
public static Set<String> referenceSet(Template template) throws TemplateModelException {
Set<String> result = new HashSet<>();
TemplateElement rootTreeNode = template.getRootTreeNode();
for (int i = 0; i < rootTreeNode.getChildCount(); i++) {
TemplateModel templateModel = rootTreeNode.getChildNodes().get(i);
if (!(templateModel instanceof StringModel)) {
continue;
}
Object wrappedObject = ((StringModel) templateModel).getWrappedObject();
if (!"DollarVariable".equals(wrappedObject.getClass().getSimpleName())) {
continue;
}
try {
Object expression = getInternalState(wrappedObject, "expression");
switch (expression.getClass().getSimpleName()) {
case "Identifier":
result.add(getInternalState(expression, "name").toString());
break;
case "DefaultToExpression":
result.add(getInternalState(expression, "lho").toString());
break;
case "BuiltinVariable":
break;
default:
throw new IllegalStateException("Unable to introspect variable");
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new TemplateModelException("Unable to reflect template model");
}
}
return result;
}
private static Object getInternalState(Object o, String fieldName) throws NoSuchFieldException, IllegalAccessException {
Field field = o.getClass().getDeclaredField(fieldName);
boolean wasAccessible = field.isAccessible();
try {
field.setAccessible(true);
return field.get(o);
} finally {
field.setAccessible(wasAccessible);
}
}
public static Set<String> getNecessaryTemplateVariables(String templateName) throws TemplateModelException {
Set<String> result = new HashSet<>();
TemplateElement rootTreeNode = getTemplate(templateName).getRootTreeNode();
if ("IteratorBlock".equals(rootTreeNode.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, rootTreeNode);
return result;
}
for (int i = 0; i < rootTreeNode.getChildCount(); i++) {
TemplateModel templateModel = rootTreeNode.getChildNodes().get(i);
if (!(templateModel instanceof StringModel)) {
continue;
}
Object wrappedObject = ((StringModel) templateModel).getWrappedObject();
if ("DollarVariable".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromDollarVariable(result, wrappedObject);
} else if ("ConditionalBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromConditionalBlock(result, wrappedObject);
} else if ("IfBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIfBlock(result, wrappedObject);
} else if ("IteratorBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, wrappedObject);
}
}
return result;
}
public static Set<String> getNecessaryTemplateVariables(Template template) throws TemplateModelException {
Set<String> result = new HashSet<>();
TemplateElement rootTreeNode = template.getRootTreeNode();
if ("IteratorBlock".equals(rootTreeNode.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, rootTreeNode);
return result;
}
for (int i = 0; i < rootTreeNode.getChildCount(); i++) {
TemplateModel templateModel = rootTreeNode.getChildNodes().get(i);
if (!(templateModel instanceof StringModel)) {
continue;
}
Object wrappedObject = ((StringModel) templateModel).getWrappedObject();
if ("DollarVariable".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromDollarVariable(result, wrappedObject);
} else if ("ConditionalBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromConditionalBlock(result, wrappedObject);
} else if ("IfBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIfBlock(result, wrappedObject);
} else if ("IteratorBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, wrappedObject);
}
}
return result;
}
private static void introspectFromIteratorBlock(Set<String> result, Object wrappedObject) {
try {
Object expression = getInternalState(wrappedObject, "listedExp");
result.add(getInternalState(expression, "name").toString());
} catch (NoSuchFieldException | IllegalAccessException ignored) {
ignored.printStackTrace();
}
}
private static void introspectFromConditionalBlock(Set<String> result, Object wrappedObject) throws TemplateModelException {
try {
Object expression = getInternalState(wrappedObject, "condition");
if (expression == null) {
return;
}
result.addAll(dealCommonExpression(expression));
String nested = getInternalState(wrappedObject, "nestedBlock").toString();
result.addAll(getNecessaryTemplateVariables(nested));
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
}
private static Set<String> dealCommonExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Set<String> ret = Sets.newHashSet();
switch (expression.getClass().getSimpleName()) {
case "ComparisonExpression":
String reference = dealComparisonExpression(expression);
ret.add(reference);
break;
case "ExistsExpression":
reference = dealExistsExpression(expression);
ret.add(reference);
break;
case "AndExpression":
ret.addAll(dealAndExpression(expression));
default:
break;
}
return ret;
}
private static String dealComparisonExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Object left = getInternalState(expression, "left");
Object right = getInternalState(expression, "right");
String reference;
if ("Identifier".equals(left.getClass().getSimpleName())) {
reference = getInternalState(left, "name").toString();
} else {
reference = getInternalState(right, "name").toString();
}
return reference;
}
private static String dealExistsExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Object exp = getInternalState(expression, "exp");
return getInternalState(exp, "name").toString();
}
private static Set<String> dealAndExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Set<String> ret = Sets.newHashSet();
Object lho = getInternalState(expression, "lho");
ret.addAll(dealCommonExpression(lho));
Object rho = getInternalState(expression, "rho");
ret.addAll(dealCommonExpression(rho));
return ret;
}
private static void introspectFromIfBlock(Set<String> result, Object wrappedObject) throws TemplateModelException {
result.addAll(getNecessaryTemplateVariables(wrappedObject.toString()));
}
private static void introspectFromDollarVariable(Set<String> result, Object wrappedObject) throws TemplateModelException {
try {
Object expression = getInternalState(wrappedObject, "expression");
switch (expression.getClass().getSimpleName()) {
case "Identifier":
result.add(getInternalState(expression, "name").toString());
break;
case "DefaultToExpression":
result.add(getInternalState(expression, "lho").toString());
break;
case "BuiltinVariable":
break;
default:
break;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new TemplateModelException("Unable to reflect template model");
}
}
public void test() throws Exception {
String templateContent = "Hello, ${name}! <#list users as u>${u.name}</#list>";
Template template = generateTemplate(templateContent);
System.out.println(JSONUtil.toJsonStr(getTemplateVariables(template)));
System.out.println(JSONUtil.toJsonStr(referenceSet(template)));
System.out.println(JSONUtil.toJsonStr(getNecessaryTemplateVariables(template)));
}
public static void main(String[] args) throws IOException, TemplateException {
String templateContent = "<#assign name = 'Alice'>Hello, ${name}!";
Set<String> variables = extractVariables(templateContent);
for (String variable : variables) {
System.out.println(variable);
}
}
public static String processContent(String sqlTemplate, Map<String, Object> params) {
try {
Template template = generateTemplate(sqlTemplate);
return FreeMarkerTemplateUtils.processTemplateIntoString(template, params);
} catch (Exception e) {
log.warn(sqlTemplate, params, e);
return null;
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.util;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
/**
* i18n util
*
* @author xuxueli 2018-01-17 20:39:06
*/
public class I18nUtil {
private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
private static Properties prop = null;
public static Properties loadI18nProp(){
if (prop != null) {
return prop;
}
try {
// build i18n prop
String i18n = "zh_CN";
String i18nFile = MessageFormat.format("i18n/message_{0}.properties", i18n);
// load prop
Resource resource = new ClassPathResource(i18nFile);
EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
prop = PropertiesLoaderUtils.loadProperties(encodedResource);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return prop;
}
/**
* get val of i18n key
*
* @param key
* @return
*/
public static String getString(String key) {
return loadI18nProp().getProperty(key);
}
/**
* get mult val of i18n mult key, as json
*
* @param keys
* @return
*/
public static String getMultString(String... keys) {
Map<String, String> map = new HashMap<String, String>();
Properties prop = loadI18nProp();
if (keys!=null && keys.length>0) {
for (String key: keys) {
map.put(key, prop.getProperty(key));
}
} else {
for (String key: prop.stringPropertyNames()) {
map.put(key, prop.getProperty(key));
}
}
String json = JacksonUtil.writeValueAsString(map);
return json;
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.util;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Types;
import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JDBCTypesUtils {
private static Logger logger = LoggerFactory.getLogger(JDBCTypesUtils.class);
private static Map<String, Integer> jdbcTypes;
private static Map<Integer, String> jdbcTypeValues;
private static Map<Integer, Class<?>> jdbcJavaTypes;
static {
jdbcTypes = new TreeMap<String, Integer>();
jdbcTypeValues = new TreeMap<Integer, String>();
jdbcJavaTypes = new TreeMap<Integer, Class<?>>();
Field[] fields = Types.class.getFields();
try {
for (int i = 0, len = fields.length; i < len; ++i) {
if (Modifier.isStatic(fields[i].getModifiers())) {
String name = fields[i].getName();
Integer value = (Integer) fields[i].get(Types.class);
jdbcTypes.put(name, value);
jdbcTypeValues.put(value, name);
}
}
} catch (Exception e) {
logger.error(e.getMessage());
}
// 初始化jdbcJavaTypes:
jdbcJavaTypes.put(new Integer(Types.LONGNVARCHAR), String.class); // -16 字符串
jdbcJavaTypes.put(new Integer(Types.NCHAR), String.class); // -15 字符串
jdbcJavaTypes.put(new Integer(Types.NVARCHAR), String.class); // -9 字符串
jdbcJavaTypes.put(new Integer(Types.ROWID), String.class); // -8 字符串
jdbcJavaTypes.put(new Integer(Types.BIT), Boolean.class); // -7 布尔
jdbcJavaTypes.put(new Integer(Types.TINYINT), Byte.class); // -6 数字
jdbcJavaTypes.put(new Integer(Types.BIGINT), Long.class); // -5 数字
jdbcJavaTypes.put(new Integer(Types.LONGVARBINARY), Blob.class); // -4 二进制
jdbcJavaTypes.put(new Integer(Types.VARBINARY), Blob.class); // -3 二进制
jdbcJavaTypes.put(new Integer(Types.BINARY), Blob.class); // -2 二进制
jdbcJavaTypes.put(new Integer(Types.LONGVARCHAR), String.class); // -1 字符串
// jdbcJavaTypes.put(new Integer(Types.NULL), String.class); // 0 /
jdbcJavaTypes.put(new Integer(Types.CHAR), String.class); // 1 字符串
jdbcJavaTypes.put(new Integer(Types.NUMERIC), BigDecimal.class); // 2 数字
jdbcJavaTypes.put(new Integer(Types.DECIMAL), BigDecimal.class); // 3 数字
jdbcJavaTypes.put(new Integer(Types.INTEGER), Integer.class); // 4 数字
jdbcJavaTypes.put(new Integer(Types.SMALLINT), Short.class); // 5 数字
jdbcJavaTypes.put(new Integer(Types.FLOAT), Float.class); // 6 数字
jdbcJavaTypes.put(new Integer(Types.REAL), BigDecimal.class); // 7 数字
jdbcJavaTypes.put(new Integer(Types.DOUBLE), BigDecimal.class); // 8 数字
jdbcJavaTypes.put(new Integer(Types.VARCHAR), String.class); // 12 字符串
jdbcJavaTypes.put(new Integer(Types.BOOLEAN), Boolean.class); // 16 布尔
// jdbcJavaTypes.put(new Integer(Types.DATALINK), String.class); // 70 /
jdbcJavaTypes.put(new Integer(Types.DATE), Date.class); // 91 日期
jdbcJavaTypes.put(new Integer(Types.TIME), Date.class); // 92 日期
jdbcJavaTypes.put(new Integer(Types.TIMESTAMP), Date.class); // 93 日期
jdbcJavaTypes.put(new Integer(Types.OTHER), Object.class); // 1111 其他类型?
// jdbcJavaTypes.put(new Integer(Types.JAVA_OBJECT), Object.class); // 2000
// jdbcJavaTypes.put(new Integer(Types.DISTINCT), String.class); // 2001
// jdbcJavaTypes.put(new Integer(Types.STRUCT), String.class); // 2002
// jdbcJavaTypes.put(new Integer(Types.ARRAY), String.class); // 2003
jdbcJavaTypes.put(new Integer(Types.BLOB), Blob.class); // 2004 二进制
jdbcJavaTypes.put(new Integer(Types.CLOB), Clob.class); // 2005 大文本
// jdbcJavaTypes.put(new Integer(Types.REF), String.class); // 2006
// jdbcJavaTypes.put(new Integer(Types.SQLXML), String.class); // 2009
jdbcJavaTypes.put(new Integer(Types.NCLOB), Clob.class); // 2011 大文本
}
public static int getJdbcCode(String jdbcName) {
return jdbcTypes.get(jdbcName);
}
public static String getJdbcName(int jdbcCode) {
return jdbcTypeValues.get(jdbcCode);
}
public static Class<?> jdbcTypeToJavaType(int jdbcType) {
return jdbcJavaTypes.get(jdbcType);
}
public static boolean isJavaNumberType(int jdbcType) {
Class<?> type = jdbcJavaTypes.get(jdbcType);
return (type == null) ? false : (Number.class.isAssignableFrom(type)) ? true : false;
}
}
package cn.com.glsx.process.util;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Jackson util
*
* 1、obj need private and set/get;
* 2、do not support inner class;
*
* @author xuxueli 2015-9-25 18:02:56
*/
public class JacksonUtil {
private static Logger logger = LoggerFactory.getLogger(JacksonUtil.class);
private final static ObjectMapper objectMapper = new ObjectMapper();
public static ObjectMapper getInstance() {
return objectMapper;
}
/**
* bean、array、List、Map --> json
*
* @param obj
* @return json string
* @throws Exception
*/
public static String writeValueAsString(Object obj) {
try {
return getInstance().writeValueAsString(obj);
} catch (JsonGenerationException e) {
logger.error(e.getMessage(), e);
} catch (JsonMappingException e) {
logger.error(e.getMessage(), e);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return null;
}
/**
* string --> bean、Map、List(array)
*
* @param jsonStr
* @param clazz
* @return obj
* @throws Exception
*/
public static <T> T readValue(String jsonStr, Class<T> clazz) {
try {
return getInstance().readValue(jsonStr, clazz);
} catch (JsonParseException e) {
logger.error(e.getMessage(), e);
} catch (JsonMappingException e) {
logger.error(e.getMessage(), e);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return null;
}
/**
* string --> List<Bean>...
*
* @param jsonStr
* @param parametrized
* @param parameterClasses
* @param <T>
* @return
*/
public static <T> T readValue(String jsonStr, Class<?> parametrized, Class<?>... parameterClasses) {
try {
JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses);
return getInstance().readValue(jsonStr, javaType);
} catch (JsonParseException e) {
logger.error(e.getMessage(), e);
} catch (JsonMappingException e) {
logger.error(e.getMessage(), e);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
return null;
}
}
package cn.com.glsx.process.util;
import java.io.IOException;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.introspect.AnnotatedField;
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.fasterxml.jackson.databind.util.JSONPObject;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DatePattern;
import lombok.val;
import lombok.extern.slf4j.Slf4j;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
@SuppressWarnings("restriction")
public class JacksonUtils {
// 转换全部字段
public final static JsonMapper normalMapper = JsonMapper.buildNormalBinder();
// 不转换默认值的字段
public final static JsonMapper nodefaultMapper = JsonMapper.buildNonDefaultBinder();
// 不转换空字段
public final static JsonMapper noemptyMapper = JsonMapper.buildNonEmptyBinder();
// 不转换null字段
public final static JsonMapper nonullMapper = JsonMapper.buildNonNullBinder();
// 不转换null字段
public final static JsonMapper null2emptyMapper = JsonMapper.buildNull2EmptyBinder();
// 首字母大写
public final static JsonMapper downCaseMapper = JsonMapper.buildDownCaseBinder();
// 下划线
public final static JsonMapper snakeMapper = JsonMapper.buildSnakeCaseBinder();
// // 下划线+base64 decode
// public final static JsonMapper wxMapper = JsonMapper.buildWxCaseBinder();
public static <T> String toJson(T t) {
return normalMapper.toJson(t);
}
public static <T> T fromJson(String json, Class<T> clazz) {
return normalMapper.fromJson(json, clazz);
}
public static <T, S> T fromJson(String json, Class<T> owner, Class<S> subClass) {
return normalMapper.fromJson(json, owner, subClass);
}
/**
* <code>
* List<String> list = JsonUtil.fromJson(json, new TypeReference<ArrayList<String>>() {});
* </code>
*
* @param <T>
* @param json
* @param t
* @return
*/
public static <T> T fromJson(String json, TypeReference<T> t) {
return normalMapper.fromJson(json, t);
}
public static <T> T convertJsonClazz(Object object, Class<T> clazz) {
return normalMapper.convertJsonClazz(object, clazz);
}
/**
* 构造函数
*/
private JacksonUtils() {
}
@Slf4j
public static class JsonMapper {
private ObjectMapper mapper;
protected JsonMapper() {
this(JsonInclude.Include.ALWAYS);
}
public JsonMapper(JsonInclude.Include include) {
mapper = new ObjectMapper();
// 设置输出时包含属性的风格
mapper.setSerializationInclusion(include);
// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// 空的bean不解析
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
// 设置日期格式
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
//
mapper.registerModule(simpleModule());
}
/** 创建输出全部属性到Json字符串的Binder. */
public static JsonMapper buildNormalBinder() {
return new JsonMapper(JsonInclude.Include.ALWAYS);
}
/** 创建只输出非空属性到Json字符串的Binder. */
public static JsonMapper buildNonNullBinder() {
return new JsonMapper(JsonInclude.Include.NON_NULL);
}
public static JsonMapper buildNull2EmptyBinder() {
JsonMapper m = new JsonMapper(JsonInclude.Include.ALWAYS);
m.mapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
@Override
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeString("");
}
});
return m;
}
/** 创建只输出初始值被改变的属性到Json字符串的Binder. */
public static JsonMapper buildNonDefaultBinder() {
return new JsonMapper(JsonInclude.Include.NON_DEFAULT);
}
/** 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Binder */
public static JsonMapper buildNonEmptyBinder() {
return new JsonMapper(JsonInclude.Include.NON_EMPTY);
}
/** 首字母大写 */
public static JsonMapper buildDownCaseBinder() {
// 首字母默认小写
JsonMapper mapper = new JsonMapper(JsonInclude.Include.ALWAYS);
mapper.mapper.setPropertyNamingStrategy(new JacksonInitialDownCaseStrategy());
return mapper;
}
/** 下划线连接 */
public static JsonMapper buildSnakeCaseBinder() {
// 下划线
JsonMapper mapper = new JsonMapper(JsonInclude.Include.NON_NULL);
mapper.mapper.setPropertyNamingStrategy(new SnakeCaseStrategy());
return mapper;
}
// /** 下划线连接+Base64 */
// public static JsonMapper buildWxCaseBinder() {
// // 下划线
// JsonMapper mapper = new JsonMapper(JsonInclude.Include.ALWAYS);
// mapper.mapper.setPropertyNamingStrategy(new SnakeCaseStrategy());
// mapper.mapper.setBase64Variant(Base64Variants.MIME_NO_LINEFEEDS);
// return mapper;
// }
/**
* 反序列化POJO或简单Collection如List<String>. 如果JSON字符串为null或"null"字符串,返回null. 如果JSON字符串为"[]",返回空集合.
* 如需读取集合如List/Map,且不是List<String>这种简单类型时,使用後面的函數.
*/
public <T> T fromJson(String jsonString, Class<T> clazz) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return mapper.readValue(jsonString, clazz);
} catch (IOException e) {
log.warn("parse json string error:" + jsonString, e);
return null;
}
}
public <T> T fromJson(String jsonString, TypeReference<T> type) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return mapper.readValue(jsonString, type);
} catch (IOException e) {
log.warn("parse json string error:" + jsonString, e);
return null;
}
}
public <T, S> T fromJson(String json, Class<T> owner, Class<S> subClass) {
if (subClass == null) {
return fromJson(json, owner);
}
Type[] types = new Type[1];
types[0] = subClass;
final ParameterizedTypeImpl type = ParameterizedTypeImpl.make(owner, types, owner.getDeclaringClass());
TypeReference<T> typeReference = new TypeReference<T>() {
@Override
public Type getType() {
return type;
}
};
return fromJson(json, typeReference);
}
/**
* 反序列化复杂Collection如List<Bean>, 先使用函數createCollectionType构造类型,然后调. 如果JSON字符串为null或"null"字符串,返回null. 如果JSON字符串为"[]",返回空集合.
*/
@SuppressWarnings("unchecked")
public <T> T fromJson(String jsonString, JavaType javaType) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return (T) mapper.readValue(jsonString, javaType);
} catch (IOException e) {
log.warn("parse json string error:" + jsonString, e);
return null;
}
}
/** 構造泛型的Type如List<MyBean>, Map<String,MyBean> */
public JavaType createCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses);
}
/**
* Object可以是POJO,也可以是Collection或数组. 如果对象为null,返回"null". 如果集合为空集合,返回"[]".
*/
public String toJson(Object object) {
try {
if (object == null) {
return null;
}
return mapper.writeValueAsString(object);
} catch (IOException e) {
log.warn("write to json string error:" + object, e);
return null;
}
}
// 转换类型
public <T> T convertJsonClazz(Object object, Class<T> clazz) {
String json = toJson(object);
return fromJson(json, clazz);
}
/** 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性. */
@SuppressWarnings("unchecked")
public <T> T update(String jsonString, T object) {
try {
return (T) mapper.readerForUpdating(object).readValue(jsonString);
} catch (Exception e) {
log.warn("parse json string" + jsonString + " to object:" + object + " error.", e);
}
return null;
}
/** 輸出JSONP格式數據. */
public String toJsonP(String functionName, Object object) {
return toJson(new JSONPObject(functionName, object));
}
/** 设定是否使用Enum的toString函數來读写Enum, */
public void enableEnumUseToString() {
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
}
}
public static SimpleModule simpleModule() {
val bean = new SimpleModule();
bean.addDeserializer(ZonedDateTime.class, new JsonDeserializer<ZonedDateTime>() {
@Override
public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
return ZonedDateTime.parse(jsonParser.getValueAsString(), DateTimeFormatter.ISO_ZONED_DATE_TIME);
}
});
bean.addDeserializer(LocalDateTime.class, new MyLocalDatetimeDeserializer());
bean.addSerializer(ZonedDateTime.class, new JsonSerializer<ZonedDateTime>() {
@Override
public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
jsonGenerator.writeString(DateTimeFormatter.ISO_ZONED_DATE_TIME.format(zonedDateTime));
}
});
bean.addSerializer(LocalDateTime.class, new MyLocalDatetimeSerializer());
return bean;
}
@SuppressWarnings("serial")
static class JacksonInitialDownCaseStrategy extends PropertyNamingStrategy {
@Override
public String nameForField(@SuppressWarnings("rawtypes") MapperConfig config, AnnotatedField field, String defaultName) {
return convert(defaultName);
}
@Override
public String nameForGetterMethod(@SuppressWarnings("rawtypes") MapperConfig config, AnnotatedMethod method, String defaultName) {
return convert(defaultName);
}
@Override
public String nameForSetterMethod(@SuppressWarnings("rawtypes") MapperConfig config, AnnotatedMethod method, String defaultName) {
String a = convert(defaultName);
return a;
}
public String convert(String defaultName) {
char[] arr = defaultName.toCharArray();
if (arr.length != 0) {
if (Character.isLowerCase(arr[0])) {
char upper = Character.toUpperCase(arr[0]);
arr[0] = upper;
}
}
return new StringBuilder().append(arr).toString();
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static class Base64Deserializer extends JsonDeserializer implements ContextualDeserializer {
@Override
public JsonDeserializer createContextual(DeserializationContext context, BeanProperty property) throws JsonMappingException {
return this;
}
@Override
public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
String value = parser.getValueAsString();
try {
if (Base64.isBase64(value)) {
// 判断是否切换编码格式
// value = Base64.decodeStr(value);
String decode = new String(org.apache.commons.codec.binary.Base64.decodeBase64(value));
// 解码后不是乱码才解码,对emoji表情单独处理
// if (StrUtils.hasNormalCode(decode)) {
// value = decode;
// }
}
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static class GBKBase64Deserializer extends JsonDeserializer implements ContextualDeserializer {
@Override
public JsonDeserializer createContextual(DeserializationContext context, BeanProperty property) throws JsonMappingException {
return this;
}
@Override
public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
String value = parser.getValueAsString();
try {
if (Base64.isBase64(value)) {
// TODO 判断是否切换编码格式
// value = new String(Base64.decode(value.getBytes()), "GBK");
value = new String(org.apache.commons.codec.binary.Base64.decodeBase64(value), "GBK");
}
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
}
public static class MyLocalDatetimeDeserializer extends StdDeserializer<LocalDateTime> {
private static final long serialVersionUID = 1L;
protected MyLocalDatetimeDeserializer() {
super(LocalDateTime.class);
}
@Override
public LocalDateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
return LocalDateTime.parse(jp.readValueAs(String.class), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
}
}
public static class MyLocalDatetimeSerializer extends StdSerializer<LocalDateTime> {
private static final long serialVersionUID = 1L;
public MyLocalDatetimeSerializer() {
super(LocalDateTime.class);
}
@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider sp) throws IOException, JsonProcessingException {
gen.writeString(value.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
}
}
// @SuppressWarnings({ "rawtypes" })
// public static class Base64Serializer extends JsonSerializer implements ContextualSerializer {
//
// @Override
// public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
// return this;
// }
//
// @Override
// public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
// if (!Base64.isBase64Pattern((String) value)) {
// value = Base64.decodeStr((String) value);
// }
// gen.writeObject(value);
// }
//
// }
@SuppressWarnings("unchecked")
public static void main(String[] args) {
String json = "[\"A\",\"B\"]";
List<String> list = JacksonUtils.fromJson(json, ArrayList.class);
System.out.println(list.get(0));
list = JacksonUtils.fromJson(json, new TypeReference<ArrayList<String>>() {
});
System.out.println(list.get(0));
System.out.println(new Date(10000000000000L));
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.util;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.experimental.UtilityClass;
import org.springframework.util.StringUtils;
import java.util.LinkedHashMap;
@UtilityClass
public class SopTplParamHandler {
public ObjectMapper objectMapper = new ObjectMapper();
public String extract(String tplParam) {
if (!StringUtils.hasLength(tplParam)) {
return null;
}
try {
JsonNode rootNode = objectMapper.readTree(tplParam);
return processNode(rootNode);
} catch (Exception e) {
throw new AdminException(ResultEnum.DATA_HANDLE_ERROR.getCode(), "参数转json对象异常");
}
}
public String addMerchantId(String paramJson, String merchantId) {
if (!StringUtils.hasLength(paramJson)) {
return null;
}
try {
JsonNode jsonNode = objectMapper.readTree(paramJson);
ObjectNode objectNode = (ObjectNode) jsonNode;
objectNode.put("merchantId", merchantId);
return objectNode.toString();
} catch (JsonProcessingException e) {
throw new AdminException(ResultEnum.DATA_HANDLE_ERROR.getCode(), "参数转json对象异常");
}
}
private String processNode(JsonNode node) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
for (JsonNode childNode : node) {
String key = childNode.path("paramKey").asText();
String valueType = childNode.path("valueType").asText();
JsonNode defaultValueNode = childNode.path("defaultValue");
switch (valueType) {
case "Number":
int defaultValueInt = defaultValueNode.asInt();
map.put(key, defaultValueInt);
break;
case "String":
String defaultValueString = defaultValueNode.asText();
map.put(key, defaultValueString);
break;
case "Map":
// 解析Map类型的默认值
LinkedHashMap<String, Object> defaultValueMap = objectMapper.convertValue(defaultValueNode, LinkedHashMap.class);
map.put(key, defaultValueMap);
break;
// 其他数据类型的解析
default:
break;
}
}
return JSON.toJSONString(map);
}
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.com.glsx.process.util;
import org.apache.commons.lang.StringUtils;
import com.google.common.base.CaseFormat;
/**
*
* @ClassName: Tools
* @Description: TODO(字符操作、hibernate validator)
* @author: 缪聪(mcg-helper@qq.com)
* @date: 2018年3月9日 下午5:41:39
*
*/
public class Tools {
public static String genFlowInstanceId(String httpSessionId, String flowId) {
return httpSessionId + "##" + flowId;
}
/*
* 分割字符串".",截取最后一段(如导入类型:java.utils.Date)截取最后的Date
*/
public static String splitLast(String data) {
if(StringUtils.isEmpty(data)) {
return null;
}
String[] split = data.split("\\.");
return split[split.length-1];
}
/*
* 字符串转换驼峰变量名
*/
public static String convertFieldName(String name) {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
}
/*
* 字符串转换类名
*/
public static String convertClassName(String name) {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name);
}
public static boolean isEmpty(String s) {
return s == null || "".equals(s) || "null".equals(s);
}
public static String genWsshConnUniqueId(String httpSessionId, String webSocketSessionId) {
return String.format("%s#%s", httpSessionId, webSocketSessionId);
}
public static String genMcgWsConnUniqueId(String mcgWebScoketCode, String httpSessionId) {
return String.format("%s#%s", mcgWebScoketCode, httpSessionId);
}
}
spring.application.name=admin server.port=9823
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log server.servlet.context-path=/process
#server # database
server.port=8202 spring.datasource.url=jdbc:mysql://192.168.3.222:3308/platform_process_dev?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&allowMultiQueries=true
server.servlet.context-path=/${spring.application.name} spring.datasource.username=user_zhouhb
server.servlet.session.timeout=2592000 spring.datasource.password=WoWP7N1u
server.max-http-header-size=8192
server.tomcat.uri-encoding=UTF-8
server.tomcat.max-threads=1000
server.tomcat.min-spare-threads=30s
server.tomcat.basedir=/temp
#database elaticjob.zookeeper.server-lists=192.168.3.101:2181
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver elaticjob.zookeeper.dynamiczk=192.168.3.101:2181
spring.datasource.url=jdbc:mysql://192.168.0.39:3306/gecc?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false elaticjob.zookeeper.namespace=glsx_sop
spring.datasource.username=root
spring.datasource.password=123456
# Hikari will use the above plus the following to setup connection pooling
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.data.redis.repositories.enabled = false
#redis config
spring.redis.host=192.168.0.39
spring.redis.port=6379
spring.redis.password=hhxredis
spring.redis.database=1
spring.redis.timeout=200000
#jwt config
jwt.config.header=Authorization
jwt.config.ttl=7200
jwt.config.key=5371f568a45e5ab1f442c38e0932aef24447139c
\ No newline at end of file \ No newline at end of file
xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
xxl.job.accessToken=default_token
xxl.job.executor.appname=xxl-job-executor-test
xxl.job.executor.address=
xxl.job.executor.ip=127.0.0.1
xxl.job.executor.port=8080
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
xxl.job.executor.logretentiondays=30
xxl.job.executor.groupId=1
...@@ -2,12 +2,21 @@ spring.application.name=platform-process ...@@ -2,12 +2,21 @@ spring.application.name=platform-process
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
### 禁用nacos,启用本地配置文件
#spring.cloud.nacos.config.enabled=false
#spring.cloud.nacos.config.refresh-enabled=false
#spring.cloud.nacos.discovery.enabled=false
#spring.cloud.nacos.discovery.instance-enabled=false
spring.cloud.nacos.config.server-addr=192.168.0.63:8868 spring.cloud.nacos.config.server-addr=192.168.0.63:8868
spring.cloud.nacos.config.group=PLATFORM_GROUP spring.cloud.nacos.config.group=platform
spring.cloud.nacos.config.prefix=${spring.application.name} spring.cloud.nacos.config.prefix=${spring.application.name}
spring.profiles.active=dev spring.profiles.active=dev
spring.cloud.nacos.config.file-extension=properties spring.cloud.nacos.config.file-extension=properties
#???????????????????????
spring.cloud.nacos.discovery.group=platform
spring.cloud.nacos.config.shared-configs[0].data-id=platform-microservice-share.properties spring.cloud.nacos.config.shared-configs[0].data-id=platform-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0].group=${spring.cloud.nacos.config.group} spring.cloud.nacos.config.shared-configs[0].group=${spring.cloud.nacos.config.group}
...@@ -15,4 +24,10 @@ spring.cloud.nacos.config.shared-configs[0].refresh=true ...@@ -15,4 +24,10 @@ spring.cloud.nacos.config.shared-configs[0].refresh=true
spring.cloud.nacos.config.shared-configs[1].group=${spring.cloud.nacos.config.group} spring.cloud.nacos.config.shared-configs[1].group=${spring.cloud.nacos.config.group}
spring.cloud.nacos.config.shared-configs[1].data-id=platform-share-dev.properties spring.cloud.nacos.config.shared-configs[1].data-id=platform-share-dev.properties
spring.cloud.nacos.config.shared-configs[1].refresh=true
\ No newline at end of file \ No newline at end of file
spring.cloud.nacos.config.shared-configs[1].refresh=true
#@PropertySource("file:${env.properties.path}/${env.profile}/application.properties")
#spring.config.location=application.properties_standalone
admin_name=Scheduling Center
admin_name_full=Distributed Task Scheduling Platform XXL-JOB
admin_version=2.4.1-SNAPSHOT
admin_i18n=en
## system
system_tips=System message
system_ok=Confirm
system_close=Close
system_save=Save
system_cancel=Cancel
system_search=Search
system_status=Status
system_opt=Operate
system_please_input=please input
system_please_choose=please choose
system_success=success
system_fail=fail
system_add_suc=add success
system_add_fail=add fail
system_update_suc=update success
system_update_fail=update fail
system_all=All
system_api_error=net error
system_show=Show
system_empty=Empty
system_opt_suc=operate success
system_opt_fail=operate fail
system_opt_edit=Edit
system_opt_del=Delete
system_opt_copy=Copy
system_unvalid=illegal
system_not_found=not exist
system_nav=Navigation
system_digits=digits
system_lengh_limit=Length limit
system_permission_limit=Permission limit
system_welcome=Welcome
## daterangepicker
daterangepicker_ranges_recent_hour=recent one hour
daterangepicker_ranges_today=today
daterangepicker_ranges_yesterday=yesterday
daterangepicker_ranges_this_month=this month
daterangepicker_ranges_last_month=last month
daterangepicker_ranges_recent_week=recent one week
daterangepicker_ranges_recent_month=recent one month
daterangepicker_custom_name=custom
daterangepicker_custom_starttime=start time
daterangepicker_custom_endtime=end time
daterangepicker_custom_daysofweek=Sun,Mon,Tue,Wed,Thu,Fri,Sat
daterangepicker_custom_monthnames=Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
## dataTable
dataTable_sProcessing=processing...
dataTable_sLengthMenu= _MENU_ records per page
dataTable_sZeroRecords=No matching results
dataTable_sInfo=page _PAGE_ ( Total _PAGES_ pages,_TOTAL_ records )
dataTable_sInfoEmpty=No Record
dataTable_sInfoFiltered=(Filtered by _MAX_ results)
dataTable_sSearch=Search
dataTable_sEmptyTable=Table data is empty
dataTable_sLoadingRecords=Loading...
dataTable_sFirst=FIRST PAGE
dataTable_sPrevious=Previous Page
dataTable_sNext=Next Page
dataTable_sLast=LAST PAGE
dataTable_sSortAscending=: Rank this column in ascending order
dataTable_sSortDescending=: Rank this column in descending order
## login
login_btn=Login
login_remember_me=Remember Me
login_username_placeholder=Please enter username
login_password_placeholder=Please enter password
login_username_empty=Please enter username
login_username_lt_4=Username length should not be less than 4
login_password_empty=Please enter password
login_password_lt_4=Password length should not be less than 4
login_success=Login success
login_fail=Login fail
login_param_empty=Username or password is empty
login_param_unvalid=Username or password error
## logout
logout_btn=Logout
logout_confirm=Confirm logout?
logout_success=Logout success
logout_fail=Logout fail
## change pwd
change_pwd=Change password
change_pwd_suc_to_logout=Change password successful, about to log out login
change_pwd_field_newpwd=new password
## dashboard
job_dashboard_name=Run report
job_dashboard_job_num=Job number
job_dashboard_job_num_tip=The number of tasks running in the scheduling center
job_dashboard_trigger_num=trigger number
job_dashboard_trigger_num_tip=The number of trigger record scheduled by the scheduling center
job_dashboard_jobgroup_num=Executor number
job_dashboard_jobgroup_num_tip=The number of online executor machines perceived by the scheduling center
job_dashboard_report=Scheduling report
job_dashboard_report_loaddata_fail=Scheduling report load data error
job_dashboard_date_report=Date distribution
job_dashboard_rate_report=Percentage distribution
## job info
jobinfo_name=Job Manage
jobinfo_job=Job
jobinfo_field_add=Add Job
jobinfo_field_update=Edit Job
jobinfo_field_id=Job ID
jobinfo_field_jobgroup=Executor
jobinfo_field_jobdesc=Job description
jobinfo_field_timeout=Job timeout period
jobinfo_field_gluetype=GLUE Type
jobinfo_field_executorparam=Param
jobinfo_field_author=Author
jobinfo_field_alarmemail=Alarm email
jobinfo_field_alarmemail_placeholder=Please enter alarm mail, if there are more than one comma separated
jobinfo_field_executorRouteStrategy=Route Strategy
jobinfo_field_childJobId=Child Job ID
jobinfo_field_childJobId_placeholder=Please enter the Child job ID, if there are more than one comma separated
jobinfo_field_executorBlockStrategy=Block Strategy
jobinfo_field_executorFailRetryCount=Fail Retry Count
jobinfo_field_executorFailRetryCount_placeholder=Fail Retry Count. effect if greater than zero
jobinfo_script_location=Script location
jobinfo_shard_index=Shard index
jobinfo_shard_total=Shard total
jobinfo_opt_stop=Stop
jobinfo_opt_start=Start
jobinfo_opt_log=Query Log
jobinfo_opt_run=Run Once
jobinfo_opt_run_tips=Please input the address for this trigger. Null will be obtained from the executor
jobinfo_opt_registryinfo=Registry Info
jobinfo_opt_next_time=Next trigger time
jobinfo_glue_remark=Resource Remark
jobinfo_glue_remark_limit=Resource Remark length is limited to 4~100
jobinfo_glue_rollback=Version Backtrack
jobinfo_glue_jobid_unvalid=Job ID is illegal
jobinfo_glue_gluetype_unvalid=The job is not GLUE Type
jobinfo_field_executorTimeout_placeholder=Job Timeout period,in seconds. effect if greater than zero
schedule_type=Schedule Type
schedule_type_none=None
schedule_type_cron=Cron
schedule_type_fix_rate=Fix rate
schedule_type_fix_delay=Fix delay
schedule_type_none_limit_start=The current schedule type disables startup
misfire_strategy=Misfire strategy
misfire_strategy_do_nothing=Do nothing
misfire_strategy_fire_once_now=Fire once now
jobinfo_conf_base=Base configuration
jobinfo_conf_schedule=Schedule configuration
jobinfo_conf_job=Job configuration
jobinfo_conf_advanced=Advanced configuration
## job log
joblog_name=Trigger Log
joblog_status=Status
joblog_status_all=All
joblog_status_suc=Success
joblog_status_fail=Fail
joblog_status_running=Running
joblog_field_triggerTime=Trigger Time
joblog_field_triggerCode=Trigger Result
joblog_field_triggerMsg=Trigger Msg
joblog_field_handleTime=Handle Time
joblog_field_handleCode=Handle Result
joblog_field_handleMsg=Trigger Msg
joblog_field_executorAddress=Executor Address
joblog_clean=Clean
joblog_clean_log=Clean Log
joblog_clean_type=Clean Type
joblog_clean_type_1=Clean up log data a month ago
joblog_clean_type_2=Clean up log data three month ago
joblog_clean_type_3=Clean up log data six month ago
joblog_clean_type_4=Clean up log data a year ago
joblog_clean_type_5=Clean up log data a thousand record ago
joblog_clean_type_6=Clean up log data ten thousand record ago
joblog_clean_type_7=Clean up log data thirty thousand record ago
joblog_clean_type_8=Clean up log data hundred thousand record ago
joblog_clean_type_9=Clean up all log data
joblog_clean_type_unvalid=Clean type is illegal
joblog_handleCode_200=Success
joblog_handleCode_500=Fail
joblog_handleCode_502=Timeout
joblog_kill_log=Kill Job
joblog_kill_log_limit=Trigger Fail, can not kill job
joblog_kill_log_byman=Manual operation, kill job
joblog_lost_fail=Job result lost, marked as failure
joblog_rolling_log=Rolling log
joblog_rolling_log_refresh=Refresh
joblog_rolling_log_triggerfail=The job trigger fail, can not view the rolling log
joblog_rolling_log_failoften=The request for the Rolling log is terminated, the number of failed requests exceeds the limit, Reload the log on the refresh page
joblog_logid_unvalid=Log ID is illegal
## job group
jobgroup_name=Executor Manage
jobgroup_list=Executor List
jobgroup_add=Add Executor
jobgroup_edit=Edit Executor
jobgroup_del=Delete Executor
jobgroup_field_title=Title
jobgroup_field_addressType=Registry Type
jobgroup_field_addressType_0=Automatic registration
jobgroup_field_addressType_1=Manual registration
jobgroup_field_addressType_limit=Manually registration type, the machine address must not be empty
jobgroup_field_registryList=machine address
jobgroup_field_registryList_unvalid=registry machine address is illegal
jobgroup_field_registryList_placeholder=Please enter the machine address, if there are more than one comma separated
jobgroup_field_appname_limit=Limit the beginning of a lowercase letter, consists of lowercase letters、number and hyphen.
jobgroup_field_appname_length=AppName length is limited to 4~64
jobgroup_field_title_length=Title length is limited to 4~12
jobgroup_field_order_digits=Please enter a positive integer
jobgroup_field_orderrange=Order is limited to 1~1000
jobgroup_del_limit_0=Refuse to delete, the executor is being used
jobgroup_del_limit_1=Refuses to delete, the system retains at least one executor
jobgroup_empty=There is no valid executor. Please contact the administrator
## job conf
jobconf_block_SERIAL_EXECUTION=Serial execution
jobconf_block_DISCARD_LATER=Discard Later
jobconf_block_COVER_EARLY=Cover Early
jobconf_route_first=First
jobconf_route_last=Last
jobconf_route_round=Round
jobconf_route_random=Random
jobconf_route_consistenthash=Consistent Hash
jobconf_route_lfu=Least Frequently Used
jobconf_route_lru=Least Recently Used
jobconf_route_failover=Failover
jobconf_route_busyover=Busyover
jobconf_route_shard=Sharding Broadcast
jobconf_idleBeat=Idle check
jobconf_beat=Heartbeats
jobconf_monitor=Task Scheduling Center monitor alarm
jobconf_monitor_detail=monitor alarm details
jobconf_monitor_alarm_title=Alarm Type
jobconf_monitor_alarm_type=Trigger Fail
jobconf_monitor_alarm_content=Alarm Content
jobconf_trigger_admin_adress=Trigger machine address
jobconf_trigger_exe_regtype=Execotor-Registry Type
jobconf_trigger_exe_regaddress=Execotor-Registry Address
jobconf_trigger_address_empty=Trigger Fail:registry address is empty
jobconf_trigger_run=Trigger Job
jobconf_trigger_child_run=Trigger child job
jobconf_callback_child_msg1={0}/{1} [Job ID={2}], Trigger {3}, Trigger msg: {4} <br>
jobconf_callback_child_msg2={0}/{1} [Job ID={2}], Trigger Fail, Trigger msg: Job ID is illegal <br>
jobconf_trigger_type=Job trigger type
jobconf_trigger_type_cron=Cron trigger
jobconf_trigger_type_manual=Manual trigger
jobconf_trigger_type_parent=Parent job trigger
jobconf_trigger_type_api=Api trigger
jobconf_trigger_type_retry=Fail retry trigger
jobconf_trigger_type_misfire=Misfire compensation trigger
## user
user_manage=User Manage
user_username=Username
user_password=Password
user_role=Role
user_role_admin=Admin User
user_role_normal=Normal User
user_permission=Permission
user_add=Add User
user_update=Edit User
user_username_repeat=Username Repeat
user_username_valid=Restrictions start with a lowercase letter and consist of lowercase letters and Numbers
user_password_update_placeholder=Please input password, empty means not update
user_update_loginuser_limit=Operation of current login account is not allowed
## help
job_help=Tutorial
job_help_document=Official Document
admin_name=任务调度中心
admin_name_full=分布式任务调度平台XXL-JOB
admin_version=2.4.1-SNAPSHOT
admin_i18n=
## system
system_tips=系统提示
system_ok=确定
system_close=关闭
system_save=保存
system_cancel=取消
system_search=搜索
system_status=状态
system_opt=操作
system_please_input=请输入
system_please_choose=请选择
system_success=成功
system_fail=失败
system_add_suc=新增成功
system_add_fail=新增失败
system_update_suc=更新成功
system_update_fail=更新失败
system_all=全部
system_api_error=接口异常
system_show=查看
system_empty=无
system_opt_suc=操作成功
system_opt_fail=操作失败
system_opt_edit=编辑
system_opt_del=删除
system_opt_copy=复制
system_unvalid=非法
system_not_found=不存在
system_nav=导航
system_digits=整数
system_lengh_limit=长度限制
system_permission_limit=权限拦截
system_welcome=欢迎
## daterangepicker
daterangepicker_ranges_recent_hour=最近一小时
daterangepicker_ranges_today=今日
daterangepicker_ranges_yesterday=昨日
daterangepicker_ranges_this_month=本月
daterangepicker_ranges_last_month=上个月
daterangepicker_ranges_recent_week=最近一周
daterangepicker_ranges_recent_month=最近一月
daterangepicker_custom_name=自定义
daterangepicker_custom_starttime=起始时间
daterangepicker_custom_endtime=结束时间
daterangepicker_custom_daysofweek=日,一,二,三,四,五,六
daterangepicker_custom_monthnames=一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月
## dataTable
dataTable_sProcessing=处理中...
dataTable_sLengthMenu=每页 _MENU_ 条记录
dataTable_sZeroRecords=没有匹配结果
dataTable_sInfo=第 _PAGE_ 页 ( 总共 _PAGES_ 页,_TOTAL_ 条记录 )
dataTable_sInfoEmpty=无记录
dataTable_sInfoFiltered=(由 _MAX_ 项结果过滤)
dataTable_sSearch=搜索
dataTable_sEmptyTable=表中数据为空
dataTable_sLoadingRecords=载入中...
dataTable_sFirst=首页
dataTable_sPrevious=上页
dataTable_sNext=下页
dataTable_sLast=末页
dataTable_sSortAscending=: 以升序排列此列
dataTable_sSortDescending=: 以降序排列此列
## login
login_btn=登录
login_remember_me=记住密码
login_username_placeholder=请输入登录账号
login_password_placeholder=请输入登录密码
login_username_empty=请输入登录账号
login_username_lt_4=登录账号不应低于4位
login_password_empty=请输入登录密码
login_password_lt_4=登录密码不应低于4位
login_success=登录成功
login_fail=登录失败
login_param_empty=账号或密码为空
login_param_unvalid=账号或密码错误
## logout
logout_btn=注销
logout_confirm=确认注销登录?
logout_success=注销成功
logout_fail=注销失败
## change pwd
change_pwd=修改密码
change_pwd_suc_to_logout=修改密码成功,即将注销登陆
change_pwd_field_newpwd=新密码
## dashboard
job_dashboard_name=运行报表
job_dashboard_job_num=任务数量
job_dashboard_job_num_tip=调度中心运行的任务数量
job_dashboard_trigger_num=调度次数
job_dashboard_trigger_num_tip=调度中心触发的调度次数
job_dashboard_jobgroup_num=执行器数量
job_dashboard_jobgroup_num_tip=调度中心在线的执行器机器数量
job_dashboard_report=调度报表
job_dashboard_report_loaddata_fail=调度报表数据加载异常
job_dashboard_date_report=日期分布图
job_dashboard_rate_report=成功比例图
## job info
jobinfo_name=任务管理
jobinfo_job=任务
jobinfo_field_add=新增
jobinfo_field_update=更新任务
jobinfo_field_id=任务ID
jobinfo_field_jobgroup=执行器
jobinfo_field_jobdesc=任务描述
jobinfo_field_gluetype=运行模式
jobinfo_field_executorparam=任务参数
jobinfo_field_author=负责人
jobinfo_field_timeout=任务超时时间
jobinfo_field_alarmemail=报警邮件
jobinfo_field_alarmemail_placeholder=请输入报警邮件,多个邮件地址则逗号分隔
jobinfo_field_executorRouteStrategy=路由策略
jobinfo_field_childJobId=子任务ID
jobinfo_field_childJobId_placeholder=请输入子任务的任务ID,如存在多个则逗号分隔
jobinfo_field_executorBlockStrategy=阻塞处理策略
jobinfo_field_executorFailRetryCount=失败重试次数
jobinfo_field_executorFailRetryCount_placeholder=失败重试次数,大于零时生效
jobinfo_script_location=脚本位置
jobinfo_shard_index=分片序号
jobinfo_shard_total=分片总数
jobinfo_opt_stop=停止
jobinfo_opt_start=启动
jobinfo_opt_log=查询日志
jobinfo_opt_run=执行一次
jobinfo_opt_run_tips=请输入本次执行的机器地址,为空则从执行器获取
jobinfo_opt_registryinfo=注册节点
jobinfo_opt_next_time=下次执行时间
jobinfo_glue_remark=源码备注
jobinfo_glue_remark_limit=源码备注长度限制为4~100
jobinfo_glue_rollback=版本回溯
jobinfo_glue_jobid_unvalid=任务ID非法
jobinfo_glue_gluetype_unvalid=该任务非GLUE模式
jobinfo_field_executorTimeout_placeholder=任务超时时间,单位秒,大于零时生效
schedule_type=调度类型
schedule_type_none=无
schedule_type_cron=CRON
schedule_type_fix_rate=固定速度
schedule_type_fix_delay=固定延迟
schedule_type_none_limit_start=当前调度类型禁止启动
misfire_strategy=调度过期策略
misfire_strategy_do_nothing=忽略
misfire_strategy_fire_once_now=立即执行一次
jobinfo_conf_base=基础配置
jobinfo_conf_schedule=调度配置
jobinfo_conf_job=任务配置
jobinfo_conf_advanced=高级配置
## job log
joblog_name=调度日志
joblog_status=状态
joblog_status_all=全部
joblog_status_suc=成功
joblog_status_fail=失败
joblog_status_running=进行中
joblog_field_triggerTime=调度时间
joblog_field_triggerCode=调度结果
joblog_field_triggerMsg=调度备注
joblog_field_handleTime=执行时间
joblog_field_handleCode=执行结果
joblog_field_handleMsg=执行备注
joblog_field_executorAddress=执行器地址
joblog_clean=清理
joblog_clean_log=日志清理
joblog_clean_type=清理方式
joblog_clean_type_1=清理一个月之前日志数据
joblog_clean_type_2=清理三个月之前日志数据
joblog_clean_type_3=清理六个月之前日志数据
joblog_clean_type_4=清理一年之前日志数据
joblog_clean_type_5=清理一千条以前日志数据
joblog_clean_type_6=清理一万条以前日志数据
joblog_clean_type_7=清理三万条以前日志数据
joblog_clean_type_8=清理十万条以前日志数据
joblog_clean_type_9=清理所有日志数据
joblog_clean_type_unvalid=清理类型参数异常
joblog_handleCode_200=成功
joblog_handleCode_500=失败
joblog_handleCode_502=失败(超时)
joblog_kill_log=终止任务
joblog_kill_log_limit=调度失败,无法终止日志
joblog_kill_log_byman=人为操作,主动终止
joblog_lost_fail=任务结果丢失,标记失败
joblog_rolling_log=执行日志
joblog_rolling_log_refresh=刷新
joblog_rolling_log_triggerfail=任务发起调度失败,无法查看执行日志
joblog_rolling_log_failoften=终止请求Rolling日志,请求失败次数超上限,可刷新页面重新加载日志
joblog_logid_unvalid=日志ID非法
## job group
jobgroup_name=执行器管理
jobgroup_list=执行器列表
jobgroup_add=新增执行器
jobgroup_edit=编辑执行器
jobgroup_del=删除执行器
jobgroup_field_title=名称
jobgroup_field_addressType=注册方式
jobgroup_field_addressType_0=自动注册
jobgroup_field_addressType_1=手动录入
jobgroup_field_addressType_limit=手动录入注册方式,机器地址不可为空
jobgroup_field_registryList=机器地址
jobgroup_field_registryList_unvalid=机器地址格式非法
jobgroup_field_registryList_placeholder=请输入执行器地址列表,多地址逗号分隔
jobgroup_field_appname_limit=限制以小写字母开头,由小写字母、数字和中划线组成
jobgroup_field_appname_length=AppName长度限制为4~64
jobgroup_field_title_length=名称长度限制为4~12
jobgroup_field_order_digits=请输入整数
jobgroup_field_orderrange=取值范围为1~1000
jobgroup_del_limit_0=拒绝删除,该执行器使用中
jobgroup_del_limit_1=拒绝删除, 系统至少保留一个执行器
jobgroup_empty=不存在有效执行器,请联系管理员
## job conf
jobconf_block_SERIAL_EXECUTION=单机串行
jobconf_block_DISCARD_LATER=丢弃后续调度
jobconf_block_COVER_EARLY=覆盖之前调度
jobconf_route_first=第一个
jobconf_route_last=最后一个
jobconf_route_round=轮询
jobconf_route_random=随机
jobconf_route_consistenthash=一致性HASH
jobconf_route_lfu=最不经常使用
jobconf_route_lru=最近最久未使用
jobconf_route_failover=故障转移
jobconf_route_busyover=忙碌转移
jobconf_route_shard=分片广播
jobconf_idleBeat=空闲检测
jobconf_beat=心跳检测
jobconf_monitor=任务调度中心监控报警
jobconf_monitor_detail=监控告警明细
jobconf_monitor_alarm_title=告警类型
jobconf_monitor_alarm_type=调度失败
jobconf_monitor_alarm_content=告警内容
jobconf_trigger_admin_adress=调度机器
jobconf_trigger_exe_regtype=执行器-注册方式
jobconf_trigger_exe_regaddress=执行器-地址列表
jobconf_trigger_address_empty=调度失败:执行器地址为空
jobconf_trigger_run=触发调度
jobconf_trigger_child_run=触发子任务
jobconf_callback_child_msg1={0}/{1} [任务ID={2}], 触发{3}, 触发备注: {4} <br>
jobconf_callback_child_msg2={0}/{1} [任务ID={2}], 触发失败, 触发备注: 任务ID格式错误 <br>
jobconf_trigger_type=任务触发类型
jobconf_trigger_type_cron=Cron触发
jobconf_trigger_type_manual=手动触发
jobconf_trigger_type_parent=父任务触发
jobconf_trigger_type_api=API触发
jobconf_trigger_type_retry=失败重试触发
jobconf_trigger_type_misfire=调度过期补偿
## user
user_manage=用户管理
user_username=账号
user_password=密码
user_role=角色
user_role_admin=管理员
user_role_normal=普通用户
user_permission=权限
user_add=新增用户
user_update=更新用户
user_username_repeat=账号重复
user_username_valid=限制以小写字母开头,由小写字母、数字组成
user_password_update_placeholder=请输入新密码,为空则不更新密码
user_update_loginuser_limit=禁止操作当前登录账号
## help
job_help=使用教程
job_help_document=官方文档
\ No newline at end of file \ No newline at end of file
admin_name=任務調度中心
admin_name_full=分布式任務調度平臺XXL-JOB
admin_version=2.4.1-SNAPSHOT
admin_i18n=
## system
system_tips=系統提示
system_ok=確定
system_close=關閉
system_save=儲存
system_cancel=取消
system_search=搜尋
system_status=狀態
system_opt=操作
system_please_input=請輸入
system_please_choose=请選擇
system_success=成功
system_fail=失敗
system_add_suc=新增成功
system_add_fail=新增失敗
system_update_suc=更新成功
system_update_fail=更新失敗
system_all=全部
system_api_error=API錯誤
system_show=查看
system_empty=無
system_opt_suc=操作成功
system_opt_fail=操作失敗
system_opt_edit=編輯
system_opt_del=刪除
system_opt_copy=復制
system_unvalid=非法
system_not_found=不存在
system_nav=導航
system_digits=整數
system_lengh_limit=長度限制
system_permission_limit=權限控管
system_welcome=歡迎
## daterangepicker
daterangepicker_ranges_recent_hour=最近一小時
daterangepicker_ranges_today=今日
daterangepicker_ranges_yesterday=昨日
daterangepicker_ranges_this_month=本月
daterangepicker_ranges_last_month=上個月
daterangepicker_ranges_recent_week=最近一周
daterangepicker_ranges_recent_month=最近一月
daterangepicker_custom_name=自定義
daterangepicker_custom_starttime=起始時間
daterangepicker_custom_endtime=結束時間
daterangepicker_custom_daysofweek=日,一,二,三,四,五,六
daterangepicker_custom_monthnames=一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月
## dataTable
dataTable_sProcessing=處理中...
dataTable_sLengthMenu=每頁 _MENU_ 條記錄
dataTable_sZeroRecords=沒有相符合記錄
dataTable_sInfo=第 _PAGE_ 頁 ( 總共 _PAGES_ 頁,_TOTAL_ 條記錄 )
dataTable_sInfoEmpty=無記錄
dataTable_sInfoFiltered=(由 _MAX_ 項結果過濾)
dataTable_sSearch=搜尋
dataTable_sEmptyTable=表中資料為空
dataTable_sLoadingRecords=載入中...
dataTable_sFirst=首頁
dataTable_sPrevious=上頁
dataTable_sNext=下頁
dataTable_sLast=末頁
dataTable_sSortAscending=: 以升幂排序此列
dataTable_sSortDescending=: 以降幂排序此列
## login
login_btn=登入
login_remember_me=記住密碼
login_username_placeholder=請輸入登入帳號
login_password_placeholder=請輸入登入密碼
login_username_empty=請輸入登入帳號
login_username_lt_4=登入帳號不應低於4位數
login_password_empty=請輸入登入密碼
login_password_lt_4=登入密碼不應低於4位數
login_success=登入成功
login_fail=登入失敗
login_param_empty=帳號或密碼為空值
login_param_unvalid=帳號或密碼錯誤
## logout
logout_btn=登出
logout_confirm=確認登出?
logout_success=登出成功
logout_fail=登出失敗
## change pwd
change_pwd=修改密碼
change_pwd_suc_to_logout=修改密碼成功,即將登出
change_pwd_field_newpwd=新密碼
## dashboard
job_dashboard_name=運行報表
job_dashboard_job_num=任務數量
job_dashboard_job_num_tip=調度中心運行的任務數量
job_dashboard_trigger_num=調度次數
job_dashboard_trigger_num_tip=調度中心觸發的調度次數
job_dashboard_jobgroup_num=執行器數量
job_dashboard_jobgroup_num_tip=調度中心在線的執行器機器數量
job_dashboard_report=調度報表
job_dashboard_report_loaddata_fail=調度報表資料加載異常
job_dashboard_date_report=日期分布圖
job_dashboard_rate_report=成功比例圖
## job info
jobinfo_name=任務管理
jobinfo_job=任務
jobinfo_field_add=新增
jobinfo_field_update=更新任務
jobinfo_field_id=任務ID
jobinfo_field_jobgroup=執行器
jobinfo_field_jobdesc=任務描述
jobinfo_field_gluetype=運行模式
jobinfo_field_executorparam=任務參數
jobinfo_field_author=負責人
jobinfo_field_timeout=任務超時秒數
jobinfo_field_alarmemail=告警郵件
jobinfo_field_alarmemail_placeholder=輸入多個告警郵件地址,請以逗號分隔
jobinfo_field_executorRouteStrategy=路由策略
jobinfo_field_childJobId=子任務ID
jobinfo_field_childJobId_placeholder=輸入子任務ID,如有多個請以逗號分隔
jobinfo_field_executorBlockStrategy=阻塞處理策略
jobinfo_field_executorFailRetryCount=失敗重試次數
jobinfo_field_executorFailRetryCount_placeholder=失敗重試次數,大於零時生效
jobinfo_script_location=腳本位置
jobinfo_shard_index=分片序號
jobinfo_shard_total=分片總數
jobinfo_opt_stop=停止
jobinfo_opt_start=啟動
jobinfo_opt_log=查詢日誌
jobinfo_opt_run=執行一次
jobinfo_opt_run_tips=請輸入本次執行的機器地址,為空則從執行器獲取
jobinfo_opt_registryinfo=注冊節點
jobinfo_opt_next_time=下次執行時間
jobinfo_glue_remark=源碼備註
jobinfo_glue_remark_limit=源碼備註長度限制為4~100
jobinfo_glue_rollback=版本回復
jobinfo_glue_jobid_unvalid=任務ID非法
jobinfo_glue_gluetype_unvalid=該任務非GLUE模式
jobinfo_field_executorTimeout_placeholder=任務超時時間,單位秒,大於零時生效
schedule_type=調度類型
schedule_type_none=無
schedule_type_cron=CRON
schedule_type_fix_rate=固定速度
schedule_type_fix_delay=固定延遲
schedule_type_none_limit_start=當前調度類型禁止啟動
misfire_strategy=調度過期策略
misfire_strategy_do_nothing=忽略
misfire_strategy_fire_once_now=立即執行壹次
jobinfo_conf_base=基礎配置
jobinfo_conf_schedule=調度配置
jobinfo_conf_job=任務配置
jobinfo_conf_advanced=高級配置
## job log
joblog_name=調度日誌
joblog_status=狀態
joblog_status_all=全部
joblog_status_suc=成功
joblog_status_fail=失敗
joblog_status_running=進行中
joblog_field_triggerTime=調度時間
joblog_field_triggerCode=調度結果
joblog_field_triggerMsg=調度備註
joblog_field_handleTime=執行時間
joblog_field_handleCode=執行结果
joblog_field_handleMsg=執行備註
joblog_field_executorAddress=執行器地址
joblog_clean=清理
joblog_clean_log=日誌清理
joblog_clean_type=清理方式
joblog_clean_type_1=清理一個月之前日誌資料
joblog_clean_type_2=清理三個月之前日誌資料
joblog_clean_type_3=清理六個月之前日誌資料
joblog_clean_type_4=清理一年之前日誌資料
joblog_clean_type_5=清理一千條以前日誌資料
joblog_clean_type_6=清理一萬條以前日誌資料
joblog_clean_type_7=清理三萬條以前日誌資料
joblog_clean_type_8=清理十萬條以前日誌資料
joblog_clean_type_9=清理所有日誌資料
joblog_clean_type_unvalid=清理類型參数異常
joblog_handleCode_200=成功
joblog_handleCode_500=失敗
joblog_handleCode_502=失敗(超時)
joblog_kill_log=终止任務
joblog_kill_log_limit=調度失敗,無法终止日誌
joblog_kill_log_byman=人為操作,主動終止
joblog_lost_fail=任務結果丟失,標記失敗
joblog_rolling_log=執行日誌
joblog_rolling_log_refresh=更新
joblog_rolling_log_triggerfail=任務發起調度失敗,無法查看執行日誌
joblog_rolling_log_failoften=終止請求Rolling日誌,請求失敗次數超上限,可刷新頁面重新加載日誌
joblog_logid_unvalid=日誌ID非法
## job group
jobgroup_name=執行器管理
jobgroup_list=執行器列表
jobgroup_add=新增執行器
jobgroup_edit=編輯執行器
jobgroup_del=刪除執行器
jobgroup_field_title=名稱
jobgroup_field_addressType=注冊方式
jobgroup_field_addressType_0=自動注冊
jobgroup_field_addressType_1=手動登錄
jobgroup_field_addressType_limit=手動登錄注冊方式,機器地址不可為空
jobgroup_field_registryList=機器地址
jobgroup_field_registryList_unvalid=機器地址格式非法
jobgroup_field_registryList_placeholder=請輸入執行器地址列表,多個地址請以逗號分隔
jobgroup_field_appname_limit=限制以小寫字母開頭,由小寫字母、數字和中划線組成
jobgroup_field_appname_length=AppName長度限制為4~64
jobgroup_field_title_length=名稱長度限制為4~12
jobgroup_field_order_digits=請輸入整數
jobgroup_field_orderrange=取值範圍為1~1000
jobgroup_del_limit_0=拒絕刪除,該執行器使用中
jobgroup_del_limit_1=拒絕删除,系统至少保留一個執行器
jobgroup_empty=不存在有效執行器,請聯絡系統管理員
## job conf
jobconf_block_SERIAL_EXECUTION=單機串行
jobconf_block_DISCARD_LATER=丢棄后續調度
jobconf_block_COVER_EARLY=覆蓋之前調度
jobconf_route_first=第一個
jobconf_route_last=最後一個
jobconf_route_round=輪詢
jobconf_route_random=隨機
jobconf_route_consistenthash=一致性HASH
jobconf_route_lfu=最不經常使用
jobconf_route_lru=最近最久未使用
jobconf_route_failover=故障轉移
jobconf_route_busyover=忙碌轉移
jobconf_route_shard=分片廣播
jobconf_idleBeat=空閒檢測
jobconf_beat=心跳檢測
jobconf_monitor=任務調度中心監控告警
jobconf_monitor_detail=監控告警明细
jobconf_monitor_alarm_title=告警類型
jobconf_monitor_alarm_type=調度失敗
jobconf_monitor_alarm_content=告警内容
jobconf_trigger_admin_adress=調度機器
jobconf_trigger_exe_regtype=執行器-注冊方式
jobconf_trigger_exe_regaddress=執行器-地址列表
jobconf_trigger_address_empty=調度失敗:執行器地址為空
jobconf_trigger_run=觸發調度
jobconf_trigger_child_run=觸發子任務
jobconf_callback_child_msg1={0}/{1} [任務ID={2}], 觸發{3}, 觸發備註: {4} <br>
jobconf_callback_child_msg2={0}/{1} [任務ID={2}], 觸發失败, 觸發備註: 任務ID格式錯誤 <br>
jobconf_trigger_type=任務觸發類型
jobconf_trigger_type_cron=Cron觸發
jobconf_trigger_type_manual=手動觸發
jobconf_trigger_type_parent=父任務觸發
jobconf_trigger_type_api=API觸發
jobconf_trigger_type_retry=失敗重試觸發
jobconf_trigger_type_misfire=調度過期補償
## user
user_manage=用户管理
user_username=帳號
user_password=密碼
user_role=角色
user_role_admin=管理員
user_role_normal=普通用戶
user_permission=權限
user_add=新增用戶
user_update=更新用戶
user_username_repeat=帳號重複
user_username_valid=限制以小寫字母開頭,由小寫字母、數字組成
user_password_update_placeholder=請輸入新密碼,為空則不更新密碼
user_update_loginuser_limit=禁止操作當前登入帳號
## help
job_help=使用教程
job_help_document=官方文件
\ No newline at end of file \ No newline at end of file
...@@ -32,7 +32,7 @@ logback-spring.xml引入文件: ...@@ -32,7 +32,7 @@ logback-spring.xml引入文件:
<!-- <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />--> <!-- <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />-->
<!-- 配置日志输出参数,彩色日志格式 --> <!-- 配置日志输出参数,彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/> <property name="CONSOLE_LOG_PATTERN" value="%date{HH:mm:ss.SSS} | %-5level | %msg | \\(%file:%line\\) %n"/>
<!-- 控制台打印日志 --> <!-- 控制台打印日志 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
...@@ -91,7 +91,21 @@ logback-spring.xml引入文件: ...@@ -91,7 +91,21 @@ logback-spring.xml引入文件:
<!-- </providers>--> <!-- </providers>-->
<!-- </encoder>--> <!-- </encoder>-->
<!-- </appender>--> <!-- </appender>-->
​
<logger name="cn.com.glsx" level="DEBUG" />
<logger name="org.apache" level="WARN" />
<logger name="org.mybatis" level="WARN" />
<logger name="freemarker.runtime" level="OFF" />
<logger name="org.springframework" level="INFO" />
<logger name="com.netflix.discovery" level="WARN" />
<logger name="com.netflix.eureka.registry.AbstractInstanceRegistry" level="WARN" />
<logger name="com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl" level="WARN" />
<logger name="com.netflix.eureka.cluster.PeerEurekaNodes" level="ERROR" />
<logger name="com.netflix.config.sources.URLConfigurationSource" level="ERROR" />
<logger name="org.springframework.boot.web.embedded.tomcat" level="INFO" />
<logger name="org.springframework.cloud.config.client.ConfigServicePropertySourceLocator" level="INFO" />
​
<root level="INFO"> <root level="INFO">
<appender-ref ref="console"/> <appender-ref ref="console"/>
<appender-ref ref="flatfile"/> <appender-ref ref="flatfile"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.JobManagerMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.JobManager">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="job_name" jdbcType="VARCHAR" property="jobName" />
<result column="cron" jdbcType="VARCHAR" property="cron" />
<result column="class" jdbcType="VARCHAR" property="className" />
<result column="parameters" jdbcType="VARCHAR" property="parameters" />
<result column="share_total_count" jdbcType="INTEGER" property="shareTotalCount" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, job_name, cron, class, parameters, share_total_count, del_flag, create_time,
update_time
</sql>
<select id="findByName" resultType="cn.com.glsx.process.modules.entity.JobManager"
parameterType="java.lang.String">
select * from job_manager
where job_name=#{jobName} LIMIT 1
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.NodeTplMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.NodeTpl">
<!--
WARNING - @mbg.generated
-->
<id column="tpl_node_id" jdbcType="INTEGER" property="tplNodeId" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="node_label" jdbcType="VARCHAR" property="nodeLabel" />
<result column="node_show" jdbcType="VARCHAR" property="nodeShow" />
<result column="node_visible" jdbcType="TINYINT" property="nodeVisible" />
<result column="node_cron" jdbcType="VARCHAR" property="nodeCron" />
<result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" />
<result column="node_skipable" jdbcType="TINYINT" property="nodeSkipable" />
<result column="node_param_def" jdbcType="LONGVARCHAR" property="nodeParamDef" />
<result column="node_content_def" jdbcType="LONGVARCHAR" property="nodeContentDef" />
<result column="node_result_def" jdbcType="LONGVARCHAR" property="nodeResultDef" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
tpl_node_id, node_name, node_type, node_label, node_show, node_visible, node_cron,
node_expire_cron, node_skipable
<!--
WARNING - @mbg.generated
-->
,node_param_def, node_content_def, node_result_def
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopDataSourceMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopDataSource">
<!--
WARNING - @mbg.generated
-->
<result column="id" jdbcType="INTEGER" property="id" />
<result column="db_type" jdbcType="VARCHAR" property="dbType" />
<result column="db_server" jdbcType="VARCHAR" property="dbServer" />
<result column="db_port" jdbcType="VARCHAR" property="dbPort" />
<result column="db_user_name" jdbcType="VARCHAR" property="dbUserName" />
<result column="db_pwd" jdbcType="VARCHAR" property="dbPwd" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="db_name" jdbcType="VARCHAR" property="dbName" />
<result column="data_source_id" jdbcType="VARCHAR" property="dataSourceId" />
</resultMap>
<select id="findByDataSourceId" resultMap="BaseResultMap"
parameterType="java.lang.String">
select *
from sop_data_source
where data_source_id = #{dataSourceId}
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopInstBatchMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInstBatch">
<!--
WARNING - @mbg.generated
-->
<id column="batch_no" jdbcType="VARCHAR" property="batchNo" />
<result column="inst_id" jdbcType="VARCHAR" property="instId" />
<result column="snapshot" jdbcType="VARCHAR" property="snapshot" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
batch_no, inst_id, snapshot, create_time, update_time
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopInstLinkMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInstLink">
<!--
WARNING - @mbg.generated
-->
<id column="link_id" jdbcType="INTEGER" property="linkId" />
<result column="inst_id" jdbcType="VARCHAR" property="instId" />
<result column="source_id" jdbcType="INTEGER" property="sourceId" />
<result column="target_id" jdbcType="INTEGER" property="targetId" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
link_id, inst_id, source_id, target_id
</sql>
<select id="findByInstId" resultMap="BaseResultMap"
parameterType="java.lang.String">
SELECT * FROM sop_inst_link WHERE inst_id=#{instId}
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopInstMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInst">
<!--
WARNING - @mbg.generated
-->
<id column="inst_id" jdbcType="VARCHAR" property="instId" />
<result column="grant_id" jdbcType="INTEGER" property="grantId" />
<result column="inst_name" jdbcType="VARCHAR" property="instName" />
<result column="inst_cron" jdbcType="VARCHAR" property="instCron" />
<result column="inst_remark" jdbcType="VARCHAR" property="instRemark" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="inst_status" jdbcType="TINYINT" property="instStatus" />
<result column="inst_param" jdbcType="VARCHAR" property="instParam" />
<result column="inst_snapshot" jdbcType="VARCHAR" property="instSnapshot" />
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
<result column="batch_no" jdbcType="VARCHAR" property="batchNo" />
</resultMap>
<resultMap id="BaseResultDTOMap" extends="BaseResultMap" type="cn.com.glsx.process.modules.model.SopInstDTO">
<association column="grant_id" property="sopTplGrant" select="cn.com.glsx.process.modules.mapper.SopTplGrantMapper.selectByPrimaryKey" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
inst_id, grant_id, inst_name, inst_cron, inst_remark, create_time, update_time, inst_status,
inst_param, inst_snapshot, expire_time, batch_no
</sql>
<update id="updateInstParamCustomData">
UPDATE sop_inst SET inst_param=json_set(inst_param,'$.customData',CAST(#{customData,typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON)) WHERE inst_id = #{instId}
</update>
<update id="updateInstStatus">
UPDATE sop_inst SET inst_status = #{status} WHERE inst_id = #{instId}
</update>
<update id="updateInstBatchNo">
UPDATE sop_inst SET batch_no = #{batchNo}, inst_snapshot=#{snapshot} WHERE inst_id = #{instId}
</update>
<select id="selectByGroupId" resultMap="BaseResultMap">
SELECT si.inst_id, si.grant_id, si.inst_name, si.inst_cron, si.inst_remark, si.create_time, si.update_time, si.inst_status,
si.inst_param, si.expire_time, si.batch_no
FROM sop_inst AS si
INNER JOIN sop_tpl_grant AS stg ON si.grant_id = stg.grant_id
WHERE stg.group_id = #{groupId}
<if test="instStatuses != null and instStatuses.size() > 0">
AND si.inst_status IN
<foreach collection="instStatuses" open="(" separator="," close=")" item="status">
#{status}
</foreach>
</if>
ORDER BY si.inst_status DESC, si.create_time DESC
</select>
<select id="selectByCustomData" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sop_inst
WHERE JSON_CONTAINS(inst_param, CAST(#{customData,typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON),'$.customData') AND inst_status != -1;
</select>
<select id="page" resultMap="BaseResultDTOMap">
SELECT
<include refid="Base_Column_List"/>
FROM sop_inst
<where>
<if test="instId != null and instId != ''">
and inst_id = #{instId}
</if>
<if test="instName != null and instName != ''">
and inst_name like CONCAT('%',#{instName},'%')
</if>
</where>
ORDER BY create_time DESC
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopInstNodeBatchMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInstNodeBatch">
<!--
WARNING - @mbg.generated
-->
<id column="node_batch_no" jdbcType="VARCHAR" property="nodeBatchNo" />
<result column="inst_node_id" jdbcType="INTEGER" property="instNodeId" />
<result column="batch_no" jdbcType="VARCHAR" property="batchNo" />
<result column="snapshot" jdbcType="VARCHAR" property="snapshot" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
node_batch_no, inst_node_id, batch_no, snapshot, create_time, update_time
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopInstNodeMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInstNode">
<!-- WARNING - @mbg.generated -->
<id column="inst_node_id" jdbcType="INTEGER" property="instNodeId" />
<result column="inst_id" jdbcType="VARCHAR" property="instId" />
<result column="node_id" jdbcType="INTEGER" property="nodeId" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="node_label" jdbcType="VARCHAR" property="nodeLabel" />
<result column="node_key" jdbcType="VARCHAR" property="nodeKey" />
<result column="node_show" jdbcType="VARCHAR" property="nodeShow" />
<result column="node_param" jdbcType="VARCHAR" property="nodeParam" />
<result column="node_content" jdbcType="VARCHAR" property="nodeContent" />
<result column="node_visible" jdbcType="TINYINT" property="nodeVisible" />
<result column="node_skip" jdbcType="TINYINT" property="nodeSkip" />
<result column="node_cron" jdbcType="VARCHAR" property="nodeCron" />
<result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" />
<result column="node_status" jdbcType="INTEGER" property="nodeStatus" />
<result column="daily_limit" jdbcType="INTEGER" property="dailyLimit" />
<result column="daily_count" jdbcType="INTEGER" property="dailyCount" />
<result column="daily_expire" jdbcType="TIMESTAMP" property="dailyExpire" />
</resultMap>
<sql id="Base_Column_List">
<!-- WARNING - @mbg.generated -->
inst_node_id, inst_id, node_id, node_name, node_type, node_label, node_key, node_show,
node_param, node_content, node_visible, node_skip, node_cron, node_expire_cron, node_status, daily_limit, daily_count, daily_expire
</sql>
<select id="findByInstId" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
node_id, node_name,node_type
FROM sop_inst_node WHERE inst_id=#{instId}
</select>
<update id="resetInstNodeDailyCount">
update sop_inst_node set daily_count=0 where inst_id=#{instId}
</update>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopNodeTplMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopNodeTpl">
<!--
WARNING - @mbg.generated
-->
<id column="tpl_node_id" jdbcType="INTEGER" property="tplNodeId" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="node_label" jdbcType="VARCHAR" property="nodeLabel" />
<result column="node_show" jdbcType="VARCHAR" property="nodeShow" />
<result column="node_param_def" jdbcType="VARCHAR" property="nodeParamDef" />
<result column="node_content_def" jdbcType="VARCHAR" property="nodeContentDef" />
<result column="node_result_def" jdbcType="VARCHAR" property="nodeResultDef" />
<result column="node_visible" jdbcType="TINYINT" property="nodeVisible" />
<result column="node_cron" jdbcType="VARCHAR" property="nodeCron" />
<result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" />
<result column="node_skipable" jdbcType="TINYINT" property="nodeSkipable" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
tpl_node_id, node_name, node_type, node_label, node_show, node_param_def, node_content_def,
node_result_def, node_visible, node_cron, node_expire_cron, node_skipable
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopTplGrantMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopTplGrant">
<!--
WARNING - @mbg.generated
-->
<id column="grant_id" jdbcType="INTEGER" property="grantId" />
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="tpl_id" jdbcType="VARCHAR" property="tplId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="grant_status" jdbcType="TINYINT" property="grantStatus" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
grant_id, group_id, group_name, tpl_id, create_time, update_time, grant_status
</sql>
<select id="countByTplId" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT group_id) FROM sop_tpl_grant WHERE tpl_id = #{tplId} AND grant_status != -1;
</select>
<select id="list" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sop_tpl_grant
where tpl_id = #{tplId} and grant_status != -1 order by create_time desc
</select>
<select id="countAllByTplId" resultType="java.lang.Integer">
SELECT COUNT(0) FROM sop_tpl_grant WHERE tpl_id = #{tplId}
</select>
<select id="selectInUseGrants" resultMap="BaseResultMap">
SELECT
stg.grant_id, stg.group_id, stg.group_name, stg.tpl_id, stg.create_time, stg.update_time, stg.grant_status
FROM sop_tpl_grant stg
INNER JOIN sop_inst si ON stg.grant_id = si.grant_id
WHERE stg.tpl_id = #{tplId}
AND stg.group_id IN <foreach collection="groupIds" item="groupId" open="(" separator="," close=")"> #{groupId} </foreach>
AND si.inst_status != -1
</select>
<delete id="del">
update sop_tpl_grant set grant_status = -1 where grant_id = #{id}
</delete>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopTplLinkMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopTplLink">
<!--
WARNING - @mbg.generated
-->
<id column="link_id" jdbcType="INTEGER" property="linkId" />
<result column="tpl_id" jdbcType="VARCHAR" property="tplId" />
<result column="source_id" jdbcType="INTEGER" property="sourceId" />
<result column="target_id" jdbcType="INTEGER" property="targetId" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
link_id, tpl_id, source_id, target_id
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopTplMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopTpl">
<!--
WARNING - @mbg.generated
-->
<id column="tpl_id" jdbcType="VARCHAR" property="tplId" />
<result column="tpl_name" jdbcType="VARCHAR" property="tplName" />
<result column="tpl_cron" jdbcType="VARCHAR" property="tplCron" />
<result column="tpl_remark" jdbcType="VARCHAR" property="tplRemark" />
<result column="tpl_status" jdbcType="TINYINT" property="tplStatus" />
<result column="tpl_param_def" jdbcType="VARCHAR" property="tplParamDef" />
<result column="tpl_result_def" jdbcType="VARCHAR" property="tplResultDef" />
<result column="tpl_singleton" jdbcType="TINYINT" property="tplSingleton" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap id="BaseResultDTOMap" extends="BaseResultMap" type="cn.com.glsx.process.modules.model.SopTplDTO">
<association column="tpl_id" jdbcType="INTEGER" property="grantCount" select="cn.com.glsx.process.modules.mapper.SopTplGrantMapper.countByTplId" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
tpl_id, tpl_name, tpl_cron, tpl_remark, tpl_status, tpl_param_def, tpl_result_def,
tpl_singleton, create_time, update_time
</sql>
<select id="page" resultMap="BaseResultDTOMap">
select
<include refid="Base_Column_List" />
from sop_tpl
<where>
<if test="tplId != null and tplId !=''">
and tpl_id = #{tplId}
</if>
<if test="tplName != null and tplName !=''">
and tpl_name = #{tplName}
</if>
<if test="tplStatus != null">
and tpl_status = #{tplStatus}
</if>
</where>
order by update_time desc
</select>
<select id="getById" resultMap="BaseResultDTOMap">
select <include refid="Base_Column_List" /> from sop_tpl where tpl_id = #{tplId}
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.process.modules.mapper.SopTplNodeMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopTplNode">
<!-- WARNING - @mbg.generated -->
<id column="node_id" jdbcType="INTEGER" property="nodeId" />
<result column="tpl_id" jdbcType="VARCHAR" property="tplId" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="node_label" jdbcType="VARCHAR" property="nodeLabel" />
<result column="node_show" jdbcType="VARCHAR" property="nodeShow" />
<result column="node_param_def" jdbcType="VARCHAR" property="nodeParamDef" />
<result column="node_content_def" jdbcType="VARCHAR" property="nodeContentDef" />
<result column="node_key" jdbcType="VARCHAR" property="nodeKey" />
<result column="node_result_def" jdbcType="VARCHAR" property="nodeResultDef" />
<result column="node_visible" jdbcType="TINYINT" property="nodeVisible" />
<result column="node_cron" jdbcType="VARCHAR" property="nodeCron" />
<result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" />
<result column="node_skipable" jdbcType="TINYINT" property="nodeSkipable" />
<result column="daily_limit" jdbcType="INTEGER" property="dailyLimit" />
</resultMap>
<sql id="Base_Column_List">
<!-- WARNING - @mbg.generated -->
node_id, tpl_id, node_name, node_type, node_label, node_show, node_param_def, node_content_def,
node_key, node_result_def, node_visible, node_cron, node_expire_cron, node_skipable, daily_limit
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
//package cn.com.glsx;
//
//import com.glsx.microservice.api.EchoCenterFeignService;
//import com.glsx.plat.core.web.R;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//
///**
// * 测试spring cloud 服务调用方式
// */
//@EnableDiscoveryClient
//@SpringBootApplication
//public class TestApplication {
//
// public static void main(String[] args) {
// SpringApplication.run(TestApplication.class, args);
// }
//
// @Slf4j
// @RestController
// static class TestController {
//
// @Autowired
// RestTemplate restTemplate;
//
// @Resource
// private EchoCenterFeignService echoCenterFeignService;
//
//// @Autowired
//// private WebClient.Builder webClientBuilder;
//
// @GetMapping("/test1")
// public String test1() {
// String result = restTemplate.getForObject("http://192.168.0.63:8829/rest-echo-center/echo/didi", String.class);
// return "Return : " + result;
// }
//
//// @GetMapping("/test")
//// public Mono<String> test() {
//// Mono<String> result = webClientBuilder.build()
//// .get()
//// .uri("http://alibaba-nacos-discovery-server/hello?name=didi")
//// .retrieve()
//// .bodyToMono(String.class);
//// return result;
//// }
//
// @GetMapping("/test3")
// public R test3() {
// String result = echoCenterFeignService.echo("this is a test!");
// return R.ok().data(result);
// }
// }
//
// @Bean
// @LoadBalanced
// public RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
//// @Bean
//// @LoadBalanced
//// public WebClient.Builder loadBalancedWebClientBuilder() {
//// return WebClient.builder();
//// }
//
//}
\ No newline at end of file \ No newline at end of file
//package cn.com.glsx;
//
//import com.glsx.microservice.api.EchoCenterFeignService;
//import com.glsx.plat.core.web.R;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//
///**
// * 测试spring cloud 服务调用方式
// */
//@EnableDiscoveryClient
//@SpringBootApplication
//public class TestApplication {
//
// public static void main(String[] args) {
// SpringApplication.run(TestApplication.class, args);
// }
//
// @Slf4j
// @RestController
// static class TestController {
//
// @Autowired
// RestTemplate restTemplate;
//
// @Resource
// private EchoCenterFeignService echoCenterFeignService;
//
//// @Autowired
//// private WebClient.Builder webClientBuilder;
//
// @GetMapping("/test1")
// public String test1() {
// String result = restTemplate.getForObject("http://192.168.0.63:8829/rest-echo-center/echo/didi", String.class);
// return "Return : " + result;
// }
//
//// @GetMapping("/test")
//// public Mono<String> test() {
//// Mono<String> result = webClientBuilder.build()
//// .get()
//// .uri("http://alibaba-nacos-discovery-server/hello?name=didi")
//// .retrieve()
//// .bodyToMono(String.class);
//// return result;
//// }
//
// @GetMapping("/test3")
// public R test3() {
// String result = echoCenterFeignService.echo("this is a test!");
// return R.ok().data(result);
// }
// }
//
// @Bean
// @LoadBalanced
// public RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
//// @Bean
//// @LoadBalanced
//// public WebClient.Builder loadBalancedWebClientBuilder() {
//// return WebClient.builder();
//// }
//
//}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test;
import cn.com.glsx.Application;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.com.glsx.process.modules.sop.CustomerInfo;
import cn.com.glsx.process.modules.sop.java.example.ControllerDisTasksDemo;
import cn.com.glsx.process.modules.sop.java.example.ControllerFoundInsDemo;
import cn.com.glsx.process.modules.sop.java.example.ControllerScreenPersonDemo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 测试spring cloud 服务调用方式
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
public class JavaNodeTestApplication {
@Resource
private SopService sopService;
@Test
public void testJava() {
Map<String, Object> resultData = new HashMap<>();
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setOneId("123456");
customerInfo.setCustomerPhone("13476670746");
customerInfo.setOrgId("123456");
customerInfo.setVin("ceshi");
customerInfo.setMessageId("ceshi");
customerInfo.setMessageContent("ceshi");
customerInfo.setSopJourneyId("xblc7");
customerInfo.setSopJourneyEnterTime(new Date());
customerInfo.setCustomerPhone("13476670746");
customerInfo.setSopJourneyStage("潜客");
customerInfo.setSopJourneyStageEnterTime(new Date());
resultData.put("users", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(2);
JSONObject jsonObject = new JSONObject();
jsonObject.put("sopInst", sopStruct.getInst());
jsonObject.put("sopInstNode", sopInstNode);
jsonObject.put("instSnapshot", resultData);
JSON execute = ControllerScreenPersonDemo.execute(jsonObject);
System.out.println(execute);
}
@Test
public void ControllerDisTasksDemotestJava() {
Map<String, Object> resultData = new HashMap<>();
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setOneId("123456");
customerInfo.setCustomerPhone("13476670746");
customerInfo.setOrgId("123456");
customerInfo.setVin("ceshi");
customerInfo.setMessageId("1");
customerInfo.setMessageContent("ceshi");
customerInfo.setSopJourneyId("xblc7");
customerInfo.setSopJourneyEnterTime(new Date());
customerInfo.setCustomerPhone("13476670746");
customerInfo.setFollowStaffPhone("13476670746");
customerInfo.setSopJourneyStage("潜客");
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-09-23"));
resultData.put("user1", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(3);
JSONObject jsonObject = new JSONObject();
jsonObject.put("sopInst", sopStruct.getInst());
jsonObject.put("sopInstNode", sopInstNode);
jsonObject.put("instSnapshot", resultData);
JSON execute = ControllerDisTasksDemo.execute(jsonObject);
System.out.println(execute);
}
@Test
public void ControllerFoundInsDemo() {
Map<String, Object> resultData = new HashMap<>();
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setOneId("123456");
customerInfo.setCustomerPhone("13476670746");
customerInfo.setOrgId("123456");
customerInfo.setVin("ceshi");
customerInfo.setMessageId("ceshi");
customerInfo.setMessageContent("ceshi");
customerInfo.setSopJourneyId("xblc7");
customerInfo.setSopJourneyEnterTime(new Date());
customerInfo.setCustomerPhone("13476670746");
customerInfo.setSopJourneyStage("潜在客户");
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-09-22"));
customerInfo.setVin("WAURFCF24MN013761");
resultData.put("user1", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(3);
JSONObject jsonObject = new JSONObject();
jsonObject.put("sopInst", sopStruct.getInst());
jsonObject.put("sopInstNode", sopInstNode);
jsonObject.put("instSnapshot", resultData);
JSON execute = ControllerFoundInsDemo.execute(jsonObject);
System.out.println(execute);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import cn.com.glsx.cdp.api.customer.CustomerSopJourneyFeignClient;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneyDTO;
import cn.com.glsx.cdp.modules.model.customer.CustomerSopJourneySearch;
import cn.com.glsx.process.modules.service.SopInstLinkService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.Application;
import cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler;
import cn.com.glsx.process.modules.entity.SopDataSource;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.User;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopDataSourceService;
import cn.com.glsx.process.modules.service.UserDemoService;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopBizAdapter;
import cn.com.glsx.process.modules.sop.execute.plugin.java.DynamicEngine;
import cn.com.glsx.process.modules.sop.java.example.ControllerHttpDemo;
import javax.annotation.Resource;
/**
* 测试spring cloud 服务调用方式
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
public class TestApplication {
@Autowired
private UserDemoService userDemoService;
@Autowired
private SopDataSourceService sopDataSourceService;
@Autowired
private SopInstNodeExecuteJobHandler sopInstNodeExecuteJobHandler;
@Autowired
private SopInstLinkService sopInstLinkService;
@Resource
private CustomerSopJourneyFeignClient customerSopJourneyFeignClient;
@Test
public void test() throws SQLException {
SopDataSource byId = sopDataSourceService.findByDataSourceId("SOP_CDP");
SopBizAdapter mcgBizAdapter = new FlowDataAdapterImpl(byId);
List<Map<String, Object>> maps = mcgBizAdapter.tableQuery("SELECT c.org_id, c.one_id, c.customer_name, c.customer_phone, j.sop_journey_id, j.sop_journey_enter_time, j.sop_journey_stage, j.sop_journey_stage_enter_time FROM `cdp_customer_sop_journey` j INNER JOIN cdp_customer c ON j.one_id = c.one_id AND j.org_id = c.org_id WHERE j.sop_journey_id='xblc'");
System.out.println(maps);
}
@Test
public void testupdate() throws SQLException {
SopDataSource byId = sopDataSourceService.findByDataSourceId("SOP_CDP");
SopBizAdapter mcgBizAdapter = new FlowDataAdapterImpl(byId);
int i = mcgBizAdapter.executeUpdate("update cdp_customer_sop_journey t1,(select t1.one_id,t1.org_id from cdp_customer t1 LEFT JOIN cdp_customer_car_relation t2 on t1.one_id=t2.one_id left join cdp_car t3 on t3.car_id=t2.car_id\n" + "where to_days(t3.arrival_date) = to_days(now()) ) t2 set t1.sop_journey_stage='保费报价',t1.sop_journey_stage_enter_time=now() where t1.one_id=t2.one_id and t1.org_id=t2.org_id;\n" + "update cdp_customer_sop_journey set sop_journey_stage='战败客户',sop_journey_stage_enter_time=now() where DATEDIFF(CURDATE(), sop_journey_enter_time) > 45 and sop_journey_stage!='成功续保';\n" + "update cdp_customer_sop_journey set sop_journey_stage='意向客户',sop_journey_stage_enter_time=now() where one_id in (SELECT one_id FROM cdp_customer_event where event_type='ORDERED' and extra->'$.orderStatus'=2 and extra->'$.payStatus'=2 and extra->'$.afterSaleStatus' is null);\n" + "update cdp_customer_sop_journey set sop_journey_stage='意向客户',sop_journey_stage_enter_time=now() where one_id in (SELECT one_id FROM cdp_customer_event where event_type='RECALL_AI_CALL' and extra->'$.taskResult[0].resultValue'='A');");
System.out.println("更新成功的行数" + i);
}
@Test
public void testjava() throws Exception {
DynamicEngine de = DynamicEngine.getInstance();
String source = "import com.alibaba.fastjson.JSON;\n" + "\n" + "public class Controller {\n" + "\n" + " public JSON execute(JSON param) {\n" + " System.out.println(\"测试java\");\n" + " return param;\n" + " }\n" + "}\n";
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", 22);
Object instance = de.execute("Controller", source, "execute", new Class[]{JSON.class}, new Object[]{jsonObject});
System.out.println(JSON.toJSONString(instance));
}
@Test
public void testredis() throws InterruptedException {
// 设置并发数量
int count = 1;
// 线程池准备
CyclicBarrier cyclicBarrier = new CyclicBarrier(count);
ExecutorService executorService = Executors.newFixedThreadPool(count);
// 开始时间
long now = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
executorService.execute(new Task(cyclicBarrier, i, userDemoService));
}
executorService.shutdown();
while (!executorService.isTerminated()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class Task implements Runnable {
private CyclicBarrier cyclicBarrier;
private int count;
private UserDemoService userDemoService;
public Task(CyclicBarrier cyclicBarrier, int count, UserDemoService userDemoService) {
this.cyclicBarrier = cyclicBarrier;
this.count = count;
this.userDemoService = userDemoService;
}
@Override
public void run() {
try {
cyclicBarrier.await();
User user = new User();
user.setAccount("123456");
userDemoService.testRedis(user);
} catch (Exception e) {
System.out.println("出现超时的线程" + count);
e.printStackTrace();
}
}
}
@Test
public void sopInstNodeExecuteJobHandler() {
SopInstNode sopInstNode = new SopInstNode();
sopInstNode.setNodeType("Java");
SopStruct sopStruct = new SopStruct();
sopInstNodeExecuteJobHandler.execute(sopStruct, sopInstNode);
}
@Test
public void testJava() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("merchantNo", "44210895");
JSON execute = ControllerHttpDemo.execute(jsonObject);
System.out.println(execute);
}
@Test
public void findByInstId() {
List<SopInstNode> xblc7 = sopInstLinkService.findByInstId("xblc7");
String listString = JSON.toJSONString(xblc7, SerializerFeature.DisableCircularReferenceDetect);
System.out.println(listString);
}
@Test
public void pageCustomerSopJourney() {
CustomerSopJourneySearch customerSopJourneySearch=new CustomerSopJourneySearch();
customerSopJourneySearch.setPageNum(1);
customerSopJourneySearch.setPageSize(10);
Result<PageInfo<CustomerSopJourneyDTO>> pageInfoResult = customerSopJourneyFeignClient.pageCustomerSopJourney(customerSopJourneySearch);
System.out.println(pageInfoResult);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test.service;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.Application;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.hutool.json.JSONUtil;
/**
* 测试spring cloud 服务调用方式
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
@Slf4j
public class TestSopService {
@Autowired
private SopService sopService;
@Test
public void test() {
String instId = "xblc7";
SopStruct sop = sopService.loadSop(instId);
System.out.println(JSONUtil.toJsonStr(sop));
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test.util;
import java.util.Map;
import java.util.Set;
import com.alibaba.nacos.shaded.com.google.common.collect.Sets;
import com.fasterxml.jackson.core.type.TypeReference;
/**
* 遍历流程所有节点
*
* @author kome
* @date 2023年9月13日 下午3:24:28
*/
public class FlowSortUtil {
public static void main(String[] args) {
String json = "{\"1\":{\"value\":[10],\"key\":[]},\"2\":{\"value\":[3,4],\"key\":[10]},\"3\":{\"value\":[9],\"key\":[2]},\"4\":{\"value\":[9],\"key\":[2]},\"5\":{\"value\":[9],\"key\":[8]},\"6\":{\"value\":[9],\"key\":[8]},\"7\":{\"value\":[],\"key\":[9]},\"8\":{\"value\":[5,6],\"key\":[10]},\"9\":{\"value\":[7],\"key\":[3,4,5,6]},\"10\":{\"value\":[2,8],\"key\":[1]}}";
Map<Integer, Pair<Set<Integer>, Set<Integer>>> instLinkMap = JacksonUtils.fromJson(json,
new TypeReference<Map<Integer, Pair<Set<Integer>, Set<Integer>>>>() {
});
Set<Integer> keys = Sets.newHashSet();
int i = 0;
while (keys.size() < instLinkMap.keySet().size()) {
Set<Integer> sets = instLinkMap.keySet();
for (Integer key : sets) {
// System.out.println("i:" + i++);
Pair<Set<Integer>, Set<Integer>> pair = instLinkMap.get(key);
if (!keys.contains(key)) {
// 第一个节点:直接执行
if (pair.getKey().isEmpty()) {
keys.add(key);
System.out.println(key);
continue;
}
// 非第一个节点:判断前置节点
if (keys.containsAll(pair.getKey())) {
keys.add(key);
System.out.println(key);
continue;
}
} else {
// 进入后置节点
sets = pair.getValue();
}
}
}
}
}
package cn.com.glsx.test.util;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.junit.jupiter.api.Test;
import com.google.common.collect.Sets;
import cn.hutool.json.JSONUtil;
import freemarker.cache.StringTemplateLoader;
import freemarker.core.Environment;
import freemarker.core.InvalidReferenceException;
import freemarker.core.NonSequenceOrCollectionException;
import freemarker.core.TemplateElement;
import freemarker.ext.beans.StringModel;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateCollectionModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateHashModelEx;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateModelIterator;
import freemarker.template.TemplateScalarModel;
import freemarker.template.TemplateSequenceModel;
public class FreemarkerUtil {
static Configuration configuration = new Configuration(Configuration.VERSION_2_3_31);
static {
configuration.setLogTemplateExceptions(false);
// configuration.setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);
}
public static Set<String> extractVariables(String templateContent) throws IOException, TemplateException {
Set<String> variables = new HashSet<>();
Template template = generateTemplate(templateContent);
StringWriter writer = new StringWriter();
Map<String, Object> dataModel = new HashMap<>();
template.process(dataModel, writer);
Environment environment = template.createProcessingEnvironment(dataModel, writer);
TemplateModel templateModel = environment.getDataModel();
extractVariablesFromTemplateModel(templateModel, variables);
return variables;
}
private static void extractVariablesFromTemplateModel(TemplateModel templateModel, Set<String> variables) throws TemplateModelException {
if (templateModel instanceof TemplateHashModelEx) {
TemplateHashModelEx hashModelEx = (TemplateHashModelEx) templateModel;
TemplateCollectionModel keys = hashModelEx.keys();
TemplateModelIterator keyIterator = keys.iterator();
while (keyIterator.hasNext()) {
TemplateModel key = keyIterator.next();
if (key instanceof TemplateScalarModel) {
String variable = ((TemplateScalarModel) key).getAsString();
variables.add(variable);
}
}
}
if (templateModel instanceof TemplateCollectionModel) {
TemplateCollectionModel hashModel = (TemplateCollectionModel) templateModel;
// TemplateCollectionModel values = hashModel.values();
TemplateModelIterator valueIterator = hashModel.iterator();
while (valueIterator.hasNext()) {
TemplateModel value = valueIterator.next();
extractVariablesFromTemplateModel(value, variables);
}
}
if (templateModel instanceof TemplateSequenceModel) {
TemplateSequenceModel sequenceModel = (TemplateSequenceModel) templateModel;
int size = sequenceModel.size();
for (int i = 0; i < size; i++) {
TemplateModel element = sequenceModel.get(i);
extractVariablesFromTemplateModel(element, variables);
}
}
}
/**
* Find all the variables used in the Freemarker Template
*
* @param templateName
* @return
*/
public static Set<String> getTemplateVariables(Template template) {
StringWriter stringWriter = new StringWriter();
Map<String, Object> dataModel = new HashMap<>();
boolean exceptionCaught;
do {
exceptionCaught = false;
try {
template.process(dataModel, stringWriter);
} catch (InvalidReferenceException e) {
exceptionCaught = true;
dataModel.put(e.getBlamedExpressionString(), "");
} catch (NonSequenceOrCollectionException e) {
} catch (Exception e) {
// throw new IllegalStateException("Failed to Load Template: " + template.getName(), e);
}
} while (exceptionCaught);
return dataModel.keySet();
}
private static Template getTemplate(String templateName) {
try {
return configuration.getTemplate(templateName);
} catch (IOException e) {
throw new IllegalStateException("Failed to Load Template: " + templateName, e);
}
}
private static Template generateTemplate(String templateContent) {
try {
StringTemplateLoader templateLoader = new StringTemplateLoader();
templateLoader.putTemplate("__testTemplate", templateContent);
configuration.setTemplateLoader(templateLoader);
Template template = configuration.getTemplate("__testTemplate");
return template;
} catch (IOException e) {
throw new IllegalStateException("Failed to generate Template: " + templateContent, e);
}
}
public static Set<String> referenceSet(Template template) throws TemplateModelException {
Set<String> result = new HashSet<>();
TemplateElement rootTreeNode = template.getRootTreeNode();
for (int i = 0; i < rootTreeNode.getChildCount(); i++) {
TemplateModel templateModel = rootTreeNode.getChildNodes().get(i);
if (!(templateModel instanceof StringModel)) {
continue;
}
Object wrappedObject = ((StringModel) templateModel).getWrappedObject();
if (!"DollarVariable".equals(wrappedObject.getClass().getSimpleName())) {
continue;
}
try {
Object expression = getInternalState(wrappedObject, "expression");
switch (expression.getClass().getSimpleName()) {
case "Identifier":
result.add(getInternalState(expression, "name").toString());
break;
case "DefaultToExpression":
result.add(getInternalState(expression, "lho").toString());
break;
case "BuiltinVariable":
break;
default:
throw new IllegalStateException("Unable to introspect variable");
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new TemplateModelException("Unable to reflect template model");
}
}
return result;
}
private static Object getInternalState(Object o, String fieldName) throws NoSuchFieldException, IllegalAccessException {
Field field = o.getClass().getDeclaredField(fieldName);
boolean wasAccessible = field.isAccessible();
try {
field.setAccessible(true);
return field.get(o);
} finally {
field.setAccessible(wasAccessible);
}
}
public static Set<String> getNecessaryTemplateVariables(String templateName) throws TemplateModelException {
Set<String> result = new HashSet<>();
TemplateElement rootTreeNode = getTemplate(templateName).getRootTreeNode();
if ("IteratorBlock".equals(rootTreeNode.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, rootTreeNode);
return result;
}
for (int i = 0; i < rootTreeNode.getChildCount(); i++) {
TemplateModel templateModel = rootTreeNode.getChildNodes().get(i);
if (!(templateModel instanceof StringModel)) {
continue;
}
Object wrappedObject = ((StringModel) templateModel).getWrappedObject();
if ("DollarVariable".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromDollarVariable(result, wrappedObject);
} else if ("ConditionalBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromConditionalBlock(result, wrappedObject);
} else if ("IfBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIfBlock(result, wrappedObject);
} else if ("IteratorBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, wrappedObject);
}
}
return result;
}
public static Set<String> getNecessaryTemplateVariables(Template template) throws TemplateModelException {
Set<String> result = new HashSet<>();
TemplateElement rootTreeNode = template.getRootTreeNode();
if ("IteratorBlock".equals(rootTreeNode.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, rootTreeNode);
return result;
}
for (int i = 0; i < rootTreeNode.getChildCount(); i++) {
TemplateModel templateModel = rootTreeNode.getChildNodes().get(i);
if (!(templateModel instanceof StringModel)) {
continue;
}
Object wrappedObject = ((StringModel) templateModel).getWrappedObject();
if ("DollarVariable".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromDollarVariable(result, wrappedObject);
} else if ("ConditionalBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromConditionalBlock(result, wrappedObject);
} else if ("IfBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIfBlock(result, wrappedObject);
} else if ("IteratorBlock".equals(wrappedObject.getClass().getSimpleName())) {
introspectFromIteratorBlock(result, wrappedObject);
}
}
return result;
}
private static void introspectFromIteratorBlock(Set<String> result, Object wrappedObject) {
try {
Object expression = getInternalState(wrappedObject, "listedExp");
result.add(getInternalState(expression, "name").toString());
} catch (NoSuchFieldException | IllegalAccessException ignored) {
ignored.printStackTrace();
}
}
private static void introspectFromConditionalBlock(Set<String> result, Object wrappedObject) throws TemplateModelException {
try {
Object expression = getInternalState(wrappedObject, "condition");
if (expression == null) {
return;
}
result.addAll(dealCommonExpression(expression));
String nested = getInternalState(wrappedObject, "nestedBlock").toString();
result.addAll(getNecessaryTemplateVariables(nested));
} catch (NoSuchFieldException | IllegalAccessException ignored) {
}
}
private static Set<String> dealCommonExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Set<String> ret = Sets.newHashSet();
switch (expression.getClass().getSimpleName()) {
case "ComparisonExpression":
String reference = dealComparisonExpression(expression);
ret.add(reference);
break;
case "ExistsExpression":
reference = dealExistsExpression(expression);
ret.add(reference);
break;
case "AndExpression":
ret.addAll(dealAndExpression(expression));
default:
break;
}
return ret;
}
private static String dealComparisonExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Object left = getInternalState(expression, "left");
Object right = getInternalState(expression, "right");
String reference;
if ("Identifier".equals(left.getClass().getSimpleName())) {
reference = getInternalState(left, "name").toString();
} else {
reference = getInternalState(right, "name").toString();
}
return reference;
}
private static String dealExistsExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Object exp = getInternalState(expression, "exp");
return getInternalState(exp, "name").toString();
}
private static Set<String> dealAndExpression(Object expression) throws NoSuchFieldException, IllegalAccessException {
Set<String> ret = Sets.newHashSet();
Object lho = getInternalState(expression, "lho");
ret.addAll(dealCommonExpression(lho));
Object rho = getInternalState(expression, "rho");
ret.addAll(dealCommonExpression(rho));
return ret;
}
private static void introspectFromIfBlock(Set<String> result, Object wrappedObject) throws TemplateModelException {
result.addAll(getNecessaryTemplateVariables(wrappedObject.toString()));
}
private static void introspectFromDollarVariable(Set<String> result, Object wrappedObject) throws TemplateModelException {
try {
Object expression = getInternalState(wrappedObject, "expression");
switch (expression.getClass().getSimpleName()) {
case "Identifier":
result.add(getInternalState(expression, "name").toString());
break;
case "DefaultToExpression":
result.add(getInternalState(expression, "lho").toString());
break;
case "BuiltinVariable":
break;
default:
break;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new TemplateModelException("Unable to reflect template model");
}
}
@Test
public void test() throws Exception {
String templateContent = "Hello, ${name}! <#list users as u>${u.name}</#list>";
Template template = generateTemplate(templateContent);
System.out.println(JSONUtil.toJsonStr(getTemplateVariables(template)));
System.out.println(JSONUtil.toJsonStr(referenceSet(template)));
System.out.println(JSONUtil.toJsonStr(getNecessaryTemplateVariables(template)));
}
public static void main(String[] args) throws IOException, TemplateException {
String templateContent = "<#assign name = 'Alice'>Hello, ${name}!";
Set<String> variables = extractVariables(templateContent);
for (String variable : variables) {
System.out.println(variable);
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test.util;
import java.io.IOException;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.introspect.AnnotatedField;
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.fasterxml.jackson.databind.util.JSONPObject;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DatePattern;
import lombok.val;
import lombok.extern.slf4j.Slf4j;
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
@SuppressWarnings("restriction")
public class JacksonUtils {
// 转换全部字段
public final static JsonMapper normalMapper = JsonMapper.buildNormalBinder();
// 不转换默认值的字段
public final static JsonMapper nodefaultMapper = JsonMapper.buildNonDefaultBinder();
// 不转换空字段
public final static JsonMapper noemptyMapper = JsonMapper.buildNonEmptyBinder();
// 不转换null字段
public final static JsonMapper nonullMapper = JsonMapper.buildNonNullBinder();
// 不转换null字段
public final static JsonMapper null2emptyMapper = JsonMapper.buildNull2EmptyBinder();
// 首字母大写
public final static JsonMapper downCaseMapper = JsonMapper.buildDownCaseBinder();
// 下划线
public final static JsonMapper snakeMapper = JsonMapper.buildSnakeCaseBinder();
// // 下划线+base64 decode
// public final static JsonMapper wxMapper = JsonMapper.buildWxCaseBinder();
public static <T> String toJson(T t) {
return normalMapper.toJson(t);
}
public static <T> T fromJson(String json, Class<T> clazz) {
return normalMapper.fromJson(json, clazz);
}
public static <T, S> T fromJson(String json, Class<T> owner, Class<S> subClass) {
return normalMapper.fromJson(json, owner, subClass);
}
/**
* <code>
* List<String> list = JsonUtil.fromJson(json, new TypeReference<ArrayList<String>>() {});
* </code>
*
* @param <T>
* @param json
* @param t
* @return
*/
public static <T> T fromJson(String json, TypeReference<T> t) {
return normalMapper.fromJson(json, t);
}
public static <T> T convertJsonClazz(Object object, Class<T> clazz) {
return normalMapper.convertJsonClazz(object, clazz);
}
/**
* 构造函数
*/
private JacksonUtils() {
}
@Slf4j
public static class JsonMapper {
private ObjectMapper mapper;
protected JsonMapper() {
this(JsonInclude.Include.ALWAYS);
}
public JsonMapper(JsonInclude.Include include) {
mapper = new ObjectMapper();
// 设置输出时包含属性的风格
mapper.setSerializationInclusion(include);
// 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// 空的bean不解析
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
// 设置日期格式
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
//
mapper.registerModule(simpleModule());
}
/** 创建输出全部属性到Json字符串的Binder. */
public static JsonMapper buildNormalBinder() {
return new JsonMapper(JsonInclude.Include.ALWAYS);
}
/** 创建只输出非空属性到Json字符串的Binder. */
public static JsonMapper buildNonNullBinder() {
return new JsonMapper(JsonInclude.Include.NON_NULL);
}
public static JsonMapper buildNull2EmptyBinder() {
JsonMapper m = new JsonMapper(JsonInclude.Include.ALWAYS);
m.mapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
@Override
public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeString("");
}
});
return m;
}
/** 创建只输出初始值被改变的属性到Json字符串的Binder. */
public static JsonMapper buildNonDefaultBinder() {
return new JsonMapper(JsonInclude.Include.NON_DEFAULT);
}
/** 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Binder */
public static JsonMapper buildNonEmptyBinder() {
return new JsonMapper(JsonInclude.Include.NON_EMPTY);
}
/** 首字母大写 */
public static JsonMapper buildDownCaseBinder() {
// 首字母默认小写
JsonMapper mapper = new JsonMapper(JsonInclude.Include.ALWAYS);
mapper.mapper.setPropertyNamingStrategy(new JacksonInitialDownCaseStrategy());
return mapper;
}
/** 下划线连接 */
public static JsonMapper buildSnakeCaseBinder() {
// 下划线
JsonMapper mapper = new JsonMapper(JsonInclude.Include.NON_NULL);
mapper.mapper.setPropertyNamingStrategy(new SnakeCaseStrategy());
return mapper;
}
// /** 下划线连接+Base64 */
// public static JsonMapper buildWxCaseBinder() {
// // 下划线
// JsonMapper mapper = new JsonMapper(JsonInclude.Include.ALWAYS);
// mapper.mapper.setPropertyNamingStrategy(new SnakeCaseStrategy());
// mapper.mapper.setBase64Variant(Base64Variants.MIME_NO_LINEFEEDS);
// return mapper;
// }
/**
* 反序列化POJO或简单Collection如List<String>. 如果JSON字符串为null或"null"字符串,返回null. 如果JSON字符串为"[]",返回空集合.
* 如需读取集合如List/Map,且不是List<String>这种简单类型时,使用後面的函數.
*/
public <T> T fromJson(String jsonString, Class<T> clazz) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return mapper.readValue(jsonString, clazz);
} catch (IOException e) {
log.warn("parse json string error:" + jsonString, e);
return null;
}
}
public <T> T fromJson(String jsonString, TypeReference<T> type) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return mapper.readValue(jsonString, type);
} catch (IOException e) {
log.warn("parse json string error:" + jsonString, e);
return null;
}
}
public <T, S> T fromJson(String json, Class<T> owner, Class<S> subClass) {
if (subClass == null) {
return fromJson(json, owner);
}
Type[] types = new Type[1];
types[0] = subClass;
final ParameterizedTypeImpl type = ParameterizedTypeImpl.make(owner, types, owner.getDeclaringClass());
TypeReference<T> typeReference = new TypeReference<T>() {
@Override
public Type getType() {
return type;
}
};
return fromJson(json, typeReference);
}
/**
* 反序列化复杂Collection如List<Bean>, 先使用函數createCollectionType构造类型,然后调. 如果JSON字符串为null或"null"字符串,返回null. 如果JSON字符串为"[]",返回空集合.
*/
@SuppressWarnings("unchecked")
public <T> T fromJson(String jsonString, JavaType javaType) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return (T) mapper.readValue(jsonString, javaType);
} catch (IOException e) {
log.warn("parse json string error:" + jsonString, e);
return null;
}
}
/** 構造泛型的Type如List<MyBean>, Map<String,MyBean> */
public JavaType createCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
return mapper.getTypeFactory().constructParametricType(collectionClass, elementClasses);
}
/**
* Object可以是POJO,也可以是Collection或数组. 如果对象为null,返回"null". 如果集合为空集合,返回"[]".
*/
public String toJson(Object object) {
try {
if (object == null) {
return null;
}
return mapper.writeValueAsString(object);
} catch (IOException e) {
log.warn("write to json string error:" + object, e);
return null;
}
}
// 转换类型
public <T> T convertJsonClazz(Object object, Class<T> clazz) {
String json = toJson(object);
return fromJson(json, clazz);
}
/** 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性. */
@SuppressWarnings("unchecked")
public <T> T update(String jsonString, T object) {
try {
return (T) mapper.readerForUpdating(object).readValue(jsonString);
} catch (Exception e) {
log.warn("parse json string" + jsonString + " to object:" + object + " error.", e);
}
return null;
}
/** 輸出JSONP格式數據. */
public String toJsonP(String functionName, Object object) {
return toJson(new JSONPObject(functionName, object));
}
/** 设定是否使用Enum的toString函數來读写Enum, */
public void enableEnumUseToString() {
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
}
}
public static SimpleModule simpleModule() {
val bean = new SimpleModule();
bean.addDeserializer(ZonedDateTime.class, new JsonDeserializer<ZonedDateTime>() {
@Override
public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
return ZonedDateTime.parse(jsonParser.getValueAsString(), DateTimeFormatter.ISO_ZONED_DATE_TIME);
}
});
bean.addDeserializer(LocalDateTime.class, new MyLocalDatetimeDeserializer());
bean.addSerializer(ZonedDateTime.class, new JsonSerializer<ZonedDateTime>() {
@Override
public void serialize(ZonedDateTime zonedDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
throws IOException {
jsonGenerator.writeString(DateTimeFormatter.ISO_ZONED_DATE_TIME.format(zonedDateTime));
}
});
bean.addSerializer(LocalDateTime.class, new MyLocalDatetimeSerializer());
return bean;
}
@SuppressWarnings("serial")
static class JacksonInitialDownCaseStrategy extends PropertyNamingStrategy {
@Override
public String nameForField(@SuppressWarnings("rawtypes") MapperConfig config, AnnotatedField field, String defaultName) {
return convert(defaultName);
}
@Override
public String nameForGetterMethod(@SuppressWarnings("rawtypes") MapperConfig config, AnnotatedMethod method, String defaultName) {
return convert(defaultName);
}
@Override
public String nameForSetterMethod(@SuppressWarnings("rawtypes") MapperConfig config, AnnotatedMethod method, String defaultName) {
String a = convert(defaultName);
return a;
}
public String convert(String defaultName) {
char[] arr = defaultName.toCharArray();
if (arr.length != 0) {
if (Character.isLowerCase(arr[0])) {
char upper = Character.toUpperCase(arr[0]);
arr[0] = upper;
}
}
return new StringBuilder().append(arr).toString();
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static class Base64Deserializer extends JsonDeserializer implements ContextualDeserializer {
@Override
public JsonDeserializer createContextual(DeserializationContext context, BeanProperty property) throws JsonMappingException {
return this;
}
@Override
public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
String value = parser.getValueAsString();
try {
if (Base64.isBase64(value)) {
// 判断是否切换编码格式
// value = Base64.decodeStr(value);
String decode = new String(org.apache.commons.codec.binary.Base64.decodeBase64(value));
// 解码后不是乱码才解码,对emoji表情单独处理
// if (StrUtils.hasNormalCode(decode)) {
// value = decode;
// }
}
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static class GBKBase64Deserializer extends JsonDeserializer implements ContextualDeserializer {
@Override
public JsonDeserializer createContextual(DeserializationContext context, BeanProperty property) throws JsonMappingException {
return this;
}
@Override
public Object deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
String value = parser.getValueAsString();
try {
if (Base64.isBase64(value)) {
// TODO 判断是否切换编码格式
// value = new String(Base64.decode(value.getBytes()), "GBK");
value = new String(org.apache.commons.codec.binary.Base64.decodeBase64(value), "GBK");
}
} catch (Exception e) {
e.printStackTrace();
}
return value;
}
}
public static class MyLocalDatetimeDeserializer extends StdDeserializer<LocalDateTime> {
private static final long serialVersionUID = 1L;
protected MyLocalDatetimeDeserializer() {
super(LocalDateTime.class);
}
@Override
public LocalDateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
return LocalDateTime.parse(jp.readValueAs(String.class), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
}
}
public static class MyLocalDatetimeSerializer extends StdSerializer<LocalDateTime> {
private static final long serialVersionUID = 1L;
public MyLocalDatetimeSerializer() {
super(LocalDateTime.class);
}
@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider sp) throws IOException, JsonProcessingException {
gen.writeString(value.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
}
}
// @SuppressWarnings({ "rawtypes" })
// public static class Base64Serializer extends JsonSerializer implements ContextualSerializer {
//
// @Override
// public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
// return this;
// }
//
// @Override
// public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
// if (!Base64.isBase64Pattern((String) value)) {
// value = Base64.decodeStr((String) value);
// }
// gen.writeObject(value);
// }
//
// }
@SuppressWarnings("unchecked")
public static void main(String[] args) {
String json = "[\"A\",\"B\"]";
List<String> list = JacksonUtils.fromJson(json, ArrayList.class);
System.out.println(list.get(0));
list = JacksonUtils.fromJson(json, new TypeReference<ArrayList<String>>() {
});
System.out.println(list.get(0));
System.out.println(new Date(10000000000000L));
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test.util;
import java.io.Serializable;
@SuppressWarnings("serial")
public class Pair<K, V> implements Serializable {
private K key;
private V value;
public Pair() {
}
public Pair(K key, V value) {
this.key = key;
this.value = value;
}
/**
* @return the key
*/
public final K getKey() {
return key;
}
/**
* @param key the key to set
*/
public final void setKey(K key) {
this.key = key;
}
/**
* @return the value
*/
public final V getValue() {
return value;
}
/**
* @param value the value to set
*/
public final void setValue(V value) {
this.value = value;
}
/**
* @return
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "[" + key + " : " + value + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((key == null) ? 0 : key.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Pair<?, ?> other = (Pair<?, ?>) obj;
if (key == null) {
if (other.key != null) {
return false;
}
} else if (!key.equals(other.key)) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
public K first() {
return getKey();
}
public V second() {
return getValue();
}
}
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC <?xml version="1.0" encoding="UTF-8" ?>
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <!-- 确保已安装mybatis generator eclipse插件 -->
<!-- 配置生成器 -->
<generatorConfiguration> <generatorConfiguration>
<!--classPathEntry:数据库的JDBC驱动,换成你自己的驱动位置 可选 -->
<!-- <classPathEntry location="F://jdbc//mysql-connector-java-8.0.18.jar"/>-->
<!-- 一个数据库一个context -->
<context id="DB2Tables" targetRuntime="Mybatis3">
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖 -->
<property name="autoDelimitKeywords" value="true"/>
<!-- 生成的Java文件的编码 -->
<property name="javaFileEncoding" value="utf-8"/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 格式化java代码 -->
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
<!-- 格式化XML代码 -->
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<!-- 配置 tk.mybatis 插件 -->
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="com.glsx.plat.mybatis.mapper.CommonBaseMapper"/>
</plugin>
<!--配置生成注释信息,最多配置一个 -->
<commentGenerator>
<!-- 阻止生成注释包含时间戳 默认为false -->
<property name="suppressDate" value="true"/>
<!-- 注释是否添加数据库表的备注信息 默认为false -->
<property name="addRemarkComments" value="true"/>
</commentGenerator>
<!-- jdbc连接-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.0.39:3306/seata_storage?serverTimeZone=Shanghai&amp;useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false"
userId="root"
password="123456">
<!--防止生成其他库同名表-->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!-- 类型转换 -->
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成实体类地址 --> <context id="DB2Tables" targetRuntime="MyBatis3">
<javaModelGenerator targetPackage="cn.com.payu.modules.entity" targetProject="src/main/java"> <property name="javaFileEncoding" value="UTF-8"/>
<!-- 是否让schema作为包的后缀 --> <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="enableSubPackages" value="true"/> <property name="mappers" value="com.glsx.plat.mybatis.mapper.CommonBaseMapper"/>
<!-- 从数据库返回的值去掉前后空格 --> <property name="caseSensitive" value="true"/>
<property name="trimStrings" value="true"/> <property name="useActualColumnNames" value="true" />
</javaModelGenerator> <!--<property name="beginningDelimiter" value="`"/>-->
<!--<property name="endingDelimiter" value="`"/>-->
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.3.222:3308/platform_process_dev?characterEncoding=utf8" userId="user_zhouhb" password="WoWP7N1u" />
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- 生成mapper.xml文件存放地址 --> <!-- api绝对路径-->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"> <javaModelGenerator targetPackage="cn.com.glsx.process.modules.entity" targetProject="F:\360MoveData\Users\11\Desktop\企微SAAS\2023\09\sop\platform-process-server\platform-process-api\src\main\java">
<property name="enableSubPackages" value="true"/> <property name="enableSubPackages" value="true" />
</sqlMapGenerator> <property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="mapper" targetProject="src\main\resources">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 --> <!-- api绝对路径-->
<javaClientGenerator targetPackage="cn.com.payu.modules.mapper" targetProject="src/main/java" type="XMLMAPPER"> <javaClientGenerator targetPackage="cn.com.glsx.process.modules.mapper" targetProject="F:\360MoveData\Users\11\Desktop\企微SAAS\2023\09\sop\platform-process-server\platform-process-api\src\main\java" type="XMLMAPPER">
<property name="enableSubPackages" value="false"/> <property name="enableSubPackages" value="true" />
</javaClientGenerator> </javaClientGenerator>
<!-- 可配置多个 -->
<!--<table tableName="sop_data_source" domainObjectName="SopDataSource" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>-->
<!-- <table tableName="sop_tpl_node" domainObjectName="SopTplNode" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="node_param_def" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="node_content_def" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="node_result_def" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="sop_tpl" domainObjectName="SopTpl" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="tpl_param_def" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="tpl_result_def" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="sop_tpl_grant" domainObjectName="SopTplGrant" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="sop_tpl_link" domainObjectName="SopTplLink" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="sop_node_tpl" domainObjectName="SopNodeTpl" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="node_param_def" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="node_content_def" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="node_result_def" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="sop_inst_node_batch" domainObjectName="SopInstNodeBatch" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="snapshot" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="sop_inst_node" domainObjectName="SopInstNode" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="node_param" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="node_content" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="sop_inst_link" domainObjectName="SopInstLink" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
<table tableName="sop_inst_batch" domainObjectName="SopInstBatch" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="snapshot" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>
<table tableName="sop_inst" domainObjectName="SopInst" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
<columnOverride column="inst_param" javaType="java.lang.String" jdbcType="VARCHAR" />
<columnOverride column="inst_snapshot" javaType="java.lang.String" jdbcType="VARCHAR" />
</table>-->
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table tableName="t_storage" domainObjectName="Storage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
</context>
</generatorConfiguration>
\ No newline at end of file \ No newline at end of file
<table tableName="job_manager" domainObjectName="JobManager" enableSelectByExample="false" enableCountByExample="false" enableDeleteByExample="false" enableUpdateByExample="false">
<generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table>
</context>
</generatorConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<parent> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<groupId>com.glsx</groupId> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>rest-admin-framework</artifactId> <parent>
<version>2.0.0-SNAPSHOT</version> <groupId>com.glsx</groupId>
</parent> <artifactId>rest-admin-framework</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx</groupId> <groupId>cn.com.glsx</groupId>
<artifactId>platform-process-server</artifactId> <artifactId>platform-process-server</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging> <packaging>pom</packaging>
<description>Microservice Scaffolding project for Spring Boot</description> <description>Microservice Scaffolding project for Spring Boot</description>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<build> <build>
<resources> <resources>
<resource> <resource>
<directory>src/main/java</directory> <directory>src/main/java</directory>
<excludes> <excludes>
<exclude>**/*.java</exclude> <exclude>**/*.java</exclude>
</excludes> </excludes>
</resource> </resource>
<resource> <resource>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<includes> <includes>
<include>**/*.*</include> <include>**/*.*</include>
</includes> </includes>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
...@@ -53,4 +55,5 @@ ...@@ -53,4 +55,5 @@
<module>platform-process</module> <module>platform-process</module>
<module>platform-process-api</module> <module>platform-process-api</module>
</modules> </modules>
</project> </project>
This diff could not be displayed because it is too large.
/*
Navicat MySQL Data Transfer
Source Server : 192.168.1.39_3306 -- scrm-dev
Source Server Version : 50505
Source Host : 192.168.1.39:3306
Source Database : sop_process
Target Server Type : MYSQL
Target Server Version : 50505
File Encoding : 65001
Date: 2023-09-10 13:26:26
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for node_tpl
-- ----------------------------
DROP TABLE IF EXISTS `node_tpl`;
CREATE TABLE `node_tpl` (
`tpl_node_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '节点id',
`node_name` varchar(32) NOT NULL COMMENT '节点任务描述',
`node_type` varchar(16) NOT NULL COMMENT '节点类型:可扩展,包括:start,end,java,python,js,',
`node_label` varchar(16) NOT NULL COMMENT '节点标签:Java、Js脚本、Sql查询等',
`node_show` varchar(255) DEFAULT NULL COMMENT 'Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class',
`node_param_def` text COMMENT '输入参数格式:Json,开始节点的输入参数全局共用',
`node_content_def` text COMMENT '节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等',
`node_result_def` text COMMENT '节点输出数据格式模板,主要用于后续节点参考',
`node_visible` tinyint(4) DEFAULT NULL COMMENT '节点可见状态,复制时不可变',
`node_cron` varchar(64) DEFAULT NULL COMMENT '调度表达式,为空则立即执行,执行前记得检查sop批次状态',
`node_expire_cron` varchar(64) DEFAULT NULL COMMENT '节点终止调度,为空则不执行过期操作',
`node_skipable` tinyint(4) DEFAULT NULL COMMENT '节点是否可以跳过,复制时不可变',
PRIMARY KEY (`tpl_node_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COMMENT='节点模板,可以将一些固定的业务操作封装成节点模板,根据节点模板可以很方便克隆出模板节点。';
-- ----------------------------
-- Records of node_tpl
-- ----------------------------
INSERT INTO `node_tpl` VALUES ('1', 'SOP开始', 'START', '开始', '{\r\n\"top\":200,\r\n\"left\":30,\r\n\"class\":\"eletype-e\"\r\n}', null, null, null, '1', null, null, '0');
INSERT INTO `node_tpl` VALUES ('2', '筛人-潜客', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"潜客\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"潜客\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": [\r\n {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '1', null, null, '0');
INSERT INTO `node_tpl` VALUES ('3', '营销-潜客第一天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `node_tpl` VALUES ('4', '营销-潜客第二天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"2\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `node_tpl` VALUES ('5', '营销-有意向第一天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `node_tpl` VALUES ('6', '营销-有意向第二天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"2\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `node_tpl` VALUES ('7', 'SOP结束', 'END', '结束', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', null, null, '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', null, null, '0');
INSERT INTO `node_tpl` VALUES ('8', '筛人-有意向', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"有意向\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"有意向\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '', '', '0');
INSERT INTO `node_tpl` VALUES ('9', '营销-旅程阶段刷新', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '0', '0 */5 * * * ?', '59 59 23 * * ?', '0');
INSERT INTO `node_tpl` VALUES ('10', '圈人-全部', 'Sql查询', 'Sql查询', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '', '{\r\n \"source\": \"select * from cdp.us ers where tag=\'xxx\'\",\r\n \"dataSourceId\":\"mysql-cdp\"\r\n} ', '{\r\n \"users\": [\r\n {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '1', '', '', '0');
-- ----------------------------
-- Table structure for sop_inst
-- ----------------------------
DROP TABLE IF EXISTS `sop_inst`;
CREATE TABLE `sop_inst` (
`inst_id` varchar(16) NOT NULL COMMENT '实例id,一般sop只允许一个实例。特殊情况可以根据输入参数来区分不同实例。实例名可以用于在cdp保存状态',
`grant_id` int(11) NOT NULL COMMENT '实例分组:当前场景下,分组id就是门店id',
`inst_name` varchar(32) NOT NULL COMMENT '实例名',
`inst_cron` varchar(32) NOT NULL COMMENT 'cron表达式,sop执行周期',
`inst_remark` varchar(255) DEFAULT NULL COMMENT 'sop简介',
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`inst_status` tinyint(4) DEFAULT NULL COMMENT '启用状态:0,未启用;1,启用;-1,已删除/过期;',
`inst_param` text COMMENT '实例默认输入参数',
`inst_snapshot` text COMMENT '实例快照,每天任务均从快照取数,修改的数据写回快照,与快照表做冗余;',
`expire_time` datetime DEFAULT NULL COMMENT 'sop有效期,每个sop都设置一个有效期,到期自动停止。',
`batch_no` varchar(16) DEFAULT NULL COMMENT '当前生效的批次',
PRIMARY KEY (`inst_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop在某个门店下的实例,一般是单实例,也可以支持多实例';
-- ----------------------------
-- Records of sop_inst
-- ----------------------------
INSERT INTO `sop_inst` VALUES ('xblc7', '1', '膨胀金7月活动-续保旅程', '0 0 8 * * ?', null, '2023-08-01 16:36:32', '2023-08-01 16:36:32', '1', '{\r\n \"merchantId\": \"M153312087\",\r\n \"stages\": {\r\n \"stage1\": {\r\n \"value\": \"潜客\",\r\n \"editable\": false,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n },\r\n \"stage2\": {\r\n \"value\": \"高意向\",\r\n \"editable\": true,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n },\r\n \"stage3\": {\r\n \"value\": \"下单\",\r\n \"editable\": false,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n },\r\n \"stage4\": {\r\n \"value\": \"战败\",\r\n \"editable\": false,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n }\r\n },\r\n \"users\": [\r\n {\r\n \"userId\": \"u0001\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-08-01 12:07:23\",\r\n \"sopTime\": \"2023-08-01 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0002\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-08-01 12:07:23\",\r\n \"sopTime\": \"2023-08-01 12:07:23\"\r\n }\r\n ]\r\n}', '{\r\n \"users\": [\r\n {\r\n \"userId\": \"u0001\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-09-06 12:07:23\",\r\n \"sopTime\": \"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0002\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-09-06 12:07:23\",\r\n \"sopTime\": \"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '2023-08-31 11:30:37', null);
INSERT INTO `sop_inst` VALUES ('xblc8', '1', '膨胀金8月活动-续保旅程', '0 0 8 * * ?', '', '2023-09-01 16:36:32', '2023-09-01 16:36:32', '1', '{\r\n \"merchantId\": \"M153312087\",\r\n \"stages\": {\r\n \"stage1\": {\r\n \"value\": \"潜客\",\r\n \"editable\": false,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n },\r\n \"stage2\": {\r\n \"value\": \"高意向\",\r\n \"editable\": true,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n },\r\n \"stage3\": {\r\n \"value\": \"下单\",\r\n \"editable\": false,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n },\r\n \"stage4\": {\r\n \"value\": \"战败\",\r\n \"editable\": false,\r\n \"conditions\": [\r\n \"链接(#膨胀金活动名称#) 反馈\",\r\n \"链接(#膨胀金活动名称#) 反馈\"\r\n ]\r\n }\r\n },\r\n \"users\": [\r\n {\r\n \"userId\": \"u0021\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-09-06 12:07:23\",\r\n \"sopTime\": \"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0022\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-09-06 12:07:23\",\r\n \"sopTime\": \"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '{\r\n \"users\": [\r\n {\r\n \"userId\": \"u0021\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-09-06 12:07:23\",\r\n \"sopTime\": \"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0022\",\r\n \"stage\": \"潜客\",\r\n \"stageTime\": \"2023-09-06 12:07:23\",\r\n \"sopTime\": \"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '2023-09-30 11:30:44', null);
-- ----------------------------
-- Table structure for sop_inst_batch
-- ----------------------------
DROP TABLE IF EXISTS `sop_inst_batch`;
CREATE TABLE `sop_inst_batch` (
`batch_no` varchar(16) NOT NULL,
`inst_id` int(11) NOT NULL,
`snapshot` text NOT NULL COMMENT '执行快照',
`create_time` datetime DEFAULT NULL COMMENT '批次启动时间',
`update_time` datetime DEFAULT NULL COMMENT '批次最后时间',
PRIMARY KEY (`batch_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop执行快照';
-- ----------------------------
-- Records of sop_inst_batch
-- ----------------------------
-- ----------------------------
-- Table structure for sop_inst_link
-- ----------------------------
DROP TABLE IF EXISTS `sop_inst_link`;
CREATE TABLE `sop_inst_link` (
`link_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`inst_id` varchar(16) NOT NULL,
`source_id` int(11) NOT NULL COMMENT '节点任务名',
`target_id` int(11) NOT NULL COMMENT '节点任务名',
PRIMARY KEY (`link_id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COMMENT='sop任务节点连接';
-- ----------------------------
-- Records of sop_inst_link
-- ----------------------------
INSERT INTO `sop_inst_link` VALUES ('1', 'xblc7', '1', '10');
INSERT INTO `sop_inst_link` VALUES ('2', 'xblc7', '10', '2');
INSERT INTO `sop_inst_link` VALUES ('3', 'xblc7', '10', '8');
INSERT INTO `sop_inst_link` VALUES ('4', 'xblc7', '2', '3');
INSERT INTO `sop_inst_link` VALUES ('5', 'xblc7', '2', '4');
INSERT INTO `sop_inst_link` VALUES ('6', 'xblc7', '8', '5');
INSERT INTO `sop_inst_link` VALUES ('7', 'xblc7', '8', '6');
INSERT INTO `sop_inst_link` VALUES ('8', 'xblc7', '3', '9');
INSERT INTO `sop_inst_link` VALUES ('9', 'xblc7', '4', '9');
INSERT INTO `sop_inst_link` VALUES ('10', 'xblc7', '5', '9');
INSERT INTO `sop_inst_link` VALUES ('11', 'xblc7', '6', '9');
INSERT INTO `sop_inst_link` VALUES ('12', 'xblc7', '9', '7');
INSERT INTO `sop_inst_link` VALUES ('13', 'xblc8', '1', '10');
INSERT INTO `sop_inst_link` VALUES ('14', 'xblc8', '10', '2');
INSERT INTO `sop_inst_link` VALUES ('15', 'xblc8', '10', '8');
INSERT INTO `sop_inst_link` VALUES ('16', 'xblc8', '2', '3');
INSERT INTO `sop_inst_link` VALUES ('17', 'xblc8', '2', '4');
INSERT INTO `sop_inst_link` VALUES ('18', 'xblc8', '8', '5');
INSERT INTO `sop_inst_link` VALUES ('19', 'xblc8', '8', '6');
INSERT INTO `sop_inst_link` VALUES ('20', 'xblc8', '3', '9');
INSERT INTO `sop_inst_link` VALUES ('21', 'xblc8', '4', '9');
INSERT INTO `sop_inst_link` VALUES ('22', 'xblc8', '5', '9');
INSERT INTO `sop_inst_link` VALUES ('23', 'xblc8', '6', '9');
INSERT INTO `sop_inst_link` VALUES ('24', 'xblc8', '9', '7');
-- ----------------------------
-- Table structure for sop_inst_node
-- ----------------------------
DROP TABLE IF EXISTS `sop_inst_node`;
CREATE TABLE `sop_inst_node` (
`inst_node_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '实例节点id',
`inst_id` varchar(16) NOT NULL,
`node_id` int(10) unsigned NOT NULL COMMENT '节点id',
`node_name` varchar(32) NOT NULL COMMENT '节点任务名',
`node_type` varchar(16) NOT NULL COMMENT '节点类型:可扩展,包括:start,end,java,python,js,',
`node_label` varchar(16) NOT NULL COMMENT '节点标签:Java、Js脚本、Sql查询等',
`node_key` varchar(32) NOT NULL COMMENT '节点的访问key',
`node_show` varchar(255) DEFAULT NULL COMMENT 'Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class',
`node_param` text COMMENT '输入参数格式:Json,开始节点的输入参数全局共用',
`node_content` text COMMENT '节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等',
`node_visible` tinyint(4) NOT NULL DEFAULT '1' COMMENT '节点可见状态',
`node_skip` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否跳过节点',
`node_cron` varchar(255) DEFAULT NULL COMMENT '节点调度表达式',
`node_expire_cron` varchar(255) DEFAULT NULL COMMENT '节点终止调度',
`node_status` int(4) NOT NULL DEFAULT '1' COMMENT '节点状态:0,停用;1,启用;',
PRIMARY KEY (`inst_node_id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COMMENT='sop任务节点';
-- ----------------------------
-- Records of sop_inst_node
-- ----------------------------
INSERT INTO `sop_inst_node` VALUES ('1', 'xblc7', '1', 'SOP开始', 'START', '开始', '', '{\r\n\"top\":200,\r\n\"left\":30,\r\n\"class\":\"eletype-e\"\r\n}', null, null, '1', '0', null, null, '1');
INSERT INTO `sop_inst_node` VALUES ('2', 'xblc7', '2', '筛人-潜客', 'Java', 'Java', 'users', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"潜客\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"潜客\",\r\n \"required\": true \r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '', '', '1');
INSERT INTO `sop_inst_node` VALUES ('3', 'xblc7', '3', '营销-潜客第一天', 'Java', 'Java', 'user1day1', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('4', 'xblc7', '4', '营销-潜客第二天', 'Java', 'Java', 'user1day2', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', null, null, '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('5', 'xblc7', '5', '营销-有意向第一天', 'Java', 'Java', 'user2day1', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('6', 'xblc7', '6', '营销-有意向第二天', 'Java', 'Java', 'user2day2', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"2\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('7', 'xblc7', '7', 'SOP结束', 'END', '结束', 'end', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '', '', '1', '0', null, null, '1');
INSERT INTO `sop_inst_node` VALUES ('8', 'xblc7', '8', '筛人-有意向', 'Java', 'Java', 'user2', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"有意向\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"有意向\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', null, null, '1');
INSERT INTO `sop_inst_node` VALUES ('9', 'xblc7', '9', '营销-旅程阶段刷新', 'Java', 'Java', '', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '0', '0', '0 */5 * * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('10', 'xblc7', '10', '圈人-全部', 'Sql查询', 'Sql查询', 'users', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', null, '{\r\n \"source\": \"select * from cdp.us ers where tag=\'xxx\'\",\r\n \"dataSourceId\":\"mysql-cdp\"\r\n} ', '1', '0', null, null, '1');
INSERT INTO `sop_inst_node` VALUES ('18', 'xblc8', '1', 'SOP开始', 'START', '开始', '', '{\r\n\"top\":200,\r\n\"left\":30,\r\n\"class\":\"eletype-e\"\r\n}', '', '', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('19', 'xblc8', '2', '筛人-潜客', 'Java', 'Java', 'users', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"潜客\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"潜客\",\r\n \"required\": true \r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '', '', '1');
INSERT INTO `sop_inst_node` VALUES ('20', 'xblc8', '3', '营销-潜客第一天', 'Java', 'Java', 'user1day1', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('22', 'xblc8', '4', '营销-潜客第二天', 'Java', 'Java', 'user1day2', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '', '', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('23', 'xblc8', '5', '营销-有意向第一天', 'Java', 'Java', 'user2day1', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('24', 'xblc8', '6', '营销-有意向第二天', 'Java', 'Java', 'user2day2', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"2\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('25', 'xblc8', '7', 'SOP结束', 'END', '结束', 'end', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '', '', '1', '0', '', '', '1');
INSERT INTO `sop_inst_node` VALUES ('26', 'xblc8', '8', '筛人-有意向', 'Java', 'Java', 'user2', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"有意向\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"有意向\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '1', '0', '', '', '1');
INSERT INTO `sop_inst_node` VALUES ('27', 'xblc8', '9', '营销-旅程阶段刷新', 'Java', 'Java', '', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '0', '0', '0 */5 * * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_inst_node` VALUES ('28', 'xblc8', '10', '圈人-全部', 'Sql查询', 'Sql查询', 'users', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '', '{\r\n \"source\": \"select * from cdp.us ers where tag=\'xxx\'\",\r\n \"dataSourceId\":\"mysql-cdp\"\r\n} ', '1', '0', null, null, '1');
-- ----------------------------
-- Table structure for sop_inst_node_batch
-- ----------------------------
DROP TABLE IF EXISTS `sop_inst_node_batch`;
CREATE TABLE `sop_inst_node_batch` (
`node_batch_no` varchar(16) NOT NULL,
`inst_node_id` int(11) NOT NULL,
`batch_no` varchar(32) DEFAULT NULL COMMENT '批次',
`snapshot` text NOT NULL COMMENT '执行快照',
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`node_batch_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop节点执行快照';
-- ----------------------------
-- Records of sop_inst_node_batch
-- ----------------------------
-- ----------------------------
-- Table structure for sop_tpl
-- ----------------------------
DROP TABLE IF EXISTS `sop_tpl`;
CREATE TABLE `sop_tpl` (
`tpl_id` varchar(8) NOT NULL COMMENT '模板id,模板代码,建议使用模板名拼音首字母缩写,不要超过8位',
`tpl_name` varchar(32) NOT NULL COMMENT '模板名',
`tpl_cron` varchar(32) NOT NULL COMMENT 'cron表达式,sop执行周期',
`tpl_remark` varchar(255) DEFAULT NULL COMMENT 'sop简介',
`tpl_status` tinyint(4) NOT NULL COMMENT '启用状态:0,禁用;1,启用;',
`tpl_param_def` text COMMENT 'JSON结构,sop默认输入参数定义,可以在分配门店时配置的参数,比如旅程阶段列表',
`tpl_result_def` text,
`tpl_singleton` tinyint(4) NOT NULL COMMENT '是否单实例模式:0,多实例;1,单实例;',
`create_time` datetime NOT NULL,
`update_time` datetime NOT NULL,
PRIMARY KEY (`tpl_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sop模板';
-- ----------------------------
-- Records of sop_tpl
-- ----------------------------
INSERT INTO `sop_tpl` VALUES ('XBLC', '续保旅程', '0 0 8 * * ?', '从膨胀金活动导出的用户进入续保旅程,可以多次导入形成多个实例', '1', '{\r\n \"merchantId\": {\r\n \"paramName\": \"merchantId\",\r\n \"paramDesc\": \"门店id,分配给门店时需要赋值\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"\",\r\n \"required\": true\r\n },\r\n \"stages\": {\r\n \"paramName\": \"stages\",\r\n \"paramDesc\": \"旅程阶段,值类型为Json\",\r\n \"valueType\": \"Json\",\r\n \"defaultValue\": {\r\n \"stage1\": {\r\n \"value\": \"潜客\",\r\n \"editable\": false,\r\n \"conditions\": [\"链接(#膨胀金活动名称#) 反馈\", \"链接(#膨胀金活动名称#) 反馈\"]\r\n },\r\n \"stage2\": {\r\n \"value\": \"高意向\",\r\n \"editable\": true,\r\n \"conditions\": [\"链接(#膨胀金活动名称#) 反馈\", \"链接(#膨胀金活动名称#) 反馈\"]\r\n },\r\n \"stage3\": {\r\n \"value\": \"下单\",\r\n \"editable\": false,\r\n \"conditions\": [\"链接(#膨胀金活动名称#) 反馈\", \"链接(#膨胀金活动名称#) 反馈\"]\r\n },\r\n \"stage4\": {\r\n \"value\": \"战败\",\r\n \"editable\": false,\r\n \"conditions\": [\"链接(#膨胀金活动名称#) 反馈\", \"链接(#膨胀金活动名称#) 反馈\"]\r\n }\r\n },\r\n \"required\": true\r\n },\r\n \"users\": {\r\n \"paramName\": \"users\",\r\n \"paramDesc\": \"通过膨胀金活动导入的用户信息\",\r\n \"valueType\": \"Json\",\r\n \"defaultValue\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"userName\": \"张三\",\r\n \"followId\": \"跟进人id1\",\r\n \"textContent\": \"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"userName\": \"李四\",\r\n \"followId\": \"跟进人id2\",\r\n \"textContent\": \"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"\r\n }\r\n },\r\n \"required\": true\r\n }\r\n}', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '0', '2023-09-06 15:33:24', '2023-09-06 15:33:24');
-- ----------------------------
-- Table structure for sop_tpl_grant
-- ----------------------------
DROP TABLE IF EXISTS `sop_tpl_grant`;
CREATE TABLE `sop_tpl_grant` (
`grant_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '授权id',
`group_id` varchar(16) NOT NULL COMMENT '实例分组:当前场景下,分组id就是门店id',
`group_name` varchar(32) DEFAULT NULL,
`tpl_id` varchar(8) NOT NULL COMMENT '模板id',
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`grant_status` tinyint(4) DEFAULT NULL COMMENT '授权状态:0,未启用;1,启用;',
PRIMARY KEY (`grant_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='sop模板针对某个分组(门店)的授权';
-- ----------------------------
-- Records of sop_tpl_grant
-- ----------------------------
INSERT INTO `sop_tpl_grant` VALUES ('1', 'M153312087', '成都丰田', 'XBLC', '2023-09-07 11:05:13', '2023-09-07 11:05:17', '1');
-- ----------------------------
-- Table structure for sop_tpl_link
-- ----------------------------
DROP TABLE IF EXISTS `sop_tpl_link`;
CREATE TABLE `sop_tpl_link` (
`link_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`tpl_id` varchar(16) NOT NULL,
`source_id` int(11) NOT NULL COMMENT '任务节点链接起点',
`target_id` int(11) NOT NULL COMMENT '任务节点链接终点',
PRIMARY KEY (`link_id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COMMENT='sop任务节点连接';
-- ----------------------------
-- Records of sop_tpl_link
-- ----------------------------
INSERT INTO `sop_tpl_link` VALUES ('1', 'XBLC', '1', '10');
INSERT INTO `sop_tpl_link` VALUES ('2', 'XBLC', '10', '2');
INSERT INTO `sop_tpl_link` VALUES ('3', 'XBLC', '10', '8');
INSERT INTO `sop_tpl_link` VALUES ('4', 'XBLC', '2', '3');
INSERT INTO `sop_tpl_link` VALUES ('5', 'XBLC', '2', '4');
INSERT INTO `sop_tpl_link` VALUES ('6', 'XBLC', '8', '5');
INSERT INTO `sop_tpl_link` VALUES ('7', 'XBLC', '8', '6');
INSERT INTO `sop_tpl_link` VALUES ('8', 'XBLC', '3', '9');
INSERT INTO `sop_tpl_link` VALUES ('9', 'XBLC', '4', '9');
INSERT INTO `sop_tpl_link` VALUES ('10', 'XBLC', '5', '9');
INSERT INTO `sop_tpl_link` VALUES ('11', 'XBLC', '6', '9');
INSERT INTO `sop_tpl_link` VALUES ('12', 'XBLC', '9', '7');
-- ----------------------------
-- Table structure for sop_tpl_node
-- ----------------------------
DROP TABLE IF EXISTS `sop_tpl_node`;
CREATE TABLE `sop_tpl_node` (
`node_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '节点id',
`tpl_id` varchar(8) NOT NULL COMMENT 'sop模板代码',
`node_name` varchar(32) NOT NULL COMMENT '节点任务描述',
`node_type` varchar(16) NOT NULL COMMENT '节点类型:可扩展,包括:start,end,java,python,js,',
`node_label` varchar(16) NOT NULL COMMENT '节点标签:Java、Js脚本、Sql查询等',
`node_show` varchar(255) DEFAULT NULL COMMENT 'Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class',
`node_param_def` text COMMENT '输入参数格式:Json,开始节点的输入参数全局共用',
`node_content_def` text COMMENT '节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等',
`node_key` varchar(32) DEFAULT NULL COMMENT '节点的访问key,复制时不可变',
`node_result_def` text COMMENT '节点输出数据格式模板,主要用于后续节点参考',
`node_visible` tinyint(4) DEFAULT NULL COMMENT '节点可见状态,复制时不可变',
`node_cron` varchar(64) DEFAULT NULL COMMENT '调度表达式,为空则立即执行,执行前记得检查sop批次状态',
`node_expire_cron` varchar(64) DEFAULT NULL COMMENT '节点终止调度,为空则立即执行',
`node_skipable` tinyint(4) DEFAULT NULL COMMENT '节点是否可以跳过,复制时不可变',
PRIMARY KEY (`node_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COMMENT='sop任务节点';
-- ----------------------------
-- Records of sop_tpl_node
-- ----------------------------
INSERT INTO `sop_tpl_node` VALUES ('1', 'XBLC', 'SOP开始', 'START', '开始', '{\r\n\"top\":200,\r\n\"left\":30,\r\n\"class\":\"eletype-e\"\r\n}', null, null, 'start', null, '1', null, null, '0');
INSERT INTO `sop_tpl_node` VALUES ('2', 'XBLC', '筛人-潜客', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"潜客\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"潜客\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', 'users', '{\r\n \"users\": [\r\n {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '1', null, null, '0');
INSERT INTO `sop_tpl_node` VALUES ('3', 'XBLC', '营销-潜客第一天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', 'user1day1', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_tpl_node` VALUES ('4', 'XBLC', '营销-潜客第二天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"2\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', 'user1day2', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_tpl_node` VALUES ('5', 'XBLC', '营销-有意向第一天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', 'user2day1', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_tpl_node` VALUES ('6', 'XBLC', '营销-有意向第二天', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"有意向第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"2\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', 'user2day2', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '0 0 10 * * ?', '59 59 23 * * ?', '1');
INSERT INTO `sop_tpl_node` VALUES ('7', 'XBLC', 'SOP结束', 'END', '结束', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', null, null, 'end', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', null, null, '0');
INSERT INTO `sop_tpl_node` VALUES ('8', 'XBLC', '筛人-有意向', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"stage\": {\r\n \"paramName\": \"stage\",\r\n \"paramDesc\": \"有意向\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"有意向\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', 'user2', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '1', '', '', '0');
INSERT INTO `sop_tpl_node` VALUES ('9', 'XBLC', '营销-旅程阶段刷新', 'Java', 'Java', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '{\r\n \"day\": {\r\n \"paramName\": \"day\",\r\n \"paramDesc\": \"潜客第?天\",\r\n \"valueType\": \"Integer\",\r\n \"defaultValue\": \"1\",\r\n \"required\": true\r\n },\r\n \"textContent\": {\r\n \"paramName\": \"textContent\",\r\n \"paramDesc\": \"营销文案\",\r\n \"valueType\": \"String\",\r\n \"defaultValue\": \"尊敬的${userName},优惠券领取url.cn/c134dqwe\",\r\n \"required\": true\r\n }\r\n}', '{\r\n \"source\": \"import com.alibaba.fastjson.JSON;\\r\\nimport com.alibaba.fastjson.JSONArray;\\r\\nimport com.alibaba.fastjson.JSONObject;\\r\\nimport com.mcg.plugin.assist.Console;\\r\\n\\r\\npublic class Controller {\\r\\n private Console console = new Console();\\r\\n\\r\\n public JSON execute(JSON param) {\\r\\n console.info(\\\"-----欢迎使用---------\\\");\\r\\n\\r\\n JSONObject result = new JSONObject();\\r\\n return result;\\r\\n }\\r\\n}\\r\\n\"\r\n}', '', '{\r\n \"users\": {\r\n \"u0001\": {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n \"u0002\": {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n }\r\n}', '0', '0 */5 * * * ?', '59 59 23 * * ?', '0');
INSERT INTO `sop_tpl_node` VALUES ('10', 'XBLC', '圈人-全部', 'Sql查询', 'Sql查询', '{\r\n\"top\":150,\r\n\"left\":80,\r\n\"class\":\"eletype-e\"\r\n}', '', '{\r\n \"source\": \"select * from cdp.us ers where tag=\'xxx\'\",\r\n \"dataSourceId\":\"mysql-cdp\"\r\n} ', 'users', '{\r\n \"users\": [\r\n {\r\n \"userId\": \"u0001\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n },\r\n {\r\n \"userId\": \"u0002\",\r\n \"stage\":\"潜客\",\r\n \"stageTime\":\"2023-09-06 12:07:23\",\r\n \"sopTime\":\"2023-09-06 12:07:23\"\r\n }\r\n ]\r\n}', '1', '', '', '0');
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!