From 53fd77af5c90a33f6fcc6d873106134bd3e8067e Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 10 Apr 2023 15:34:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/voice/VoiceDiscriminateConfigDAO.java | 17 +-- .../entity/voice/VoiceDiscriminateConfig.java | 22 +++ .../voice/VoiceDiscriminateConfigExample.java | 140 ++++++++++++++++++ .../VoiceDiscriminateConfigWithBLOBs.java | 28 ---- .../voice/IVoiceDataConfigService.java | 4 +- .../VoiceDataConfigServiceImpl.java | 53 +++++-- .../cbtc/discriminate/ExtractRule.java | 19 ++- .../vo/voice/VoiceDiscriminateConfigVO.java | 10 +- .../joylink/rtss/vo/voice/VoiceQueryVO.java | 6 + .../voice/VoiceDiscriminateConfigDAO.xml | 99 +++++++------ .../services/voice/VoiceConfigDataTest.java | 91 ++++++++++++ 11 files changed, 381 insertions(+), 108 deletions(-) delete mode 100644 src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigWithBLOBs.java create mode 100644 src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java diff --git a/src/main/java/club/joylink/rtss/dao/voice/VoiceDiscriminateConfigDAO.java b/src/main/java/club/joylink/rtss/dao/voice/VoiceDiscriminateConfigDAO.java index 0f55dfa91..8579199b7 100644 --- a/src/main/java/club/joylink/rtss/dao/voice/VoiceDiscriminateConfigDAO.java +++ b/src/main/java/club/joylink/rtss/dao/voice/VoiceDiscriminateConfigDAO.java @@ -2,7 +2,6 @@ package club.joylink.rtss.dao.voice; import club.joylink.rtss.entity.voice.VoiceDiscriminateConfig; import club.joylink.rtss.entity.voice.VoiceDiscriminateConfigExample; -import club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs; import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -17,25 +16,25 @@ public interface VoiceDiscriminateConfigDAO { int deleteByPrimaryKey(Long id); - int insert(VoiceDiscriminateConfigWithBLOBs record); + int insert(VoiceDiscriminateConfig record); - int insertSelective(VoiceDiscriminateConfigWithBLOBs record); + int insertSelective(VoiceDiscriminateConfig record); - List selectByExampleWithBLOBs(VoiceDiscriminateConfigExample example); + List selectByExampleWithBLOBs(VoiceDiscriminateConfigExample example); List selectByExample(VoiceDiscriminateConfigExample example); - VoiceDiscriminateConfigWithBLOBs selectByPrimaryKey(Long id); + VoiceDiscriminateConfig selectByPrimaryKey(Long id); - int updateByExampleSelective(@Param("record") VoiceDiscriminateConfigWithBLOBs record, @Param("example") VoiceDiscriminateConfigExample example); + int updateByExampleSelective(@Param("record") VoiceDiscriminateConfig record, @Param("example") VoiceDiscriminateConfigExample example); - int updateByExampleWithBLOBs(@Param("record") VoiceDiscriminateConfigWithBLOBs record, @Param("example") VoiceDiscriminateConfigExample example); + int updateByExampleWithBLOBs(@Param("record") VoiceDiscriminateConfig record, @Param("example") VoiceDiscriminateConfigExample example); int updateByExample(@Param("record") VoiceDiscriminateConfig record, @Param("example") VoiceDiscriminateConfigExample example); - int updateByPrimaryKeySelective(VoiceDiscriminateConfigWithBLOBs record); + int updateByPrimaryKeySelective(VoiceDiscriminateConfig record); - int updateByPrimaryKeyWithBLOBs(VoiceDiscriminateConfigWithBLOBs record); + int updateByPrimaryKeyWithBLOBs(VoiceDiscriminateConfig record); int updateByPrimaryKey(VoiceDiscriminateConfig record); } \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfig.java b/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfig.java index e65147b4d..6be17f076 100644 --- a/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfig.java +++ b/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfig.java @@ -3,6 +3,10 @@ package club.joylink.rtss.entity.voice; import java.io.Serializable; import java.time.LocalDateTime; import java.util.Date; + +import club.joylink.rtss.simulation.cbtc.discriminate.OperateRule; +import club.joylink.rtss.simulation.cbtc.discriminate.ParamExtractRule; +import club.joylink.rtss.simulation.cbtc.discriminate.ReplyRule; import lombok.Data; /** @@ -18,6 +22,18 @@ public class VoiceDiscriminateConfig implements Serializable { */ private String keyWordRules; + /** + * 执行指令(系统操作指令) + * {@link OperateRule} + */ + private String execOperateRule; + + /** + * 回复指令(系统指令操作完毕或者无系统指令时,交互回复) + * {@link ReplyRule} + */ + private String replyRule; + private Long mapId; private LocalDateTime createTime; @@ -36,5 +52,11 @@ public class VoiceDiscriminateConfig implements Serializable { */ private Integer status; + /** + * 所需参数 List + * {@link ParamExtractRule} + */ + private String paramsRules; + private static final long serialVersionUID = 1L; } diff --git a/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigExample.java b/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigExample.java index 6234eea5d..00238783d 100644 --- a/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigExample.java +++ b/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigExample.java @@ -255,6 +255,146 @@ public class VoiceDiscriminateConfigExample { return (Criteria) this; } + public Criteria andExecOperateRuleIsNull() { + addCriterion("exec_operate_rule is null"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleIsNotNull() { + addCriterion("exec_operate_rule is not null"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleEqualTo(String value) { + addCriterion("exec_operate_rule =", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleNotEqualTo(String value) { + addCriterion("exec_operate_rule <>", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleGreaterThan(String value) { + addCriterion("exec_operate_rule >", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleGreaterThanOrEqualTo(String value) { + addCriterion("exec_operate_rule >=", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleLessThan(String value) { + addCriterion("exec_operate_rule <", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleLessThanOrEqualTo(String value) { + addCriterion("exec_operate_rule <=", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleLike(String value) { + addCriterion("exec_operate_rule like", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleNotLike(String value) { + addCriterion("exec_operate_rule not like", value, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleIn(List values) { + addCriterion("exec_operate_rule in", values, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleNotIn(List values) { + addCriterion("exec_operate_rule not in", values, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleBetween(String value1, String value2) { + addCriterion("exec_operate_rule between", value1, value2, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andExecOperateRuleNotBetween(String value1, String value2) { + addCriterion("exec_operate_rule not between", value1, value2, "execOperateRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleIsNull() { + addCriterion("reply_rule is null"); + return (Criteria) this; + } + + public Criteria andReplyRuleIsNotNull() { + addCriterion("reply_rule is not null"); + return (Criteria) this; + } + + public Criteria andReplyRuleEqualTo(String value) { + addCriterion("reply_rule =", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleNotEqualTo(String value) { + addCriterion("reply_rule <>", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleGreaterThan(String value) { + addCriterion("reply_rule >", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleGreaterThanOrEqualTo(String value) { + addCriterion("reply_rule >=", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleLessThan(String value) { + addCriterion("reply_rule <", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleLessThanOrEqualTo(String value) { + addCriterion("reply_rule <=", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleLike(String value) { + addCriterion("reply_rule like", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleNotLike(String value) { + addCriterion("reply_rule not like", value, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleIn(List values) { + addCriterion("reply_rule in", values, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleNotIn(List values) { + addCriterion("reply_rule not in", values, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleBetween(String value1, String value2) { + addCriterion("reply_rule between", value1, value2, "replyRule"); + return (Criteria) this; + } + + public Criteria andReplyRuleNotBetween(String value1, String value2) { + addCriterion("reply_rule not between", value1, value2, "replyRule"); + return (Criteria) this; + } + public Criteria andMapIdIsNull() { addCriterion("map_id is null"); return (Criteria) this; diff --git a/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigWithBLOBs.java b/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigWithBLOBs.java deleted file mode 100644 index fb3280ff6..000000000 --- a/src/main/java/club/joylink/rtss/entity/voice/VoiceDiscriminateConfigWithBLOBs.java +++ /dev/null @@ -1,28 +0,0 @@ -package club.joylink.rtss.entity.voice; - -import java.io.Serializable; -import lombok.Data; - -/** - * @author - * - */ -@Data -public class VoiceDiscriminateConfigWithBLOBs extends VoiceDiscriminateConfig implements Serializable { - /** - * 所需参数 - */ - private String paramsRules; - - /** - * 执行指令(系统操作指令) - */ - private String execOperateRule; - - /** - * 回复指令(系统指令操作完毕或者无系统指令时,交互回复) - */ - private String replyRule; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/services/voice/IVoiceDataConfigService.java b/src/main/java/club/joylink/rtss/services/voice/IVoiceDataConfigService.java index 89e34d57a..cee775c4f 100644 --- a/src/main/java/club/joylink/rtss/services/voice/IVoiceDataConfigService.java +++ b/src/main/java/club/joylink/rtss/services/voice/IVoiceDataConfigService.java @@ -3,9 +3,11 @@ package club.joylink.rtss.services.voice; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.voice.VoiceDiscriminateConfigVO; +import club.joylink.rtss.vo.voice.VoiceQueryVO; public interface IVoiceDataConfigService { - PageVO query(); + PageVO query(VoiceQueryVO queryVO); VoiceDiscriminateConfigVO byId(Long id); void saveOrUpdate(VoiceDiscriminateConfigVO configVO , LoginUserInfoVO userInfo); + void changeStatus(Long id,Integer status, LoginUserInfoVO userInfo); } diff --git a/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceDataConfigServiceImpl.java b/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceDataConfigServiceImpl.java index 784d78400..f01f77893 100644 --- a/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceDataConfigServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceDataConfigServiceImpl.java @@ -2,8 +2,7 @@ package club.joylink.rtss.services.voice.discriminate; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.dao.voice.VoiceDiscriminateConfigDAO; -import club.joylink.rtss.entity.voice.VoiceDiscriminateConfigExample; -import club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs; +import club.joylink.rtss.entity.voice.VoiceDiscriminateConfig; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.voice.IVoiceDataConfigService; import club.joylink.rtss.simulation.cbtc.discriminate.IVoiceDiscriminateRule; @@ -12,7 +11,10 @@ import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.voice.VoiceDiscriminateConfigVO; import club.joylink.rtss.vo.voice.VoiceQueryVO; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,47 +31,72 @@ public class VoiceDataConfigServiceImpl implements IVoiceDataConfigService, IVoi @Autowired private VoiceDiscriminateConfigDAO configDAO; - private VoiceDiscriminateConfigWithBLOBs findById(Long id){ + private VoiceDiscriminateConfig findById(Long id){ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(id),"数据id不能为空"); - VoiceDiscriminateConfigWithBLOBs data = this.configDAO.selectByPrimaryKey(id); + VoiceDiscriminateConfig data = this.configDAO.selectByPrimaryKey(id); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(Objects.nonNull(data),String.format("未找到对应的数据id:%s",id)); return data; } @Override - public PageVO query() { - return null; + public PageVO query(VoiceQueryVO query) { + PageHelper.startPage(query.getPageNum(), query.getPageSize()); + Page page = (Page) this.configDAO.selectByExampleWithBLOBs(query.buildQueryExample()); + List voList = page.getResult().stream().map(VoiceDiscriminateConfigVO::convertVO).collect(Collectors.toList()); + return PageVO.convert(page, voList); + } @Override public VoiceDiscriminateConfigVO byId(Long id) { - VoiceDiscriminateConfigWithBLOBs data = this.findById(id); + VoiceDiscriminateConfig data = this.findById(id); return VoiceDiscriminateConfigVO.convertVO(data); } @Override public void saveOrUpdate(VoiceDiscriminateConfigVO configVO, LoginUserInfoVO userInfo) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(configVO.getMapId()),"请选择对应的线路"); LocalDateTime dateTime = LocalDateTime.now(); - VoiceDiscriminateConfigWithBLOBs newData = configVO.convertToEntry(); + VoiceDiscriminateConfig newData = configVO.convertToEntry(); newData.setOperateId(userInfo.getAccountVO().getId()); + newData.setStatus(BusinessConsts.STATUS_NOT_USE_INT); + newData.setCreateTime(dateTime); + newData.setUpdateTime(dateTime); if(Objects.isNull(configVO.getId())){ - newData.setCreateTime(dateTime); - newData.setUpdateTime(dateTime); this.configDAO.insert(newData); }else{ - VoiceDiscriminateConfigWithBLOBs data = this.findById(configVO.getId()); + VoiceDiscriminateConfig data = this.findById(configVO.getId()); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(data.getStatus()== BusinessConsts.STATUS_NOT_USE_INT,"正在使用的配置数据不能编辑"); newData.setCreateTime(data.getCreateTime()); - newData.setUpdateTime(dateTime); this.configDAO.updateByPrimaryKeyWithBLOBs(newData); } } + @Override + public void changeStatus(Long id, Integer status, LoginUserInfoVO userInfo) { + VoiceDiscriminateConfig data = this.findById(id); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(status == BusinessConsts.STATUS_NOT_USE_INT || status == BusinessConsts.STATUS_USE_INT,"变更状态参数错误"); + if(status == BusinessConsts.STATUS_USE_INT){ + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.isNotEmpty(data.getParamsRules()),"匹配参数不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.isNotEmpty(data.getExecOperateRule()),"执行指令参数不能为空"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(StringUtils.isNotEmpty(data.getReplyRule()),"回复指令参数不能为空"); + } + + VoiceDiscriminateConfig update = new VoiceDiscriminateConfig(); + update.setId(id); + update.setStatus(status); + update.setUpdateTime(LocalDateTime.now()); + update.setOperateId(userInfo.getAccountVO().getId()); + this.configDAO.updateByPrimaryKeySelective(update); + + } + @Override public List findRuleByMapId(Long mapId) { VoiceQueryVO queryVO = new VoiceQueryVO(); queryVO.setMapId(mapId); queryVO.setStatus(BusinessConsts.STATUS_USE_INT); - List list = this.configDAO.selectByExampleWithBLOBs(queryVO.buildQueryExample()); + List list = this.configDAO.selectByExampleWithBLOBs(queryVO.buildQueryExample()); return list.stream().map(VoiceDiscriminateConfigVO::convertRule).collect(Collectors.toList()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/ExtractRule.java b/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/ExtractRule.java index 0d9d35a26..5e53e974f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/ExtractRule.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/discriminate/ExtractRule.java @@ -71,19 +71,22 @@ public enum ExtractRule { throw new IllegalArgumentException("定位参数缺失"); } String startSignalName = sourceStr[0], endSignalName = sourceStr[1]; + MapNamedElement startSignal = ExtractRule.findDevice(simulation, MapElement.DeviceType.SIGNAL,Signal.class,startSignalName); + MapNamedElement endSinal = ExtractRule.findDevice(simulation, MapElement.DeviceType.SIGNAL,Signal.class,endSignalName); Optional routeOptional = simulation.getRepository().getRouteList().stream() .filter(route -> { if (route.getStart() == null || route.getDestination() == null) { return false; } - return Objects.equals(startSignalName, route.getStart().getShowName()) - || Objects.equals(endSignalName, route.getDestination().getShowName()); + return Objects.equals(startSignal.getCode(), route.getStart().getCode()) + || Objects.equals(endSinal, route.getDestination().getCode()); }).findFirst(); if (routeOptional.isPresent()) { return routeOptional.get(); } - throw new IllegalArgumentException("未找到【" + startSignalName + "-" + endSignalName + "】进路"); +// throw new IllegalArgumentException("未找到【" + startSignalName + "-" + endSignalName + "】进路"); + throw new IllegalArgumentException(String.format("未找到信号机始端[%s-%s],终端[%s-%s]",startSignalName,startSignal.getName(),endSignalName,endSinal.getName())); } }, STAND_STATION_UP_DOWN_EXTRACT("根据车站、上下行匹配站台") { @@ -106,13 +109,19 @@ public enum ExtractRule { @Override public Object matchParam(Simulation simulation, String... sourceStr) { String way = sourceStr[0]; - if(StringUtils.containsAnyIgnoreCase(way,"shang")){ + if(StringUtils.containsIgnoreCase(way,"shang")){ return true; - }else if(StringUtils.containsAnyIgnoreCase(way,"xia")){ + }else if(StringUtils.containsIgnoreCase(way,"xia")){ return false; } throw new IllegalArgumentException(String.format("不能解析上下行[%s]",way)); } + },SWITCH_NAME("道岔名称"){ + @Override + public Object matchParam(Simulation simulation, String... sourceStr) { + String swtichName = sourceStr[0]; + return ExtractRule.findDevice(simulation, MapElement.DeviceType.SWITCH,Switch.class,swtichName); + } }, ; diff --git a/src/main/java/club/joylink/rtss/vo/voice/VoiceDiscriminateConfigVO.java b/src/main/java/club/joylink/rtss/vo/voice/VoiceDiscriminateConfigVO.java index be06a2a8b..6badf6a46 100644 --- a/src/main/java/club/joylink/rtss/vo/voice/VoiceDiscriminateConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/voice/VoiceDiscriminateConfigVO.java @@ -1,6 +1,6 @@ package club.joylink.rtss.vo.voice; -import club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs; +import club.joylink.rtss.entity.voice.VoiceDiscriminateConfig; import club.joylink.rtss.simulation.cbtc.discriminate.OperateRule; import club.joylink.rtss.simulation.cbtc.discriminate.ParamExtractRule; import club.joylink.rtss.simulation.cbtc.discriminate.ReplyRule; @@ -54,8 +54,8 @@ public class VoiceDiscriminateConfigVO implements Serializable { */ private ReplyRule replyRule; - public VoiceDiscriminateConfigWithBLOBs convertToEntry(){ - VoiceDiscriminateConfigWithBLOBs data = new VoiceDiscriminateConfigWithBLOBs(); + public VoiceDiscriminateConfig convertToEntry(){ + VoiceDiscriminateConfig data = new VoiceDiscriminateConfig(); BeanUtils.copyProperties(this, data); if(!CollectionUtils.isEmpty(this.paramsRules)){ data.setParamsRules(JsonUtils.writeValueAsString(this.paramsRules)); @@ -69,7 +69,7 @@ public class VoiceDiscriminateConfigVO implements Serializable { return data; } - public static VoiceDiscriminateConfigVO convertVO(VoiceDiscriminateConfigWithBLOBs data){ + public static VoiceDiscriminateConfigVO convertVO(VoiceDiscriminateConfig data){ VoiceDiscriminateConfigVO vo = new VoiceDiscriminateConfigVO(); BeanUtils.copyProperties(data, vo); if(StringUtils.hasText(data.getParamsRules())){ @@ -84,7 +84,7 @@ public class VoiceDiscriminateConfigVO implements Serializable { return vo; } - public static VoiceDiscriminateRule convertRule(VoiceDiscriminateConfigWithBLOBs data){ + public static VoiceDiscriminateRule convertRule(VoiceDiscriminateConfig data){ VoiceDiscriminateConfigVO configVO = convertVO(data); VoiceDiscriminateRule rule = new VoiceDiscriminateRule(); diff --git a/src/main/java/club/joylink/rtss/vo/voice/VoiceQueryVO.java b/src/main/java/club/joylink/rtss/vo/voice/VoiceQueryVO.java index 1ae807507..05d901c56 100644 --- a/src/main/java/club/joylink/rtss/vo/voice/VoiceQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/voice/VoiceQueryVO.java @@ -1,8 +1,10 @@ package club.joylink.rtss.vo.voice; import club.joylink.rtss.entity.voice.VoiceDiscriminateConfigExample; +import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.vo.client.PageQueryVO; import lombok.Data; +import org.apache.commons.lang3.StringUtils; import java.util.Objects; @@ -10,6 +12,7 @@ import java.util.Objects; public class VoiceQueryVO extends PageQueryVO { private Long mapId; private Integer status; + private Operation.Type operation; public VoiceDiscriminateConfigExample buildQueryExample(){ VoiceDiscriminateConfigExample example = new VoiceDiscriminateConfigExample(); @@ -20,6 +23,9 @@ public class VoiceQueryVO extends PageQueryVO { if(Objects.nonNull(this.status)){ criteria.andStatusEqualTo(this.status); } + if(Objects.nonNull(this.operation)){ + criteria.andExecOperateRuleLike(String.format("%%%s%%",this.operation.name())); + } return example; } } diff --git a/src/main/resources/mybatis/mapper/voice/VoiceDiscriminateConfigDAO.xml b/src/main/resources/mybatis/mapper/voice/VoiceDiscriminateConfigDAO.xml index f51366bd7..217f9a9bd 100644 --- a/src/main/resources/mybatis/mapper/voice/VoiceDiscriminateConfigDAO.xml +++ b/src/main/resources/mybatis/mapper/voice/VoiceDiscriminateConfigDAO.xml @@ -4,6 +4,8 @@ + + @@ -11,10 +13,8 @@ - + - - @@ -75,10 +75,11 @@ - id, key_word_rules, map_id, create_time, update_time, operate_id, `describe`, `status` + id, key_word_rules, exec_operate_rule, reply_rule, map_id, create_time, update_time, + operate_id, `describe`, `status` - params_rules, exec_operate_rule, reply_rule + params_rules @@ -236,6 +237,12 @@ key_word_rules = #{record.keyWordRules,jdbcType=VARCHAR}, + + exec_operate_rule = #{record.execOperateRule,jdbcType=VARCHAR}, + + + reply_rule = #{record.replyRule,jdbcType=VARCHAR}, + map_id = #{record.mapId,jdbcType=BIGINT}, @@ -257,12 +264,6 @@ params_rules = #{record.paramsRules,jdbcType=LONGVARCHAR}, - - exec_operate_rule = #{record.execOperateRule,jdbcType=LONGVARCHAR}, - - - reply_rule = #{record.replyRule,jdbcType=LONGVARCHAR}, - @@ -272,15 +273,15 @@ update rts_voice_discriminate_config set id = #{record.id,jdbcType=BIGINT}, key_word_rules = #{record.keyWordRules,jdbcType=VARCHAR}, + exec_operate_rule = #{record.execOperateRule,jdbcType=VARCHAR}, + reply_rule = #{record.replyRule,jdbcType=VARCHAR}, map_id = #{record.mapId,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP}, operate_id = #{record.operateId,jdbcType=BIGINT}, `describe` = #{record.describe,jdbcType=VARCHAR}, `status` = #{record.status,jdbcType=INTEGER}, - params_rules = #{record.paramsRules,jdbcType=LONGVARCHAR}, - exec_operate_rule = #{record.execOperateRule,jdbcType=LONGVARCHAR}, - reply_rule = #{record.replyRule,jdbcType=LONGVARCHAR} + params_rules = #{record.paramsRules,jdbcType=LONGVARCHAR} @@ -289,6 +290,8 @@ update rts_voice_discriminate_config set id = #{record.id,jdbcType=BIGINT}, key_word_rules = #{record.keyWordRules,jdbcType=VARCHAR}, + exec_operate_rule = #{record.execOperateRule,jdbcType=VARCHAR}, + reply_rule = #{record.replyRule,jdbcType=VARCHAR}, map_id = #{record.mapId,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP}, @@ -299,12 +302,18 @@ - + update rts_voice_discriminate_config key_word_rules = #{keyWordRules,jdbcType=VARCHAR}, + + exec_operate_rule = #{execOperateRule,jdbcType=VARCHAR}, + + + reply_rule = #{replyRule,jdbcType=VARCHAR}, + map_id = #{mapId,jdbcType=BIGINT}, @@ -326,32 +335,28 @@ params_rules = #{paramsRules,jdbcType=LONGVARCHAR}, - - exec_operate_rule = #{execOperateRule,jdbcType=LONGVARCHAR}, - - - reply_rule = #{replyRule,jdbcType=LONGVARCHAR}, - where id = #{id,jdbcType=BIGINT} - + update rts_voice_discriminate_config set key_word_rules = #{keyWordRules,jdbcType=VARCHAR}, + exec_operate_rule = #{execOperateRule,jdbcType=VARCHAR}, + reply_rule = #{replyRule,jdbcType=VARCHAR}, map_id = #{mapId,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, operate_id = #{operateId,jdbcType=BIGINT}, `describe` = #{describe,jdbcType=VARCHAR}, `status` = #{status,jdbcType=INTEGER}, - params_rules = #{paramsRules,jdbcType=LONGVARCHAR}, - exec_operate_rule = #{execOperateRule,jdbcType=LONGVARCHAR}, - reply_rule = #{replyRule,jdbcType=LONGVARCHAR} + params_rules = #{paramsRules,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=BIGINT} update rts_voice_discriminate_config set key_word_rules = #{keyWordRules,jdbcType=VARCHAR}, + exec_operate_rule = #{execOperateRule,jdbcType=VARCHAR}, + reply_rule = #{replyRule,jdbcType=VARCHAR}, map_id = #{mapId,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, diff --git a/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java b/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java new file mode 100644 index 000000000..db2721c52 --- /dev/null +++ b/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java @@ -0,0 +1,91 @@ +package club.joylink.rtss.services.voice; + +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.entity.project.Project; +import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; +import club.joylink.rtss.simulation.cbtc.discriminate.*; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.project.ProjectVO; +import club.joylink.rtss.vo.voice.VoiceDiscriminateConfigVO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import java.util.ArrayList; +import java.util.List; + +@SpringBootTest +public class VoiceConfigDataTest { + @Autowired + private IVoiceDataConfigService service; + + private LoginUserInfoVO getInfo(){ + String testJsonData = "{\"accountVO\":{\"id\":\"8146\",\"account\":\"13992867352\",\"type\":\"2\",\"nickname\":\"13992867352\",\"mobile\":\"13992867352\",\"password\":\"e10adc3949ba59abbe56e057f20f883e\",\"roles\":[\"01\",\"05\"],\"email\":\"\",\"status\":\"1\",\"companyId\":124,\"companyName\":\"默认组织\",\"companyAdmin\":false,\"projectCodes\":[\"BJD\",\"CGY\",\"DEFAULT\",\"DRTS\",\"HEB\",\"HYD_RAILWAY\",\"JJJLM\",\"JXGM\",\"NOLOGO\",\"RICHOR\",\"RICHOR_CXJS\",\"RICHOR_HHCJ\",\"RICHOR_JOINT\",\"RICHOR_YGY\",\"SR_SANDBOX\",\"THAILAND_SANDBOX\",\"WJLS\",\"YJDDZH\",\"ZZWW\",\"ZZWWTEST\"]},\"client\":\"Joylink\",\"project\":\"DEFAULT\",\"token\":\"34a5b6916e60eea26a53c820c644c4e8\",\"projectDeviceLogin\":false,\"wechatLogin\":false,\"topOrgId\":124,\"dispatcherRaceTrainingLogin\":false}\n"; + LoginUserInfoVO infoVO = JsonUtils.read(testJsonData,LoginUserInfoVO.class); + Project project = new Project(); + project.setName("默认项目"); + project.setCode("DEFAULT"); + ProjectVO projectVO = new ProjectVO(project); + infoVO.setProjectInfo(projectVO); + return infoVO; + } + + @Test + public void save(){ +// this.service.saveOrUpdate(); + VoiceDiscriminateConfigVO configVO = new VoiceDiscriminateConfigVO(); + configVO.setDescribe("测试"); + configVO.setKeyWordRules("keyword rules"); + configVO.setMapId(63L); + List paramExtractRuleList = new ArrayList<>(); + ParamExtractRule extractRule = new ParamExtractRule(); + extractRule.setParseRule(ExtractRule.ROUTE_SIGNAL_EXTRACT); + extractRule.setIndexArr(new Integer[]{0}); + + paramExtractRuleList.add(extractRule); + configVO.setParamsRules(paramExtractRuleList); + + OperateRule operateRule = new OperateRule(); + operateRule.setType(Operation.Type.Switch_Force_Turn); + List operateParamList = new ArrayList<>(); + operateRule.setParamRules(operateParamList); + CommandParamRule cpr = new CommandParamRule(); + cpr.setName("stationCode"); + cpr.setParamIndex(0); + cpr.setParseRule(CommandParamParseRule.MAP_ELEMENT_CODE); + cpr.setIndexArr(new Integer[]{1}); + operateParamList.add(cpr); + + configVO.setExecOperateRule(operateRule); + this.service.saveOrUpdate(configVO,this.getInfo()); + } + + @Test + public void find(){ + VoiceDiscriminateConfigVO vo = this.service.byId(1L); + System.out.println(JsonUtils.writeValueAsString(vo)); + } + + @Test + public void update(){ + VoiceDiscriminateConfigVO vo = this.service.byId(1L); + List paramList = vo.getParamsRules(); + ParamExtractRule extractRule = new ParamExtractRule(); + extractRule.setParseRule(ExtractRule.UP_DOWN_WAY); + extractRule.setIndexArr(new Integer[]{1}); + paramList.add(extractRule); + this.service.saveOrUpdate(vo,this.getInfo()); + } + + @Test + public void changeStatusErr(){ +// this.service.changeStatus(3L,1,this.getInfo()); + this.service.changeStatus(1L,3,this.getInfo()); + } + @Test + public void changeStatus(){ + + this.service.changeStatus(1L, BusinessConsts.STATUS_NOT_USE_INT,this.getInfo()); + } +}