From 7e1839ebc062801c7bf0a91b2ef3c6748fd62057 Mon Sep 17 00:00:00 2001 From: orgin Date: Thu, 21 Sep 2023 19:58:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96ReadBaseCtrlInfo?= =?UTF-8?q?=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 | 108 +++++++++++++++++- 1 file changed, 105 insertions(+), 3 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 5caf617a..945ea4dd 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 @@ -31,9 +31,7 @@ import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.DecimalFormat; @@ -482,6 +480,110 @@ public class GammaFileUtil { } } + public void ReadBaseCtrlInfo(PHDFile phd, InputStream in){ + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String line ; + String block_name = null; + HashMap> map = new HashMap<>(); + while (null != (line = reader.readLine())) { + if (line.contains("#")) { + block_name = line.trim(); + map.put(block_name, new LinkedList<>()); + continue; + } + List data = map.get(block_name); + String[] split = line.split("\\s+"); + for(String str : split) { + if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ + double d = Double.parseDouble(str); + data.add(d); + } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { + data.add(0.0); + } + } + } + if(map.containsKey("#AnalyseRange")) { + List vTemp = map.get("#AnalyseRange"); + if(vTemp.size() == 2) { + phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); + phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); + } + } else if(map.containsKey("#XCtrl")) { + List vTemp = map.get("#XCtrl"); + phd.getBaseCtrls().setXCtrl(vTemp); + } else if(map.containsKey("#YCtrl")) { + List vTemp = map.get("#YCtrl"); + phd.getBaseCtrls().setYCtrl(vTemp); + } else if(map.containsKey("#YSlope")) { + List vTemp = map.get("#YSlope"); + phd.getBaseCtrls().setYSlope(vTemp); + } else 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")) { + List vTemp = map.get("#StepCounts"); + List list = vTemp.subList(1, vTemp.size()); + phd.getBaseCtrls().setStepCounts(list); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void ReadBaseCtrlInfo(PHDFile phd, InputStream in){ + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + String line ; + String block_name = null; + HashMap> map = new HashMap<>(); + while (null != (line = reader.readLine())) { + if (line.contains("#")) { + block_name = line.trim(); + map.put(block_name, new LinkedList<>()); + continue; + } + List data = map.get(block_name); + String[] split = line.split("\\s+"); + for(String str : split) { + if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ + double d = Double.parseDouble(str); + data.add(d); + } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { + data.add(0.0); + } + } + } + if(map.containsKey("#AnalyseRange")) { + List vTemp = map.get("#AnalyseRange"); + if(vTemp.size() == 2) { + phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); + phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); + } + } else if(map.containsKey("#XCtrl")) { + List vTemp = map.get("#XCtrl"); + phd.getBaseCtrls().setXCtrl(vTemp); + } else if(map.containsKey("#YCtrl")) { + List vTemp = map.get("#YCtrl"); + phd.getBaseCtrls().setYCtrl(vTemp); + } else if(map.containsKey("#YSlope")) { + List vTemp = map.get("#YSlope"); + phd.getBaseCtrls().setYSlope(vTemp); + } else 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")) { + List vTemp = map.get("#StepCounts"); + List list = vTemp.subList(1, vTemp.size()); + phd.getBaseCtrls().setStepCounts(list); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) { //判断连接的数据库 String T_analy, T_calib, T_peaks, T_param, T_nuc_line, T_nuc_act, T_qc, T_setting;