diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/Demo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/Demo.java deleted file mode 100644 index 690b0702..00000000 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/Demo.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.jeecg.modules; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; - -import java.io.*; -import java.util.*; - -public class Demo { - - public static Map processFile(File file){ - Map m_mapNuclideInfo = new TreeMap<>(); - if (ObjectUtil.isNull(file)) return m_mapNuclideInfo; - try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - String nucline_flag = "-----------------------------------------"; - String energy_flag = "REL. IMPULSANZ. KORR.FAKTOR"; - String line = reader.readLine(); - String nucName; - - while (line != null) { - if (line.trim().equals(nucline_flag)) { - line = reader.readLine(); // 空行 - nucName = reader.readLine().trim(); // 核素名称 - nucName = StrUtil.subBefore(nucName, " ", false); - - while (line != null && !line.trim().equals(nucline_flag)) { - if (line.trim().equals(energy_flag)) { - line = reader.readLine(); // 空行 - line = reader.readLine(); - - List energyList = new LinkedList<>(); - List factorList = new LinkedList<>(); - - while (line != null && !line.trim().isEmpty()) { - List strList = StrUtil.splitTrim(line.trim(), " "); - if (strList.size() == 3) { - energyList.add(Double.parseDouble(strList.get(0))); - factorList.add(Double.parseDouble(strList.get(2))); - } - line = reader.readLine(); - } - NuclideInfo nuclideInfo = new NuclideInfo(); - nuclideInfo.setEnergy(energyList); - nuclideInfo.setFactor(factorList); - m_mapNuclideInfo.put(nucName, nuclideInfo); - } else { - line = reader.readLine(); - } - } - } else { - line = reader.readLine(); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - - // 排序 - for (NuclideInfo ni : m_mapNuclideInfo.values()) { - for (int i = 0; i < ni.energy.size() - 1; ++i) { - for (int j = i + 1; j < ni.energy.size(); ++j) { - if (ni.energy.get(i) > ni.energy.get(j)) { - double tempEnergy = ni.energy.get(i); - double tempFactor = ni.factor.get(i); - ni.energy.set(i, ni.energy.get(j)); - ni.factor.set(i, ni.factor.get(j)); - ni.energy.set(j, tempEnergy); - ni.factor.set(j, tempFactor); - } - } - } - } - - return m_mapNuclideInfo; - } - - private static class NuclideInfo { - List energy; - List factor; - - public List getEnergy() { - return energy; - } - - public void setEnergy(List energy) { - this.energy = energy; - } - - public List getFactor() { - return factor; - } - - public void setFactor(List factor) { - this.factor = factor; - } - - NuclideInfo() { - energy = new LinkedList<>(); - factor = new LinkedList<>(); - } - - @Override - public String toString() { - return "NuclideInfo{" + - "energy=" + energy + - ", factor=" + factor + - '}'; - } - } -} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfoData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfoData.java new file mode 100644 index 00000000..2bb5ec07 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideInfoData.java @@ -0,0 +1,41 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; +import java.util.LinkedList; +import java.util.List; + +@Data +public class NuclideInfoData { + + public List energy; + public List factor; + + public List getEnergy() { + return energy; + } + + public void setEnergy(List energy) { + this.energy = energy; + } + + public List getFactor() { + return factor; + } + + public void setFactor(List factor) { + this.factor = factor; + } + + public NuclideInfoData() { + energy = new LinkedList<>(); + factor = new LinkedList<>(); + } + + @Override + public String toString() { + return "NuclideInfo{" + + "energy=" + energy + + ", factor=" + factor + + '}'; + } +} 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 f65e9a67..ea66940f 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 @@ -2245,13 +2245,79 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi throw new RuntimeException(e); } //读取生成的结果文件 并将数据存入对应的map中 - Map m_mapNuclideInfo = new HashMap<>(); - + String outFilePath = parameterProperties.getFilePath() + File.separator + "result.out"; + Map m_mapNuclideInfo = processFile(new File(outFilePath)); result.setSuccess(true); result.setResult(m_mapNuclideInfo); return result; } + private Map processFile(File file){ + Map m_mapNuclideInfo = new TreeMap<>(); + if (ObjectUtil.isNull(file)) return m_mapNuclideInfo; + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String nucline_flag = "-----------------------------------------"; + String energy_flag = "REL. IMPULSANZ. KORR.FAKTOR"; + String line = reader.readLine(); + String nucName; + + while (line != null) { + if (line.trim().equals(nucline_flag)) { + line = reader.readLine(); // 空行 + nucName = reader.readLine().trim(); // 核素名称 + nucName = StrUtil.subBefore(nucName, " ", false); + + while (line != null && !line.trim().equals(nucline_flag)) { + if (line.trim().equals(energy_flag)) { + line = reader.readLine(); // 空行 + line = reader.readLine(); + + List energyList = new LinkedList<>(); + List factorList = new LinkedList<>(); + + while (line != null && !line.trim().isEmpty()) { + List strList = StrUtil.splitTrim(line.trim(), " "); + if (strList.size() == 3) { + energyList.add(Double.parseDouble(strList.get(0))); + factorList.add(Double.parseDouble(strList.get(2))); + } + line = reader.readLine(); + } + NuclideInfoData nuclideInfo = new NuclideInfoData(); + nuclideInfo.setEnergy(energyList); + nuclideInfo.setFactor(factorList); + m_mapNuclideInfo.put(nucName, nuclideInfo); + } else { + line = reader.readLine(); + } + } + } else { + line = reader.readLine(); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + // 排序 + for (NuclideInfoData ni : m_mapNuclideInfo.values()) { + for (int i = 0; i < ni.energy.size() - 1; ++i) { + for (int j = i + 1; j < ni.energy.size(); ++j) { + if (ni.energy.get(i) > ni.energy.get(j)) { + double tempEnergy = ni.energy.get(i); + double tempFactor = ni.factor.get(i); + ni.energy.set(i, ni.energy.get(j)); + ni.factor.set(i, ni.factor.get(j)); + ni.energy.set(j, tempEnergy); + ni.factor.set(j, tempFactor); + } + } + } + } + + return m_mapNuclideInfo; + } + private String ReadRemaining() { String txtPath = parameterProperties.getFilePath() + StringPool.SLASH + "Kordat_Remaining.txt"; File file = new File(txtPath);