From 6d641930021f7b45f1d5c8bcc53f6b585934b4f8 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 22 Sep 2023 11:22:37 +0800 Subject: [PATCH 1/5] =?UTF-8?q?gamma=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95dl?= =?UTF-8?q?l=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 90 +++++-------------- .../modules/controller/GammaController.java | 5 ++ .../modules/native_jni/CalValuesHandler.java | 5 +- .../jeecg/modules/service/IGammaService.java | 2 + .../service/impl/GammaServiceImpl.java | 31 ++++++- 5 files changed, 63 insertions(+), 70 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index a5b84b9d..a315cfcc 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool; import org.apache.commons.lang3.StringUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPFile; import org.ejml.simple.SimpleMatrix; import org.jeecg.common.api.vo.Result; import org.jeecg.common.properties.SpectrumPathProperties; @@ -366,12 +365,10 @@ public class GammaFileUtil { String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; inputStream = ftpClient.retrieveFileStream(baselineFileName); if (Objects.nonNull(inputStream)){ - //声明一个临时文件 - File file = File.createTempFile("tmp", null); - //将ftp文件的输入流复制给临时文件 - FileUtils.copyInputStreamToFile(inputStream, file); - List readLines = FileUtils.readLines(file, "UTF-8"); - ReadBaseCtrlInfo(phd,readLines); + long start = System.currentTimeMillis(); + ReadBaseCtrlInfo(phd, inputStream); + long end = System.currentTimeMillis(); + System.out.println(end-start); phd.setVBase(phd.getBaseCtrls().getBaseline()); } } catch (IOException e) { @@ -426,61 +423,7 @@ public class GammaFileUtil { return vData; } - public void ReadBaseCtrlInfo(PHDFile phd, List readLines) { - for (int i=0; i< readLines.size(); i++){ - String line = readLines.get(i); - if (line.contains("#")){ - String block_name = line.trim(); - int j=i+1; - line = readLines.get(j); - String block_data = line; - while(j!= readLines.size()-1 && StringUtils.isNotBlank(line)) { - j++; - line = readLines.get(j); - if (!line.contains("#")){ - block_data += StringPool.SPACE + line; - }else { - break; - } - } - i=j-1; - block_data = block_data.trim(); - List str_list = Arrays.asList(block_data.split("\\s+")); - if(str_list.size() < 1){ - continue; - } - List vTemp = new LinkedList<>(); - for(String str:str_list) { - if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ - double d = Double.valueOf(str); - vTemp.add(d); - } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { - vTemp.add(0.0); - } - } - if(block_name.contains("#AnalyseRange")) { - if(vTemp.size() == 2) { - phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); - phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); - } - } else if(block_name.contains("#XCtrl")) { - phd.getBaseCtrls().setXCtrl(vTemp); - } else if(block_name.contains("#YCtrl")) { - phd.getBaseCtrls().setYCtrl(vTemp); - } else if(block_name.contains("#YSlope")) { - phd.getBaseCtrls().setYSlope(vTemp); - } else if(block_name.contains("#Baseline")) { - List list = vTemp.subList(1, vTemp.size()); - phd.getBaseCtrls().setBaseline(list); - } else if(block_name.contains("#StepCounts")) { - List list = vTemp.subList(1, vTemp.size()); - phd.getBaseCtrls().setStepCounts(list); - } - } - } - } - - public void ReadBaseCtrlInfo(PHDFile phd, InputStream in){ + public void ReadBaseCtrlInfo(PHDFile phd, InputStream in) { try { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line ; @@ -509,20 +452,25 @@ public class GammaFileUtil { phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); } - } else if(map.containsKey("#XCtrl")) { + } + if(map.containsKey("#XCtrl")) { List vTemp = map.get("#XCtrl"); phd.getBaseCtrls().setXCtrl(vTemp); - } else if(map.containsKey("#YCtrl")) { + } + if(map.containsKey("#YCtrl")) { List vTemp = map.get("#YCtrl"); phd.getBaseCtrls().setYCtrl(vTemp); - } else if(map.containsKey("#YSlope")) { + } + if(map.containsKey("#YSlope")) { List vTemp = map.get("#YSlope"); phd.getBaseCtrls().setYSlope(vTemp); - } else if(map.containsKey("#Baseline")) { + } + if(map.containsKey("#Baseline")) { List vTemp = map.get("#Baseline"); List list = vTemp.subList(1, vTemp.size()); phd.getBaseCtrls().setBaseline(list); - } else if(map.containsKey("#StepCounts")) { + } + if(map.containsKey("#StepCounts")) { List vTemp = map.get("#StepCounts"); List list = vTemp.subList(1, vTemp.size()); phd.getBaseCtrls().setStepCounts(list); @@ -2761,6 +2709,14 @@ public class GammaFileUtil { return strBuffer.toString(); } + public List DoubleLimit_L(List data) { + List rData = new LinkedList<>(); + for(int pos=0;pos DoubleLimit(List data) { List rData = new LinkedList<>(); for(int pos=0;pos certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta); - public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta); + public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta, List Peaks); - public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta); + public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta, double ECutLow, double ECutHigh, double deltaE, double pssLow); public static native String fitPeakFull(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index 5423acf1..b9bf8285 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -13,6 +13,8 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName, HttpServletRequest request); + Result testFun(String fileName); + Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByFile(String fileName, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 70d242f7..e6b0055e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -143,6 +143,35 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result testFun(String fileName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + Map map = new HashMap<>(); + System.loadLibrary("GammaAnaly"); +// List baseInfo_s_Energy = CalValuesHandler.calValues(0, phd.getSpec().getCounts().size()); +// map.put("baseInfo_s_Energy", baseInfo_s_Energy); +// List baseInfo_s_fwhmcAll = CalValuesHandler.GetFwhmcAll(phd.getSpec().getCounts().size()); +// map.put("baseInfo_s_fwhmcAll", baseInfo_s_fwhmcAll); +// List baseInfo_s_Lc = CalValuesHandler.calculateLC(phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll, phd.getSetting().getRiskLevelK()); +// map.put("baseInfo_s_Lc", baseInfo_s_Lc); +// List values = gammaFileUtil.DoubleLimit_L(phd.getSpec().getCounts()); +// List baseInfo_s_Scac = CalValuesHandler.calculateSCAC(values, phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll); +// map.put("baseInfo_s_Scac", baseInfo_s_Scac); +// boolean armaAny = CalValuesHandler.armaAny(values); +// map.put("armaAny", armaAny); + String dataType = phd.getMsgInfo().getData_type().substring(0, 1); + List gEnergy = phd.getCertificate().getG_energy(); + String calUpdateStr = CalValuesHandler.calUpdate(dataType, gEnergy, true, true, true, phd.getSetting().isKeepCalPeakSearchPeaks(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta()); + map.put("calUpdateStr", calUpdateStr); +// CalValuesHandler.peakSearch(phd.getSetting().getECutAnalysis_Low(), phd.getSetting().getECutAnalysis_High(), +// phd.getSetting().getEnergyTolerance(), phd.getSetting().getPSS_low(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta(), phd.getVPeak()); + result.setSuccess(true); + result.setResult(map); + return result; + } + @Override public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); @@ -1851,7 +1880,7 @@ public class GammaServiceImpl implements IGammaService { String fileName = file.getOriginalFilename(); //从最后一个。切割文件名称 获取文件名称后缀 String fileSuffix = fileName.substring(fileName.lastIndexOf(StringPool.DOT)); - if (fileSuffix.equalsIgnoreCase(".eft")) { + if (fileSuffix.equalsIgnoreCase(".eft") || fileSuffix.equalsIgnoreCase(".ent")) { Map map = new HashMap<>(); List m_vCurEffi = new LinkedList<>(); List m_vCurEnergy = new LinkedList<>(); From e32e1085f1fc5d9bfd08aeb8566c3dabb9c06900 Mon Sep 17 00:00:00 2001 From: orgin Date: Fri, 22 Sep 2023 13:49:55 +0800 Subject: [PATCH 2/5] delete --- .../java/org/jeecg/common/NameStandUtil.java | 196 ------------------ 1 file changed, 196 deletions(-) delete mode 100644 jeecg-module-auto-process/src/main/java/org/jeecg/common/NameStandUtil.java diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/common/NameStandUtil.java b/jeecg-module-auto-process/src/main/java/org/jeecg/common/NameStandUtil.java deleted file mode 100644 index 9a98db16..00000000 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/common/NameStandUtil.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.jeecg.common; - -import com.baomidou.mybatisplus.core.toolkit.StringPool; -import org.jeecg.common.util.DateUtils; -import org.jeecg.modules.base.enums.DataType; -import org.jeecg.modules.base.enums.SystemType; -import org.jeecg.modules.entity.vo.PHDFile; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.ParseException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -@Component -public class NameStandUtil { - - public String GetSysTemSubdir(String systemType) { - StringBuffer path = new StringBuffer(); - if(systemType.contains(SystemType.BETA.getType())) { - path.append(StringPool.SLASH+"Spectrum"); - path.append(StringPool.SLASH+"Xenon"); - path.append(StringPool.SLASH+"Sauna"); - } else if(systemType.contains(SystemType.GAMMA.getType())) { - path.append(StringPool.SLASH+"Spectrum"); - path.append(StringPool.SLASH+"Xenon"); - path.append(StringPool.SLASH+"Spalax"); - } else if(systemType.contains(SystemType.PARTICULATE.getType())) { - path.append(StringPool.SLASH+"Spectrum"); - path.append(StringPool.SLASH+"Particulates"); - } - return path.toString(); - } - - public String GetDateTypeSubdir(String dataType){ - StringBuffer path = new StringBuffer(); - if(dataType.contains(DataType.SAMPLEPHD.getType())) - { - path.append(StringPool.SLASH+"Samplephd"); - } - else if(dataType.contains(DataType.QCPHD.getType())) - { - path.append(StringPool.SLASH+"Qcphd"); - } - else if(dataType.contains(DataType.DETBKPHD.getType())) - { - path.append(StringPool.SLASH+"Detbkphd"); - } - else if(dataType.contains(DataType.GASBKPHD.getType())) - { - path.append(StringPool.SLASH+"Gasbkphd"); - } - else if(dataType.contains(DataType.SOH.getType())) - { - path.append(StringPool.SLASH+"Soh"); - } - else if(dataType.contains(DataType.MET.getType())) - { - path.append(StringPool.SLASH+"Met"); - } - else if(dataType.contains(DataType.ALERT_FLOW.getType())|| - dataType.contains(DataType.ALERT_SYSTEM.getType())|| - dataType.contains(DataType.ALERT_TEMP.getType())|| - dataType.contains(DataType.ALERT_UPS.getType())) - { - path.append(StringPool.SLASH+"Alert"); - } - else if(dataType.contains(DataType.ERROR.getType())) - { - path.append(StringPool.SLASH+"Error"); - } - else - { - path.append(StringPool.SLASH+"Other"); - } - return path.toString(); - } - - public Map NameStandard(String path, PHDFile fileAnlyse) { - String suffix = GetSuffix(fileAnlyse.getMsgInfo().getData_type(),fileAnlyse.getHeader().getSystem_type(),fileAnlyse.getHeader().getSpectrum_quantity(),String.valueOf(fileAnlyse.getAcq().getAcquisition_live_time())); - Map fileNames = NameStandardByName(path, fileAnlyse.getFilename(), fileAnlyse.getHeader().getMeasurement_id(),suffix); - return fileNames; - } - - public String GetSuffix(String dataType,String sysType,String Fulltype,String LT) { - String rData = ""; - BigDecimal bd = new BigDecimal(LT); - if(dataType.contains(DataType.SAMPLEPHD.getType())) { - bd = bd.setScale(1, RoundingMode.HALF_UP); - rData = "_S_"+Fulltype+"_"+bd+".PHD"; - } else if(dataType.contains(DataType.GASBKPHD.getType())){ - bd = bd.setScale(1, RoundingMode.HALF_UP); - rData = "_G_"+Fulltype+"_"+bd+".PHD"; - }else if(dataType.contains(DataType.DETBKPHD.getType())){ - bd = bd.setScale(0, RoundingMode.HALF_UP); - rData = "_D_"+Fulltype+"_"+bd+".PHD"; - }else if(dataType.contains(DataType.QCPHD.getType())){ - bd = bd.setScale(2, RoundingMode.HALF_UP); - rData = "_Q_"+Fulltype+"_"+bd+".PHD"; - } - return rData; - } - - public Map NameStandardByName(String path, String fileName, String dateTimeFormat, String suffix) { - Map map = new HashMap<>(); - String StandardFileName=""; - String measurementName = GetFileNameFromDateTime(dateTimeFormat, suffix); - String fileDir = path + StringPool.SLASH; - if(measurementName != fileName) { - StandardFileName = fileDir+measurementName; - } - String fileSuffix = "PHD"; - - String m_lcFileName = StandardFileName; - String m_baseLineFileName = StandardFileName; - String m_scacFileName = StandardFileName; - String m_logfileName = StandardFileName; - String m_reportFileName = StandardFileName; - - m_lcFileName.replace(fileSuffix,"lc"); - m_baseLineFileName.replace(fileSuffix,"baseline"); - m_scacFileName.replace(fileSuffix,"scac"); - m_logfileName.replace(fileSuffix,"log"); - m_reportFileName.replace("."+fileSuffix,"_rpt"); - - String m_saveFileName = StandardFileName; - - map.put("lc", m_lcFileName); - map.put("baseline", m_baseLineFileName); - map.put("scac", m_scacFileName); - map.put("log", m_logfileName); - map.put("rpt", m_reportFileName); - map.put("saveFile", m_saveFileName); - return map; - } - - public String GetFileNameFromDateTime(String dateTimeFormat, String suffix){ - String rData = ""; - int pos = dateTimeFormat.indexOf("-"); - if(-1 != pos) { - String dateTime = dateTimeFormat; - if (pos+17>dateTime.length()){ - dateTime = dateTime.substring(pos+1); - }else { - dateTime = dateTime.substring(pos+1, pos+17); - } - dateTime = dateTime.replace(" ","-"); - String fileHeader = dateTimeFormat.substring(0, pos+1); - String temp = DateTimeStandardToFileFormat(dateTime); - rData = fileHeader+ temp + suffix; - } - return rData; - } - - public String DateTimeStandardToFileFormat(String data) { - String dateTime = ""; - try { - if ( data.indexOf("-") > 0 ){ - dateTime = DateUtils.formatDate(DateUtils.parseDate(data,"yyyy/MM/dd-HH:mm"), "yyyyMMdd_HHmm"); - } else if( data.indexOf(" ") > 0 ) { - dateTime = DateUtils.formatDate(DateUtils.parseDate(data,"yyyy/MM/dd HH:mm"), "yyyyMMdd_HHmm"); - } else if( data.indexOf("-")<0 && data.indexOf(" ") < 0) { - dateTime = DateUtils.formatDate(DateUtils.parseDate(data,"yyyy/MM/dd"), "yyyyMMdd"); - } - } catch (ParseException e) { - throw new RuntimeException(e); - } - return dateTime; - } - - public String SetFileDir(String path, String saveFileName) { - String input_file_name = path; - //添加文件名日期 - List dateSub = GetSubDirByFileName(saveFileName); - for(int pos=0;pos GetSubDirByFileName(String fileName) { - List rData = new LinkedList<>(); - int pos = fileName.indexOf('-'); - if(-1 == pos) { - // - } else if(fileName.length()>=pos+7) { - rData.add(fileName.substring(pos+1, pos+5)); - rData.add(fileName.substring(pos+5, pos+7)); - } - return rData; - } - -} From e08f3d4208b5b3d55298654b227ed57643e75f11 Mon Sep 17 00:00:00 2001 From: orgin Date: Fri, 22 Sep 2023 13:52:12 +0800 Subject: [PATCH 3/5] =?UTF-8?q?delete=EF=BC=9AnameStandUtil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/jeecg/common/GammaFileUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java index ee83e1ee..ca7b2c77 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java @@ -11,6 +11,7 @@ import org.jeecg.common.api.vo.Result; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.FTPUtil; +import org.jeecg.common.util.NameStandUtil; import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; @@ -2788,7 +2789,7 @@ public class GammaFileUtil { String subDirSavePath = ""; subDirSavePath+=nameStandUtil.GetSysTemSubdir(fileAnlyse.getHeader().getSystem_type()); subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType); - Map fileNames = nameStandUtil.NameStandard(subDirSavePath, fileAnlyse); + Map fileNames = nameStandUtil.NameStandard(fileAnlyse); String lcName = fileNames.get("lc"); String scacName = fileNames.get("scac"); String baselineName = fileNames.get("baseline"); From 2d0ea1e7546c7cf30f9152e580fecbee37dadf6a Mon Sep 17 00:00:00 2001 From: orgin Date: Fri, 22 Sep 2023 17:17:59 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20gamma=E8=87=AA=E5=8A=A8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/spectrum/Sample_G_Analysis.java | 83 +++++-------------- 1 file changed, 20 insertions(+), 63 deletions(-) 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 fc94021f..340158f1 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 @@ -23,7 +23,6 @@ import org.jeecg.modules.base.entity.rnauto.*; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; -import java.io.File; import java.lang.reflect.Field; import java.util.*; @@ -104,10 +103,11 @@ public class Sample_G_Analysis { GammaFileUtil gammaFileUtil = new GammaFileUtil(); PHDFile phdFile = new PHDFile(); - // todo 获取数据库 Gamma 默认参数 - // todo 文件路径 + // 获取数据库 Gamma 默认参数 + getSettingFromDB(phdFile); + // 文件路径 middleData.setAnalyses_save_filePath(this.sampleInputFilename); - // todo 读取文件内容并附值 + // 读取文件内容并附值 this.setPHDFile(phdFile, this.energySpectrumStruct); // todo 根据系统类型传入不同的核素参数 Map nuclideLibs = new HashMap<>(); @@ -124,22 +124,22 @@ public class Sample_G_Analysis { // 获取分析结果ID ==> SELECT IDANALYSIS Integer IdAnalysis = getIdAnalysis(sampleId); // 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA -// serviceQuotes.getSampleDataService().updateStatus(null,null); + serviceQuotes.getSampleDataService().updateStatus(null,null); /* GARDS_CALIBRATION_PAIRS 数据表保存 */ -// saveCalibrationPairs(middleData,sampleId,IdAnalysis); + saveCalibrationPairs(middleData, sampleId, IdAnalysis); /* GARDS_CALIBRATION 数据表保存 */ -// saveCalibration(middleData,sampleId,IdAnalysis); + saveCalibration(middleData, sampleId, IdAnalysis); /* Gards_Peaks 数据表保存 */ -// savePeaks(middleData); + savePeaks(middleData); /* Gards_Nucl_Lines_Ided 数据表保存 */ -// saveNuclLinesIded(middleData,sampleId,IdAnalysis); + saveNuclLinesIded(middleData, sampleId, IdAnalysis); /* Gards_Nucl_Ided 数据表保存 */ -// saveNuclIded(middleData,sampleId,IdAnalysis); + saveNuclIded(middleData, sampleId, IdAnalysis); /* Gards_Qc_Check 数据表保存 */ -// saveQcCheck(middleData,sampleId,IdAnalysis); - /* */ - /** 收尾处理 ==> 写日志文件和报告文件 **/ + saveQcCheck(middleData, sampleId, IdAnalysis, phdFile.getQcItems()); + // 生成日志文件 writeLog(middleData.getAnalyses_LogPath(), middleData); + // todo 报告文件 }catch (Exception e){ e.printStackTrace(); @@ -148,6 +148,11 @@ public class Sample_G_Analysis { } } + /** + * 生成日志文件 + * @param logFilePath + * @param middleData + */ private void writeLog(String logFilePath, GStoreMiddleProcessData middleData) { String sampleId = middleData.getSample_id(); MyLogFormatUtil myLogFormatUtil = new MyLogFormatUtil(); @@ -411,51 +416,6 @@ public class Sample_G_Analysis { FileUtil.writeLines(writes, logFilePath, "utf8"); } - private static List getAttribute(List channel, String channelUnit, List energys, String energyUnit, - List errors, String errorUnit){ - - List> data = new ArrayList<>(); - List result = new ArrayList<>(); - - // 初始化数据 - for (int i = 0; i < channel.size(); i++) { - data.add(Arrays.asList( - "Channel : " + channel.get(i) + " " + channelUnit, - "Energy : " + energys.get(i) + " " + energyUnit, - "Error : " + errors.get(i) + " " + errorUnit) - ); - } - // 计算每列数据中最长的字符串长度 - int[] columnWidths = new int[data.get(0).size()]; - for (List row : data) { - for (int i = 0; i < row.size(); i++) { - columnWidths[i] = Math.max(columnWidths[i], row.get(i).length()); - } - } - - // 构造格式化字符串 - StringBuilder formatBuilder = new StringBuilder(); - for (int i = 0; i < columnWidths.length; i++) { - formatBuilder.append("%-" + (columnWidths[i] + 4) + "s"); - } - formatBuilder.append("\n"); - String format = formatBuilder.toString(); - // 格式化输出日志 - for (List row : data) { - String log = String.format(format, row.toArray()); - result.add(log); - System.out.print(log); - } - return result; - } - - public static void main(String[] args) { - List channels = Arrays.asList("59.541", "88.034", "122.061", "165.857", "391.698", "661.657", "834.838", "898.036", "1115.540", "1173.230", "1332.490", "1836.050"); - List energies = Arrays.asList("0.168", "0.176", "0.174", "0.155", "0.092", "0.059", "0.051", "0.040", "0.040", "0.031", "0.028", "0.022"); - List errors = Arrays.asList("0.003", "0.004", "0.003", "0.003", "0.002", "0.001", "0.001", "0.001", "0.001", "0.001", "0.001", "0.000"); - getAttribute(channels,"",energies,"",errors,""); - } - public void saveAnalysis(GStoreMiddleProcessData middleData,Integer sampleId){ GardsAnalyses analysis = toAnalysis(middleData); analysis.setSampleId(sampleId); @@ -669,10 +629,8 @@ public class Sample_G_Analysis { } public void saveQcCheck(GStoreMiddleProcessData middleData, - Integer sampleId, Integer IdAnalysis){ + Integer sampleId, Integer IdAnalysis,Map qcItems){ // Gards_Qc_Check数据表 ==> INSERT INTO RNAUTO.GARDS_QC_CHECK - PHDFile phdFile = getSettingFromDB(); - Map qcItems = phdFile.getQcItems(); if (MapUtil.isNotEmpty(qcItems)){ String base_QC = String.valueOf(qcItems.size()); QcCheckDto qcCheckDto = new QcCheckDto(); @@ -772,10 +730,9 @@ public class Sample_G_Analysis { return fieldMap; } - public PHDFile getSettingFromDB(){ + public PHDFile getSettingFromDB(PHDFile phdFile){ Map mapSetting = serviceQuotes.getGammaDefaultParamsService() .mapSetting(); - PHDFile phdFile = new PHDFile(); SpecSetup setting = phdFile.getSetting(); String BaseImprovePSS = mapSetting.get(Setting.BASEIMPROVEPSS); if (StrUtil.isNotBlank(BaseImprovePSS)) From 9c9fbbb80ebe4a9d4cc022ee87cebcdd38281a3e Mon Sep 17 00:00:00 2001 From: orgin Date: Fri, 22 Sep 2023 19:19:25 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20gamma=E5=88=86=E6=9E=90=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E9=80=9A=E8=BF=87=20redis=20=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=8F=91=E9=80=81=20webSocket=20=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/WebSocketHandlerConst.java | 11 +++++++ .../modules/controller/GammaController.java | 24 +++++++++++++++ .../modules/feignclient/SystemClient.java | 16 ++++++++++ .../message/handle/AnalysisHandler.java | 30 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebSocketHandlerConst.java create mode 100644 jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/feignclient/SystemClient.java create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/AnalysisHandler.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebSocketHandlerConst.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebSocketHandlerConst.java new file mode 100644 index 00000000..351a8993 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/WebSocketHandlerConst.java @@ -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"; +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index a8b6068d..b4d947b1 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -3,10 +3,16 @@ package org.jeecg.modules.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.entity.postgre.SysUser; import org.jeecg.modules.entity.vo.*; +import org.jeecg.modules.feignclient.SystemClient; import org.jeecg.modules.service.IGammaService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -22,12 +28,30 @@ public class GammaController { @Autowired private IGammaService gammaService; + @Autowired + private RedisTemplate redisTemplate; + + @Autowired + private SystemClient systemClient; + @GetMapping("initValue") @ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据") public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) { return gammaService.initValue(sampleId, dbName, request); } + @GetMapping("analysisProcess") + @ApiOperation(value = "分析进度", notes = "分析进度") + public void message(String message) { + Result 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") public Result testFun(String fileName){ return gammaService.testFun(fileName); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/feignclient/SystemClient.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/feignclient/SystemClient.java new file mode 100644 index 00000000..f1d391eb --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/feignclient/SystemClient.java @@ -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 getUserData(); +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/AnalysisHandler.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/AnalysisHandler.java new file mode 100644 index 00000000..b6fde5bf --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/handle/AnalysisHandler.java @@ -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")); + } + +}