【调整语音指令实体参数】

This commit is contained in:
weizhihong 2023-04-07 17:51:18 +08:00
parent 264306b0dc
commit e31facba91
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<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()) {
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;
}
extractResult = rule.getParseRule().matchParam(simulation, groupList.get(rule.getIndex()));
groupStrArr[index] = groupList.get(rule.getIndexArr()[index]);
}
}
extractResult = new ParamExtractResult();
extractResult.setValue(rule.getParseRule().matchParam(simulation, groupStrArr));
paramExtractResults.add(extractResult);
}
result.setParamExtractResultList(paramExtractResults);

View File

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

View File

@ -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);
}

View File

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

View File

@ -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;
}

View File

@ -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;