Commit e6379388 by zhouhaibao

java配置添加

1 parent 430b30f7
......@@ -88,18 +88,19 @@ public class ControllerDisTasksDemo {
System.out.println("入参" + JSONObject.toJSONString(multiValueMap));
post = SopHelper.post(multiValueMap, Object.class, ConfigUtils.getProperty("scrm.baseurl")+baseurl, method);
System.out.println("返回" + JSONObject.toJSONString(post));
map.put("sendTask",post);
map.put("sendTaskRes",post);
// 新增任务记录
RestTemplate restTemplate = new RestTemplate();
Object o = restTemplate.postForObject(ConfigUtils.getProperty("scrm.sopurl")+taskUrl, sopNodeTaskInfoList, Object.class);
map.put("sendTask",post);
map.put("sendTaskLogRes",o);
} catch (Exception e) {
throw new RuntimeException(e);
e.printStackTrace();
map.put("errMessage",e.getMessage());
}
return (JSONObject) JSONObject.toJSON(post);
}
return null;
map.put("message","未找到匹配客户");
return (JSONObject) JSONObject.toJSON(map);
}
}
\ No newline at end of file
......@@ -42,11 +42,9 @@ public class ControllerGetEntCusDemo {
try {
String merchantId = SopHelper.getValueFromJsonString(instParam,
"merchantId");
String instDefalutName = SopHelper.getValueFromJsonString(instParam, "stages", "stage1",
"value");
multiValueMap.add("merchantId",merchantId);
multiValueMap.add("instId",sopInst.getInstId());
multiValueMap.add("instDefalutName",instDefalutName);
multiValueMap.add("instDefalutName","初始化阶段");
System.out.println("入参" + JSONObject.toJSONString(multiValueMap));
post = SopHelper.post(multiValueMap, Object.class, ConfigUtils.getProperty("scrm.baseurl")+ baseurl, method);
System.out.println("返回" + JSONObject.toJSONString(post));
......
......@@ -30,11 +30,9 @@ public class ControllerGetGrCusDemo {
try {
String merchantId = SopHelper.getValueFromJsonString(instParam,
"merchantId");
String instDefalutName = SopHelper.getValueFromJsonString(instParam, "stages", "stage1",
"value");
multiValueMap.add("merchantId",merchantId);
multiValueMap.add("instId",sopInst.getInstId());
multiValueMap.add("instDefalutName",instDefalutName);
multiValueMap.add("instDefalutName","初始化阶段");
System.out.println("入参" + JSONObject.toJSONString(multiValueMap));
post = SopHelper.post(multiValueMap, Object.class, ConfigUtils.getProperty("scrm.baseurl")+ baseurl, method);
System.out.println("返回" + JSONObject.toJSONString(post));
......
......@@ -13,6 +13,7 @@ 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;
......@@ -35,60 +36,68 @@ public class ControllerSendMessageDemo {
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
Map map = new HashMap();
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();
try {
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)) {
// 获取营销类型 1.短信发送 2.企微群发 3.企微朋友圈
String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType");
if (StringUtils.isNotEmpty(sendType)) {
List<CustomerTouchModel> customerTouchModels = new ArrayList<>();
Map<String, List<CustomerInfo>> collect = customerInfoList.stream()
.collect(Collectors.groupingBy(CustomerInfo::getUserId));
Iterator<Entry<String, List<CustomerInfo>>> iterator = collect.entrySet().iterator();
CustomerTouchModel customerTouchModel = new CustomerTouchModel();
while (iterator.hasNext()) {
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels = new ArrayList<>();
Entry<String, List<CustomerInfo>> next = iterator.next();
String key = next.getKey();
List<CustomerInfo> value = next.getValue();
switch (sendType) {
case "10":
buildMessageParam(customerTouchModel, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setSendType(1);
break;
case "8":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setChatType("single");
customerTouchModel.setSendType(2);
break;
case "9":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setSendType(3);
break;
default:
break;
List<CustomerInfo> customerInfoList = SopHelper.getMeetWithCustomer(sopInstNode, resultData);
// 营销的客户存在
if (CollectionUtils.isNotEmpty(customerInfoList)) {
// 获取营销类型 1.短信发送 2.企微群发 3.企微朋友圈
String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType");
if (StringUtils.isNotEmpty(sendType)) {
List<CustomerTouchModel> customerTouchModels = new ArrayList<>();
Map<String, List<CustomerInfo>> collect = customerInfoList.stream()
.collect(Collectors.groupingBy(CustomerInfo::getUserId));
Iterator<Entry<String, List<CustomerInfo>>> iterator = collect.entrySet().iterator();
CustomerTouchModel customerTouchModel = new CustomerTouchModel();
while (iterator.hasNext()) {
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels = new ArrayList<>();
Entry<String, List<CustomerInfo>> next = iterator.next();
String key = next.getKey();
List<CustomerInfo> value = next.getValue();
switch (sendType) {
case "10":
buildMessageParam(customerTouchModel, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setSendType(1);
break;
case "8":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setChatType("single");
customerTouchModel.setSendType(2);
break;
case "9":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setSendType(3);
break;
default:
break;
}
}
RestTemplate restTemplate = new RestTemplate();
System.out.println("发送消息参数" + JSONObject.toJSONString(customerTouchModel));
post = restTemplate.postForObject(
ConfigUtils.getProperty("sop.baseurl") + sendCustomerUrl,
customerTouchModel, Object.class);
System.out.println("发送消息参数结果" + JSONObject.toJSONString(post));
return (JSONObject) JSONObject.toJSON(collect);
}
RestTemplate restTemplate = new RestTemplate();
System.out.println("发送消息参数" + JSONObject.toJSONString(customerTouchModel));
post = restTemplate.postForObject(ConfigUtils.getProperty("sop.baseurl") + sendCustomerUrl,
customerTouchModel, Object.class);
System.out.println("发送消息参数结果" + JSONObject.toJSONString(post));
return (JSONObject) JSONObject.toJSON(collect);
}
map.put("message","未找到匹配客户");
} catch (Exception e) {
e.printStackTrace();
map.put("errMessage", e.getMessage());
}
return null;
return (JSONObject) JSONObject.toJSON(map);
}
/**
......@@ -106,7 +115,7 @@ public class ControllerSendMessageDemo {
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,
sopTaskExecuteStaffModels);
sopTaskExecuteStaffModels, false);
List<String> collect = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
.map(CustomerInfo::getExternalUserId).collect(
......@@ -120,21 +129,24 @@ public class ControllerSendMessageDemo {
private static void buildDefaultParam(CustomerTouchModel customerTouchModel, SopInst sopInst,
SopInstNode sopInstNode, String nodeParam,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels, boolean flag) {
String taskParam = SopHelper.getListValueFromJsonString(nodeParam, "taskParam");
String contentlists = SopHelper.getListValueFromJsonString(taskParam, "attachments");
customerTouchModel.setInstId(sopInst.getInstId());
customerTouchModel.setNodeId(sopInstNode.getNodeId());
String supMerchantNo = SopHelper.getValueFromJsonString(sopInst.getInstParam(),"customData", "supMerchantNo");
String supMerchantNo = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "customData",
"supMerchantNo");
String merchantId = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "merchantId");
String merchantName = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "merchantName");
customerTouchModel.setMerchantId(Integer.parseInt(merchantId));
setConverContentList(contentlists, customerTouchModel, sopInst.getInstId(),
sopInstNode.getNodeId(), merchantId);
sopInstNode.getNodeId(), merchantId, merchantName, flag);
customerTouchModel.setSupMerchantNo(Integer.parseInt(supMerchantNo));
}
private static void setConverContentList(String contentlists,
CustomerTouchModel customerTouchModel, String instId, Integer nodeId, String merchantId) {
CustomerTouchModel customerTouchModel, String instId, Integer nodeId, String merchantId,
String merchantName, boolean flag) {
List<CustomerTouchSourceModel> customerTouchSourceModels = JSONObject.parseArray(contentlists,
CustomerTouchSourceModel.class);
if (CollectionUtils.isNotEmpty(customerTouchSourceModels)) {
......@@ -146,6 +158,15 @@ public class ControllerSendMessageDemo {
.replace("{3}", instId);
customerTouchSourceModel.setAttContent(replace);
}
if (1 == attType.intValue()) {
String attContent = customerTouchSourceModel.getAttContent();
if (flag) {
String replace = "【" + merchantName + "】" + attContent;
customerTouchSourceModel.setAttContent(replace);
} else {
customerTouchSourceModel.setAttContent(attContent);
}
}
}
}
customerTouchModel.setContentList(customerTouchSourceModels);
......@@ -165,7 +186,7 @@ public class ControllerSendMessageDemo {
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,
sopTaskExecuteStaffModels);
sopTaskExecuteStaffModels, true);
List<String> phones = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
.map(CustomerInfo::getCustomerPhone).collect(
......
......@@ -38,73 +38,87 @@ public class ControllerSendRemindDemo {
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
Map map=new HashMap();
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();
SopInstNodeBatch nodeBatch = excustorParam.getNodeBatch();
SopInstBatch batch = excustorParam.getBatch();
String nodeParam = sopInstNode.getNodeParam();
try {
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();
SopInstNodeBatch nodeBatch = excustorParam.getNodeBatch();
SopInstBatch batch = excustorParam.getBatch();
String nodeParam = sopInstNode.getNodeParam();
List<CustomerInfo> customerInfoList = SopHelper.getMeetWithCustomer(sopInstNode, resultData);
// 营销的客户存在
if (CollectionUtils.isNotEmpty(customerInfoList)) {
List<String> filterUserList = null;
// 获取营销类型 发送提醒
String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType");
String taskParam = SopHelper.getListValueFromJsonString(nodeParam, "taskParam");
String userIds = SopHelper.getValueFromJsonString(taskParam, "staffUserIds");
if (StringUtils.isNotEmpty(userIds)) {
filterUserList = Arrays.asList(userIds.split(","));
}
if (StringUtils.isNotEmpty(sendType)) {
Map<String, List<CustomerInfo>> collect = customerInfoList.stream()
.collect(Collectors.groupingBy(CustomerInfo::getUserId));
Iterator<Entry<String, List<CustomerInfo>>> iterator = collect.entrySet().iterator();
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels=new ArrayList<>();
SopTaskToStaffExecuteModel customerTouchModel = new SopTaskToStaffExecuteModel();
while (iterator.hasNext()) {
SopTaskExecuteStaffModel sopTaskExecuteStaffModel=new SopTaskExecuteStaffModel();
Entry<String, List<CustomerInfo>> next = iterator.next();
String key = next.getKey();
List<CustomerInfo> value = next.getValue();
// 过滤条件为空,或者过滤条件存在
if (CollectionUtils.isEmpty(filterUserList) || (CollectionUtils.isNotEmpty(filterUserList)
&& filterUserList.contains(key))) {
List<String> externalUserList = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getExternalUserId()))
.map(CustomerInfo::getExternalUserId).collect(
Collectors.toList());
sopTaskExecuteStaffModel.setSendUserId(key);
sopTaskExecuteStaffModel.setSendExternalUserId(externalUserList);
sopTaskExecuteStaffModels.add(sopTaskExecuteStaffModel);
List<CustomerInfo> customerInfoList = SopHelper.getMeetWithCustomer(sopInstNode, resultData);
// 营销的客户存在
if (CollectionUtils.isNotEmpty(customerInfoList)) {
List<String> filterUserList = null;
// 获取营销类型 发送提醒
String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType");
String taskParam = SopHelper.getListValueFromJsonString(nodeParam, "taskParam");
String userIds = SopHelper.getValueFromJsonString(taskParam, "staffUserIds");
if (StringUtils.isNotEmpty(userIds)) {
filterUserList = Arrays.asList(userIds.split(","));
}
if (StringUtils.isNotEmpty(sendType)) {
Map<String, List<CustomerInfo>> collect = customerInfoList.stream()
.collect(Collectors.groupingBy(CustomerInfo::getUserId));
Iterator<Entry<String, List<CustomerInfo>>> iterator = collect.entrySet().iterator();
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels = new ArrayList<>();
SopTaskToStaffExecuteModel customerTouchModel = new SopTaskToStaffExecuteModel();
while (iterator.hasNext()) {
SopTaskExecuteStaffModel sopTaskExecuteStaffModel = new SopTaskExecuteStaffModel();
Entry<String, List<CustomerInfo>> next = iterator.next();
String key = next.getKey();
List<CustomerInfo> value = next.getValue();
// 过滤条件为空,或者过滤条件存在
if (CollectionUtils.isEmpty(filterUserList) || (
CollectionUtils.isNotEmpty(filterUserList)
&& filterUserList.contains(key))) {
List<String> externalUserList = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getExternalUserId()))
.map(CustomerInfo::getExternalUserId).collect(
Collectors.toList());
sopTaskExecuteStaffModel.setSendUserId(key);
sopTaskExecuteStaffModel.setSendExternalUserId(externalUserList);
sopTaskExecuteStaffModels.add(sopTaskExecuteStaffModel);
}
}
if(CollectionUtils.isNotEmpty(sopTaskExecuteStaffModels)) {
customerTouchModel.setExecuteStaffRequestList(sopTaskExecuteStaffModels);
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,nodeBatch.getNodeBatchNo(),batch.getBatchNo());
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,
nodeBatch.getNodeBatchNo(), batch.getBatchNo());
RestTemplate restTemplate = new RestTemplate();
System.out.println("发送提醒参数" + JSONObject.toJSONString(customerTouchModel));
post = restTemplate.postForObject(ConfigUtils.getProperty("sop.baseurl") + sendStaffUrl,
customerTouchModel, Object.class);
System.out.println("发送提醒参数结果" + JSONObject.toJSONString(customerTouchModel));
return (JSONObject) JSONObject.toJSON(collect);
}
map.put("message","未找到匹配客户");
}
RestTemplate restTemplate = new RestTemplate();
System.out.println("发送提醒参数"+JSONObject.toJSONString(customerTouchModel));
post = restTemplate.postForObject(ConfigUtils.getProperty("sop.baseurl")+sendStaffUrl, customerTouchModel, Object.class);
System.out.println("发送提醒参数结果"+JSONObject.toJSONString(customerTouchModel));
return (JSONObject) JSONObject.toJSON(collect);
}
map.put("message","未找到匹配客户");
} catch (Exception e) {
e.printStackTrace();
map.put("errMessage",e.getMessage());
}
return null;
return (JSONObject) JSONObject.toJSON(map);
}
/**
* 构建发送提醒链接
*
* @param customerTouchModel 客户信息
* @param sopInst 实例
* @param sopInstNode 节点
* @param nodeParam 节点参数
* @param notebatchNo 节点批次号
* @param batchNo 实例批次号
* @param sopInst 实例
* @param sopInstNode 节点
* @param nodeParam 节点参数
* @param notebatchNo 节点批次号
* @param batchNo 实例批次号
*/
private static void buildDefaultParam(SopTaskToStaffExecuteModel customerTouchModel, SopInst sopInst,
private static void buildDefaultParam(SopTaskToStaffExecuteModel customerTouchModel,
SopInst sopInst,
SopInstNode sopInstNode, String nodeParam, String notebatchNo, String batchNo) {
String taskParam = SopHelper.getListValueFromJsonString(nodeParam, "taskParam");
String noticeContent = SopHelper.getValueFromJsonString(taskParam, "content");
......@@ -113,15 +127,20 @@ public class ControllerSendRemindDemo {
int size = sopTaskExecuteStaffModel.getSendExternalUserId().size();
String replace = noticeContent.replace("{客户人数}", size + "");
// 链接追加参数
customerTouchModel.setUrl(ConfigUtils.getProperty("notict.url")+"?notebatchNo="+notebatchNo+"&batchNo="+
batchNo+"&nodeId="+sopInstNode.getNodeId()+"&userId="+sopTaskExecuteStaffModel.getSendUserId()+"&noticeContent="+replace);
customerTouchModel.setUrl(
ConfigUtils.getProperty("notict.url") + "?notebatchNo=" + notebatchNo + "&batchNo=" +
batchNo + "&nodeId=" + sopInstNode.getInstNodeId() + "&userId="
+ sopTaskExecuteStaffModel.getSendUserId() + "&noticeContent=" + replace);
customerTouchModel.setTitle("客户跟进提醒");
customerTouchModel.setDescription("您有"+sopTaskExecuteStaffModel.getSendExternalUserId().size()+"位客户的待跟进,请及时跟进。");
customerTouchModel.setDescription(
"您有" + sopTaskExecuteStaffModel.getSendExternalUserId().size()
+ "位客户的待跟进,请及时跟进。");
String msgtype = SopHelper.getValueFromJsonString(nodeParam, "msgtype");
customerTouchModel.setInstId(sopInst.getInstId());
customerTouchModel.setType("textcard");
customerTouchModel.setNodeId(sopInstNode.getNodeId());
String supMerchantNo = SopHelper.getValueFromJsonString(sopInst.getInstParam(),"customData", "supMerchantNo");
String supMerchantNo = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "customData",
"supMerchantNo");
String merchantId = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "merchantId");
customerTouchModel.setMerchantId(Integer.parseInt(merchantId));
customerTouchModel.setSupMerchantNo(Integer.parseInt(supMerchantNo));
......
......@@ -85,7 +85,7 @@ public class JavaNodeTestApplication {
customerInfo.setCustomerPhone("13476670746");
customerInfo.setFollowStaffPhone("13476670746");
customerInfo.setSopJourneyStage("潜客");
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2024-01-04"));
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2024-01-07"));
resultData.put("user2", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(3);
......@@ -260,6 +260,7 @@ public class JavaNodeTestApplication {
String ControllerSendMessageDemo = JavaFileToString.getString(
"F:\\360MoveData\\Users\\11\\Desktop\\企微SAAS\\2023\\12\\sop\\process\\platform-process-server\\platform-process\\src\\main\\java\\cn\\com\\glsx\\process\\modules\\sop\\java\\example\\ControllerSendMessageDemo.java",
"ControllerSendMessageDemo");
System.out.println(ControllerSendMessageDemo);
SopTplNodeProto sopTplNodeProto=new SopTplNodeProto();
sopTplNodeProto.setId(7);
sopTplNodeProto.setNodeContentDef(ControllerSendMessageDemo);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!