【调整语音指令实体参数】
This commit is contained in:
parent
264306b0dc
commit
e31facba91
@ -114,13 +114,22 @@ public class VoiceParseServiceImpl implements VoiceParseService {
|
||||
List<ParamExtractRule> paramsRules = result.getRule().getParamsRules();
|
||||
List<ParamExtractResult> paramExtractResults = new ArrayList<>(paramsRules.size());
|
||||
ParamExtractResult extractResult = null;
|
||||
String[] groupStrArr = null;
|
||||
int groupSize = groupList.size();
|
||||
for (ParamExtractRule rule : paramsRules) {
|
||||
if (groupList.size() < rule.getIndex()) {
|
||||
result.setSuccess(false);
|
||||
result.setMsg("提取参数出错");
|
||||
return;
|
||||
if (rule.getIndexArr() != null) { // 如果定位信息不为空
|
||||
groupStrArr = new String[rule.getIndexArr().length];
|
||||
for (int index = 0, len = groupStrArr.length; index < len; index ++) {
|
||||
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);
|
||||
}
|
||||
result.setParamExtractResultList(paramExtractResults);
|
||||
|
@ -9,17 +9,17 @@ import lombok.Data;
|
||||
public class CommandParamRule {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
* 方法参数对应的参数名:优先使用
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 结果类型
|
||||
* 方法参数所在位置:通过反射获取
|
||||
*/
|
||||
private String type;
|
||||
private Integer paramIndex;
|
||||
|
||||
/**
|
||||
* 对应解析参数位置
|
||||
* 对应解析参数位置:VoiceDiscriminateResult.paramExtractResultList的位置
|
||||
*/
|
||||
private Integer index;
|
||||
|
||||
|
@ -11,11 +11,12 @@ public enum ExtractRule {
|
||||
|
||||
STATION_NAME {
|
||||
@Override
|
||||
public ParamExtractResult matchParam(Simulation simulation, String sourceStr) {
|
||||
public Object matchParam(Simulation simulation, String... sourceStr) {
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract ParamExtractResult matchParam(Simulation simulation, String sourceStr);
|
||||
|
||||
public abstract Object matchParam(Simulation simulation, String... sourceStr);
|
||||
}
|
@ -7,13 +7,10 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class ParamExtractResult {
|
||||
/**
|
||||
* 设置名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
* 参数解析出的相关数据
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
}
|
@ -7,23 +7,13 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class ParamExtractRule {
|
||||
/**
|
||||
* 参数名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否是设备
|
||||
*/
|
||||
private boolean isDevice;
|
||||
|
||||
/**
|
||||
* 解析规则
|
||||
*/
|
||||
private ExtractRule parseRule;
|
||||
|
||||
/**
|
||||
* group位置索引
|
||||
* group位置索引,有时需要多个参数信息定位具体值,始终信号机定位进路
|
||||
*/
|
||||
private Integer index;
|
||||
private Integer[] indexArr;
|
||||
}
|
@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc.discriminate;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user