fix: 连续语料添加排序字段,流程调用时按照字段排序

This commit is contained in:
stream 2025-10-14 14:53:44 +08:00
parent 9ec26e7ac5
commit e769336616
5 changed files with 36 additions and 16 deletions

View File

@ -41,23 +41,23 @@ public class ViPlayOperateService implements VIOperateService {
String audioPath = inputParams.getString("audioPath");
String terminalId = message.getTerminalId();
// log.info("播放语料成功,deviceId={},audioPath={},terminalId={}", deviceId, audioPath, terminalId);
edgeSpeakerService.playAudio(terminalId, deviceId, audioPath);
// 等待播放完成
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
SpeakerCommand.GetSpeakerStateCommand.Feedback status = edgeSpeakerService.getStatus(terminalId, deviceId);
boolean isRunning = status.getState().getIsRunning();
if (!isRunning) {
break;
}
}
// edgeSpeakerService.playAudio(terminalId, deviceId, audioPath);
// // 等待播放完成
// while (true) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// SpeakerCommand.GetSpeakerStateCommand.Feedback status = edgeSpeakerService.getStatus(terminalId, deviceId);
// boolean isRunning = status.getState().getIsRunning();
// if (!isRunning) {
// break;
// }
// }
// todo 本机测试播放
// playAudio(audioPath);
playAudio(audioPath);
return TaskNodeExecuteResult.success();
}

View File

@ -73,8 +73,17 @@ public class ViSchemeOperateService implements VIOperateService {
obj -> obj.getString("parentId")
));
// 转成 List<List<JSONObject>>
// 转成 List<List<JSONObject>> 并排序
List<List<JSONObject>> continuousCorpusGroup = new ArrayList<>(grouped.values());
continuousCorpusGroup.sort((group1, group2) -> {
Integer sort1 = group1.get(0).getInteger("sortParent");
Integer sort2 = group2.get(0).getInteger("sortParent");
if (sort1 == null && sort2 == null) return 0;
if (sort1 == null) return 1; // null 排后面
if (sort2 == null) return -1; // null 排后面
return Integer.compare(sort1, sort2);
});
output.put("testCorpus", continuousCorpusGroup);
break;

View File

@ -49,6 +49,10 @@ public class ViCorpus extends BaseEntity {
@ApiModelProperty("预期结果(预留)")
private String expectedResult;
@Excel(name = "连续语料的顺序")
@ApiModelProperty("连续语料的顺序")
private Integer sortParent;
@Excel(name = "同一父语料下的顺序")
@ApiModelProperty("同一父语料下的顺序")
private Integer sortOrder;

View File

@ -23,6 +23,9 @@ public class ViContinuousCorpusVO {
@ApiModelProperty("方言")
private String dialect;
@ApiModelProperty("连续语料的顺序")
private Integer sortParent;
@ApiModelProperty("子语料列表")
private List<ViCorpus> children;
}

View File

@ -98,6 +98,10 @@ public class IViCorpusServiceImpl extends ServiceImpl<ViCorpusMapper, ViCorpus>
.orderByAsc(ViCorpus::getSortOrder)
);
vo.setChildren(children);
if (CollUtil.isNotEmpty(children)) {
Integer sortParent = children.get(0).getSortParent();
vo.setSortParent(sortParent);
}
}
return list;