fix: gamma分析进度通过 redis 订阅发送 webSocket 消息
This commit is contained in:
parent
2d0ea1e754
commit
9c9fbbb80e
|
@ -0,0 +1,11 @@
|
||||||
|
package org.jeecg.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Websocket Redis Monitor Handler
|
||||||
|
*/
|
||||||
|
public class WebSocketHandlerConst {
|
||||||
|
/**
|
||||||
|
* Gamma 分析
|
||||||
|
*/
|
||||||
|
public static final String GAMMA_ANALYSIS_HANDLER = "gammaAnalysisHandler";
|
||||||
|
}
|
|
@ -3,10 +3,16 @@ package org.jeecg.modules.controller;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.base.BaseMap;
|
||||||
|
import org.jeecg.common.constant.GlobalConstants;
|
||||||
|
import org.jeecg.common.constant.WebSocketHandlerConst;
|
||||||
import org.jeecg.modules.base.bizVo.GammaRLR;
|
import org.jeecg.modules.base.bizVo.GammaRLR;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysUser;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
|
import org.jeecg.modules.feignclient.SystemClient;
|
||||||
import org.jeecg.modules.service.IGammaService;
|
import org.jeecg.modules.service.IGammaService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@ -22,12 +28,30 @@ public class GammaController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IGammaService gammaService;
|
private IGammaService gammaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemClient systemClient;
|
||||||
|
|
||||||
@GetMapping("initValue")
|
@GetMapping("initValue")
|
||||||
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
|
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
|
||||||
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
|
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
|
||||||
return gammaService.initValue(sampleId, dbName, request);
|
return gammaService.initValue(sampleId, dbName, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("analysisProcess")
|
||||||
|
@ApiOperation(value = "分析进度", notes = "分析进度")
|
||||||
|
public void message(String message) {
|
||||||
|
Result<SysUser> user = systemClient.getUserData();
|
||||||
|
BaseMap params = new BaseMap();
|
||||||
|
params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
|
||||||
|
params.put("userId", user.getResult().getId());
|
||||||
|
params.put("message", message);
|
||||||
|
// 通过 redis 订阅发送 websocket 消息
|
||||||
|
redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("testFun")
|
@GetMapping("testFun")
|
||||||
public Result testFun(String fileName){
|
public Result testFun(String fileName){
|
||||||
return gammaService.testFun(fileName);
|
return gammaService.testFun(fileName);
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.jeecg.modules.feignclient;
|
||||||
|
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysUser;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@FeignClient("jeecg-system")
|
||||||
|
public interface SystemClient {
|
||||||
|
|
||||||
|
/* 获取当前用户信息 */
|
||||||
|
@GetMapping("/sys/user/login/setting/getUserData")
|
||||||
|
Result<SysUser> getUserData();
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package org.jeecg.modules.message.handle;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.jeecg.common.base.BaseMap;
|
||||||
|
import org.jeecg.common.constant.WebSocketHandlerConst;
|
||||||
|
import org.jeecg.common.modules.redis.listener.JeecgRedisListener;
|
||||||
|
import org.jeecg.modules.message.websocket.WebSocket;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分析进度
|
||||||
|
* @author xiao
|
||||||
|
* @date: 9 月 22 日
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component(WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER)
|
||||||
|
public class AnalysisHandler implements JeecgRedisListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WebSocket webSocket;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(BaseMap message) {
|
||||||
|
webSocket.sendMessage(message.get("userId").toString(), message.get("message"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user