Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin

This commit is contained in:
tiger_zhou 2023-04-07 18:09:59 +08:00
commit 600f4ebe04
6 changed files with 25 additions and 29 deletions

View File

@ -114,13 +114,22 @@ public class VoiceParseServiceImpl implements VoiceParseService {
List<ParamExtractRule> paramsRules = result.getRule().getParamsRules(); List<ParamExtractRule> paramsRules = result.getRule().getParamsRules();
List<ParamExtractResult> paramExtractResults = new ArrayList<>(paramsRules.size()); List<ParamExtractResult> paramExtractResults = new ArrayList<>(paramsRules.size());
ParamExtractResult extractResult = null; ParamExtractResult extractResult = null;
String[] groupStrArr = null;
int groupSize = groupList.size();
for (ParamExtractRule rule : paramsRules) { for (ParamExtractRule rule : paramsRules) {
if (groupList.size() < rule.getIndex()) { if (rule.getIndexArr() != null) { // 如果定位信息不为空
result.setSuccess(false); groupStrArr = new String[rule.getIndexArr().length];
result.setMsg("提取参数出错"); for (int index = 0, len = groupStrArr.length; index < len; index ++) {
return; if (groupSize < rule.getIndexArr()[index]) {
result.setSuccess(false);
result.setMsg("提取参数出错");
return;
}
groupStrArr[index] = groupList.get(rule.getIndexArr()[index]);
}
} }
extractResult = rule.getParseRule().matchParam(simulation, groupList.get(rule.getIndex())); extractResult = new ParamExtractResult();
extractResult.setValue(rule.getParseRule().matchParam(simulation, groupStrArr));
paramExtractResults.add(extractResult); paramExtractResults.add(extractResult);
} }
result.setParamExtractResultList(paramExtractResults); result.setParamExtractResultList(paramExtractResults);

View File

@ -9,17 +9,17 @@ import lombok.Data;
public class CommandParamRule { public class CommandParamRule {
/** /**
* 名称 * 方法参数对应的参数名优先使用
*/ */
private String name; private String name;
/** /**
* 结果类型 * 方法参数所在位置通过反射获取
*/ */
private String type; private Integer paramIndex;
/** /**
* 对应解析参数位置 * 对应解析参数位置VoiceDiscriminateResult.paramExtractResultList的位置
*/ */
private Integer index; private Integer index;

View File

@ -11,11 +11,12 @@ public enum ExtractRule {
STATION_NAME { STATION_NAME {
@Override @Override
public ParamExtractResult matchParam(Simulation simulation, String sourceStr) { public Object matchParam(Simulation simulation, String... sourceStr) {
return null; return null;
} }
}; };
public abstract ParamExtractResult matchParam(Simulation simulation, String sourceStr);
public abstract Object matchParam(Simulation simulation, String... sourceStr);
} }

View File

@ -7,13 +7,10 @@ import lombok.Data;
*/ */
@Data @Data
public class ParamExtractResult { public class ParamExtractResult {
/**
* 设置名
*/
private String name;
/** /**
* 数据 * 参数解析出的相关数据
*/ */
private Object value; private Object value;
} }

View File

@ -7,23 +7,13 @@ import lombok.Data;
*/ */
@Data @Data
public class ParamExtractRule { public class ParamExtractRule {
/**
* 参数名
*/
private String name;
/**
* 是否是设备
*/
private boolean isDevice;
/** /**
* 解析规则 * 解析规则
*/ */
private ExtractRule parseRule; private ExtractRule parseRule;
/** /**
* group位置索引 * group位置索引,有时需要多个参数信息定位具体值始终信号机定位进路
*/ */
private Integer index; private Integer[] indexArr;
} }

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc.discriminate;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.Data; import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;