Commit 82c5d19d by 谢海旭

实例开启时,增加前置动作:更新 更新客户阶段的sql

1 parent 3afa027a
...@@ -21,4 +21,6 @@ public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> { ...@@ -21,4 +21,6 @@ public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> {
List<SopTaskDTO> findPageListByInstId(@Param("instId")String instId); List<SopTaskDTO> findPageListByInstId(@Param("instId")String instId);
int updateNodeParamById(@Param("instNodeId") Integer instNodeId, @Param("nodeParam") Map<String, Object> nodeParam); int updateNodeParamById(@Param("instNodeId") Integer instNodeId, @Param("nodeParam") Map<String, Object> nodeParam);
int updateNodeContentById(@Param("instNodeId") Integer instNodeId, @Param("nodeContent") String nodeContent);
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,14 +3,17 @@ package cn.com.glsx.process.modules.assembler; ...@@ -3,14 +3,17 @@ package cn.com.glsx.process.modules.assembler;
import cn.com.glsx.process.common.sysenum.ResultEnum; import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException; import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.modules.converter.SopTplNodeProtoConverter; import cn.com.glsx.process.modules.converter.SopTplNodeProtoConverter;
import cn.com.glsx.process.modules.entity.SopTplLink; import cn.com.glsx.process.modules.entity.*;
import cn.com.glsx.process.modules.entity.SopTplNode; import cn.com.glsx.process.modules.mapper.SopInstNodeMapper;
import cn.com.glsx.process.modules.entity.SopTplNodeProto;
import cn.com.glsx.process.modules.mapper.SopTplNodeProtoMapper; import cn.com.glsx.process.modules.mapper.SopTplNodeProtoMapper;
import cn.com.glsx.process.modules.model.SopInstDTO;
import cn.com.glsx.process.modules.model.SopTplDTO; import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.service.SopDataService;
import cn.com.glsx.process.modules.sop.execute.SopNodeType;
import cn.com.glsx.process.util.CronUtil; import cn.com.glsx.process.util.CronUtil;
import cn.com.glsx.process.util.JacksonUtil; import cn.com.glsx.process.util.JacksonUtil;
import cn.com.glsx.process.util.JacksonUtils; import cn.com.glsx.process.util.JacksonUtils;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -49,6 +52,12 @@ public class KeHuLvChengAssembler { ...@@ -49,6 +52,12 @@ public class KeHuLvChengAssembler {
@Autowired @Autowired
private SopTplNodeProtoMapper sopTplNodeProtoMapper; private SopTplNodeProtoMapper sopTplNodeProtoMapper;
@Autowired
private SopDataService sopDataService;
@Autowired
private SopInstNodeMapper sopInstNodeMapper;
/** /**
* 客户旅程模板组装 * 客户旅程模板组装
* 备注:taskType 1 门店短信 2 门店ai外呼 3 门店助手朋友圈 4 门店助手1v1转发 5 门店客户跟进提醒 6 查询到保 7 企微提醒 8 企微群发 9 企微朋友圈 10 群发短信 * 备注:taskType 1 门店短信 2 门店ai外呼 3 门店助手朋友圈 4 门店助手1v1转发 5 门店客户跟进提醒 6 查询到保 7 企微提醒 8 企微群发 9 企微朋友圈 10 群发短信
...@@ -244,4 +253,42 @@ public class KeHuLvChengAssembler { ...@@ -244,4 +253,42 @@ public class KeHuLvChengAssembler {
sopTplLink.setTargetId(targetTplNode.getNodeId()); sopTplLink.setTargetId(targetTplNode.getNodeId());
tplNodeLinks.add(sopTplLink); tplNodeLinks.add(sopTplLink);
} }
/**
* 开启实例之前的动作
* 根据阶段条件,刷新 更新客户阶段 的sql
*
* @param instDTO
*/
public void doBeforeInstStart(SopInstDTO instDTO) {
String instParam = instDTO.getInstParam();
String stagesStr = JacksonUtil.getStrValueInJsonStrByPath(instParam, "stages");
if (!StringUtils.hasLength(stagesStr)) {
//无阶段 返回
return;
}
Map<String, Object> map = JacksonUtil.readValue(stagesStr, Map.class);
if (CollectionUtils.isEmpty(map)) {
//无阶段 返回
return;
}
List<SopInstNode> nodes = instDTO.getNodes();
SopInstNode endNode = nodes.stream().filter(node -> SopNodeType.END.getBusType().equalsIgnoreCase(node.getNodeType())).findFirst().get();
List<SopInstLink> links = instDTO.getLinks();
SopInstLink lastLink = links.stream().filter(link -> link.getTargetId().equals(endNode.getNodeId())).findFirst().get();
Integer sourceId = lastLink.getSourceId();
SopInstNode updateStageNode = nodes.stream().filter(node -> node.getNodeId().equals(sourceId)).findFirst().get();
// TODO 获取阶段更新的sql
String nodeContent = updateStageNode.getNodeContent();
Map<String, Object> nodeContentMap = JSON.parseObject(nodeContent, Map.class);
String updateSql = nodeContentMap.get("source").toString();
nodeContentMap.put("source", updateSql);
sopInstNodeMapper.updateNodeContentById(updateStageNode.getInstNodeId(), JSON.toJSONString(nodeContentMap));
}
} }
...@@ -10,6 +10,7 @@ import cn.com.glsx.execute.modules.model.task.SopNodeTaskSearch; ...@@ -10,6 +10,7 @@ import cn.com.glsx.execute.modules.model.task.SopNodeTaskSearch;
import cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel; import cn.com.glsx.execute.modules.model.task.SopNodeTaskStaticModel;
import cn.com.glsx.process.common.sysenum.ResultEnum; import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException; import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.modules.assembler.KeHuLvChengAssembler;
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;
...@@ -84,6 +85,9 @@ public class SopInstService { ...@@ -84,6 +85,9 @@ public class SopInstService {
@Autowired @Autowired
private SopInstNodeBatchService sopInstNodeBatchService; private SopInstNodeBatchService sopInstNodeBatchService;
@Autowired
private KeHuLvChengAssembler keHuLvChengAssembler;
/** /**
* 根据id查询 * 根据id查询
* *
...@@ -283,6 +287,11 @@ public class SopInstService { ...@@ -283,6 +287,11 @@ public class SopInstService {
} }
} }
if (status.equals(SopInstStatusEnum.NORMAL.getValue())) {
SopInstDTO instDTO = this.findById(instId);
keHuLvChengAssembler.doBeforeInstStart(instDTO);
}
sopInstMapper.updateInstStatus(instId, status); sopInstMapper.updateInstStatus(instId, status);
return result; return result;
} }
......
...@@ -47,5 +47,8 @@ ...@@ -47,5 +47,8 @@
<update id="updateNodeParamById"> <update id="updateNodeParamById">
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 sop_inst_node set node_param = CAST(#{nodeParam, typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON) where inst_node_id = #{instNodeId}
</update> </update>
<update id="updateNodeContentById">
update sop_inst_node set node_content = CAST(#{nodeContent} AS JSON) where inst_node_id = #{instNodeId}
</update>
</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!