Commit 8f044a0b by zhouhaibao

Merge remote-tracking branch 'origin/v1.0.1' into v1.0.1

# Conflicts:
#	platform-process/pom.xml
2 parents f7ab189f fb28ac4b
Showing 24 changed files with 860 additions and 539 deletions
package cn.com.glsx.process.modules.entity; package cn.com.glsx.process.modules.entity;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.util.List;
@Table(name = "sop_inst_node") @Table(name = "sop_inst_node")
public class SopInstNode { public class SopInstNode {
public static final byte NODE_SKIP_FALSE = 0; public static final byte NODE_SKIP_FALSE = 0;
public static final byte NODE_SKIP_TRUE = 1; public static final byte NODE_SKIP_TRUE = 1;
public static final int NODE_STATUS_DELETED = 0; public static final int NODE_STATUS_DELETED = 0;
public static final int NODE_STATUS_NORMAL = 1; public static final int NODE_STATUS_NORMAL = 1;
/** /**
* 实例节点id * 实例节点id
*/ */
@Id @Id
@Column(name = "inst_node_id") @Column(name = "inst_node_id")
private Integer instNodeId; private Integer instNodeId;
@Column(name = "inst_id") @Column(name = "inst_id")
private String instId; private String instId;
/** /**
* 节点id * 节点id
*/ */
@Column(name = "node_id") @Column(name = "node_id")
private Integer nodeId; private Integer nodeId;
/** /**
* 节点任务名 * 节点任务名
*/ */
@Column(name = "node_name") @Column(name = "node_name")
private String nodeName; private String nodeName;
/** /**
* 节点类型:可扩展,包括:start,end,java,python,js, * 节点类型:可扩展,包括:start,end,java,python,js,
*/ */
@Column(name = "node_type") @Column(name = "node_type")
private String nodeType; private String nodeType;
/** /**
* 节点标签:Java、Js脚本、Sql查询等 * 节点标签:Java、Js脚本、Sql查询等
*/ */
@Column(name = "node_label") @Column(name = "node_label")
private String nodeLabel; private String nodeLabel;
/** /**
* 节点的访问key * 节点的访问key
*/ */
@Column(name = "node_key") @Column(name = "node_key")
private String nodeKey; private String nodeKey;
/** /**
* Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class * Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
*/ */
@Column(name = "node_show") @Column(name = "node_show")
private String nodeShow; private String nodeShow;
/** /**
* 输入参数格式:Json,开始节点的输入参数全局共用 * 输入参数格式:Json,开始节点的输入参数全局共用
*/ */
@Column(name = "node_param") @Column(name = "node_param")
private String nodeParam; private String nodeParam;
/** /**
* 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等 * 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
*/ */
@Column(name = "node_content") @Column(name = "node_content")
private String nodeContent; private String nodeContent;
/** /**
* 节点可见状态 * 节点可见状态
*/ */
@Column(name = "node_visible") @Column(name = "node_visible")
private Byte nodeVisible; private Byte nodeVisible;
/** /**
* 是否跳过节点 * 是否跳过节点
*/ */
@Column(name = "node_skip") @Column(name = "node_skip")
private Byte nodeSkip; private Byte nodeSkip;
@Column(name = "node_async") @Column(name = "node_async")
private Byte nodeAsync; private Byte nodeAsync;
/** /**
* 节点调度表达式 * 节点调度表达式
*/ */
@Column(name = "node_cron") @Column(name = "node_cron")
private String nodeCron; private String nodeCron;
/** /**
* 节点终止调度 * 节点终止调度
*/ */
@Column(name = "node_expire_cron") @Column(name = "node_expire_cron")
private String nodeExpireCron; private String nodeExpireCron;
/** /**
* 节点状态:0,停用;1,启用; * 节点状态:0,停用;1,启用;
*/ */
@Column(name = "node_status") @Column(name = "node_status")
private Integer nodeStatus; private Integer nodeStatus;
@Transient /**
private List<SopInstNode> sopInstNodeList; * 每日执行次数限制,0表示不限制。
*/
public List<SopInstNode> getSopInstNodeList() { @Column(name = "daily_limit")
return sopInstNodeList; private Integer dailyLimit;
}
/**
public void setSopInstNodeList(List<SopInstNode> sopInstNodeList) { * 每日执行次数限制,0表示不限制。
this.sopInstNodeList = sopInstNodeList; */
} @Column(name = "daily_count")
private Integer dailyCount;
/**
* 获取实例节点id @Transient
* private List<SopInstNode> sopInstNodeList;
* @return inst_node_id - 实例节点id
*/ public List<SopInstNode> getSopInstNodeList() {
public Integer getInstNodeId() { return sopInstNodeList;
return instNodeId; }
}
public void setSopInstNodeList(List<SopInstNode> sopInstNodeList) {
/** this.sopInstNodeList = sopInstNodeList;
* 设置实例节点id }
*
* @param instNodeId 实例节点id /**
*/ * 获取实例节点id
public void setInstNodeId(Integer instNodeId) { *
this.instNodeId = instNodeId; * @return inst_node_id - 实例节点id
} */
public Integer getInstNodeId() {
/** return instNodeId;
* @return inst_id }
*/
public String getInstId() { /**
return instId; * 设置实例节点id
} *
* @param instNodeId 实例节点id
/** */
* @param instId public void setInstNodeId(Integer instNodeId) {
*/ this.instNodeId = instNodeId;
public void setInstId(String instId) { }
this.instId = instId == null ? null : instId.trim();
} /**
* @return inst_id
/** */
* 获取节点id public String getInstId() {
* return instId;
* @return node_id - 节点id }
*/
public Integer getNodeId() { /**
return nodeId; * @param instId
} */
public void setInstId(String instId) {
/** this.instId = instId == null ? null : instId.trim();
* 设置节点id }
*
* @param nodeId 节点id /**
*/ * 获取节点id
public void setNodeId(Integer nodeId) { *
this.nodeId = nodeId; * @return node_id - 节点id
} */
public Integer getNodeId() {
/** return nodeId;
* 获取节点任务名 }
*
* @return node_name - 节点任务名 /**
*/ * 设置节点id
public String getNodeName() { *
return nodeName; * @param nodeId 节点id
} */
public void setNodeId(Integer nodeId) {
/** this.nodeId = nodeId;
* 设置节点任务名 }
*
* @param nodeName 节点任务名 /**
*/ * 获取节点任务名
public void setNodeName(String nodeName) { *
this.nodeName = nodeName == null ? null : nodeName.trim(); * @return node_name - 节点任务名
} */
public String getNodeName() {
/** return nodeName;
* 获取节点类型:可扩展,包括:start,end,java,python,js, }
*
* @return node_type - 节点类型:可扩展,包括:start,end,java,python,js, /**
*/ * 设置节点任务名
public String getNodeType() { *
return nodeType; * @param nodeName 节点任务名
} */
public void setNodeName(String nodeName) {
/** this.nodeName = nodeName == null ? null : nodeName.trim();
* 设置节点类型:可扩展,包括:start,end,java,python,js, }
*
* @param nodeType 节点类型:可扩展,包括:start,end,java,python,js, /**
*/ * 获取节点类型:可扩展,包括:start,end,java,python,js,
public void setNodeType(String nodeType) { *
this.nodeType = nodeType == null ? null : nodeType.trim(); * @return node_type - 节点类型:可扩展,包括:start,end,java,python,js,
} */
public String getNodeType() {
/** return nodeType;
* 获取节点标签:Java、Js脚本、Sql查询等 }
*
* @return node_label - 节点标签:Java、Js脚本、Sql查询等 /**
*/ * 设置节点类型:可扩展,包括:start,end,java,python,js,
public String getNodeLabel() { *
return nodeLabel; * @param nodeType 节点类型:可扩展,包括:start,end,java,python,js,
} */
public void setNodeType(String nodeType) {
/** this.nodeType = nodeType == null ? null : nodeType.trim();
* 设置节点标签:Java、Js脚本、Sql查询等 }
*
* @param nodeLabel 节点标签:Java、Js脚本、Sql查询等 /**
*/ * 获取节点标签:Java、Js脚本、Sql查询等
public void setNodeLabel(String nodeLabel) { *
this.nodeLabel = nodeLabel == null ? null : nodeLabel.trim(); * @return node_label - 节点标签:Java、Js脚本、Sql查询等
} */
public String getNodeLabel() {
/** return nodeLabel;
* 获取节点的访问key }
*
* @return node_key - 节点的访问key /**
*/ * 设置节点标签:Java、Js脚本、Sql查询等
public String getNodeKey() { *
return nodeKey; * @param nodeLabel 节点标签:Java、Js脚本、Sql查询等
} */
public void setNodeLabel(String nodeLabel) {
/** this.nodeLabel = nodeLabel == null ? null : nodeLabel.trim();
* 设置节点的访问key }
*
* @param nodeKey 节点的访问key /**
*/ * 获取节点的访问key
public void setNodeKey(String nodeKey) { *
this.nodeKey = nodeKey == null ? null : nodeKey.trim(); * @return node_key - 节点的访问key
} */
public String getNodeKey() {
/** return nodeKey;
* 获取Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class }
*
* @return node_show - Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class /**
*/ * 设置节点的访问key
public String getNodeShow() { *
return nodeShow; * @param nodeKey 节点的访问key
} */
public void setNodeKey(String nodeKey) {
/** this.nodeKey = nodeKey == null ? null : nodeKey.trim();
* 设置Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class }
*
* @param nodeShow Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class /**
*/ * 获取Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
public void setNodeShow(String nodeShow) { *
this.nodeShow = nodeShow == null ? null : nodeShow.trim(); * @return node_show - Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
} */
public String getNodeShow() {
/** return nodeShow;
* 获取输入参数格式:Json,开始节点的输入参数全局共用 }
*
* @return node_param - 输入参数格式:Json,开始节点的输入参数全局共用 /**
*/ * 设置Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
public String getNodeParam() { *
return nodeParam; * @param nodeShow Json结构,记录节点位置和展示样式,提供给前端使用。包括top,left,class
} */
public void setNodeShow(String nodeShow) {
/** this.nodeShow = nodeShow == null ? null : nodeShow.trim();
* 设置输入参数格式:Json,开始节点的输入参数全局共用 }
*
* @param nodeParam 输入参数格式:Json,开始节点的输入参数全局共用 /**
*/ * 获取输入参数格式:Json,开始节点的输入参数全局共用
public void setNodeParam(String nodeParam) { *
this.nodeParam = nodeParam == null ? null : nodeParam.trim(); * @return node_param - 输入参数格式:Json,开始节点的输入参数全局共用
} */
public String getNodeParam() {
/** return nodeParam;
* 获取节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等 }
*
* @return node_content - 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等 /**
*/ * 设置输入参数格式:Json,开始节点的输入参数全局共用
public String getNodeContent() { *
return nodeContent; * @param nodeParam 输入参数格式:Json,开始节点的输入参数全局共用
} */
public void setNodeParam(String nodeParam) {
/** this.nodeParam = nodeParam == null ? null : nodeParam.trim();
* 设置节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等 }
*
* @param nodeContent 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等 /**
*/ * 获取节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
public void setNodeContent(String nodeContent) { *
this.nodeContent = nodeContent == null ? null : nodeContent.trim(); * @return node_content - 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
} */
public String getNodeContent() {
/** return nodeContent;
* 获取节点可见状态 }
*
* @return node_visible - 节点可见状态 /**
*/ * 设置节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
public Byte getNodeVisible() { *
return nodeVisible; * @param nodeContent 节点源码,配合node_type使用,比如java源码,python脚本,sql脚本+数据源等
} */
public void setNodeContent(String nodeContent) {
/** this.nodeContent = nodeContent == null ? null : nodeContent.trim();
* 设置节点可见状态 }
*
* @param nodeVisible 节点可见状态 /**
*/ * 获取节点可见状态
public void setNodeVisible(Byte nodeVisible) { *
this.nodeVisible = nodeVisible; * @return node_visible - 节点可见状态
} */
public Byte getNodeVisible() {
/** return nodeVisible;
* 获取是否跳过节点 }
*
* @return node_skip - 是否跳过节点 /**
*/ * 设置节点可见状态
public Byte getNodeSkip() { *
return nodeSkip; * @param nodeVisible 节点可见状态
} */
public void setNodeVisible(Byte nodeVisible) {
/** this.nodeVisible = nodeVisible;
* 设置是否跳过节点 }
*
* @param nodeSkip 是否跳过节点 /**
*/ * 获取是否跳过节点
public void setNodeSkip(Byte nodeSkip) { *
this.nodeSkip = nodeSkip; * @return node_skip - 是否跳过节点
} */
public Byte getNodeSkip() {
/** return nodeSkip;
* 获取节点调度表达式 }
*
* @return node_cron - 节点调度表达式 /**
*/ * 设置是否跳过节点
public String getNodeCron() { *
return nodeCron; * @param nodeSkip 是否跳过节点
} */
public void setNodeSkip(Byte nodeSkip) {
/** this.nodeSkip = nodeSkip;
* 设置节点调度表达式 }
*
* @param nodeCron 节点调度表达式 /**
*/ * 获取节点调度表达式
public void setNodeCron(String nodeCron) { *
this.nodeCron = nodeCron == null ? null : nodeCron.trim(); * @return node_cron - 节点调度表达式
} */
public String getNodeCron() {
/** return nodeCron;
* 获取节点终止调度 }
*
* @return node_expire_cron - 节点终止调度 /**
*/ * 设置节点调度表达式
public String getNodeExpireCron() { *
return nodeExpireCron; * @param nodeCron 节点调度表达式
} */
public void setNodeCron(String nodeCron) {
/** this.nodeCron = nodeCron == null ? null : nodeCron.trim();
* 设置节点终止调度 }
*
* @param nodeExpireCron 节点终止调度 /**
*/ * 获取节点终止调度
public void setNodeExpireCron(String nodeExpireCron) { *
this.nodeExpireCron = nodeExpireCron == null ? null : nodeExpireCron.trim(); * @return node_expire_cron - 节点终止调度
} */
public String getNodeExpireCron() {
/** return nodeExpireCron;
* 获取节点状态:0,停用;1,启用; }
*
* @return node_status - 节点状态:0,停用;1,启用; /**
*/ * 设置节点终止调度
public Integer getNodeStatus() { *
return nodeStatus; * @param nodeExpireCron 节点终止调度
} */
public void setNodeExpireCron(String nodeExpireCron) {
/** this.nodeExpireCron = nodeExpireCron == null ? null : nodeExpireCron.trim();
* 设置节点状态:0,停用;1,启用; }
*
* @param nodeStatus 节点状态:0,停用;1,启用; /**
*/ * 获取节点状态:0,停用;1,启用;
public void setNodeStatus(Integer nodeStatus) { *
this.nodeStatus = nodeStatus; * @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() { public Byte getNodeAsync() {
return nodeAsync; return nodeAsync;
...@@ -391,4 +404,20 @@ public class SopInstNode { ...@@ -391,4 +404,20 @@ public class SopInstNode {
this.nodeAsync = 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;
}
} }
\ 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 javax.persistence.*; import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "sop_tpl_node") @Table(name = "sop_tpl_node")
public class SopTplNode { public class SopTplNode {
...@@ -95,6 +97,12 @@ public class SopTplNode { ...@@ -95,6 +97,12 @@ public class SopTplNode {
@Column(name = "node_async") @Column(name = "node_async")
private Byte nodeAsync; private Byte nodeAsync;
/**
* 每日执行次数限制,0表示不限制。
*/
@Column(name = "daily_limit")
private Integer dailyLimit;
/** /**
* 获取节点id * 获取节点id
* *
...@@ -354,4 +362,13 @@ public class SopTplNode { ...@@ -354,4 +362,13 @@ public class SopTplNode {
public void setNodeAsync(Byte nodeAsync) { public void setNodeAsync(Byte nodeAsync) {
this.nodeAsync = 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; package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstNode; import java.util.List;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import cn.com.glsx.process.modules.entity.SopInstNode;
@Mapper @Mapper
public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> { public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> {
List<SopInstNode> findByInstId(@Param("instId") String instId); 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.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;
/**
* 进入sop旅程时间-开始
*/
private String sopJourneyEnterTimeBegin;
/**
* 进入sop旅程时间-结束
*/
private String sopJourneyEnterTimeEnd;
}
...@@ -134,6 +134,19 @@ ...@@ -134,6 +134,19 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId> <artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency> </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> <dependency>
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>rest-admin-office</artifactId> <artifactId>rest-admin-office</artifactId>
......
...@@ -25,7 +25,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil; ...@@ -25,7 +25,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
@EnableDubbo @EnableDubbo
@EnableRestAdmin @EnableRestAdmin
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = { "cn.com.glsx.*.api","cn.com.glsx.*.*.api" }) @EnableFeignClients(basePackages = { "cn.com.glsx.*.api", "cn.com.glsx.process.modules.client" })
@SpringBootApplication @SpringBootApplication
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
public class Application implements CommandLineRunner { public class Application implements CommandLineRunner {
......
package cn.com.glsx.process.job.xxljob.core; package cn.com.glsx.process.job.xxljob.core;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;
import com.google.common.collect.Lists;
import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.context.XxlJobHelper;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam; import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInst; import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode; import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct; import cn.com.glsx.process.modules.model.SopStruct;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Pair; import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
...@@ -34,11 +37,13 @@ public class SopXxlJobUtil { ...@@ -34,11 +37,13 @@ public class SopXxlJobUtil {
String jobBusId = jobBusId(sop.getInst()); String jobBusId = jobBusId(sop.getInst());
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId); XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
if (job != null && job.getTriggerStatus() == 1) { if (job == null) {
String pause = XxlJobUtil.pause(jobBusId); SopXxlJobUtil.log(log, "【{}】Sop任务不存在:{}", jobBusId, sop.getInst().getInstName());
SopXxlJobUtil.log(log, "【{}】Sop任务停止:{}", jobBusId, pause); } else if (job.getTriggerStatus() != 1) {
SopXxlJobUtil.log(log, "【{}】Sop任务已停止:{}", jobBusId, sop.getInst().getInstName());
} else { } else {
SopXxlJobUtil.log(log, "【{}】Sop任务已停止:{}", jobBusId, job == null ? "null" : job.getTriggerStatus()); String pause = XxlJobUtil.pause(jobBusId);
SopXxlJobUtil.log(log, "【{}】Sop任务停止:{} - {}", jobBusId, pause, sop.getInst().getInstName());
} }
// 遍历node,停止任务 // 遍历node,停止任务
...@@ -163,7 +168,6 @@ public class SopXxlJobUtil { ...@@ -163,7 +168,6 @@ public class SopXxlJobUtil {
String add = XxlJobUtil.add(job); String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】Sop任务节点启动,cron:{},result:{}", jobBusId, job.getScheduleConf(), add); SopXxlJobUtil.log(log, "【{}】Sop任务节点启动,cron:{},result:{}", jobBusId, job.getScheduleConf(), add);
} }
} }
public static void finishSopNodeJob(SopStruct sop, SopInstNode node) { public static void finishSopNodeJob(SopStruct sop, SopInstNode node) {
...@@ -191,6 +195,30 @@ public class SopXxlJobUtil { ...@@ -191,6 +195,30 @@ public class SopXxlJobUtil {
} }
} }
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) { public static String jobBusId(SopInst inst) {
return inst.getInstId(); return inst.getInstId();
} }
......
...@@ -188,7 +188,7 @@ public class XxlJobUtil { ...@@ -188,7 +188,7 @@ public class XxlJobUtil {
} }
public static <T> T doPost(String url, Object json, Class<T> clazz) { 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); log.info("请求url: {}, 请求参数: {} {} : {}", url, GsonTool.toJson(json), XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN, accessToken);
ReturnT<T> returnT = XxlJobRemotingUtil.postBody(url, accessToken, 30, json, clazz); ReturnT<T> returnT = XxlJobRemotingUtil.postBody(url, accessToken, 30, json, clazz);
if (returnT.getCode() != SUCCESS_CODE) { if (returnT.getCode() != SUCCESS_CODE) {
log.info(String.format("【xxl-job】接口调用失败,错误码:%s,原因:%s", returnT.getCode(), returnT.getMsg())); log.info(String.format("【xxl-job】接口调用失败,错误码:%s,原因:%s", returnT.getCode(), returnT.getMsg()));
......
...@@ -34,6 +34,9 @@ public class SopInstExecuteJobHandler { ...@@ -34,6 +34,9 @@ public class SopInstExecuteJobHandler {
SopInstBatch batch = sopService.createBatch(sop.getInst()); SopInstBatch batch = sopService.createBatch(sop.getInst());
sop.setBatch(batch); sop.setBatch(batch);
// 重置节点执行次数
sopService.resetNodeDailyCount(sop);
// 创建所有节点任务 // 创建所有节点任务
SopXxlJobUtil.initSopNodesJob(sop); SopXxlJobUtil.initSopNodesJob(sop);
} }
......
...@@ -35,15 +35,18 @@ public class SopInstLoadJobHandler { ...@@ -35,15 +35,18 @@ public class SopInstLoadJobHandler {
inst.setInstStatus((byte) -1); inst.setInstStatus((byte) -1);
} }
if (inst.getInstStatus() != 1) { if (inst.getInstStatus() == 1) {
// 启动sop任务
SopXxlJobUtil.initSopJob(inst);
} else {
// 停止实例任务以及所有子任务 // 停止实例任务以及所有子任务
SopStruct sop = sopService.loadSop(inst.getInstId()); SopStruct sop = sopService.loadSop(inst.getInstId());
SopXxlJobUtil.pauseSop(sop); SopXxlJobUtil.pauseSop(sop);
continue;
}
// 启动sop任务 }
SopXxlJobUtil.initSopJob(inst);
} }
} }
......
...@@ -25,6 +25,7 @@ import cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory; ...@@ -25,6 +25,7 @@ import cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory;
import cn.com.glsx.process.modules.sop.execute.SopNodeType; import cn.com.glsx.process.modules.sop.execute.SopNodeType;
import cn.com.glsx.process.util.JacksonUtils; import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.lang.Pair; import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -111,18 +112,22 @@ public class SopInstNodeExecuteJobHandler { ...@@ -111,18 +112,22 @@ public class SopInstNodeExecuteJobHandler {
if (node.getNodeSkip() != 1) { if (node.getNodeSkip() != 1) {
// 重新加载sop // 重新加载sop
sop = reloadAndCreateNodeBatch(sop, node); sop = reloadAndCreateNodeBatch(sop, node);
node = sop.getInstNodeMap().get(node.getNodeId());
// 预备执行参数 // 没超执行次数限制
SnapshotStruct snapshotStruct = instance.prepare(sop, node); if (node.getDailyLimit() == 0 || node.getDailyCount() < node.getDailyLimit()) {
// 预备执行参数
SnapshotStruct snapshotStruct = instance.prepare(sop, node);
// 执行sop节点 // 执行sop节点
Object result = instance.execute(sop, node, snapshotStruct); Object result = instance.execute(sop, node, snapshotStruct);
// 处理执行结果 // 处理执行结果
snapshotStruct = instance.handleResult(sop, node, snapshotStruct, result); snapshotStruct = instance.handleResult(sop, node, snapshotStruct, result);
// 保存快照 // 保存快照
updateBatch(sop, node, snapshotStruct); updateBatch(sop, node, snapshotStruct);
}
} }
// 更新后续节点状态 // 更新后续节点状态
...@@ -149,6 +154,7 @@ public class SopInstNodeExecuteJobHandler { ...@@ -149,6 +154,7 @@ public class SopInstNodeExecuteJobHandler {
// 刷新实例快照 // 刷新实例快照
SopInst inst = sop.getInst(); SopInst inst = sop.getInst();
inst.setInstSnapshot(snapshot); inst.setInstSnapshot(snapshot);
node.setDailyCount(ObjectUtil.defaultIfNull(node.getDailyCount(), 0) + 1);
// 刷新实例批次快照 // 刷新实例批次快照
SopInstBatch batch = sop.getBatch(); SopInstBatch batch = sop.getBatch();
...@@ -163,7 +169,7 @@ public class SopInstNodeExecuteJobHandler { ...@@ -163,7 +169,7 @@ public class SopInstNodeExecuteJobHandler {
nodeBatch.setSnapshot(snapshot); nodeBatch.setSnapshot(snapshot);
nodeBatch.setUpdateTime(new Date()); nodeBatch.setUpdateTime(new Date());
} }
sopService.updateNodeBatch(inst, batch, nodeBatch); sopService.updateNodeBatch(inst, node, batch, nodeBatch);
} }
private SopStruct reloadAndCreateNodeBatch(SopStruct sop, SopInstNode node) { private SopStruct reloadAndCreateNodeBatch(SopStruct sop, SopInstNode node) {
......
package cn.com.glsx.process.modules.client;
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 com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @Title: CustomerSopJourneyFeignClient.java
* @Description: 客户sop旅程
* @author caiym
* @date 2023年09月13日 11:12:51
* @version V1.0.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2021
*/
@FeignClient(name = "platform-cdp1", url = "http://192.168.3.122:8616/cdp/sop", contextId = "customerSopJourney", path = "/api/customerSopJourney", decode404 = true)
public interface CustomerSopJourneyFeignClient_T {
@Operation(description = "分页查询客户旅程信息")
@PostMapping("/page")
Result<PageInfo<CustomerSopJourneyDTO>> pageCustomerSopJourney(@RequestBody CustomerSopJourneySearch request);
@Operation(description = "获取客户旅程详情")
@GetMapping("/detail")
Result<CustomerSopJourneyDetailDTO> detail(@RequestParam("orgId") String orgId, @RequestParam("sopJourneyId") String sopJourneyId, @RequestParam("oneId") String oneId);
}
package cn.com.glsx.process.modules.api; package cn.com.glsx.process.modules.controller;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -8,7 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -8,7 +8,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody; 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.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService; import cn.com.glsx.process.modules.service.SopService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -23,7 +25,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -23,7 +25,7 @@ import lombok.extern.slf4j.Slf4j;
@RestController @RestController
@RequestMapping(value = "/sop") @RequestMapping(value = "/sop")
@ResponseResultBody @ResponseResultBody
public class SopApiController { public class SopController {
@Resource @Resource
private SopService sopService; private SopService sopService;
...@@ -35,4 +37,12 @@ public class SopApiController { ...@@ -35,4 +37,12 @@ public class SopApiController {
return sop; 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);
}
} }
package cn.com.glsx.process.modules.controller; package cn.com.glsx.process.modules.controller;
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.BaseController;
import cn.com.glsx.process.modules.entity.SopInst; 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.SopInstDTO;
import cn.com.glsx.process.modules.model.SopInstSearch; import cn.com.glsx.process.modules.model.SopInstSearch;
import cn.com.glsx.process.modules.service.SopInstService; import cn.com.glsx.process.modules.service.SopInstService;
...@@ -39,6 +42,18 @@ public class SopInstController extends BaseController { ...@@ -39,6 +42,18 @@ public class SopInstController extends BaseController {
return sopInstService.selectByGroupId(search); return sopInstService.selectByGroupId(search);
} }
@Operation(summary = "查询模板实例客户分页列表", description = "查询模板实例客户分页列表")
@GetMapping("/customers")
public Result<PageInfo<CustomerSopJourneyDTO>> customers(SopCustomerSearch search) {
return sopInstService.customers(search);
}
@Operation(summary = "查询模板实例客户详细信息", description = "查询模板实例客户详细信息")
@GetMapping("/customers/detail")
public Result<CustomerSopJourneyDetailDTO> customerDetail(SopCustomerSearch search) {
return sopInstService.customerDetail(search);
}
@Operation(summary = "根据id查询SOP门店模板实例详情", description = "根据id查询SOP门店模板实例详情") @Operation(summary = "根据id查询SOP门店模板实例详情", description = "根据id查询SOP门店模板实例详情")
@GetMapping("/{instId}") @GetMapping("/{instId}")
public SopInstDTO findById(@PathVariable("instId") String instId) { public SopInstDTO findById(@PathVariable("instId") String instId) {
......
...@@ -37,11 +37,4 @@ public class SopTplGrantController extends BaseController { ...@@ -37,11 +37,4 @@ public class SopTplGrantController extends BaseController {
return sopTplGrantService.list(search); return sopTplGrantService.list(search);
} }
@Operation(summary = "下发门店", description = "下发门店")
@PostMapping
public String add(@RequestBody @Validated List<SopTplGrant> sopTplGrants) {
sopTplGrantService.add(sopTplGrants);
return "success";
}
} }
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());
log.info("消息id:{},推送数据到mq:{}",correlationId, JSON.toJSONString(content));
rabbitTemplate.convertAndSend(exchange,routingKey, content,correlationId);
}
/**
* topic模式
* 交换机使用本项目默认
*
* @param content
*/
public void topicSend(String routingKey,Object content) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
log.info("消息id:{},推送数据到mq:{}",correlationId, JSON.toJSONString(content));
rabbitTemplate.convertAndSend(RabbitMQConstants.TOPIC_EXCHANGE_PLATFORM_PROCESS,routingKey, content,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.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();
}
}
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";
}
package cn.com.glsx.process.modules.service; 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.process.modules.client.CustomerSopJourneyFeignClient_T;
import cn.com.glsx.process.modules.converter.SopInstConverter; import cn.com.glsx.process.modules.converter.SopInstConverter;
import cn.com.glsx.process.modules.converter.SopTplConverter; import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.converter.SopTplLinKConverter; import cn.com.glsx.process.modules.converter.SopTplLinKConverter;
import cn.com.glsx.process.modules.converter.SopTplNodeConverter; import cn.com.glsx.process.modules.converter.SopTplNodeConverter;
import cn.com.glsx.process.modules.entity.*; import cn.com.glsx.process.modules.entity.*;
import cn.com.glsx.process.modules.mapper.*; import cn.com.glsx.process.modules.mapper.*;
import cn.com.glsx.process.modules.model.SopCustomerSearch;
import cn.com.glsx.process.modules.model.SopInstDTO; import cn.com.glsx.process.modules.model.SopInstDTO;
import cn.com.glsx.process.modules.model.SopInstSearch; import cn.com.glsx.process.modules.model.SopInstSearch;
import cn.com.glsx.process.modules.model.SopTplDTO; import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.model.enums.SopInstStatusEnum; import cn.com.glsx.process.modules.model.enums.SopInstStatusEnum;
import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
import cn.com.glsx.process.modules.rabbitmq.RabbitMQConstants;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.Result; import com.glsx.plat.core.web.Result;
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.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -48,6 +58,14 @@ public class SopInstService { ...@@ -48,6 +58,14 @@ public class SopInstService {
@Autowired @Autowired
private SopTplGrantMapper sopTplGrantMapper; private SopTplGrantMapper sopTplGrantMapper;
@Autowired
private CustomerSopJourneyFeignClient customerSopJourneyFeignClient;
@Autowired
private CustomerSopJourneyFeignClient_T customerSopJourneyFeignClientT;
@Autowired
private MsgProducer msgProducer;
/** /**
* 根据id查询 * 根据id查询
...@@ -174,6 +192,10 @@ public class SopInstService { ...@@ -174,6 +192,10 @@ public class SopInstService {
} }
sopInstMapper.updateInstParamCustomData(instId, customData); sopInstMapper.updateInstParamCustomData(instId, customData);
//发送字段数据变更通知消息
customData.put("instId", instId);
msgProducer.topicSend(RabbitMQConstants.ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE, customData);
return result; return result;
} }
...@@ -276,6 +298,7 @@ public class SopInstService { ...@@ -276,6 +298,7 @@ public class SopInstService {
Integer grantId = sopTplGrant.getGrantId(); Integer grantId = sopTplGrant.getGrantId();
//克隆模板内容 //克隆模板内容
SopInst sopInst = sopTplConverter.dto2inst(sopTplDTO); SopInst sopInst = sopTplConverter.dto2inst(sopTplDTO);
sopInst.setInstName(String.format("%s-%s", sopTplGrant.getGroupName(), sopTplDTO.getTplName()));
sopInst.setInstId(tplId + grantId); sopInst.setInstId(tplId + grantId);
sopInst.setGrantId(grantId); sopInst.setGrantId(grantId);
sopInst.setCreateTime(date); sopInst.setCreateTime(date);
...@@ -300,6 +323,7 @@ public class SopInstService { ...@@ -300,6 +323,7 @@ public class SopInstService {
sopInstNode.setInstId(instId); sopInstNode.setInstId(instId);
sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL); sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL);
//页面选择是否跳过处理
SopInstNode sopInstNodeTemp = customNodesMap.get(sopInstNode.getNodeId()); SopInstNode sopInstNodeTemp = customNodesMap.get(sopInstNode.getNodeId());
sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp)?sopInstNodeTemp.getNodeSkip():SopInstNode.NODE_SKIP_FALSE); sopInstNode.setNodeSkip(!Objects.isNull(sopInstNodeTemp)?sopInstNodeTemp.getNodeSkip():SopInstNode.NODE_SKIP_FALSE);
sopInstNodes.add(sopInstNode); sopInstNodes.add(sopInstNode);
...@@ -307,4 +331,52 @@ public class SopInstService { ...@@ -307,4 +331,52 @@ public class SopInstService {
sopInstNodeMapper.insertList(sopInstNodes); 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 ResultException.create(SystemMessage.ARGS_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.setSopJourneyEnterTimeBegin(search.getSopJourneyEnterTimeBegin());
request.setSopJourneyEnterTimeEnd(search.getSopJourneyEnterTimeEnd());
return customerSopJourneyFeignClientT.pageCustomerSopJourney(request);
}
/**
* 查询模板实例客户详细信息
*
* @param search
* @return
*/
public Result<CustomerSopJourneyDetailDTO> customerDetail(SopCustomerSearch search) {
return customerSopJourneyFeignClientT.detail(search.getOrgId(), search.getSopJourneyId(), search.getOneId());
}
} }
...@@ -182,7 +182,7 @@ public class SopService { ...@@ -182,7 +182,7 @@ public class SopService {
return curBatch; return curBatch;
} }
public void updateNodeBatch(SopInst sopInst, SopInstBatch batch, SopInstNodeBatch nodeBatch) { public void updateNodeBatch(SopInst sopInst, SopInstNode node, SopInstBatch batch, SopInstNodeBatch nodeBatch) {
if (nodeBatch != null) { if (nodeBatch != null) {
instNodeBatchMapper.updateByPrimaryKey(nodeBatch); instNodeBatchMapper.updateByPrimaryKey(nodeBatch);
} }
...@@ -191,7 +191,12 @@ public class SopService { ...@@ -191,7 +191,12 @@ public class SopService {
instBatchMapper.updateByPrimaryKey(batch); instBatchMapper.updateByPrimaryKey(batch);
} }
instMapper.updateByPrimaryKey(sopInst); instMapper.updateByPrimaryKey(sopInst); // 更新快照
instNodeMapper.updateByPrimaryKey(node); // 更新执行次数
}
public void resetNodeDailyCount(SopStruct sop) {
instNodeMapper.resetInstNodeDailyCount(sop.getInst().getInstId());
} }
} }
...@@ -62,70 +62,4 @@ public class SopTplGrantService { ...@@ -62,70 +62,4 @@ public class SopTplGrantService {
sopTplGrantMapper.del(id); sopTplGrantMapper.del(id);
} }
@Transactional
public void add(List<SopTplGrant> sopTplGrants) {
String tplId = sopTplGrants.get(0).getTplId();
List<String> groupIds = sopTplGrants.stream().map(sopTplGrant -> sopTplGrant.getGroupId()).collect(Collectors.toList());
List<SopTplGrant> grants = sopTplGrantMapper.selectByTplIdAndGroupIds(tplId, groupIds);
if (!CollectionUtils.isEmpty(grants)) {
throw ResultException.create(SystemMessage.ARGS_ERROR.getCode(), String.format("%s已存在该旅程,请确认后重新操作", grants.get(0).getGroupName()));
}
Date date = new Date();
//新增派发门店记录
sopTplGrants.forEach(sopTplGrant -> {
sopTplGrant.setGrantStatus(SopTplGrant.GRANT_STATUS_NORMAL);
sopTplGrant.setCreateTime(date);
sopTplGrant.setUpdateTime(date);
});
sopTplGrantMapper.insertList(sopTplGrants);
SopTpl sopTpl = sopTplMapper.selectByPrimaryKey(tplId);
Assert.state(sopTpl != null, "模板不存在!");
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);
SopTplConverter sopTplConverter = SopTplConverter.INSTANCE;
SopTplLinKConverter sopTplLinKConverter = SopTplLinKConverter.INSTANCE;
SopTplNodeConverter sopTplNodeConverter = SopTplNodeConverter.INSTANCE;
for (SopTplGrant sopTplGrant : sopTplGrants) {
Integer grantId = sopTplGrant.getGrantId();
//克隆模板内容
SopInst sopInst = sopTplConverter.do2inst(sopTpl);
sopInst.setInstId(tplId + grantId);
sopInst.setGrantId(grantId);
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<>();
nodes.forEach(sopTplNode -> {
SopInstNode sopInstNode = sopTplNodeConverter.tpl2inst(sopTplNode);
sopInstNode.setInstId(instId);
sopInstNode.setNodeSkip(SopInstNode.NODE_SKIP_FALSE);
sopInstNode.setNodeStatus(SopInstNode.NODE_STATUS_NORMAL);
sopInstNodes.add(sopInstNode);
});
sopInstNodeMapper.insertList(sopInstNodes);
}
}
} }
package cn.com.glsx.process.modules.sop.java.example; 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.SopInst;
import cn.com.glsx.process.modules.entity.SopInstNode; import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.sop.CustomerInfo; import cn.com.glsx.process.modules.sop.CustomerInfo;
import cn.com.glsx.process.modules.sop.SopExecutorResult; import cn.com.glsx.process.modules.sop.SopExecutorResult;
import cn.com.glsx.process.modules.sop.SopHelper; import cn.com.glsx.process.modules.sop.SopHelper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.util.List;
import java.util.Map;
/** /**
......
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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"> <mapper namespace="cn.com.glsx.process.modules.mapper.SopInstNodeMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInstNode"> <resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopInstNode">
<!-- <!-- WARNING - @mbg.generated -->
WARNING - @mbg.generated <id column="inst_node_id" jdbcType="INTEGER" property="instNodeId" />
--> <result column="inst_id" jdbcType="VARCHAR" property="instId" />
<id column="inst_node_id" jdbcType="INTEGER" property="instNodeId" /> <result column="node_id" jdbcType="INTEGER" property="nodeId" />
<result column="inst_id" jdbcType="VARCHAR" property="instId" /> <result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="node_id" jdbcType="INTEGER" property="nodeId" /> <result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" /> <result column="node_label" jdbcType="VARCHAR" property="nodeLabel" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" /> <result column="node_key" jdbcType="VARCHAR" property="nodeKey" />
<result column="node_label" jdbcType="VARCHAR" property="nodeLabel" /> <result column="node_show" jdbcType="VARCHAR" property="nodeShow" />
<result column="node_key" jdbcType="VARCHAR" property="nodeKey" /> <result column="node_param" jdbcType="VARCHAR" property="nodeParam" />
<result column="node_show" jdbcType="VARCHAR" property="nodeShow" /> <result column="node_content" jdbcType="VARCHAR" property="nodeContent" />
<result column="node_param" jdbcType="VARCHAR" property="nodeParam" /> <result column="node_visible" jdbcType="TINYINT" property="nodeVisible" />
<result column="node_content" jdbcType="VARCHAR" property="nodeContent" /> <result column="node_skip" jdbcType="TINYINT" property="nodeSkip" />
<result column="node_visible" jdbcType="TINYINT" property="nodeVisible" /> <result column="node_cron" jdbcType="VARCHAR" property="nodeCron" />
<result column="node_skip" jdbcType="TINYINT" property="nodeSkip" /> <result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" />
<result column="node_cron" jdbcType="VARCHAR" property="nodeCron" /> <result column="node_status" jdbcType="INTEGER" property="nodeStatus" />
<result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" /> <result column="daily_limit" jdbcType="INTEGER" property="dailyLimit" />
<result column="node_status" jdbcType="INTEGER" property="nodeStatus" /> <result column="daily_count" jdbcType="INTEGER" property="dailyCount" />
</resultMap> </resultMap>
<sql id="Base_Column_List">
<!-- <sql id="Base_Column_List">
WARNING - @mbg.generated <!-- WARNING - @mbg.generated -->
--> inst_node_id, inst_id, node_id, node_name, node_type, node_label, node_key, node_show,
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
node_param, node_content, node_visible, node_skip, node_cron, node_expire_cron, node_status </sql>
</sql>
<select id="findByInstId" resultMap="BaseResultMap" <select id="findByInstId" resultMap="BaseResultMap" parameterType="java.lang.String">
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>
SELECT
node_id, node_name,node_type
FROM sop_inst_node WHERE inst_id=#{instId}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!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"> <mapper namespace="cn.com.glsx.process.modules.mapper.SopTplNodeMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopTplNode"> <resultMap id="BaseResultMap" type="cn.com.glsx.process.modules.entity.SopTplNode">
<!-- <!-- WARNING - @mbg.generated -->
WARNING - @mbg.generated <id column="node_id" jdbcType="INTEGER" property="nodeId" />
--> <result column="tpl_id" jdbcType="VARCHAR" property="tplId" />
<id column="node_id" jdbcType="INTEGER" property="nodeId" /> <result column="node_name" jdbcType="VARCHAR" property="nodeName" />
<result column="tpl_id" jdbcType="VARCHAR" property="tplId" /> <result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="node_name" jdbcType="VARCHAR" property="nodeName" /> <result column="node_label" jdbcType="VARCHAR" property="nodeLabel" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" /> <result column="node_show" jdbcType="VARCHAR" property="nodeShow" />
<result column="node_label" jdbcType="VARCHAR" property="nodeLabel" /> <result column="node_param_def" jdbcType="VARCHAR" property="nodeParamDef" />
<result column="node_show" jdbcType="VARCHAR" property="nodeShow" /> <result column="node_content_def" jdbcType="VARCHAR" property="nodeContentDef" />
<result column="node_param_def" jdbcType="VARCHAR" property="nodeParamDef" /> <result column="node_key" jdbcType="VARCHAR" property="nodeKey" />
<result column="node_content_def" jdbcType="VARCHAR" property="nodeContentDef" /> <result column="node_result_def" jdbcType="VARCHAR" property="nodeResultDef" />
<result column="node_key" jdbcType="VARCHAR" property="nodeKey" /> <result column="node_visible" jdbcType="TINYINT" property="nodeVisible" />
<result column="node_result_def" jdbcType="VARCHAR" property="nodeResultDef" /> <result column="node_cron" jdbcType="VARCHAR" property="nodeCron" />
<result column="node_visible" jdbcType="TINYINT" property="nodeVisible" /> <result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" />
<result column="node_cron" jdbcType="VARCHAR" property="nodeCron" /> <result column="node_skipable" jdbcType="TINYINT" property="nodeSkipable" />
<result column="node_expire_cron" jdbcType="VARCHAR" property="nodeExpireCron" /> <result column="daily_limit" jdbcType="INTEGER" property="dailyLimit" />
<result column="node_skipable" jdbcType="TINYINT" property="nodeSkipable" /> </resultMap>
</resultMap> <sql id="Base_Column_List">
<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,
WARNING - @mbg.generated node_key, node_result_def, node_visible, node_cron, node_expire_cron, node_skipable, daily_limit
--> </sql>
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
</sql>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!