Browse Source

add:暂存

zhongwei
haungxing 8 months ago
parent
commit
24bc529965
  1. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/DateEnum.java
  2. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/AnalyseDataServiceImpl.java
  3. 14
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  4. 23
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java

1
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), HOUR("hour","每小时","按小时",2,2),
MINUTE("minute","每分钟","按分钟",1,1), MINUTE("minute","每分钟","按分钟",1,1),
SECOND("second","每秒","按秒",0,0), SECOND("second","每秒","按秒",0,0),
USUAL("usual","详情","按秒",0,0)
; ;
@Getter @Getter
private String code; private String code;

4
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() + "_" String label = searchVO.getStationName() + "_"
+ searchVO.getDeviceName() + "_" + searchVO.getDeviceName() + "_"
+ dataVO.getFieldMap().get(searchVO.getSignage()) + "_" + dataVO.getFieldMap().get(searchVO.getSignage()) + "_"
+ adapterDate.getName() + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : adapterDate.getName())
+ enumByMethod.getMethod() + enumByMethod.getMethod()
+ note + (DataMethodEnum.USUAL.getMethod().equals(enumByMethod.getMethod()) ? "" : note)
+ ":"; + ":";
extraVO.setLabel(label); extraVO.setLabel(label);
params.put("data",datalist); params.put("data",datalist);

14
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"); extraVO.setFuncCode("stations_num");
String label; String label;
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); 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); label = String.format("自%s到%s时间为止,",startTime,endTime);
} }
else { else {
@ -239,12 +239,20 @@ public class InteractiveServiceImpl implements IInteractiveService {
logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body());
} }
result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> { result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> {
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId());
Object[] extras = answerVO.getExtras(); Object[] extras = answerVO.getExtras();
if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){ if(ObjectUtil.isEmpty(answerVO.getExtras()) || extras.length == 0){
return; return;
} }
List<String> extraList = Arrays.stream(extras).map(Object::toString).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); try {
answerVO.setExtras(extraList.toArray(new String[extraList.size()])); List<String> 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; return result;
} }

23
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; return ReturnT.SUCCESS;
} }
List<AnswerVO> answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); List<AnswerVO> answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds));
answerList.parallelStream().forEach(answerVO -> CompletableFuture.runAsync(() -> { for (AnswerVO answerVO : answerList) {
XxlJobLogger.log("开始获取" + answerVO.getSessionId() + "答案!"); Runnable task = () -> {
if(sessionIds.contains(answerVO.getSessionId())){ if(sessionIds.contains(answerVO.getSessionId())){
WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId());
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
if(Func.isNotEmpty(session)) { if(Func.isNotEmpty(session)) {
wsService.sendMessage(session,message); wsService.sendMessage(session,message);
}
} }
} };
if(answerVO.getRunning() == 0) { getAnswerPoolExecutor.submit(task);
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); }
}
}, getAnswerPoolExecutor));
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }

Loading…
Cancel
Save