diff --git a/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java b/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java index 067f67f8a..db1e16d5b 100644 --- a/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java +++ b/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java @@ -60,7 +60,8 @@ public class TrainingV2PublishController { * @return */ @PostMapping("/manage/infos") - public PageVO findTrainingListManageInfosForPage(@RequestBody PublishedTrainingListRspVo vo){ + public PageVO findTrainingListManageInfosForPage(@RequestBody PublishedTrainingListRspVo vo,@RequestAttribute(AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO userInfoVO){ + vo.setOrgId(userInfoVO.getTopOrgId()); return this.publishService.findTrainingInfoForPage(vo); } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java index 3635570da..e30ab525a 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java @@ -78,7 +78,7 @@ public class Training2PublishService { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(orgId),"组织信息不能为空"); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(type),"查询类型信息不能为空"); criteria.andMapIdEqualTo(mapId); -// c.andOrgIdEqualTo(orgId); + criteria.andOrgIdEqualTo(orgId); criteria.andTypeEqualTo(type); criteria.andStateEqualTo(1);//上架 } diff --git a/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceParseServiceImpl.java b/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceParseServiceImpl.java index 41fbdd2bd..c9f3d909f 100644 --- a/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceParseServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/voice/discriminate/VoiceParseServiceImpl.java @@ -132,24 +132,24 @@ public class VoiceParseServiceImpl implements VoiceParseService { */ private void paramExtract(Simulation simulation, VoiceDiscriminateResult result) { List paramsRules = result.getRule().getParamsRules(); - List paramExtractResults = new ArrayList<>(paramsRules.size()); - int groupSize = result.getGroupCount(); boolean hasEmpty = paramsRules.stream().anyMatch(d->ArrayUtils.isEmpty(d.getIndexArr())); if(hasEmpty){ log.error("参数解析配置数据错误,原文:[{}],匹配规则:[{}]",result.getOriginContent(),result.getRule().getKeyWordRules()); throw new BusinessException(BusinessExceptionAssertEnum.VOICE_COMMAND_CONFIG_NULL); } - paramsRules.stream().flatMap(d-> Arrays.stream(d.getIndexArr())).anyMatch(d->groupSize < d); + boolean paramError = paramsRules.stream().flatMap(d-> Arrays.stream(d.getIndexArr())).anyMatch(item-> result.getGroupCount() < item); + if(paramError){ + log.error("提取参数出错,原文:[{}],匹配规则:[{}]",result.getOriginContent(),result.getRule().getKeyWordRules()); + result.setSuccess(false); + result.setMsg("提取参数出错"); + return; + } + List paramExtractResults = new ArrayList<>(paramsRules.size()); for (ParamExtractRule rule : paramsRules) { String[] originGroupArr = new String[rule.getIndexArr().length]; String[] correctGroupArr = new String[rule.getIndexArr().length]; for (int index = 0, len = originGroupArr.length; index < len; index ++) { - if (groupSize < rule.getIndexArr()[index]) { - result.setSuccess(false); - result.setMsg("提取参数出错"); - return; - } Integer paramIndex = rule.getIndexArr()[index]; originGroupArr[index] = result.getGroup(paramIndex); correctGroupArr[index] = result.getCorrectGroup(paramIndex); diff --git a/src/test/java/club/joylink/rtss/services/voice/SimulationVoiceSwitchTest.java b/src/test/java/club/joylink/rtss/services/voice/SimulationVoiceSwitchTest.java index f30c83427..ad46a7224 100644 --- a/src/test/java/club/joylink/rtss/services/voice/SimulationVoiceSwitchTest.java +++ b/src/test/java/club/joylink/rtss/services/voice/SimulationVoiceSwitchTest.java @@ -10,13 +10,17 @@ import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.project.ProjectVO; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.task.TaskExecutor; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.util.FileCopyUtils; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.List; +import java.util.concurrent.TimeUnit; @SpringBootTest public class SimulationVoiceSwitchTest { @@ -27,6 +31,9 @@ public class SimulationVoiceSwitchTest { private SimulationManager simulationManager; @Autowired private VoiceDiscriminateService voiceDiscriminateService; + @Autowired + @Qualifier("voiceDiscriminateExecutor") + private TaskExecutor voiceDiscriminateExecutor; private LoginUserInfoVO getInfo(){ String testJsonData = "{\"accountVO\":{\"id\":\"8146\",\"account\":\"13992867352\",\"type\":\"2\",\"nickname\":\"13992867352\",\"mobile\":\"13992867352\",\"password\":\"e10adc3949ba59abbe56e057f20f883e\",\"roles\":[\"01\",\"05\"],\"email\":\"\",\"status\":\"1\",\"companyId\":124,\"companyName\":\"默认组织\",\"companyAdmin\":false,\"projectCodes\":[\"BJD\",\"CGY\",\"DEFAULT\",\"DRTS\",\"HEB\",\"HYD_RAILWAY\",\"JJJLM\",\"JXGM\",\"NOLOGO\",\"RICHOR\",\"RICHOR_CXJS\",\"RICHOR_HHCJ\",\"RICHOR_JOINT\",\"RICHOR_YGY\",\"SR_SANDBOX\",\"THAILAND_SANDBOX\",\"WJLS\",\"YJDDZH\",\"ZZWW\",\"ZZWWTEST\"]},\"client\":\"Joylink\",\"project\":\"DEFAULT\",\"token\":\"34a5b6916e60eea26a53c820c644c4e8\",\"projectDeviceLogin\":false,\"wechatLogin\":false,\"topOrgId\":124,\"dispatcherRaceTrainingLogin\":false}\n"; @@ -39,29 +46,31 @@ public class SimulationVoiceSwitchTest { return infoVO; } - private String findLocalVoiceFileData(String filePath) throws IOException { - File file = new File(filePath); - String fileBase64 = FileCopyUtils.copyToString(new FileReader(file)); - return fileBase64; - } @Test - public void testSource(){ + public void testSource() throws InterruptedException { LoginUserInfoVO userInfoVO = this.getInfo(); String simKey = simulationService.createSimulation(10641L,userInfoVO); Simulation simulation = (Simulation)this.simulationManager.getById(simKey); // simulation.setVoiceRuleList(); voiceDiscriminateService.doAnalysis(simulation,"办理道岔w0101定位123123"); + ThreadPoolTaskExecutor poolTaskExecutor = (ThreadPoolTaskExecutor) this.voiceDiscriminateExecutor; + while(poolTaskExecutor.getActiveCount() > 0){ + TimeUnit.SECONDS.sleep(5); + } } @Test - public void testSwitchFan(){ + public void testSwitchFan() throws InterruptedException { LoginUserInfoVO userInfoVO = this.getInfo(); String simKey = simulationService.createSimulation(10641L,userInfoVO); Simulation simulation = (Simulation)this.simulationManager.getById(simKey); -// simulation.setVoiceRuleList(); voiceDiscriminateService.doAnalysis(simulation,"办理道岔w0101反位123123"); + ThreadPoolTaskExecutor poolTaskExecutor = (ThreadPoolTaskExecutor) this.voiceDiscriminateExecutor; + while(poolTaskExecutor.getActiveCount() > 0){ + TimeUnit.SECONDS.sleep(5); + } } }