From 24bc529965b4d3b08434431137f3a763e072dbd0 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Thu, 30 May 2024 15:37:17 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/constants/DateEnum.java | 1 + .../service/impl/AnalyseDataServiceImpl.java | 4 ++-- .../service/impl/InteractiveServiceImpl.java | 14 ++++++++++--- .../bigmodel/schedule/InteractiveSchedule.java | 23 +++++++++++----------- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java index 019f2ef..a615988 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java @@ -17,6 +17,7 @@ public enum DateEnum { HOUR("hour","每小时","按小时",2,2), MINUTE("minute","每分钟","按分钟",1,1), SECOND("second","每秒","按秒",0,0), + USUAL("usual","详情","按秒",0,0) ; @Getter private String code; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java index 2385bca..aac20c6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java @@ -73,9 +73,9 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { String label = searchVO.getStationName() + "_" + searchVO.getDeviceName() + "_" + dataVO.getFieldMap().get(searchVO.getSignage()) + "_" - + adapterDate.getName() + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName()) + enumByMethod.getMethod() - + note + + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note) + ":"; extraVO.setLabel(label); params.put("data",datalist); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 1531362..ba92539 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -109,7 +109,7 @@ public class InteractiveServiceImpl implements IInteractiveService { extraVO.setFuncCode("stations_num"); String label; SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); - if(!startTime.equals(endTime)) { + if(!startTime.equals(endTime) && SearchTypeEnum.HISTORY.getSearchType().equals(type)) { label = String.format("自%s到%s时间为止,",startTime,endTime); } else { @@ -239,12 +239,20 @@ public class InteractiveServiceImpl implements IInteractiveService { logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); } result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); Object[] extras = answerVO.getExtras(); if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){ return; } - List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); - answerVO.setExtras(extraList.toArray(new String[extraList.size()])); + try { + List extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); + answerVO.setExtras(extraList.toArray(new String[extraList.size()])); + } + catch(Exception e) { + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,answerVO.getSessionId()); + e.printStackTrace(); + throw new RuntimeException(e); + } }); return result; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index e145733..6d02c9c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -97,19 +97,18 @@ public class InteractiveSchedule { return ReturnT.SUCCESS; } List answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); - answerList.parallelStream().forEach(answerVO -> CompletableFuture.runAsync(() -> { - XxlJobLogger.log("开始获取" + answerVO.getSessionId() + "答案!"); - if(sessionIds.contains(answerVO.getSessionId())){ - WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - if(Func.isNotEmpty(session)) { - wsService.sendMessage(session,message); + for (AnswerVO answerVO : answerList) { + Runnable task = () -> { + if(sessionIds.contains(answerVO.getSessionId())){ + WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); + if(Func.isNotEmpty(session)) { + wsService.sendMessage(session,message); + } } - } - if(answerVO.getRunning() == 0) { - redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); - } - }, getAnswerPoolExecutor)); + }; + getAnswerPoolExecutor.submit(task); + } return ReturnT.SUCCESS; }