数据管理
This commit is contained in:
parent
f81c160b21
commit
53fd77af5c
@ -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<VoiceDiscriminateConfigWithBLOBs> selectByExampleWithBLOBs(VoiceDiscriminateConfigExample example);
|
||||
List<VoiceDiscriminateConfig> selectByExampleWithBLOBs(VoiceDiscriminateConfigExample example);
|
||||
|
||||
List<VoiceDiscriminateConfig> 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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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<String> values) {
|
||||
addCriterion("exec_operate_rule in", values, "execOperateRule");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andExecOperateRuleNotIn(List<String> 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<String> values) {
|
||||
addCriterion("reply_rule in", values, "replyRule");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andReplyRuleNotIn(List<String> 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;
|
||||
|
@ -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;
|
||||
}
|
@ -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<VoiceDiscriminateConfigVO> query();
|
||||
PageVO<VoiceDiscriminateConfigVO> query(VoiceQueryVO queryVO);
|
||||
VoiceDiscriminateConfigVO byId(Long id);
|
||||
void saveOrUpdate(VoiceDiscriminateConfigVO configVO , LoginUserInfoVO userInfo);
|
||||
void changeStatus(Long id,Integer status, LoginUserInfoVO userInfo);
|
||||
}
|
||||
|
@ -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<VoiceDiscriminateConfigVO> query() {
|
||||
return null;
|
||||
public PageVO<VoiceDiscriminateConfigVO> query(VoiceQueryVO query) {
|
||||
PageHelper.startPage(query.getPageNum(), query.getPageSize());
|
||||
Page<VoiceDiscriminateConfig> page = (Page<VoiceDiscriminateConfig>) this.configDAO.selectByExampleWithBLOBs(query.buildQueryExample());
|
||||
List<VoiceDiscriminateConfigVO> 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<VoiceDiscriminateRule> findRuleByMapId(Long mapId) {
|
||||
VoiceQueryVO queryVO = new VoiceQueryVO();
|
||||
queryVO.setMapId(mapId);
|
||||
queryVO.setStatus(BusinessConsts.STATUS_USE_INT);
|
||||
List<VoiceDiscriminateConfigWithBLOBs> list = this.configDAO.selectByExampleWithBLOBs(queryVO.buildQueryExample());
|
||||
List<VoiceDiscriminateConfig> list = this.configDAO.selectByExampleWithBLOBs(queryVO.buildQueryExample());
|
||||
return list.stream().map(VoiceDiscriminateConfigVO::convertRule).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -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<Route> 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);
|
||||
}
|
||||
},
|
||||
;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="key_word_rules" jdbcType="VARCHAR" property="keyWordRules" />
|
||||
<result column="exec_operate_rule" jdbcType="VARCHAR" property="execOperateRule" />
|
||||
<result column="reply_rule" jdbcType="VARCHAR" property="replyRule" />
|
||||
<result column="map_id" jdbcType="BIGINT" property="mapId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||
@ -11,10 +13,8 @@
|
||||
<result column="describe" jdbcType="VARCHAR" property="describe" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs">
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig">
|
||||
<result column="params_rules" jdbcType="LONGVARCHAR" property="paramsRules" />
|
||||
<result column="exec_operate_rule" jdbcType="LONGVARCHAR" property="execOperateRule" />
|
||||
<result column="reply_rule" jdbcType="LONGVARCHAR" property="replyRule" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -75,10 +75,11 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
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`
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
params_rules, exec_operate_rule, reply_rule
|
||||
params_rules
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
@ -144,22 +145,28 @@
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs" useGeneratedKeys="true">
|
||||
insert into rts_voice_discriminate_config (key_word_rules, map_id, create_time,
|
||||
update_time, operate_id, `describe`,
|
||||
`status`, params_rules, exec_operate_rule,
|
||||
reply_rule)
|
||||
values (#{keyWordRules,jdbcType=VARCHAR}, #{mapId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{updateTime,jdbcType=TIMESTAMP}, #{operateId,jdbcType=BIGINT}, #{describe,jdbcType=VARCHAR},
|
||||
#{status,jdbcType=INTEGER}, #{paramsRules,jdbcType=LONGVARCHAR}, #{execOperateRule,jdbcType=LONGVARCHAR},
|
||||
#{replyRule,jdbcType=LONGVARCHAR})
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig" useGeneratedKeys="true">
|
||||
insert into rts_voice_discriminate_config (key_word_rules, exec_operate_rule, reply_rule,
|
||||
map_id, create_time, update_time,
|
||||
operate_id, `describe`, `status`,
|
||||
params_rules)
|
||||
values (#{keyWordRules,jdbcType=VARCHAR}, #{execOperateRule,jdbcType=VARCHAR}, #{replyRule,jdbcType=VARCHAR},
|
||||
#{mapId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
|
||||
#{operateId,jdbcType=BIGINT}, #{describe,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
|
||||
#{paramsRules,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs" useGeneratedKeys="true">
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig" useGeneratedKeys="true">
|
||||
insert into rts_voice_discriminate_config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="keyWordRules != null">
|
||||
key_word_rules,
|
||||
</if>
|
||||
<if test="execOperateRule != null">
|
||||
exec_operate_rule,
|
||||
</if>
|
||||
<if test="replyRule != null">
|
||||
reply_rule,
|
||||
</if>
|
||||
<if test="mapId != null">
|
||||
map_id,
|
||||
</if>
|
||||
@ -181,17 +188,17 @@
|
||||
<if test="paramsRules != null">
|
||||
params_rules,
|
||||
</if>
|
||||
<if test="execOperateRule != null">
|
||||
exec_operate_rule,
|
||||
</if>
|
||||
<if test="replyRule != null">
|
||||
reply_rule,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="keyWordRules != null">
|
||||
#{keyWordRules,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="execOperateRule != null">
|
||||
#{execOperateRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="replyRule != null">
|
||||
#{replyRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="mapId != null">
|
||||
#{mapId,jdbcType=BIGINT},
|
||||
</if>
|
||||
@ -213,12 +220,6 @@
|
||||
<if test="paramsRules != null">
|
||||
#{paramsRules,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="execOperateRule != null">
|
||||
#{execOperateRule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="replyRule != null">
|
||||
#{replyRule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigExample" resultType="java.lang.Long">
|
||||
@ -236,6 +237,12 @@
|
||||
<if test="record.keyWordRules != null">
|
||||
key_word_rules = #{record.keyWordRules,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.execOperateRule != null">
|
||||
exec_operate_rule = #{record.execOperateRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.replyRule != null">
|
||||
reply_rule = #{record.replyRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.mapId != null">
|
||||
map_id = #{record.mapId,jdbcType=BIGINT},
|
||||
</if>
|
||||
@ -257,12 +264,6 @@
|
||||
<if test="record.paramsRules != null">
|
||||
params_rules = #{record.paramsRules,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.execOperateRule != null">
|
||||
exec_operate_rule = #{record.execOperateRule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.replyRule != null">
|
||||
reply_rule = #{record.replyRule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -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}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -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 @@
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs">
|
||||
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig">
|
||||
update rts_voice_discriminate_config
|
||||
<set>
|
||||
<if test="keyWordRules != null">
|
||||
key_word_rules = #{keyWordRules,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="execOperateRule != null">
|
||||
exec_operate_rule = #{execOperateRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="replyRule != null">
|
||||
reply_rule = #{replyRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="mapId != null">
|
||||
map_id = #{mapId,jdbcType=BIGINT},
|
||||
</if>
|
||||
@ -326,32 +335,28 @@
|
||||
<if test="paramsRules != null">
|
||||
params_rules = #{paramsRules,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="execOperateRule != null">
|
||||
exec_operate_rule = #{execOperateRule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="replyRule != null">
|
||||
reply_rule = #{replyRule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfigWithBLOBs">
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig">
|
||||
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>
|
||||
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.voice.VoiceDiscriminateConfig">
|
||||
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},
|
||||
|
@ -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<ParamExtractRule> 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<CommandParamRule> 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<ParamExtractRule> 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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user