Commit 68f8770e by zhouhaibao

[+]JAVA节点处理

1 parent 260cc9db
Showing 17 changed files with 230 additions and 27 deletions
/*
package cn.com.glsx.process.job.elastic;
import org.springframework.beans.factory.annotation.Value;
......@@ -33,3 +34,4 @@ public class DynamicConfig {
}
*/
/*
package cn.com.glsx.process.job.elastic;
import java.util.List;
......@@ -42,7 +43,8 @@ public class DynamicTaskService {
jobClass.getCanonicalName()));
}
/***
*/
/***
* 动态创建定时任务
*
* @param jobName:定时任务名称
......@@ -50,7 +52,8 @@ public class DynamicTaskService {
* @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();
......@@ -58,12 +61,14 @@ public class DynamicTaskService {
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) {
......@@ -74,11 +79,13 @@ public class DynamicTaskService {
}
}
/**
*/
/**
* 删除定时任务
*
* @param jobName
*/
*//*
public void removeJob(String jobName) {
JobScheduleController schedule = JobRegistry.getInstance().getJobScheduleController(jobName);
if (schedule == null) {
......@@ -89,11 +96,13 @@ public class DynamicTaskService {
}
}
/**
*/
/**
* 停止定时任务
*
* @param jobName
*/
*//*
public void stopJob(String jobName) {
JobScheduleController schedule = JobRegistry.getInstance().getJobScheduleController(jobName);
if (schedule == null) {
......@@ -116,9 +125,11 @@ public class DynamicTaskService {
}
}
/**
* 扫描搜索下线的服务
*/
/**
* 扫描搜索下线的服务
*//*
public void scanAddJob() {
List<JobManager> jobManagers = jobManagerMapper.selectAll();
if (CollectionUtils.isNotEmpty(jobManagers)) {
......@@ -135,3 +146,4 @@ public class DynamicTaskService {
}
}
}
*/
/*
package cn.com.glsx.process.job.elastic;
import com.dangdang.ddframe.job.executor.ShardingContexts;
......@@ -20,3 +21,4 @@ public class ElasticJobListener extends AbstractDistributeOnceElasticJobListener
}
}
*/
/*
package cn.com.glsx.process.job.elastic.impl;
import com.dangdang.ddframe.job.api.ShardingContext;
......@@ -13,3 +14,4 @@ public class DynamicJob implements SimpleJob {
}
}
*/
......@@ -8,6 +8,7 @@ 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.model.task.SopNoticeDetailSearch;
import cn.com.glsx.process.modules.model.task.SopTaskDTO;
import cn.com.glsx.process.modules.model.task.SopTaskSearch;
import cn.com.glsx.process.modules.service.SopInstService;
......@@ -111,4 +112,10 @@ public class SopInstController extends BaseController {
public PageInfo<SopTaskDTO> getTaskList(@RequestParam SopTaskSearch search) {
return sopInstService.getTaskList(search);
}
@Operation(summary = "查询提醒客户", description = "查询提醒客户")
@PostMapping("/getNoticeCustomerList")
public Result<Object> getNoticeCustomerList(@RequestBody SopNoticeDetailSearch sopNoticeDetailSearch) {
return sopInstService.getNoticeCustomerList(sopNoticeDetailSearch);
}
}
package cn.com.glsx.process.modules.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -59,4 +60,14 @@ public class SopInstNodeBatchService {
}
return false;
}
/**
* 查询批次的快照
* @param sopInstNodeBatch 入参
* @return
*/
public List<SopInstNodeBatch> findByCondition(SopInstNodeBatch sopInstNodeBatch) {
return sopInstNodeBatchMapper.selectByExample(
sopInstNodeBatch);
}
}
......@@ -18,6 +18,7 @@ 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.model.task.SopNoticeDetailSearch;
import cn.com.glsx.process.modules.model.task.SopTaskDTO;
import cn.com.glsx.process.modules.model.task.SopTaskSearch;
import cn.com.glsx.process.modules.rabbitmq.MsgProducer;
......@@ -27,6 +28,7 @@ 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.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.enums.SysConstants;
......@@ -79,6 +81,9 @@ public class SopInstService {
@Autowired
private SopInstNodeTaskApiClient sopInstNodeTaskApiClient;
@Autowired
private SopInstNodeBatchService sopInstNodeBatchService;
/**
* 根据id查询
*
......@@ -582,4 +587,37 @@ public class SopInstService {
}
return sopInstNodeList;
}
/**
* 查询提醒客户
*
* @param sopNoticeDetailSearch 查询条件
* @return
*/
public Result<Object> getNoticeCustomerList(SopNoticeDetailSearch sopNoticeDetailSearch) {
Integer nodeId = sopNoticeDetailSearch.getNodeId();
SopInstNode sopInstNode = sopInstNodeMapper.selectByPrimaryKey(nodeId);
if(sopInstNode!=null){
String nodeKey = sopInstNode.getNodeKey();
SopInstNodeBatch sopInstNodeBatch=new SopInstNodeBatch();
sopInstNodeBatch.setBatchNo(sopNoticeDetailSearch.getBatchNo());
sopInstNodeBatch.setNodeBatchNo(sopNoticeDetailSearch.getNotebatchNo());
sopInstNodeBatch.setInstNodeId(nodeId);
List<SopInstNodeBatch> byCondition = sopInstNodeBatchService.findByCondition(
sopInstNodeBatch);
if(!CollectionUtils.isEmpty(byCondition)){
String snapshot = byCondition.get(0).getSnapshot();
String valueFromJsonString = SopHelper.getValueFromJsonString(snapshot, "resultMap",
nodeKey);
if(org.apache.commons.lang3.StringUtils.isNotEmpty(valueFromJsonString)) {
Map map = JSONObject.parseObject(snapshot, Map.class);
Object o = map.get(sopNoticeDetailSearch.getUserId());
return Result.success(o);
}
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "模板node节点快照结果未查到");
}
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "模板node节点快照未查到");
}
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "模板node节点未查到");
}
}
......@@ -5,6 +5,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* 动态参数配置
*
*/
public class ConfigUtils {
private static Properties props = new Properties();
......@@ -12,7 +16,7 @@ public class ConfigUtils {
static {
String environment = System.getenv("ENVIRONMENT"); // 或者 System.getProperty("ENVIRONMENT")
String configFile = String.format(CONFIG_FILE_PATTERN, environment != null ? environment : "default");
String configFile = String.format(CONFIG_FILE_PATTERN, environment != null ? environment : "dev");
try (InputStream input = ConfigUtils.class.getClassLoader().getResourceAsStream(configFile)) {
if (input == null) {
......
package cn.com.glsx.process.modules.sop;
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 lombok.Data;
import java.util.Map;
......@@ -13,10 +15,18 @@ public class SopExecutorResult {
private SopInstNode sopInstNode;
private Map<String, Object> resultData;
public SopExecutorResult(SopInst sopInst, SopInstNode sopInstNode, Map<String, Object> resultData) {
private SopInstBatch batch;
/** 实例节点当前批次 */
private SopInstNodeBatch nodeBatch;
public SopExecutorResult(SopInst sopInst, SopInstNode sopInstNode, Map<String, Object> resultData,
SopInstBatch batch, SopInstNodeBatch nodeBatch) {
this.sopInst = sopInst;
this.sopInstNode = sopInstNode;
this.resultData = resultData;
this.batch = batch;
this.nodeBatch = nodeBatch;
}
public SopExecutorResult() {
......
package cn.com.glsx.process.modules.sop;
import cn.com.glsx.entmicro.model.request.mass.LabelRequest;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.sop.java.model.CustOneIdModel;
import cn.com.glsx.process.modules.sop.java.model.LabelModel;
import cn.com.glsx.scrm.proxy.dto.RopResponse;
......@@ -104,8 +106,10 @@ public class SopHelper {
JSONObject jsonObject = (JSONObject) param;
SopInst sopInst = (SopInst) jsonObject.get("sopInst");
SopInstNode sopInstNode = (SopInstNode) jsonObject.get("sopInstNode");
SopInstBatch sopInstBatch = (SopInstBatch) jsonObject.get("instbatch");
SopInstNodeBatch sopInstNodeBatch = (SopInstNodeBatch) jsonObject.get("nodeBatch");
Map<String, Object> resultData = (Map<String, Object>) jsonObject.get("instSnapshot");
return new SopExecutorResult(sopInst, sopInstNode, resultData);
return new SopExecutorResult(sopInst, sopInstNode, resultData,sopInstBatch,sopInstNodeBatch);
}
/**
......@@ -121,7 +125,7 @@ public class SopHelper {
// 拿到过滤出阶段的客户
List<CustomerInfo> customerInfoList = JSON.parseArray(JSON.toJSONString(resultData.get(key)), CustomerInfo.class);
String diffday = SopHelper.getValueFromJsonString(nodeParam, "day");
String label = SopHelper.getValueFromJsonString(nodeParam, "day");
String label = SopHelper.getValueFromJsonString(nodeParam, "label");
if (org.apache.commons.lang3.StringUtils.isEmpty(diffday)) {
return null;
}
......
......@@ -39,6 +39,10 @@ public class JavaExecutor implements SopNodeExecutor {
jsonObject.put("sopInst", inst);
// 节点信息
jsonObject.put("sopInstNode", node);
// 实例批次信息
jsonObject.put("instbatch", sop.getBatch());
// 节点批次信息
jsonObject.put("nodeBatch", sop.getNodeBatch());
// 实例快照
jsonObject.put("instSnapshot", executeStruct.getResultMap());
......
......@@ -33,7 +33,7 @@ public class ControllerDisTasksDemo {
private final static String method = "scrm.api.sop.marketing.task.customer";
// 下发任务url
private final static String taskUrl = "/api/soptask/add";
private final static String taskUrl = "/execute/api/soptask/add";
public static JSON execute(JSON param) {
Map<String,Object> map=new HashMap<>();
......@@ -41,7 +41,8 @@ public class ControllerDisTasksDemo {
// 将Map中的数据放入MultiValueMap中
Object post = null;
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
SopExecutorResult excustorParam = SopHelper.getExcustorParam(param);
SopExecutorResult excustorParam = SopHelper.
getExcustorParam(param);
Map<String, Object> resultData = excustorParam.getResultData();
SopInst sopInst = excustorParam.getSopInst();
SopInstNode sopInstNode = excustorParam.getSopInstNode();
......
......@@ -28,7 +28,7 @@ import org.springframework.web.client.RestTemplate;
*/
public class ControllerSendMessageDemo {
private final static String sendCustomerUrl = "/sop/api/execute/sendCustomer";
private final static String sendCustomerUrl = "/execute/sop/api/execute/sendCustomer";
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
......
package cn.com.glsx.process.modules.sop.java.example;
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.sop.ConfigUtils;
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 cn.com.glsx.process.modules.sop.java.model.CustomerTouchModel;
import cn.com.glsx.process.modules.sop.java.model.CustomerTouchSourceModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -29,7 +31,7 @@ import org.springframework.web.client.RestTemplate;
*/
public class ControllerSendRemindDemo {
private final static String sendStaffUrl = "/sop/api/execute/sendStaff";
private final static String sendStaffUrl = "/execute/sop/api/execute/sendStaff";
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
......@@ -40,6 +42,8 @@ public class ControllerSendRemindDemo {
Map<String, Object> resultData = excustorParam.getResultData();
SopInst sopInst = excustorParam.getSopInst();
SopInstNode sopInstNode = excustorParam.getSopInstNode();
SopInstNodeBatch nodeBatch = excustorParam.getNodeBatch();
SopInstBatch batch = excustorParam.getBatch();
String nodeParam = sopInstNode.getNodeParam();
List<CustomerInfo> customerInfoList = SopHelper.getMeetWithCustomer(sopInstNode, resultData);
......@@ -65,7 +69,7 @@ public class ControllerSendRemindDemo {
if (CollectionUtils.isEmpty(filterUserList) || (CollectionUtils.isNotEmpty(filterUserList)
&& filterUserList.contains(key))) {
CustomerTouchModel customerTouchModel = new CustomerTouchModel();
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam);
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,nodeBatch.getBatchNo(),batch.getBatchNo());
customerTouchModel.setSendType(Integer.parseInt(sendType));
customerTouchModel.setSendUserId(key);
List<String> externalUserList = value.stream()
......@@ -78,18 +82,36 @@ public class ControllerSendRemindDemo {
}
RestTemplate restTemplate = new RestTemplate();
post = restTemplate.postForObject(ConfigUtils.getProperty("scrm.sopurl")+sendStaffUrl, customerTouchModels, Object.class);
return (JSONObject) JSONObject.toJSON(collect);
}
return (JSONObject) JSONObject.toJSON(post);
}
return null;
}
/**
* 构建发送提醒链接
*
* @param customerTouchModel 客户信息
* @param sopInst 实例
* @param sopInstNode 节点
* @param nodeParam 节点参数
* @param notebatchNo 节点批次号
* @param batchNo 实例批次号
*/
private static void buildDefaultParam(CustomerTouchModel customerTouchModel, SopInst sopInst,
SopInstNode sopInstNode, String nodeParam) {
String notice = SopHelper.getValueFromJsonString(nodeParam, "notice");
SopInstNode sopInstNode, String nodeParam, String notebatchNo, String batchNo) {
String noticeContent = SopHelper.getValueFromJsonString(nodeParam, "noticeContent");
int size = customerTouchModel.getSendExternalUserId().size();
noticeContent.replace("{客户人数}",size+"");
// 链接追加参数
Map map = new HashMap();
map.put("url",ConfigUtils.getProperty("notict.url")+"?notebatchNo="+notebatchNo+"&batchNo="+
batchNo+"&nodeId="+sopInstNode.getNodeId()+"&userId="+customerTouchModel.getSendUserId()+"&noticeContent="+noticeContent);
map.put("title","客户跟进提醒");
map.put("description","您有"+customerTouchModel.getSendExternalUserId().size()+"位客户的待跟进,请及时跟进。");
String msgtype = SopHelper.getValueFromJsonString(nodeParam, "msgtype");
customerTouchModel.setInstId(sopInst.getInstId());
customerTouchModel.setNotice(notice);
customerTouchModel.setNotice(JSONObject.toJSONString(map));
customerTouchModel.setMsgtype(msgtype);
customerTouchModel.setMerchantNo(sopInst.getGrantId());
customerTouchModel.setNodeId(sopInstNode.getNodeId());
......
scrm.baseurl=http://scrm.dev.glsx.com.cn
sop.baseurl=
\ No newline at end of file
sop.baseurl=http://gateway.platform.dev.glsx.com.cn
notict.url=
\ No newline at end of file
scrm.baseurl=http://scrm.test.glsx.com.cn
sop.baseurl=
\ No newline at end of file
sop.baseurl=http://gateway.platform.test.glsx.com.cn
\ No newline at end of file
......@@ -7,7 +7,10 @@ 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.ControllerGetEntCusDemo;
import cn.com.glsx.process.modules.sop.java.example.ControllerScreenPersonDemo;
import cn.com.glsx.process.modules.sop.java.example.ControllerSendMessageDemo;
import cn.com.glsx.process.modules.sop.java.example.ControllerSendRemindDemo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.common.utils.DateUtils;
......@@ -73,7 +76,7 @@ public class JavaNodeTestApplication {
customerInfo.setCustomerPhone("13476670746");
customerInfo.setFollowStaffPhone("13476670746");
customerInfo.setSopJourneyStage("潜客");
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-09-23"));
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-12-26"));
resultData.put("user1", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(3);
......@@ -113,4 +116,84 @@ public class JavaNodeTestApplication {
System.out.println(execute);
}
@Test
public void ControllerGetEntCusDemoJava() {
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.setExternalUserId("13476670746");
customerInfo.setUserId("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 = ControllerGetEntCusDemo.execute(jsonObject);
System.out.println(execute);
}
@Test
public void ControllerSendMessageDemo() {
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.setExternalUserId("");
customerInfo.setUserId("");
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 = ControllerSendMessageDemo.execute(jsonObject);
System.out.println(execute);
}
@Test
public void ControllerSendRemindDemoDemo() {
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.setExternalUserId("");
customerInfo.setUserId("");
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 = ControllerSendRemindDemo.execute(jsonObject);
System.out.println(execute);
}
}
\ 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!