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 a754fb006..d1efb2abf 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 @@ -153,19 +153,35 @@ public enum ExtractRule { throw new IllegalArgumentException("定位参数缺失"); } ParamExtractResult result = new ParamExtractResult(); + String way = originArr[0]; if (correctArr != null && correctArr[0] != null) { // 有正确值,直接匹配 - result.setValue(correctArr[0]); - } else { - String way = originArr[0]; - if(StringUtils.containsIgnoreCase(way,"shang")) { - result.setValue(true); - result.setCorrectGroupMap(way, "上"); - }else if(StringUtils.containsIgnoreCase(way,"xia")){ - result.setValue(false); - result.setCorrectGroupMap(way, "下"); + String correctArrStr = correctArr[0]; + boolean isRight = true; + if(StringUtils.equals(correctArrStr,"下")){ + isRight = false; } + result.setValue(isRight); + result.setCorrectGroupMap(way,isRight ? "上" : "下"); + return result; + } else { + Boolean isRight = null; + if(StringUtils.containsIgnoreCase(way,"shang")) { + isRight = true; +// result.setValue(true); +// result.setCorrectGroupMap(way, "上"); +// return result; + }else if(StringUtils.containsIgnoreCase(way,"xia")){ + isRight = false; +// result.setValue(false); +// result.setCorrectGroupMap(way, "下"); +// return result; + }else{ + throw new IllegalArgumentException(String.format("不能解析上下行[%s]", originArr[0])); + } + result.setValue(isRight); + result.setCorrectGroupMap(way,isRight ? "上" : "下"); + return result; } - throw new IllegalArgumentException(String.format("不能解析上下行[%s]", originArr[0])); } }, SWITCH_NAME("道岔名称"){ diff --git a/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java b/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java index 9afbc0d8c..b84b3b6f5 100644 --- a/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java +++ b/src/test/java/club/joylink/rtss/services/voice/VoiceConfigDataTest.java @@ -153,8 +153,11 @@ public class VoiceConfigDataTest { public void saveForStand(){ // this.service.saveOrUpdate(); VoiceDiscriminateConfigVO configVO = new VoiceDiscriminateConfigVO(); + configVO.setId(4L); configVO.setDescribe("测试站台扣车"); - configVO.setKeyWordRules("(.*?)站(.*?)站台扣车"); + +// ^(?:BANLI|CHULI)(.*?ZHAN(?:YI|ER))ZHAN(.*?)ZHANTAIKOUCHE + configVO.setKeyWordRules("^(?:办理|处理)(.*?站(?:一|二))站(.*?)站台扣车"); configVO.setMapId(63L); List paramExtractRuleList = new ArrayList<>(); ParamExtractRule extractRule = new ParamExtractRule();