Commit c725f3fc by 林永健

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

2 parents 71cf63b2 f776a862
Showing 24 changed files with 341 additions and 150 deletions
......@@ -2,8 +2,12 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SopInstNodeBatchMapper extends CommonBaseMapper<SopInstNodeBatch> {
List<SopInstNodeBatch> findByCondition(@Param("sopInstNodeBatch") SopInstNodeBatch sopInstNodeBatch);
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.model.task.SopTaskDTO;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -17,7 +18,7 @@ public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> {
int resetInstNodeDailyCount(@Param("instId") String instId);
PageInfo<SopTaskDTO> findPageListByInstId(@Param("instId")String instId);
List<SopTaskDTO> findPageListByInstId(@Param("instId")String instId);
int updateNodeParamById(SopInstNode node);
int updateNodeParamById(@Param("instNodeId") Integer instNodeId, @Param("nodeParam") Map<String, Object> nodeParam);
}
\ No newline at end of file
package cn.com.glsx.process.modules.model.task;
import cn.hutool.db.Page;
import java.io.Serializable;
import lombok.Data;
@Data
public class SopTaskSearch extends Page {
public class SopTaskSearch extends Page implements Serializable {
/**
* 实例id
*/
private String instId;
/**
* 实例id
*/
private String instId;
}
......@@ -77,12 +77,12 @@
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>com.github.kuhn-he</groupId>
<artifactId>elastic-job-lite-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
-->
<!-- xxl-job依赖,maven仓库有该依赖,不需要手动安装 -->
<dependency>
<groupId>com.xuxueli</groupId>
......@@ -156,6 +156,11 @@
<groupId>com.glsx</groupId>
<artifactId>rest-admin-office</artifactId>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.2</version>
</dependency>
</dependencies>
<build>
......
......@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
/**
* @Title:
* @Description:
* @Description: 客户旅程 模板节点组装器
* @Author xiehx
* @Date 2023/12/21
**/
......@@ -34,12 +34,21 @@ import java.util.stream.Collectors;
@Component
public class KeHuLvChengAssembler {
/**
* 模板 输入参数定义
*/
private static final String TPL_PARAM_DEF_TPL = "{\"customData\":{\"paramKey\":\"customData\",\"defaultValue\":{},\"required\":true,\"paramDesc\":\"门店相关自定义参数\",\"valueType\":\"Map\"},\"merchantId\":{\"paramKey\":\"merchantId\",\"defaultValue\":\"\",\"required\":true,\"paramDesc\":\"商户号\",\"valueType\":\"String\"},\"stages\":{\"paramKey\":\"stages\",\"defaultValue\":{},\"required\":true,\"paramDesc\":\"阶段集\",\"valueType\":\"Map\"},\"dataTypeCode\":{\"paramKey\":\"dataTypeCode\",\"defaultValue\":\"\",\"required\":true,\"paramDesc\":\"圈人方式标识码\",\"valueType\":\"String\"}}";
/**
* 模板阶段节点 输入参数
*/
private static final String STAGE_TPL_NODE_PARAM_DEF_TPL = "{\"stage\":{\"paramKey\":\"stage\",\"defaultValue\":\"\",\"required\":true,\"paramDesc\":\"stage\",\"valueType\":\"String\"}}";
@Autowired
private SopTplNodeProtoMapper sopTplNodeProtoMapper;
/**
* 客户旅程模板组装
* TODO 需要增加 触发时间转换为cron表达式,保存到对应字段里
* 备注:taskType 1 门店短信 2 门店ai外呼 3 门店助手朋友圈 4 门店助手1v1转发 5 门店客户跟进提醒 6 查询到保 7 企微提醒 8 企微群发 9 企微朋友圈 10 群发短信
*
* @param sopTplDTO
*/
......@@ -52,7 +61,7 @@ public class KeHuLvChengAssembler {
sopTplDTO.setTplRemark("运营端新增模板");
sopTplDTO.setTplStatus((byte) 1);
sopTplDTO.setTplSingleton((byte) 1);
sopTplDTO.setTplParamDef(JacksonUtil.jsonStrDeepSub(getTplParamDef(dataTypeCode), tplParamDef));
sopTplDTO.setTplParamDef(JacksonUtil.jsonStrDeepSub(TPL_PARAM_DEF_TPL, tplParamDef));
List<SopTplNodeProto> tplNodeProtos = sopTplNodeProtoMapper.selectByExample(
Example.builder(SopTplNodeProto.class).where(Sqls.custom().andEqualTo("dataTypeCode", dataTypeCode).orIsNull("dataTypeCode")).build());
......@@ -94,8 +103,6 @@ public class KeHuLvChengAssembler {
//阶段与其排序后的序号的对应关系
Map<String, Integer> stageOrderMap = new HashMap<>();
//创建阶段对应的节点
String stageNodeParamDefModel = "{\"stage\":{\"paramKey\":\"stage\",\"defaultValue\":\"\",\"required\":true,\"paramDesc\":\"stage\",\"valueType\":\"String\"}}";
List<String> stageSortedKeys = new ArrayList<>(stages.keySet());
Collections.sort(stageSortedKeys);
......@@ -107,7 +114,7 @@ public class KeHuLvChengAssembler {
SopTplNode stageNode = protoConverter.proto2tpl(stageProto);
stageNode.setNodeId(tplNodeLastNum++);
stageNode.setNodeParamDef(JacksonUtil.jsonStrDeepSub(stageNodeParamDefModel, String.format("{\"stage\":{\"defaultValue\":\"%s\"}}", stageValue)));
stageNode.setNodeParamDef(JacksonUtil.jsonStrDeepSub(STAGE_TPL_NODE_PARAM_DEF_TPL, String.format("{\"stage\":{\"defaultValue\":\"%s\"}}", stageValue)));
stageNode.setNodeKey(String.format("%s%d", stageProto.getNodeKey(), stageOrder));
tplNodes.add(stageNode);
......@@ -186,20 +193,6 @@ public class KeHuLvChengAssembler {
}
/**
* 根据圈人方式获取预定义初始化参数 tplParamDef
*
* @param dataTypeCode
* @return
*/
private String getTplParamDef(String dataTypeCode) {
if ("xbpzj".equals(dataTypeCode)) {
return "{\"customData\":{\"paramKey\":\"customData\",\"defaultValue\":{\"textMessage\":null,\"activityName\":null,\"activityId\":null,\"activityUrl\":null,\"aiSpeech\":null},\"required\":true,\"paramDesc\":\"customData\",\"valueType\":\"Map\"},\"merchantId\":{\"paramKey\":\"merchantId\",\"defaultValue\":\"\",\"required\":true,\"paramDesc\":\"merchantId\",\"valueType\":\"String\"},\"stages\":{\"paramKey\":\"stages\",\"defaultValue\":{},\"required\":true,\"paramDesc\":\"stages\",\"valueType\":\"Map\"},\"dataTypeCode\":{\"paramKey\":\"dataTypeCode\",\"defaultValue\":\"圈人方式标识码\",\"required\":true,\"paramDesc\":\"dataTypeCode\",\"valueType\":\"String\"}}";
} else {
return "{\"merchantId\":{\"paramKey\":\"merchantId\",\"defaultValue\":\"\",\"required\":true,\"paramDesc\":\"merchantId\",\"valueType\":\"String\"},\"stages\":{\"paramKey\":\"stages\",\"defaultValue\":{},\"required\":true,\"paramDesc\":\"stages\",\"valueType\":\"Map\"},\"dataTypeCode\":{\"paramKey\":\"dataTypeCode\",\"defaultValue\":\"圈人方式标识码\",\"required\":true,\"paramDesc\":\"dataTypeCode\",\"valueType\":\"String\"}}";
}
}
/**
* 获取指定 节点原型组 第一个 节点原型
*
* @param tplNodeProtos
......
......@@ -82,7 +82,7 @@ public class SopInstController extends BaseController {
return instDTO;
}
@Operation(summary = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)", description = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)")
@Operation(summary = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动等)", description = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动等)")
@PostMapping("/{instId}/instParam/customData")
public Result<String> updateInstParamCustomData(@PathVariable("instId") String instId, @RequestBody Map<String, Object> customData) {
return sopInstService.updateInstParamCustomData(instId, customData);
......@@ -108,8 +108,8 @@ public class SopInstController extends BaseController {
}
@Operation(summary = "查询任务详情", description = "查询任务详情")
@GetMapping("/getTaskList")
public PageInfo<SopTaskDTO> getTaskList(@RequestParam SopTaskSearch search) {
@PostMapping("/getTaskList")
public PageInfo<SopTaskDTO> getTaskList(@RequestBody SopTaskSearch search) {
return sopInstService.getTaskList(search);
}
......
package cn.com.glsx.process.modules.controller;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.service.SopInstNodeService;
......@@ -7,12 +9,11 @@ import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
@Slf4j
@Tag(name = "SOP门店模板实例节点开放接口")
......@@ -25,10 +26,15 @@ public class SopInstNodeController extends BaseController {
private SopInstNodeService sopInstNodeService;
@Operation(summary = "更新SOP模板实例节点输入参数", description = "更新SOP模板实例节点输入参数")
@PostMapping("/updateParam")
public String updateNodeParam(@RequestBody SopInstNode node) {
log.info("更新节点输入参数 入参:instNodeId {} nodeParam {}", node.getInstNodeId(), node.getNodeParam());
sopInstNodeService.updateNodeParam(node);
@PostMapping("/{instNodeId}/updateParam")
public String updateNodeParam(@PathVariable Integer instNodeId, @RequestBody Map<String, Object> nodeParam) {
log.info("更新节点输入参数 入参:instNodeId {} nodeParam {}", instNodeId, nodeParam);
if (CollectionUtils.isEmpty(nodeParam)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "参数nodeParam不能为空!");
}
sopInstNodeService.updateNodeParam(instNodeId, nodeParam);
return "success";
}
......
......@@ -67,7 +67,7 @@ public class SopInstNodeBatchService {
* @return
*/
public List<SopInstNodeBatch> findByCondition(SopInstNodeBatch sopInstNodeBatch) {
return sopInstNodeBatchMapper.selectByExample(
return sopInstNodeBatchMapper.findByCondition(
sopInstNodeBatch);
}
}
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.Map;
@Service
public class SopInstNodeService {
......@@ -18,12 +18,13 @@ public class SopInstNodeService {
private SopInstNodeMapper sopInstNodeMapper;
@Transactional
public void updateNodeParam(SopInstNode node) {
if (Objects.isNull(node.getInstNodeId())) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "实例节点id必传!");
public void updateNodeParam(Integer instNodeId, Map<String, Object> nodeParam) {
boolean exists = sopInstNodeMapper.existsWithPrimaryKey(instNodeId);
if (!exists) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "实例节点不存在!");
}
sopInstNodeMapper.updateNodeParamById(node);
sopInstNodeMapper.updateNodeParamById(instNodeId, nodeParam);
}
/**
......
......@@ -554,15 +554,16 @@ public class SopInstService {
public PageInfo<SopTaskDTO> getTaskList(SopTaskSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
PageInfo<SopTaskDTO> sopInstNodeList=sopInstNodeMapper.findPageListByInstId(search.getInstId());
List<SopTaskDTO> sopTaskDTOList = sopInstNodeList.getList();
List<SopTaskDTO> sopTaskDTOList=sopInstNodeMapper.findPageListByInstId(search.getInstId());
if(org.apache.commons.collections.CollectionUtils.isNotEmpty(sopTaskDTOList)){
List<Integer> collect = sopTaskDTOList.stream().map(SopTaskDTO::getNodeId)
.collect(Collectors.toList());
SopNodeTaskSearch sopNodeTaskSearch=new SopNodeTaskSearch();
sopNodeTaskSearch.setInstId(search.getInstId());
sopNodeTaskSearch.setNodeIds(collect);
List<SopNodeTaskStaticModel> list = sopInstNodeTaskApiClient.findList(sopNodeTaskSearch);
Result<List<SopNodeTaskStaticModel>> sopInstNodeTaskApiClientList = sopInstNodeTaskApiClient.findList(
sopNodeTaskSearch);
List<SopNodeTaskStaticModel> list = sopInstNodeTaskApiClientList.getData();
sopTaskDTOList.forEach(index->{
String nodeParam = index.getNodeParam();
String day = SopHelper.getValueFromJsonString(nodeParam, "day");
......@@ -572,7 +573,7 @@ public class SopInstService {
index.setTaskType(Integer.parseInt(taskType));
if(org.apache.commons.collections.CollectionUtils.isNotEmpty(list)){
List<SopNodeTaskStaticModel> sopNodeTaskStaticModelList = list.stream()
.filter(ind -> ind.getNodeId().equals(index.getInstId())).collect(
.filter(ind -> ind.getNodeId().equals(index.getNodeId())).collect(
Collectors.toList());
if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(sopNodeTaskStaticModelList)){
SopNodeTaskStaticModel sopNodeTaskStaticModel = sopNodeTaskStaticModelList.get(
......@@ -585,7 +586,7 @@ public class SopInstService {
}
});
}
return sopInstNodeList;
return new PageInfo<>(sopTaskDTOList);
}
/**
......@@ -607,10 +608,10 @@ public class SopInstService {
sopInstNodeBatch);
if(!CollectionUtils.isEmpty(byCondition)){
String snapshot = byCondition.get(0).getSnapshot();
String valueFromJsonString = SopHelper.getValueFromJsonString(snapshot, "resultMap",
String valueFromJsonString = SopHelper.getValueListFromJsonString(snapshot, "resultMap",
nodeKey);
if(org.apache.commons.lang3.StringUtils.isNotEmpty(valueFromJsonString)) {
Map map = JSONObject.parseObject(snapshot, Map.class);
Map map = JSONObject.parseObject(valueFromJsonString, Map.class);
Object o = map.get(sopNoticeDetailSearch.getUserId());
return Result.success(o);
}
......
......@@ -91,4 +91,6 @@ public class CustomerInfo {
* scrm的oneid
*/
private String scrmOneId;
private String carNumber;
}
......@@ -246,6 +246,18 @@ public class SopHelper {
}
return null;
}
public static String getValueListFromJsonString(String jsonString, String objectName, String fieldName) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonString);
JsonNode objectNode = rootNode.get(objectName);
JsonNode fieldNode = objectNode.get(fieldName);
return objectMapper.writeValueAsString(fieldNode);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String getValueFromJsonString(String jsonString, String objectName, String objectNameTwo, String fieldName) {
try {
......@@ -276,6 +288,21 @@ public class SopHelper {
}
return null;
}
public static String getListValueFromJsonString(String jsonString, String fieldName) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonString);
JsonNode fieldNode = rootNode.get(fieldName);
if (fieldNode != null) {
return objectMapper.writeValueAsString(fieldNode);
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static <T> T post(MultiValueMap<String, String> paramsMap, Class<T> responseType, String baseurl, String method) throws Exception {
addBaseParam(paramsMap, method);
......
package cn.com.glsx.process.modules.sop.java.example;
import cn.com.glsx.process.modules.entity.SopInst;
import cn.com.glsx.process.modules.sop.ConfigUtils;
import cn.com.glsx.process.modules.sop.SopExecutorResult;
import cn.com.glsx.process.modules.sop.SopHelper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* java执行器使用demo,rop请求,类名Controller,方法名execute 获取门店的国任客户
*/
public class ControllerGetGrCusDemo {
private final static String baseurl = "/rop-scrm-shopmall/router";
private final static String method = "scrm.api.shopmall.integral.import.record.sendGRCustomerToSop";
public static JSON execute(JSON param) {
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
Object post = null;
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
SopExecutorResult excustorParam = SopHelper.getExcustorParam(param);
SopInst sopInst = excustorParam.getSopInst();
String instParam = sopInst.getInstParam();
try {
String instDefalutName = SopHelper.getValueFromJsonString(instParam, "stages", "stage1",
"value");
multiValueMap.add("merchantId",sopInst.getGrantId()+"");
multiValueMap.add("instId",sopInst.getInstId());
multiValueMap.add("instDefalutName",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));
} catch (Exception e) {
throw new RuntimeException(e);
}
return (JSONObject) JSONObject.toJSON(post);
}
}
\ No newline at end of file
......@@ -8,9 +8,11 @@ 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 cn.com.glsx.process.modules.sop.java.model.SopTaskExecuteStaffModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -45,95 +47,103 @@ public class ControllerSendMessageDemo {
// 营销的客户存在
if (CollectionUtils.isNotEmpty(customerInfoList)) {
// 获取营销类型 1.短信发送 2.企微群发 3.企微朋友圈
String sendType = SopHelper.getValueFromJsonString(nodeParam, "sendType");
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()) {
CustomerTouchModel customerTouchModel = new CustomerTouchModel();
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels=new ArrayList<>();
customerTouchModel.setSendType(Integer.parseInt(sendType));
Entry<String, List<CustomerInfo>> next = iterator.next();
String key = next.getKey();
List<CustomerInfo> value = next.getValue();
switch (sendType) {
case "1":
buildMessageParam(customerTouchModel, value, nodeParam, sopInst, sopInstNode);
buildMessageParam(customerTouchModel, value, nodeParam, sopInst, sopInstNode,sopTaskExecuteStaffModels);
break;
case "2":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,sopTaskExecuteStaffModels);
customerTouchModel.setChatType("single");
break;
case "3":
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode);
buildMassParam(customerTouchModel, key, value, nodeParam, sopInst, sopInstNode,sopTaskExecuteStaffModels);
break;
default:
break;
}
customerTouchModels.add(customerTouchModel);
}
RestTemplate restTemplate = new RestTemplate();
post = restTemplate.postForObject(ConfigUtils.getProperty("scrm.sopurl")+sendCustomerUrl, customerTouchModels, Object.class);
System.out.println("发送消息参数"+JSONObject.toJSONString(customerTouchModel));
post = restTemplate.postForObject(ConfigUtils.getProperty("sop.baseurl") + sendCustomerUrl,
customerTouchModel, Object.class);
}
return (JSONObject) JSONObject.toJSON(post);
}
return null;
}
private static void buildMonmentParam(CustomerTouchModel customerTouchModel, String key,
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode) {
}
/**
* 构建短信参数
*
* @param customerTouchModel 参数
* @param key 员工id
* @param value 客户信息
* @param nodeParam 节点入参信息
* @param sopInst 实例信息
* @param sopInstNode 实例节点信息
* @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) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam);
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,
sopTaskExecuteStaffModels);
List<String> collect = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
.map(CustomerInfo::getExternalUserId).collect(
Collectors.toList());
customerTouchModel.setSendExternalUserId(collect);
customerTouchModel.setSendUserId(key);
SopTaskExecuteStaffModel sopTaskExecuteStaffModel=new SopTaskExecuteStaffModel();
sopTaskExecuteStaffModel.setSendExternalUserId(collect);
sopTaskExecuteStaffModel.setSendUserId(key);
sopTaskExecuteStaffModels.add(sopTaskExecuteStaffModel);
customerTouchModel.setExecuteStaffRequestList(sopTaskExecuteStaffModels);
}
private static void buildDefaultParam(CustomerTouchModel customerTouchModel, SopInst sopInst,
SopInstNode sopInstNode, String nodeParam) {
String contentlists = SopHelper.getValueFromJsonString(nodeParam, "contentlists");
SopInstNode sopInstNode, String nodeParam,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
String contentlists = SopHelper.getListValueFromJsonString(nodeParam, "contentlists");
customerTouchModel.setInstId(sopInst.getInstId());
customerTouchModel.setMerchantNo(sopInst.getGrantId());
customerTouchModel.setNodeId(sopInstNode.getNodeId());
customerTouchModel.setContentlists(JSONObject.parseArray(contentlists,
customerTouchModel.setContentList(JSONObject.parseArray(contentlists,
CustomerTouchSourceModel.class));
String valueFromJsonString = SopHelper.getValueFromJsonString(sopInst.getInstSnapshot(),
"initMap", "supMerchantNo");
customerTouchModel.setSupMerchantNo(Integer.parseInt(valueFromJsonString));
String supMerchantNo = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "supMerchantNo");
String merchantId = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "merchantId");
customerTouchModel.setMerchantId(Integer.parseInt(merchantId));
customerTouchModel.setSupMerchantNo(Integer.parseInt(supMerchantNo));
}
/**
* 构建短信参数
*
* @param customerTouchModel 参数
* @param key 员工id
* @param customerTouchModel 参数
* @param value
* @param nodeParam 节点入参信息
* @param sopInst 实例信息
* @param sopInstNode 实例节点信息
* @param nodeParam 节点入参信息
* @param sopInst 实例信息
* @param sopInstNode 实例节点信息
* @param sopTaskExecuteStaffModels
*/
private static void buildMessageParam(CustomerTouchModel customerTouchModel,
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam);
List<CustomerInfo> value, String nodeParam, SopInst sopInst, SopInstNode sopInstNode,
List<SopTaskExecuteStaffModel> sopTaskExecuteStaffModels) {
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,sopTaskExecuteStaffModels);
List<String> phones = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getCustomerPhone()))
.map(CustomerInfo::getCustomerPhone).collect(
Collectors.toList());
customerTouchModel.setSendPhone(phones);
customerTouchModel.setSendPhoneList(phones);
}
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ 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.SopTaskExecuteStaffModel;
import cn.com.glsx.process.modules.sop.java.model.SopTaskToStaffExecuteModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
......@@ -51,7 +53,7 @@ public class ControllerSendRemindDemo {
if (CollectionUtils.isNotEmpty(customerInfoList)) {
List<String> filterUserList = null;
// 获取营销类型 发送提醒
String sendType = SopHelper.getValueFromJsonString(nodeParam, "sendType");
String sendType = SopHelper.getValueFromJsonString(nodeParam, "taskType");
String userIds = SopHelper.getValueFromJsonString(nodeParam, "userIds");
if (StringUtils.isNotEmpty(userIds)) {
filterUserList = Arrays.asList(userIds.split(","));
......@@ -61,27 +63,30 @@ public class ControllerSendRemindDemo {
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))) {
CustomerTouchModel customerTouchModel = new CustomerTouchModel();
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,nodeBatch.getBatchNo(),batch.getBatchNo());
customerTouchModel.setSendType(Integer.parseInt(sendType));
customerTouchModel.setSendUserId(key);
List<String> externalUserList = value.stream()
.filter(index -> StringUtils.isNotEmpty(index.getExternalUserId()))
.map(CustomerInfo::getExternalUserId).collect(
Collectors.toList());
customerTouchModel.setSendExternalUserId(externalUserList);
customerTouchModels.add(customerTouchModel);
sopTaskExecuteStaffModel.setSendUserId(key);
sopTaskExecuteStaffModel.setSendExternalUserId(externalUserList);
sopTaskExecuteStaffModels.add(sopTaskExecuteStaffModel);
customerTouchModel.setExecuteStaffRequestList(sopTaskExecuteStaffModels);
buildDefaultParam(customerTouchModel, sopInst, sopInstNode, nodeParam,nodeBatch.getNodeBatchNo(),batch.getBatchNo());
}
}
RestTemplate restTemplate = new RestTemplate();
post = restTemplate.postForObject(ConfigUtils.getProperty("scrm.sopurl")+sendStaffUrl, customerTouchModels, Object.class);
System.out.println("发送提醒参数"+JSONObject.toJSONString(customerTouchModel));
post = restTemplate.postForObject(ConfigUtils.getProperty("sop.baseurl")+sendStaffUrl, customerTouchModel, Object.class);
return (JSONObject) JSONObject.toJSON(collect);
}
}
......@@ -98,26 +103,26 @@ public class ControllerSendRemindDemo {
* @param notebatchNo 节点批次号
* @param batchNo 实例批次号
*/
private static void buildDefaultParam(CustomerTouchModel customerTouchModel, SopInst sopInst,
private static void buildDefaultParam(SopTaskToStaffExecuteModel customerTouchModel, SopInst sopInst,
SopInstNode sopInstNode, String nodeParam, String notebatchNo, String batchNo) {
String noticeContent = SopHelper.getValueFromJsonString(nodeParam, "noticeContent");
int size = customerTouchModel.getSendExternalUserId().size();
SopTaskExecuteStaffModel sopTaskExecuteStaffModel = customerTouchModel.getExecuteStaffRequestList()
.get(0);
int size = sopTaskExecuteStaffModel.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()+"位客户的待跟进,请及时跟进。");
customerTouchModel.setUrl(ConfigUtils.getProperty("notict.url")+"?notebatchNo="+notebatchNo+"&batchNo="+
batchNo+"&nodeId="+sopInstNode.getNodeId()+"&userId="+sopTaskExecuteStaffModel.getSendUserId()+"&noticeContent="+noticeContent);
customerTouchModel.setTitle("客户跟进提醒");
customerTouchModel.setDescription("您有"+sopTaskExecuteStaffModel.getSendExternalUserId().size()+"位客户的待跟进,请及时跟进。");
String msgtype = SopHelper.getValueFromJsonString(nodeParam, "msgtype");
customerTouchModel.setInstId(sopInst.getInstId());
customerTouchModel.setNotice(JSONObject.toJSONString(map));
customerTouchModel.setMsgtype(msgtype);
customerTouchModel.setMerchantNo(sopInst.getGrantId());
customerTouchModel.setType("textcard");
customerTouchModel.setNodeId(sopInstNode.getNodeId());
String valueFromJsonString = SopHelper.getValueFromJsonString(sopInst.getInstSnapshot(),
"initMap", "supMerchantNo");
customerTouchModel.setSupMerchantNo(Integer.parseInt(valueFromJsonString));
String supMerchantNo = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "supMerchantNo");
String merchantId = SopHelper.getValueFromJsonString(sopInst.getInstParam(), "merchantId");
customerTouchModel.setMerchantId(Integer.parseInt(merchantId));
customerTouchModel.setSupMerchantNo(Integer.parseInt(supMerchantNo));
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ public class JavaFileToString {
public static void main(String[] args) {
StringBuilder javaCodeBuilder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader("F:\\360MoveData\\Users\\11\\Desktop\\企微SAAS\\2023\\09\\sop\\platform-process-server\\platform-process\\src\\main\\java\\cn\\com\\glsx\\process\\modules\\sop\\java\\example\\ControllerHttpDemo.java"))) {
try (BufferedReader reader = new BufferedReader(new FileReader("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\\ControllerSendRemindDemo.java"))) {
String line;
while (true) {
try {
......
package cn.com.glsx.process.modules.sop.java.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Data;
......@@ -18,22 +20,13 @@ public class CustomerTouchModel {
/**
* 发送手机号
*/
private List<String> sendPhone;
private List<String> sendPhoneList;
/**
* 发送员工
*/
private String sendUserId;
/**
* 发送外部联系人
*/
private List<String> sendExternalUserId;
/**
* 商户号
*/
private Integer merchantNo;
private Integer merchantId;
/**
* 实例id
......@@ -50,19 +43,14 @@ public class CustomerTouchModel {
*/
private Integer supMerchantNo;
@JsonProperty("chatType")
@Schema(name = "chatType", description = "群发任务的类型 sendType为2时候必传,默认为single,表示发送给客户,group表示发送给客户群", allowableValues = {"single", "group"})
private String chatType;
/**
* 素材
*/
private List<CustomerTouchSourceModel> contentlists;
private List<CustomerTouchSourceModel> contentList;
/**
* 通知的素材
*/
private String notice;
/**
* 通知类型
*/
private String msgtype;
private List<SopTaskExecuteStaffModel> executeStaffRequestList;
}
package cn.com.glsx.process.modules.sop.java.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
@Data
public class SopTaskExecuteStaffModel implements Serializable {
private String sendUserId;
private List<String> sendExternalUserId;
}
package cn.com.glsx.process.modules.sop.java.model;
import cn.com.glsx.execute.modules.model.sopTask.SopTaskExecuteStaffRequest;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.Data;
import org.codehaus.jackson.annotate.JsonProperty;
@Data
public class SopTaskToStaffExecuteModel implements Serializable {
@Schema(name = "executeStaffRequestList", description = "发送员工及客户")
private List<SopTaskExecuteStaffModel> executeStaffRequestList;
@JsonProperty("content")
@Schema(name = "content",description = "消息内容")
private String content;
@JsonProperty("description")
@Schema(name = "description",description = "描述")
private String description;
@JsonProperty("merchantId")
@Schema(name = "merchantId",description = "商户号")
private Integer merchantId;
@NotNull
private Integer supMerchantNo;
/**
* 实例id
*/
@NotNull
private String instId;
/**
* 节点id
*/
@NotNull
private Integer nodeId;
@JsonProperty("title")
@Schema(name = "title",description = "内容标题")
private String title;
@JsonProperty("type")
@Schema(name = "type",description = "1:text 2:image 3:voice 4:video 5:file 6:textCard 7:news 8:mpnews 9:markdown 10:miniprogram_notice")
private String type;
@JsonProperty("url")
@Schema(name = "url",description = "点击后跳转的链接")
private String url;
@JsonProperty("mediaId")
@Schema(name = "mediaId",description = "企微mediaId")
private String mediaId;
@JsonProperty("picurl")
@Schema(name = "picurl",description = "图片地址")
private String picurl;
@JsonProperty("btnTxt")
@Schema(name = "btnTxt",description = "按钮文字。 默认为“详情”, 不超过4个文字")
private String btnTxt;
}
......@@ -11,6 +11,7 @@ import lombok.experimental.UtilityClass;
import org.springframework.util.StringUtils;
import java.util.LinkedHashMap;
import java.util.List;
@UtilityClass
public class SopTplParamHandler {
......@@ -52,19 +53,24 @@ public class SopTplParamHandler {
String valueType = childNode.path("valueType").asText();
JsonNode defaultValueNode = childNode.path("defaultValue");
if (defaultValueNode.isNull()) {
continue;
}
switch (valueType) {
case "Number":
int defaultValueInt = defaultValueNode.asInt();
map.put(key, defaultValueInt);
map.put(key, defaultValueNode.asInt());
break;
case "String":
String defaultValueString = defaultValueNode.asText();
map.put(key, defaultValueString);
map.put(key, defaultValueNode.asText());
break;
case "Map":
// 解析Map类型的默认值
LinkedHashMap<String, Object> defaultValueMap = objectMapper.convertValue(defaultValueNode, LinkedHashMap.class);
map.put(key, defaultValueMap);
map.put(key, objectMapper.convertValue(defaultValueNode, LinkedHashMap.class));
break;
case "Array":
case "List":
map.put(key, objectMapper.convertValue(defaultValueNode, List.class));
break;
// 其他数据类型的解析
default:
......
scrm.baseurl=http://scrm.dev.glsx.com.cn
sop.baseurl=http://gateway.platform.dev.glsx.com.cn
notict.url=
\ No newline at end of file
sop.baseurl=http://192.168.3.122:9821
notict.url=http://xxxxxxx
\ No newline at end of file
......@@ -18,4 +18,10 @@
-->
node_batch_no, inst_node_id, batch_no, snapshot, create_time, update_time
</sql>
<select id="findByCondition"
resultMap="BaseResultMap">
SELECT * FROM sop_inst_node_batch WHERE node_batch_no=#{sopInstNodeBatch.nodeBatchNo}
AND inst_node_id=#{sopInstNodeBatch.instNodeId} AND batch_no=#{sopInstNodeBatch.batchNo}
</select>
</mapper>
\ No newline at end of file
......@@ -37,7 +37,7 @@
<select id="findPageListByInstId"
resultType="cn.com.glsx.process.modules.model.task.SopTaskDTO">
select inst_id as instId, node_id as nodeId,node_param as nodeParam from sop_inst_node where inst_id=#{instId} and node_param->'$.taskType' is not null
select inst_id as instId, node_id as nodeId,node_param as nodeParam from sop_inst_node where inst_id=#{instId} and node_param!='' and node_param->'$.taskType' is not null
</select>
<update id="resetInstNodeDailyCount">
......@@ -45,7 +45,7 @@
</update>
<update id="updateNodeParamById">
update sop_inst_node set node_param = CAST(#{nodeParam} AS JSON) where inst_node_id = #{instNodeId}
update sop_inst_node set node_param = CAST(#{nodeParam, typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON) where inst_node_id = #{instNodeId}
</update>
</mapper>
\ No newline at end of file
package cn.com.glsx.test;
import cn.com.glsx.Application;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.com.glsx.process.modules.sop.CustomerInfo;
......@@ -149,16 +151,16 @@ public class JavaNodeTestApplication {
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setOneId("123456");
customerInfo.setCustomerPhone("13476670746");
customerInfo.setOrgId("123456");
customerInfo.setOrgId("44211227");
customerInfo.setVin("ceshi");
customerInfo.setMessageId("1");
customerInfo.setMessageContent("ceshi");
customerInfo.setSopJourneyId("xblc7");
customerInfo.setSopJourneyEnterTime(new Date());
customerInfo.setExternalUserId("wo-ZewEAAAKaTWUHns_kySCyh2EvmfbQ");
customerInfo.setUserId("wo-ZewEAAAKaTWUHns_kySCyh2EvmfbQ");
customerInfo.setExternalUserId("wm-ZewEAAA22dA72qtla54HxDPHBQfcg");
customerInfo.setUserId("wo-ZewEAAA3Ew-zJPQGZHxsU48lRzw-w");
customerInfo.setSopJourneyStage("潜客");
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-09-23"));
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-12-27"));
resultData.put("user1", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(3);
......@@ -176,16 +178,16 @@ public class JavaNodeTestApplication {
CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setOneId("123456");
customerInfo.setCustomerPhone("13476670746");
customerInfo.setOrgId("123456");
customerInfo.setOrgId("44211227");
customerInfo.setVin("ceshi");
customerInfo.setMessageId("1");
customerInfo.setMessageContent("ceshi");
customerInfo.setSopJourneyId("xblc7");
customerInfo.setSopJourneyEnterTime(new Date());
customerInfo.setExternalUserId("");
customerInfo.setUserId("");
customerInfo.setExternalUserId("wm-ZewEAAA22dA72qtla54HxDPHBQfcg");
customerInfo.setUserId("wo-ZewEAAA3Ew-zJPQGZHxsU48lRzw-w");
customerInfo.setSopJourneyStage("潜客");
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-09-23"));
customerInfo.setSopJourneyStageEnterTime(DateUtils.parse("2023-12-27"));
resultData.put("user1", Arrays.asList(customerInfo));
SopStruct sopStruct = sopService.loadSop("xblc7");
SopInstNode sopInstNode = sopStruct.getInstNodeMap().get(3);
......@@ -193,6 +195,12 @@ public class JavaNodeTestApplication {
jsonObject.put("sopInst", sopStruct.getInst());
jsonObject.put("sopInstNode", sopInstNode);
jsonObject.put("instSnapshot", resultData);
SopInstBatch sopInstBatch=new SopInstBatch();
sopInstBatch.setBatchNo("693104751520509952");
SopInstNodeBatch sopInstNodeBatch=new SopInstNodeBatch();
sopInstNodeBatch.setNodeBatchNo("693129900839923712");
jsonObject.put("nodeBatch", sopInstNodeBatch);
jsonObject.put("instbatch", sopInstBatch);
JSON execute = ControllerSendRemindDemo.execute(jsonObject);
System.out.println(execute);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!