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;