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),
MINUTE("minute","每分钟","按分钟",1,1),
SECOND("second","每秒","按秒",0,0),
USUAL("usual","详情","按秒",0,0)
;
@Getter
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() + "_"
+ 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);

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");
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<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()]));
try {
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;
}

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;
}
List<AnswerVO> 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;
}

Loading…
Cancel
Save