|
|
@ -4,9 +4,13 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.UpdateStationVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.bigmodel.interactive.vo.UpdateUsualVO; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.service.InteractiveWsService; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
|
|
|
import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.station.feign.IStationClient; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; |
|
|
|
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; |
|
|
@ -25,7 +29,9 @@ import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.web.socket.TextMessage; |
|
|
|
import org.springframework.web.socket.TextMessage; |
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -54,8 +60,33 @@ public class InteractiveSchedule { |
|
|
|
|
|
|
|
|
|
|
|
private final ScadaClient scadaClient; |
|
|
|
private final ScadaClient scadaClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IStationClient stationClient; |
|
|
|
|
|
|
|
|
|
|
|
private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; |
|
|
|
private final static String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @XxlJob(GET_INTERACTIVE_RESULT)
|
|
|
|
|
|
|
|
// public ReturnT execute(String params) {
|
|
|
|
|
|
|
|
// String resultKey = ParamCache.getValue(GET_INTERACTIVE_RESULT);
|
|
|
|
|
|
|
|
// Set<String> keySet = redisTemplate.keys(resultKey + "*");
|
|
|
|
|
|
|
|
// keySet.parallelStream().forEach(key -> {
|
|
|
|
|
|
|
|
// // 根据Key获取sessionId
|
|
|
|
|
|
|
|
// List<String> keySplits = Func.toStrList(":", key);
|
|
|
|
|
|
|
|
// String sessionId = keySplits.get(2);
|
|
|
|
|
|
|
|
// // 查询websocket是否存在连接session
|
|
|
|
|
|
|
|
// WebSocketSession session = InteractiveSessionManager.get(sessionId);
|
|
|
|
|
|
|
|
// if(session == null) {
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// TextMessage message = new TextMessage(JSON.toJSONString(redisTemplate.opsForValue().get(key)));
|
|
|
|
|
|
|
|
// Boolean sendResult = wsService.sendMessage(sessionId, message);
|
|
|
|
|
|
|
|
// Assert.isTrue(sendResult, () -> {
|
|
|
|
|
|
|
|
// throw new ServiceException(key + "推送消息失败,推送消息体为:" + JSON.toJSONString(redisTemplate.opsForValue().get(key)));
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// redisTemplate.delete(key);
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// return ReturnT.SUCCESS;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@XxlJob(GET_INTERACTIVE_RESULT) |
|
|
|
@XxlJob(GET_INTERACTIVE_RESULT) |
|
|
|
public ReturnT getInteractiveResult(String params) { |
|
|
|
public ReturnT getInteractiveResult(String params) { |
|
|
|
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); |
|
|
|
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); |
|
|
@ -85,11 +116,36 @@ public class InteractiveSchedule { |
|
|
|
|
|
|
|
|
|
|
|
@XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT) |
|
|
|
@XxlJob(SYNCHRONOUS_VIDEO_INSTRUCT) |
|
|
|
public ReturnT synchronousVideoInstruct(String params) { |
|
|
|
public ReturnT synchronousVideoInstruct(String params) { |
|
|
|
|
|
|
|
Map<String,Object> request = new HashMap<>(2); |
|
|
|
|
|
|
|
// 获取站点列表
|
|
|
|
|
|
|
|
R<List<StationEntity>> stationsR = stationClient.list(new StationEntity()); |
|
|
|
|
|
|
|
if(!stationsR.isSuccess() || CollectionUtil.isEmpty(stationsR.getData())) { |
|
|
|
|
|
|
|
XxlJobLogger.log("获取站点列表失败!"); |
|
|
|
|
|
|
|
return ReturnT.FAIL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<UpdateStationVO> updateStationList = stationsR.getData().stream().map(station -> { |
|
|
|
|
|
|
|
UpdateStationVO stationVO = new UpdateStationVO(); |
|
|
|
|
|
|
|
stationVO.setId(station.getCode()); |
|
|
|
|
|
|
|
stationVO.setName(station.getName()); |
|
|
|
|
|
|
|
return stationVO; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
request.put("stations", updateStationList); |
|
|
|
|
|
|
|
// 获取视频列表
|
|
|
|
R<List<StationVideoTypeEntity>> videoListR = videoClient.list(new StationVideoTypeEntity()); |
|
|
|
R<List<StationVideoTypeEntity>> videoListR = videoClient.list(new StationVideoTypeEntity()); |
|
|
|
if(videoListR.isSuccess()) { |
|
|
|
if(!videoListR.isSuccess() || CollectionUtil.isEmpty(videoListR.getData())) { |
|
|
|
List<StationVideoTypeEntity> stationVideoList = videoListR.getData(); |
|
|
|
XxlJobLogger.log("获取视频列表失败!"); |
|
|
|
//TODO 同步站点视频指令
|
|
|
|
return ReturnT.FAIL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<UpdateUsualVO> updateUsualList = videoListR.getData().stream().map(video -> { |
|
|
|
|
|
|
|
UpdateUsualVO usualVO = new UpdateUsualVO(); |
|
|
|
|
|
|
|
usualVO.setStationId(video.getStationId()); |
|
|
|
|
|
|
|
usualVO.setId(String.valueOf(video.getId())); |
|
|
|
|
|
|
|
usualVO.setName(video.getName()); |
|
|
|
|
|
|
|
return usualVO; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
request.put("videos", updateUsualList); |
|
|
|
|
|
|
|
// 同步指令
|
|
|
|
|
|
|
|
interactiveService.updateVideo(request); |
|
|
|
return ReturnT.SUCCESS; |
|
|
|
return ReturnT.SUCCESS; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|