Commit fffe5fdc by zhouhaibao

java配置添加

1 parent 2b2bacf2
...@@ -52,36 +52,57 @@ public class ControllerSendMessageDemo { ...@@ -52,36 +52,57 @@ public class ControllerSendMessageDemo {
// 获取营销类型 10.短信发送 9.企微群发 8.企微朋友圈 // 获取营销类型 10.短信发送 9.企微群发 8.企微朋友圈
String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType"); String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType");
if (StringUtils.isNotEmpty(sendType)) { if (StringUtils.isNotEmpty(sendType)) {
List<CustomerTouchModel> customerTouchModels = new ArrayList<>();
Map<String, List<CustomerInfo>> collect = customerInfoList.stream() Map<String, List<CustomerInfo>> collect = customerInfoList.stream()
.collect(Collectors.groupingBy(CustomerInfo::getUserId)); .collect(Collectors.groupingBy(CustomerInfo::getUserId));
Iterator<Entry<String, List<CustomerInfo>>> iterator = collect.entrySet().iterator(); Iterator<Entry<String, List<CustomerInfo>>> iterator = collect.entrySet().iterator();
CustomerTouchModel customerTouchModel = new CustomerTouchModel(); CustomerTouchModel customerTouchModel = new CustomerTouchModel();
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels = new ArrayList<>();
// 构建基础参数
switch (sendType) {
case "10":
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam, true);
break;
case "8":
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam, false);
customerTouchModel.setChatType("single");
customerTouchModel.setSendType(2);
break;
case "9":
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam, false);
customerTouchModel.setSendType(3);
break;
default:
break;
}
while (iterator.hasNext()) { while (iterator.hasNext()) {
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels = new ArrayList<>(); List<String> phoneList=new ArrayList<>();
Entry<String, List<CustomerInfo>> next = iterator.next(); Entry<String, List<CustomerInfo>> next = iterator.next();
String key = next.getKey(); String key = next.getKey();
List<CustomerInfo> value = next.getValue(); List<CustomerInfo> value = next.getValue();
switch (sendType) { switch (sendType) {
case "10": case "10":
buildMessageParam(customerTouchModel, value, nodeParam, sopInst, sopInstNode, List<String> phones = value.stream()
sopTaskExecuteStaffModels); .filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
customerTouchModel.setSendType(1); .map(CustomerInfo::getCustomerPhone).collect(
Collectors.toList());
phoneList.addAll(phones);
customerTouchModel.setSendPhoneList(phoneList);
break; break;
case "8": case "8":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,
sopTaskExecuteStaffModels);
customerTouchModel.setChatType("single");
customerTouchModel.setSendType(2);
break;
case "9": case "9":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode, List<String> sendExecuteList = value.stream()
sopTaskExecuteStaffModels); .filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
customerTouchModel.setSendType(3); .map(CustomerInfo::getExternalUserId).collect(
Collectors.toList());
SopTaskExecuteStaffModel sopTaskExecuteStaffModel = new SopTaskExecuteStaffModel();
sopTaskExecuteStaffModel.setSendExternalUserId(sendExecuteList);
sopTaskExecuteStaffModel.setSendUserId(key);
sopTaskExecuteStaffModels.add(sopTaskExecuteStaffModel);
break; break;
default: default:
break; break;
} }
customerTouchModel.setExecuteStaffRequestList(sopTaskExecuteStaffModels);
} }
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
System.out.println("发送消息参数" + JSONObject.toJSONString(customerTouchModel)); System.out.println("发送消息参数" + JSONObject.toJSONString(customerTouchModel));
...@@ -100,36 +121,8 @@ public class ControllerSendMessageDemo { ...@@ -100,36 +121,8 @@ public class ControllerSendMessageDemo {
return (JSONObject) JSONObject.toJSON(map); return (JSONObject) JSONObject.toJSON(map);
} }
/**
* 构建短信参数
*
* @param customerTouchModel 参数
* @param key 员工id
* @param value 客户信息
* @param nodeParam 节点入参信息
* @param sopInst 实例信息
* @param sopInstNode 实例节点信息
* @param sopTaskExecuteStaffModels
*/
private static void buildMassParam(CustomerTouchModel customerTouchModel, String key,
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,
sopTaskExecuteStaffModels, false);
List<String> collect = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
.map(CustomerInfo::getExternalUserId).collect(
Collectors.toList());
SopTaskExecuteStaffModel sopTaskExecuteStaffModel = new SopTaskExecuteStaffModel();
sopTaskExecuteStaffModel.setSendExternalUserId(collect);
sopTaskExecuteStaffModel.setSendUserId(key);
sopTaskExecuteStaffModels.add(sopTaskExecuteStaffModel);
customerTouchModel.setExecuteStaffRequestList(sopTaskExecuteStaffModels);
}
private static void buildDefaultParam(CustomerTouchModel customerTouchModel, SopInst sopInst, private static void buildDefaultParam(CustomerTouchModel customerTouchModel, SopInst sopInst,
SopInstNode sopInstNode, String nodeParam, SopInstNode sopInstNode, String nodeParam, boolean flag) {
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels, boolean flag) {
String taskParam = SopHelper.getListValueFromJsonString(nodeParam, "taskParam"); String taskParam = SopHelper.getListValueFromJsonString(nodeParam, "taskParam");
String contentlists = SopHelper.getListValueFromJsonString(taskParam, "attachments"); String contentlists = SopHelper.getListValueFromJsonString(taskParam, "attachments");
customerTouchModel.setInstId(sopInst.getInstId()); customerTouchModel.setInstId(sopInst.getInstId());
...@@ -174,25 +167,4 @@ public class ControllerSendMessageDemo { ...@@ -174,25 +167,4 @@ public class ControllerSendMessageDemo {
customerTouchModel.setContentList(customerTouchSourceModels); customerTouchModel.setContentList(customerTouchSourceModels);
} }
/**
* 构建短信参数
*
* @param customerTouchModel 参数
* @param value
* @param nodeParam 节点入参信息
* @param sopInst 实例信息
* @param sopInstNode 实例节点信息
* @param sopTaskExecuteStaffModels
*/
private static void buildMessageParam(CustomerTouchModel customerTouchModel,
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,
sopTaskExecuteStaffModels, true);
List<String> phones = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
.map(CustomerInfo::getCustomerPhone).collect(
Collectors.toList());
customerTouchModel.setSendPhoneList(phones);
}
} }
\ 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!