fix:解决gamma分析过程通过websocket给前端推送消息失败问题
This commit is contained in:
parent
df34dd9199
commit
27c0fdd629
|
@ -55,6 +55,8 @@ public class GammaFileUtil {
|
|||
@Autowired
|
||||
private NameStandUtil nameStandUtil;
|
||||
|
||||
@Autowired
|
||||
private AnalysisProcess analysisProcess;
|
||||
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) {
|
||||
phd.setFilepath(pathName);
|
||||
phd.setFilename(fileName);
|
||||
|
@ -1366,14 +1368,13 @@ public class GammaFileUtil {
|
|||
}
|
||||
|
||||
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
|
||||
//System.loadLibrary("GammaAnaly");
|
||||
//解析获取临时文件信息
|
||||
File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
String phdStr = mapper.writeValueAsString(phd);
|
||||
String nuclideLinesMap = mapper.writeValueAsString(mapLines);
|
||||
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath(), new AnalysisProcess());
|
||||
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath(), analysisProcess);
|
||||
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
|
||||
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
|
||||
|
|
|
@ -1,20 +1,63 @@
|
|||
package org.jeecg.modules.native_jni;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.common.constant.WebsocketConst;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.base.entity.postgre.SysUser;
|
||||
import org.jeecg.modules.entity.vo.PHDFile;
|
||||
import org.jeecg.modules.feignclient.SystemClient;
|
||||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
public class AnalysisProcess {
|
||||
|
||||
// @Autowired
|
||||
// private RedisTemplate<String, Object> redisTemplate;
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
|
||||
public void gammaProcess(String userId, String process){
|
||||
// BaseMap params = new BaseMap();
|
||||
// params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
|
||||
// params.put("userId", userId);
|
||||
// // userId, fileName, process
|
||||
// params.put("message", process);
|
||||
// String str = "";
|
||||
// JSON.parseObject(str, PHDFile.class);
|
||||
// // 通过 redis 订阅发送 websocket 消息
|
||||
// redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);;
|
||||
if (null == redisTemplate) {
|
||||
redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
|
||||
}
|
||||
BaseMap params = new BaseMap();
|
||||
params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
|
||||
params.put("userId", userId);
|
||||
JSONObject obj = new JSONObject();
|
||||
// 消息类型
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_ANALYSIS_PROCESS);
|
||||
// obj.put(WebsocketConst.MSG_ID, "M0001");
|
||||
// 消息内容
|
||||
obj.put(WebsocketConst.MSG_TXT, process);
|
||||
params.put("message", obj.toJSONString());
|
||||
// 通过 redis 订阅发送 websocket 消息
|
||||
redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);
|
||||
System.out.println(userId+"-----"+process);
|
||||
}
|
||||
public void process(String userId, String process){
|
||||
redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
|
||||
BaseMap params = new BaseMap();
|
||||
params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
|
||||
params.put("userId", userId);
|
||||
|
||||
// userId, fileName, process
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_ANALYSIS_PROCESS);
|
||||
// obj.put(WebsocketConst.MSG_ID, "M0001");
|
||||
obj.put(WebsocketConst.MSG_TXT, process);
|
||||
params.put("message", obj.toJSONString());
|
||||
String str = "";
|
||||
JSON.parseObject(str, PHDFile.class);
|
||||
// 通过 redis 订阅发送 websocket 消息
|
||||
redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user