修改根据已知数据获取未知数据的问题

This commit is contained in:
tiger_zhou 2023-04-11 16:32:06 +08:00
parent ca6870ae17
commit 1ef8a6e41e
2 changed files with 30 additions and 11 deletions

View File

@ -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("道岔名称"){

View File

@ -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<ParamExtractRule> paramExtractRuleList = new ArrayList<>();
ParamExtractRule extractRule = new ParamExtractRule();