From 1660113cb3e14677fa367bcf6cfcc425d268b094 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 6 May 2021 15:02:14 +0800 Subject: [PATCH] =?UTF-8?q?<=E6=95=B4=E4=B8=AA=E5=9C=BA=E6=99=AF=E7=9A=84?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E6=A0=A1=E9=AA=8C=E6=8E=A5=E5=8F=A3>?= =?UTF-8?q?=E5=B0=8F=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompetitionPracticalController.java | 4 ++-- .../controller/voice/VoiceController.java | 4 ++-- .../CompetitionPracticalService.java | 14 +++++++----- .../ICompetitionPracticalService.java | 4 ++-- .../services/voice/IVoiceTrainingService.java | 4 ++-- .../services/voice/VoiceTrainingService.java | 6 ++--- .../CompetitionAndScriptManager.java | 6 ++--- ...VoiceErrorSetVO.java => VoiceErrorVO.java} | 22 ++++++++++++------- 8 files changed, 36 insertions(+), 28 deletions(-) rename src/main/java/club/joylink/rtss/vo/client/competition/{VoiceErrorSetVO.java => VoiceErrorVO.java} (75%) diff --git a/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java b/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java index 15ad42962..07aa9bc96 100644 --- a/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java +++ b/src/main/java/club/joylink/rtss/controller/competition/CompetitionPracticalController.java @@ -129,13 +129,13 @@ public class CompetitionPracticalController { @ApiOperation("语音录制校验") @PostMapping("/voice/record/check/{recordId}") - public VoiceErrorSetVO voiceRecordCheck(@PathVariable Long recordId, @RequestBody CommandPublishStatisticVO commandPublishStatisticVO) { + public VoiceErrorVO voiceRecordCheck(@PathVariable Long recordId, @RequestBody CommandPublishStatisticVO commandPublishStatisticVO) { return iCompetitionPracticalService.voiceRecordCheck(recordId, commandPublishStatisticVO); } @ApiOperation("语音录制校验(整个场景)") @GetMapping("/voice/record/check/{competitionId}/{userId}") - public List voiceRecordCheck(@PathVariable Long competitionId, @PathVariable Long userId) { + public List voiceRecordCheck(@PathVariable Long competitionId, @PathVariable Long userId) { return iCompetitionPracticalService.voiceRecordCheck(competitionId, userId); } diff --git a/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java b/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java index 2cb79bd3c..3366fa41a 100644 --- a/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java +++ b/src/main/java/club/joylink/rtss/controller/voice/VoiceController.java @@ -6,7 +6,7 @@ import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.VoiceRecognitionResult; -import club.joylink.rtss.vo.client.competition.VoiceErrorSetVO; +import club.joylink.rtss.vo.client.competition.VoiceErrorVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +41,7 @@ public class VoiceController { @ApiOperation("查询语音识别错误集") @GetMapping("/errorSet/paged") - public PageVO pagedQueryErrorSet(PageQueryVO queryVO) { + public PageVO pagedQueryErrorSet(PageQueryVO queryVO) { return iVoiceTrainingService.pagedQueryErrorSet(queryVO); } diff --git a/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java b/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java index 222908d17..d5a458ee8 100644 --- a/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java +++ b/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java @@ -491,7 +491,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService } @Override - public VoiceErrorSetVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO) { + public VoiceErrorVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO) { String actionContent = commandPublishStatisticVO.getActionVO().getContent(); List keyWords = commandPublishStatisticVO.getKeyWords(); CompetitionVoiceRecord record = getVoiceRecordEntity(recordId); @@ -499,7 +499,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService } @Override - public List voiceRecordCheck(Long competitionId, Long userId) { + public List voiceRecordCheck(Long competitionId, Long userId) { CompetitionWithBLOBs competitionWithBLOBs = getEntity(competitionId); CompetitionVO competitionVO = new CompetitionVO(competitionWithBLOBs); ScriptVO scriptVO = iScriptService.getDetailById(competitionWithBLOBs.getScriptId()); @@ -507,7 +507,9 @@ public class CompetitionPracticalService implements ICompetitionPracticalService return records.stream().map(record -> { List keyWords = competitionVO.getCmdPubStaVO(record.getCommandEvaluationRuleId()).getKeyWords(); String actionContent = scriptVO.getActionById(record.getActionId()).getContent(); - return voiceRecordCheck(record, actionContent, keyWords); + VoiceErrorVO errorVO = voiceRecordCheck(record, actionContent, keyWords); + errorVO.setRecordId(record.getId()); + return errorVO; }).collect(Collectors.toList()); } @@ -534,7 +536,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService return competitionVoiceRecordDAO.selectByExample(example); } - private VoiceErrorSetVO voiceRecordCheck(CompetitionVoiceRecord record, String actionContent, List keyWords) { + private VoiceErrorVO voiceRecordCheck(CompetitionVoiceRecord record, String actionContent, List keyWords) { String filePath = record.getFilePath(); String uri = IVoiceService.FileUriPrefix + filePath; byte[] bytes = restTemplate.getForObject(uri, byte[].class); @@ -543,8 +545,8 @@ public class CompetitionPracticalService implements ICompetitionPracticalService String replacedContent = competitionAndScriptManager.pronunciationCheckAndReplace(result.getResult(), actionContent, errorPNCT); List errorKW = new ArrayList<>(); competitionAndScriptManager.keyWordsCheck(replacedContent, keyWords, errorKW); - return new VoiceErrorSetVO(null, record.getUserId(), record.getCompetitionId(), record.getCommandEvaluationRuleId(), record.getActionId(), actionContent, - replacedContent, errorKW, errorPNCT, filePath); + return new VoiceErrorVO(null, record.getUserId(), record.getCompetitionId(), record.getCommandEvaluationRuleId(), record.getActionId(), actionContent, + replacedContent, errorKW, errorPNCT, filePath, record.getId()); } private CompetitionVoiceRecord getVoiceRecordEntity(Long id) { diff --git a/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java b/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java index fd7b37f03..8c493dade 100644 --- a/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java +++ b/src/main/java/club/joylink/rtss/services/completition/ICompetitionPracticalService.java @@ -126,9 +126,9 @@ public interface ICompetitionPracticalService { CompetitionVoiceRecordVO updateVoiceRecord(Long recordId, MultipartFile file, UserVO user); - VoiceErrorSetVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO); + VoiceErrorVO voiceRecordCheck(Long recordId, CommandPublishStatisticVO commandPublishStatisticVO); - List voiceRecordCheck(Long competitionId, Long userId); + List voiceRecordCheck(Long competitionId, Long userId); List queryVoiceRecords(Long userId, Long competitionId); diff --git a/src/main/java/club/joylink/rtss/services/voice/IVoiceTrainingService.java b/src/main/java/club/joylink/rtss/services/voice/IVoiceTrainingService.java index 8a72d8f37..15bc58b86 100644 --- a/src/main/java/club/joylink/rtss/services/voice/IVoiceTrainingService.java +++ b/src/main/java/club/joylink/rtss/services/voice/IVoiceTrainingService.java @@ -3,7 +3,7 @@ package club.joylink.rtss.services.voice; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.VoiceRecognitionResult; -import club.joylink.rtss.vo.client.competition.VoiceErrorSetVO; +import club.joylink.rtss.vo.client.competition.VoiceErrorVO; import org.springframework.web.multipart.MultipartFile; /** @@ -11,7 +11,7 @@ import org.springframework.web.multipart.MultipartFile; */ public interface IVoiceTrainingService { - PageVO pagedQueryErrorSet(PageQueryVO queryVO); + PageVO pagedQueryErrorSet(PageQueryVO queryVO); VoiceRecognitionResult voiceRecognition(MultipartFile file); diff --git a/src/main/java/club/joylink/rtss/services/voice/VoiceTrainingService.java b/src/main/java/club/joylink/rtss/services/voice/VoiceTrainingService.java index 98ea8f652..15ee048fa 100644 --- a/src/main/java/club/joylink/rtss/services/voice/VoiceTrainingService.java +++ b/src/main/java/club/joylink/rtss/services/voice/VoiceTrainingService.java @@ -7,7 +7,7 @@ import club.joylink.rtss.simulation.cbtc.conversation.SimulationVoiceHandler; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.VoiceRecognitionResult; -import club.joylink.rtss.vo.client.competition.VoiceErrorSetVO; +import club.joylink.rtss.vo.client.competition.VoiceErrorVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; @@ -33,10 +33,10 @@ public class VoiceTrainingService implements IVoiceTrainingService { @Override - public PageVO pagedQueryErrorSet(PageQueryVO queryVO) { + public PageVO pagedQueryErrorSet(PageQueryVO queryVO) { Page page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); List sets = competitionErrorSetDAO.selectByExample(null); - List list = sets.stream().map(VoiceErrorSetVO::new).collect(Collectors.toList()); + List list = sets.stream().map(VoiceErrorVO::new).collect(Collectors.toList()); return PageVO.convert(page, list); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionAndScriptManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionAndScriptManager.java index 98a924e38..c508a2bff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionAndScriptManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/competition/CompetitionAndScriptManager.java @@ -278,14 +278,14 @@ public class CompetitionAndScriptManager { //发音校验 List errorPNCT = new ArrayList<>(); //错误的发音 String replacedContent = pronunciationCheckAndReplace(conversationMessage.getContent(), action.getContent(), errorPNCT); - boolean match = CollectionUtils.isEmpty(errorPNCT); //发音正确 + boolean pronunciationRight = CollectionUtils.isEmpty(errorPNCT); //发音正确 //关键词校验 List errorKW = new ArrayList<>(); //错误的关键词 CommandPublishStatisticBO statistic = competition.findCommandPublishStatistic(action.getId()); boolean keyWordsRight = keyWordsCheck(replacedContent, statistic.getKeyWords(), errorKW); //关键词正确 - match = match && keyWordsRight; + pronunciationRight = pronunciationRight && keyWordsRight; - if (match) { + if (pronunciationRight) { action.finish(); applicationContext.publishEvent(new SimulationScriptActionFinishEvent(this, simulation, action)); CommandPublishStatisticBO commandPublishStatistic = competition.findCommandPublishStatistic(action.getId()); diff --git a/src/main/java/club/joylink/rtss/vo/client/competition/VoiceErrorSetVO.java b/src/main/java/club/joylink/rtss/vo/client/competition/VoiceErrorVO.java similarity index 75% rename from src/main/java/club/joylink/rtss/vo/client/competition/VoiceErrorSetVO.java rename to src/main/java/club/joylink/rtss/vo/client/competition/VoiceErrorVO.java index a9949b0b6..63452c00e 100644 --- a/src/main/java/club/joylink/rtss/vo/client/competition/VoiceErrorSetVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/competition/VoiceErrorVO.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import org.springframework.util.StringUtils; import java.util.ArrayList; @@ -13,7 +14,7 @@ import java.util.List; @Getter @NoArgsConstructor -public class VoiceErrorSetVO { +public class VoiceErrorVO { @JsonSerialize(using = ToStringSerializer.class) private Long id; @@ -27,17 +28,21 @@ public class VoiceErrorSetVO { private String actionId; - private String right = "道岔试验"; + private String right; - private String result = "刀叉试验"; + private String result; - private List keyWords = List.of("道岔"); + private List keyWords; - private List tripNumbers = List.of("2027"); + private List tripNumbers; private String filePath; - public VoiceErrorSetVO(CompetitionErrorSet set) { + @Setter + @JsonSerialize(using = ToStringSerializer.class) + private Long recordId; + + public VoiceErrorVO(CompetitionErrorSet set) { this.id = set.getId(); this.userId = set.getUserId(); this.competitionId = set.getId(); @@ -52,8 +57,8 @@ public class VoiceErrorSetVO { this.filePath = set.getFilePath(); } - public VoiceErrorSetVO(Long id, Long userId, Long competitionId, Long cmdEvaRuleId, String actionId, String right, - String result, List keyWords, List tripNumbers, String filePath) { + public VoiceErrorVO(Long id, Long userId, Long competitionId, Long cmdEvaRuleId, String actionId, String right, + String result, List keyWords, List tripNumbers, String filePath, Long recordId) { this.id = id; this.userId = userId; this.competitionId = competitionId; @@ -64,5 +69,6 @@ public class VoiceErrorSetVO { this.keyWords = keyWords; this.tripNumbers = tripNumbers; this.filePath = filePath; + this.recordId = recordId; } }