Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
nieziyan 2023-10-12 15:59:01 +08:00
commit e1aa3b0fc6
5 changed files with 81 additions and 16 deletions

View File

@ -63,4 +63,9 @@ public class WebsocketConst {
*/ */
public static final String NEWS_PUBLISH = "publish"; public static final String NEWS_PUBLISH = "publish";
/**
* 消息类型 交互分析进度
*/
public static final String CMD_ANALYSIS_PROCESS = "analysis-process";
} }

View File

@ -152,6 +152,22 @@ public class Sample_G_Analysis {
// 生成日志文件 // 生成日志文件
writeLog(middleData.getAnalyses_LogPath(), middleData); writeLog(middleData.getAnalyses_LogPath(), middleData);
// todo 报告文件 // todo 报告文件
String reportContent = gammaFileUtil.GetReportContent(phdFile, false);
String reportPath = StringUtils.substringBeforeLast(middleData.getAnalyses_ReportPath(), StringPool.SLASH);
String reportName = StringUtils.substringAfterLast(middleData.getAnalyses_ReportPath(), StringPool.SLASH) + ".txt";
String savePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + reportPath;
String tempDir = System.getProperty("java.io.tmpdir");
// 创建文件
File reportFile = FileUtil.writeString(reportContent, tempDir + System.currentTimeMillis(), "utf8");
try {
ftpUtil.saveFile(savePath, reportName, new FileInputStream(reportFile));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} finally {
if (null != reportFile) {
reportFile.delete();
}
}
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
@ -207,7 +223,7 @@ public class Sample_G_Analysis {
* @param middleData * @param middleData
*/ */
private void writeLog(String logFilePath, GStoreMiddleProcessData middleData) { private void writeLog(String logFilePath, GStoreMiddleProcessData middleData) {
logFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + logFilePath; logFilePath = StringPool.SLASH + spectrumPathProperties.getLogPath() + StringPool.SLASH + logFilePath;
String sampleId = middleData.getSample_id(); String sampleId = middleData.getSample_id();
MyLogFormatUtil myLogFormatUtil = new MyLogFormatUtil(); MyLogFormatUtil myLogFormatUtil = new MyLogFormatUtil();
List<String> writes = new LinkedList<>(); List<String> writes = new LinkedList<>();

View File

@ -55,6 +55,8 @@ public class GammaFileUtil {
@Autowired @Autowired
private NameStandUtil nameStandUtil; private NameStandUtil nameStandUtil;
@Autowired
private AnalysisProcess analysisProcess;
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) { public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) {
phd.setFilepath(pathName); phd.setFilepath(pathName);
phd.setFilename(fileName); phd.setFilename(fileName);
@ -1366,14 +1368,13 @@ public class GammaFileUtil {
} }
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){ public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
//System.loadLibrary("GammaAnaly");
//解析获取临时文件信息 //解析获取临时文件信息
File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename()); File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename());
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
try { try {
String phdStr = mapper.writeValueAsString(phd); String phdStr = mapper.writeValueAsString(phd);
String nuclideLinesMap = mapper.writeValueAsString(mapLines); 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); Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
for (Map.Entry<String, Object> entry:parseMap.entrySet()) { for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
if (entry.getKey().equalsIgnoreCase("bAnalyed")) { if (entry.getKey().equalsIgnoreCase("bAnalyed")) {

View File

@ -1,20 +1,63 @@
package org.jeecg.modules.native_jni; 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 { public class AnalysisProcess {
// @Autowired @Resource
// private RedisTemplate<String, Object> redisTemplate; private RedisTemplate<String, Object> redisTemplate;
public void gammaProcess(String userId, String process){ public void gammaProcess(String userId, String process){
// BaseMap params = new BaseMap(); if (null == redisTemplate) {
// params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER); redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
// params.put("userId", userId); }
// // userId, fileName, process BaseMap params = new BaseMap();
// params.put("message", process); params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
// String str = ""; params.put("userId", userId);
// JSON.parseObject(str, PHDFile.class); JSONObject obj = new JSONObject();
// // 通过 redis 订阅发送 websocket 消息 // 消息类型
// redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; 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); 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);;
}
} }

View File

@ -219,7 +219,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
List<Map<String, Object>> resultList = new LinkedList<>(); List<Map<String, Object>> resultList = new LinkedList<>();
String userName = JwtUtil.getUserNameByToken(request); String userName = JwtUtil.getUserNameByToken(request);
String filePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName; String filePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH +userName;
String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.PHD"; String sampleRx = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S.*.PHD";
Pattern regexPattern = Pattern.compile(sampleRx); Pattern regexPattern = Pattern.compile(sampleRx);
String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD"; String sampleRx1 = "[a-zA-Z]{3}[0-9]{2}_[0-9]{3}-[0-9]{8}_[0-9]{4}_S_(FULL_|PREL_)\\d+\\.\\d+\\.PHD";
Pattern regexPattern1 = Pattern.compile(sampleRx1); Pattern regexPattern1 = Pattern.compile(sampleRx1);
@ -234,7 +234,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
for (String matchFileName :matchFileNames) { for (String matchFileName :matchFileNames) {
Map<String, Object> map =new HashMap<>(); Map<String, Object> map =new HashMap<>();
//判断sample文件名称是否匹配正则表达式 如果满足 则查询出对应的文件信息 //判断sample文件名称是否匹配正则表达式 如果满足 则查询出对应的文件信息
if ( regexPattern.matcher(matchFileName).find() || regexPattern1.matcher(matchFileName).find() ){ if ( regexPattern.matcher(matchFileName).find()){
//查询sampleFile文件内容信息 获取文件内容 获取大致的gas det文件名称 //查询sampleFile文件内容信息 获取文件内容 获取大致的gas det文件名称
Map<String, String> fileData = phdFileUtil.getFileData(filePath, matchFileName); Map<String, String> fileData = phdFileUtil.getFileData(filePath, matchFileName);
if (CollectionUtils.isEmpty(fileData)) { if (CollectionUtils.isEmpty(fileData)) {