From 27c0fdd6295a9fc7802d70af8e11e89ecf1fcaf0 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 12 Oct 2023 14:23:26 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=EF=BC=9A=E8=A7=A3=E5=86=B3gamma?= =?UTF-8?q?=E5=88=86=E6=9E=90=E8=BF=87=E7=A8=8B=E9=80=9A=E8=BF=87websocket?= =?UTF-8?q?=E7=BB=99=E5=89=8D=E7=AB=AF=E6=8E=A8=E9=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 5 +- .../modules/native_jni/AnalysisProcess.java | 65 +++++++++++++++---- 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 7ff8f529..de5d9f8a 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -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 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 parseMap = JSON.parseObject(strValue, Map.class); for (Map.Entry entry:parseMap.entrySet()) { if (entry.getKey().equalsIgnoreCase("bAnalyed")) { diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/AnalysisProcess.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/AnalysisProcess.java index c9ae586f..995c8415 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/AnalysisProcess.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/native_jni/AnalysisProcess.java @@ -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 redisTemplate; + @Resource + private RedisTemplate 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) 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) 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);; + } } From a807f410c37eb2a50d015ad8771021a29abf8c20 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 12 Oct 2023 14:24:46 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix=EF=BC=9A=E8=A7=A3=E5=86=B3=E8=83=BD?= =?UTF-8?q?=E8=B0=B1=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89full=E6=88=96=E8=80=85repl=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=20=E4=B8=8D=E8=83=BD=E6=AD=A3=E7=A1=AE=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E8=83=BD=E8=B0=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/service/impl/SpectrumAnalysisServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index d1eadc03..fed6defc 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -219,7 +219,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { List> resultList = new LinkedList<>(); String userName = JwtUtil.getUserNameByToken(request); 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); 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); @@ -234,7 +234,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { for (String matchFileName :matchFileNames) { Map map =new HashMap<>(); //判断sample文件名称是否匹配正则表达式 如果满足 则查询出对应的文件信息 - if ( regexPattern.matcher(matchFileName).find() || regexPattern1.matcher(matchFileName).find() ){ + if ( regexPattern.matcher(matchFileName).find()){ //查询sampleFile文件内容信息 获取文件内容 获取大致的gas det文件名称 Map fileData = phdFileUtil.getFileData(filePath, matchFileName); if (CollectionUtils.isEmpty(fileData)) { From f838ba0a082526be349769bc8b40181ed25c3ce4 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 12 Oct 2023 14:27:04 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix=EF=BC=9Agamma=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=94=9F=E6=88=90=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/spectrum/Sample_G_Analysis.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index fe6a6756..4f0c752d 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -152,6 +152,22 @@ public class Sample_G_Analysis { // 生成日志文件 writeLog(middleData.getAnalyses_LogPath(), middleData); // 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){ e.printStackTrace(); @@ -207,7 +223,7 @@ public class Sample_G_Analysis { * @param 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(); MyLogFormatUtil myLogFormatUtil = new MyLogFormatUtil(); List writes = new LinkedList<>(); From b685cf53de26028901385bccf98f8daeaa0e9af9 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 12 Oct 2023 14:27:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=EF=BC=9Agamma=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=B8=88=E6=8E=A8=E9=80=81=E6=B6=88=E6=81=AF=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=20=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/jeecg/common/constant/WebsocketConst.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebsocketConst.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebsocketConst.java index 449b70a1..14c98f4e 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebsocketConst.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebsocketConst.java @@ -63,4 +63,9 @@ public class WebsocketConst { */ public static final String NEWS_PUBLISH = "publish"; + /** + * 消息类型 交互分析进度 + */ + public static final String CMD_ANALYSIS_PROCESS = "analysis-process"; + }