|
|
|
@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.schedule;
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.impl.ExtraResolveStrategyService; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO; |
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO; |
|
|
|
@ -32,10 +33,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.web.socket.TextMessage; |
|
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -66,6 +64,8 @@ public class InteractiveSchedule {
|
|
|
|
|
|
|
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
|
|
private final ExtraResolveStrategyService extraResolveStrategyService; |
|
|
|
|
|
|
|
|
|
// @XxlJob(GET_INTERACTIVE_RESULT)
|
|
|
|
|
// public ReturnT execute(String params) {
|
|
|
|
|
// String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT);
|
|
|
|
@ -97,8 +97,23 @@ public class InteractiveSchedule {
|
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
List<AnswerVO> answerList = interactiveService.getAnswerBySessionIds(String.join(",", sessionIds)); |
|
|
|
|
for (AnswerVO answerVO : answerList) { |
|
|
|
|
Runnable task = () -> { |
|
|
|
|
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> { |
|
|
|
|
// 如果已经获取到答案 则删除缓存
|
|
|
|
|
if(answerVO.getRunning() == 0) { |
|
|
|
|
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); |
|
|
|
|
} |
|
|
|
|
Object[] extras = answerVO.getExtras(); |
|
|
|
|
if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(sessionIds.contains(answerVO.getSessionId())){ |
|
|
|
|
WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); |
|
|
|
|
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); |
|
|
|
@ -106,9 +121,7 @@ public class InteractiveSchedule {
|
|
|
|
|
wsService.sendMessage(session,message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
getAnswerPoolExecutor.submit(task); |
|
|
|
|
} |
|
|
|
|
}, getAnswerPoolExecutor)); |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|