Merge branch '0418_小程序开发' of http://182.92.166.109:3000/zhuangyuanke/PostDischargePatientManage into 0418_小程序开发
This commit is contained in:
commit
990c809a2a
@ -81,11 +81,6 @@ public class ScriptInfoController extends BaseController {
|
||||
return toAjax(scriptInfoService.insertScriptInfo(scriptInfo));
|
||||
}
|
||||
|
||||
@PostMapping("/insertScriptEdgeNode")
|
||||
public AjaxResult insertScriptEdgeNode(@RequestBody ScriptVO scriptVO) {
|
||||
return scriptInfoService.insertScriptEdgeNode(scriptVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改话术信息
|
||||
*/
|
||||
@ -121,4 +116,28 @@ public class ScriptInfoController extends BaseController {
|
||||
}
|
||||
return scriptInfoService.uploadScriptInfo(multipartFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询话术节点
|
||||
*/
|
||||
@GetMapping("/selectScriptEdgeNode")
|
||||
public AjaxResult selectScriptEdgeNode(Long id) {
|
||||
return scriptInfoService.selectScriptEdgeNode(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增话术节点
|
||||
*/
|
||||
@PostMapping("/insertScriptEdgeNode")
|
||||
public AjaxResult insertScriptEdgeNode(@RequestBody ScriptVO scriptVO) {
|
||||
return scriptInfoService.insertScriptEdgeNode(scriptVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改话术节点
|
||||
*/
|
||||
@PostMapping("/updateScriptEdgeNode")
|
||||
public AjaxResult updateScriptEdgeNode(@RequestBody ScriptVO scriptVO) {
|
||||
return scriptInfoService.updateScriptEdgeNode(scriptVO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.manage.mapper.scriptInfo;
|
||||
|
||||
import com.xinelu.manage.domain.scriptInfo.ScriptInfo;
|
||||
import com.xinelu.manage.vo.scriptInfo.ScriptVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -69,4 +70,11 @@ public interface ScriptInfoMapper {
|
||||
* 检查是否存在除当前记录之外的同名记录
|
||||
*/
|
||||
int countByScriptNameExcludingId(@Param("scriptName") String scriptName, @Param("departmentId") Long departmentId, @Param("id") Long id, @Param("commonScriptName") String commonScriptName);
|
||||
|
||||
|
||||
ScriptVO selectScriptEdgeNode(Long id);
|
||||
|
||||
List<Long> selectScriptInfoEdgeIds(Long id);
|
||||
|
||||
List<Long> selectScriptInfoNodeIds(Long id);
|
||||
}
|
||||
|
||||
@ -60,4 +60,6 @@ public interface ScriptInfoEdgeMapper {
|
||||
int deleteScriptInfoEdgeByIds(Long[] ids);
|
||||
|
||||
int insertScriptInfoEdgeList(List<ScriptInfoEdge> scriptInfoEdges);
|
||||
|
||||
int deleteScriptInfoEdgeByScriptInfoIds(Long[] ids);
|
||||
}
|
||||
|
||||
@ -60,5 +60,7 @@ public interface ScriptInfoNodeMapper {
|
||||
*/
|
||||
int deleteScriptInfoNodeByIds(Long[] ids);
|
||||
|
||||
int deleteScriptInfoNodeByScriptInfoIds(Long[] ids);
|
||||
|
||||
int insertScriptInfoNodeList(List<Node> scriptInfoNodes);
|
||||
}
|
||||
|
||||
@ -38,8 +38,6 @@ public interface IScriptInfoService {
|
||||
*/
|
||||
public int insertScriptInfo(ScriptInfo scriptInfo);
|
||||
|
||||
AjaxResult insertScriptEdgeNode(ScriptVO scriptVO);
|
||||
|
||||
/**
|
||||
* 修改话术信息
|
||||
*
|
||||
@ -68,4 +66,16 @@ public interface IScriptInfoService {
|
||||
* 话术图片上传
|
||||
*/
|
||||
AjaxResult uploadScriptInfo(MultipartFile multipartFile) throws Exception;
|
||||
|
||||
AjaxResult selectScriptEdgeNode(Long id);
|
||||
|
||||
/**
|
||||
* 新增话术节点
|
||||
*/
|
||||
AjaxResult insertScriptEdgeNode(ScriptVO scriptVO);
|
||||
|
||||
/**
|
||||
* 新增话术节点
|
||||
*/
|
||||
AjaxResult updateScriptEdgeNode(ScriptVO scriptVO);
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import com.xinelu.manage.service.scriptInfo.IScriptInfoService;
|
||||
import com.xinelu.manage.vo.scriptInfo.Edge;
|
||||
import com.xinelu.manage.vo.scriptInfo.Node;
|
||||
import com.xinelu.manage.vo.scriptInfo.ScriptVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -92,6 +93,81 @@ public class ScriptInfoServiceImpl implements IScriptInfoService {
|
||||
return scriptInfoMapper.insertScriptInfo(scriptInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改话术信息
|
||||
*
|
||||
* @param scriptInfo 话术信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateScriptInfo(ScriptInfo scriptInfo) {
|
||||
// 检查除当前记录之外是否存在同名的话术名称
|
||||
if (scriptInfoMapper.countByScriptNameExcludingId(scriptInfo.getScriptName(), scriptInfo.getDepartmentId(), scriptInfo.getId(), scriptInfo.getCommonScriptName()) > 0) {
|
||||
// 存在同名的通用话术名称,不能进行更新
|
||||
throw new ServiceException("通用话术名称已存在,请使用其他名称。");
|
||||
}
|
||||
// 不存在同名的话术名称或者名称未改变,设置修改人和修改时间
|
||||
scriptInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
scriptInfo.setUpdateTime(LocalDateTime.now());
|
||||
// 进行更新操作
|
||||
return scriptInfoMapper.updateScriptInfo(scriptInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除话术信息
|
||||
*
|
||||
* @param ids 需要删除的话术信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteScriptInfoByIds(Long[] ids) {
|
||||
scriptInfoEdgeMapper.deleteScriptInfoEdgeByScriptInfoIds(ids);
|
||||
scriptInfoNodeMapper.deleteScriptInfoNodeByScriptInfoIds(ids);
|
||||
return scriptInfoMapper.deleteScriptInfoByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除话术信息信息
|
||||
*
|
||||
* @param id 话术信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteScriptInfoById(Long id) {
|
||||
return scriptInfoMapper.deleteScriptInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 话术图片上传
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult uploadScriptInfo(MultipartFile multipartFile) throws Exception {
|
||||
// 获取文件路径
|
||||
String uploadPathUrl = SystemBusinessConfig.getProfile() + systemBusinessConfig.getScriptFileUrl();
|
||||
if (StringUtils.isBlank(uploadPathUrl)) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
// 上传
|
||||
String scriptFilePath = FileUploadUtils.upload(uploadPathUrl, multipartFile, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
if (StringUtils.isBlank(scriptFilePath)) {
|
||||
throw new ServiceException("图片上传失败,请联系管理员!");
|
||||
}
|
||||
// 上传成功,返回话术图片url
|
||||
AjaxResult ajax = AjaxResult.success("上传成功!");
|
||||
ajax.put("imgUrl", scriptFilePath);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult selectScriptEdgeNode(Long id) {
|
||||
return AjaxResult.success(scriptInfoMapper.selectScriptEdgeNode(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增话术节点
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public AjaxResult insertScriptEdgeNode(ScriptVO scriptVO) {
|
||||
@ -100,10 +176,13 @@ public class ScriptInfoServiceImpl implements IScriptInfoService {
|
||||
scriptInfo.setFlowScheme(scriptVO.getFlowScheme());
|
||||
scriptInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
scriptInfo.setUpdateTime(LocalDateTime.now());
|
||||
int i = scriptInfoMapper.updateScriptInfo(scriptInfo);
|
||||
if (i <= 0) {
|
||||
int updateScriptInfo = scriptInfoMapper.updateScriptInfo(scriptInfo);
|
||||
if (updateScriptInfo <= 0) {
|
||||
return AjaxResult.error("新增话术图失败!");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(scriptVO.getNodes()) || CollectionUtils.isEmpty(scriptVO.getEdges())) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
List<Node> scriptInfoNodes = scriptVO.getNodes();
|
||||
List<ScriptInfoEdge> scriptInfoEdges = new ArrayList<>();
|
||||
for (Node node : scriptVO.getNodes()) {
|
||||
@ -138,68 +217,65 @@ public class ScriptInfoServiceImpl implements IScriptInfoService {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改话术信息
|
||||
*
|
||||
* @param scriptInfo 话术信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateScriptInfo(ScriptInfo scriptInfo) {
|
||||
// 检查除当前记录之外是否存在同名的话术名称
|
||||
if (scriptInfoMapper.countByScriptNameExcludingId(scriptInfo.getScriptName(), scriptInfo.getDepartmentId(), scriptInfo.getId(), scriptInfo.getCommonScriptName()) > 0) {
|
||||
// 存在同名的通用话术名称,不能进行更新
|
||||
throw new ServiceException("通用话术名称已存在,请使用其他名称。");
|
||||
}
|
||||
// 不存在同名的话术名称或者名称未改变,设置修改人和修改时间
|
||||
@Override
|
||||
public AjaxResult updateScriptEdgeNode(ScriptVO scriptVO) {
|
||||
List<Long> scriptInfoEdgeIds = scriptInfoMapper.selectScriptInfoEdgeIds(scriptVO.getScriptInfoId());
|
||||
List<Long> scriptInfoNodeIds = scriptInfoMapper.selectScriptInfoNodeIds(scriptVO.getScriptInfoId());
|
||||
ScriptInfo scriptInfo = new ScriptInfo();
|
||||
scriptInfo.setId(scriptVO.getScriptInfoId());
|
||||
scriptInfo.setFlowScheme(scriptVO.getFlowScheme());
|
||||
scriptInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
scriptInfo.setUpdateTime(LocalDateTime.now());
|
||||
// 进行更新操作
|
||||
return scriptInfoMapper.updateScriptInfo(scriptInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除话术信息
|
||||
*
|
||||
* @param ids 需要删除的话术信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteScriptInfoByIds(Long[] ids) {
|
||||
return scriptInfoMapper.deleteScriptInfoByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除话术信息信息
|
||||
*
|
||||
* @param id 话术信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteScriptInfoById(Long id) {
|
||||
return scriptInfoMapper.deleteScriptInfoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 话术图片上传
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult uploadScriptInfo(MultipartFile multipartFile) throws Exception {
|
||||
// 获取文件路径
|
||||
String uploadPathUrl = SystemBusinessConfig.getProfile() + systemBusinessConfig.getScriptFileUrl();
|
||||
if (StringUtils.isBlank(uploadPathUrl)) {
|
||||
int updateScriptInfo = scriptInfoMapper.updateScriptInfo(scriptInfo);
|
||||
if (updateScriptInfo <= 0) {
|
||||
return AjaxResult.error("修改话术图失败!");
|
||||
}
|
||||
List<Node> scriptInfoNodes = scriptVO.getNodes();
|
||||
List<ScriptInfoEdge> scriptInfoEdges = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (Node node : scriptVO.getNodes()) {
|
||||
node.setScriptInfoId(scriptVO.getScriptInfoId());
|
||||
String[] split = node.getLabel().split("\\n");
|
||||
node.setScriptNodeName(StringUtils.isBlank(split[0]) ? "" : split[0]);
|
||||
node.setScriptContent(StringUtils.isBlank(split[1]) ? "" : split[0]);
|
||||
node.setScriptNodeType(node.getType());
|
||||
node.setCreateBy(SecurityUtils.getUsername());
|
||||
node.setCreateTime(LocalDateTime.now());
|
||||
if (CollectionUtils.isNotEmpty(scriptInfoNodeIds) && (i < scriptInfoNodeIds.size()) && Objects.nonNull(scriptInfoNodeIds.get(i))) {
|
||||
node.setId(scriptInfoNodeIds.get(i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
int i1 = scriptInfoNodeMapper.insertScriptInfoNodeList(scriptInfoNodes);
|
||||
if (i1 <= 0) {
|
||||
return AjaxResult.error("修改话术图失败!");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(scriptVO.getNodes()) || CollectionUtils.isEmpty(scriptVO.getEdges())) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
// 上传
|
||||
String scriptFilePath = FileUploadUtils.upload(uploadPathUrl, multipartFile, MimeTypeUtils.IMAGE_EXTENSION);
|
||||
if (StringUtils.isBlank(scriptFilePath)) {
|
||||
throw new ServiceException("图片上传失败,请联系管理员!");
|
||||
int num = 0;
|
||||
for (Edge edge : scriptVO.getEdges()) {
|
||||
ScriptInfoEdge scriptInfoEdge = new ScriptInfoEdge();
|
||||
scriptInfoEdge.setKeywords(edge.getKeyword());
|
||||
Node startNode = scriptInfoNodes.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getCode()) && edge.getSource().equals(item.getCode())).findFirst().orElse(new Node());
|
||||
scriptInfoEdge.setStartNodeId(startNode.getId());
|
||||
scriptInfoEdge.setStartNodeName(startNode.getLabel());
|
||||
Node endNode = scriptInfoNodes.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getCode()) && edge.getTarget().equals(item.getCode())).findFirst().orElse(new Node());
|
||||
scriptInfoEdge.setEndNodeId(endNode.getId());
|
||||
scriptInfoEdge.setEndNodeName(endNode.getLabel());
|
||||
scriptInfoEdge.setScriptInfoId(scriptVO.getScriptInfoId());
|
||||
scriptInfoEdge.setScriptEdgeName(edge.getLabel());
|
||||
scriptInfoEdges.add(scriptInfoEdge);
|
||||
if (CollectionUtils.isNotEmpty(scriptInfoEdgeIds) && (num < scriptInfoEdgeIds.size()) && Objects.nonNull(scriptInfoEdgeIds.get(num))) {
|
||||
scriptInfoEdge.setId(scriptInfoEdgeIds.get(num));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
// 上传成功,返回话术图片url
|
||||
AjaxResult ajax = AjaxResult.success("上传成功!");
|
||||
ajax.put("imgUrl", scriptFilePath);
|
||||
return ajax;
|
||||
int i2 = scriptInfoEdgeMapper.insertScriptInfoEdgeList(scriptInfoEdges);
|
||||
if (i2 <= 0) {
|
||||
return AjaxResult.error("修改话术图失败!");
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,12 +19,19 @@
|
||||
<result property="scriptSort" column="script_sort"/>
|
||||
<result property="scriptRemark" column="script_remark"/>
|
||||
<result property="scriptFilePath" column="script_file_path"/>
|
||||
<result property="flowScheme" column="flow_scheme"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.xinelu.manage.vo.scriptInfo.ScriptVO" id="ScriptVOResult">
|
||||
<result property="scriptInfoId" column="scriptInfoId"/>
|
||||
<result property="flowScheme" column="flow_scheme"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="selectScriptInfoVo">
|
||||
select id,
|
||||
department_id,
|
||||
@ -40,6 +47,7 @@
|
||||
script_sort,
|
||||
script_remark,
|
||||
script_file_path,
|
||||
flow_scheme,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
@ -62,6 +70,7 @@
|
||||
si.script_sort,
|
||||
si.script_remark,
|
||||
si.script_file_path,
|
||||
si.flow_scheme,
|
||||
si.create_by,
|
||||
si.create_time,
|
||||
si.update_by,
|
||||
@ -168,6 +177,8 @@
|
||||
</if>
|
||||
<if test="scriptFilePath != null">script_file_path,
|
||||
</if>
|
||||
<if test="flowScheme != null">flow_scheme,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
@ -204,6 +215,8 @@
|
||||
</if>
|
||||
<if test="scriptFilePath != null">#{scriptFilePath},
|
||||
</if>
|
||||
<if test="flowScheme != null">#{flowScheme},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
@ -253,6 +266,9 @@
|
||||
<if test="scriptFilePath != null">script_file_path=
|
||||
#{scriptFilePath},
|
||||
</if>
|
||||
<if test="flowScheme != null">flow_scheme =
|
||||
#{flowScheme},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
@ -281,4 +297,23 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectScriptEdgeNode" resultType="com.xinelu.manage.vo.scriptInfo.ScriptVO">
|
||||
select id scriptInfoId,
|
||||
flow_scheme
|
||||
from script_info
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectScriptInfoEdgeIds" resultType="java.lang.Long">
|
||||
select id
|
||||
from script_info_edge
|
||||
where script_info_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectScriptInfoNodeIds" resultType="java.lang.Long">
|
||||
select id
|
||||
from script_info_node
|
||||
where script_info_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -195,15 +195,22 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertScriptInfoEdgeList" parameterType="java.util.List">
|
||||
insert into script_info_edge(
|
||||
<delete id="deleteScriptInfoEdgeByScriptInfoIds">
|
||||
delete from script_info_edge where script_info_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertScriptInfoEdgeList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into script_info_edge (
|
||||
script_info_id,
|
||||
script_edge_name,
|
||||
start_node_id,
|
||||
start_node_name,
|
||||
end_node_id,
|
||||
end_node_name,
|
||||
condition,
|
||||
`condition`,
|
||||
keywords,
|
||||
remark,
|
||||
create_by,
|
||||
|
||||
@ -147,6 +147,13 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteScriptInfoNodeByScriptInfoIds">
|
||||
delete from script_info_node where script_info_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertScriptInfoNodeList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into script_info_node(
|
||||
script_info_id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user