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<>();