diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIChannelsDto.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIChannelsDto.java
index 6e386e85..25fd469a 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIChannelsDto.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIChannelsDto.java
@@ -37,11 +37,8 @@ public class ROIChannelsDto {
private String gChanStr;
- public void setbChanStr() {
+ public void shift(){
this.bChanStr = this.bChanStart + " to " + this.bChanStop;
- }
-
- public void setgChanStr() {
this.gChanStr = this.gChanStart + " to " + this.gChanStop;
}
}
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIResultsDto.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIResultsDto.java
index 3cbb170a..dfb983b0 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIResultsDto.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIResultsDto.java
@@ -1,7 +1,9 @@
package org.jeecg.modules.base.dto;
+import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
+import org.jeecg.common.util.NumUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@@ -64,11 +66,16 @@ public class ROIResultsDto {
private String concStr;
- public void setNetCount() {
- this.netCount = this.net + " +/- " + Math.sqrt(this.netErr);
- }
-
- public void setConcStr() {
+ public void shift(){
+ this.lc = NumUtil.keep(this.lc, 5);
+ this.mdc = NumUtil.keep(this.mdc, 5);
+ this.net = NumUtil.keep(this.net, 5);
+ Double netErrSqrt = null;
+ if (ObjectUtil.isNotNull(this.netErr))
+ netErrSqrt = NumUtil.keep(Math.sqrt(this.netErr), 5);
+ this.netCount = this.net + " +/- " + netErrSqrt;
+ this.conc = NumUtil.keep(this.conc, 5);
+ this.concErr = NumUtil.keep(this.concErr, 5);
this.concStr = this.conc + " +/- " + this.concErr;
}
}
diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/XeResultsDto.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/XeResultsDto.java
index cc3a6d5d..51bc9afc 100644
--- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/XeResultsDto.java
+++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/XeResultsDto.java
@@ -2,6 +2,7 @@ package org.jeecg.modules.base.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
+import org.jeecg.common.util.NumUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@@ -35,7 +36,11 @@ public class XeResultsDto {
private String concStr;
- public void setConcStr() {
+ public void shift(){
+ this.conc = NumUtil.keep(this.conc, 5);
+ this.concErr = NumUtil.keep(this.concErr, 5);
this.concStr = this.conc + " +/- " + this.concErr;
+ this.lc = NumUtil.keep(this.lc, 5);
+ this.mdc = NumUtil.keep(this.mdc, 5);
}
}
diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveExcel.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveExcel.xls
index 06aecadf..17c625ee 100644
Binary files a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveExcel.xls and b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveExcel.xls differ
diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveHtml.html b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveHtml.html
index 5c933aa1..42d06c65 100644
--- a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveHtml.html
+++ b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveHtml.html
@@ -135,10 +135,10 @@
Beta |
Gamma |
-
+
|
- |
- |
+ |
+ |
  |
@@ -187,10 +187,11 @@
Beta |
Gamma |
-
+
|
- |
- |
+ |
+ |
+
  |
@@ -239,10 +240,10 @@
Beta |
Gamma |
-
+
|
- |
- |
+ |
+ |
  |
@@ -256,7 +257,7 @@
GasBkgnd |
DetBkgnd |
-
+
|
|
|
@@ -272,9 +273,9 @@
Roi |
Net count |
-
+
|
- |
+ |
  |
@@ -288,9 +289,9 @@
LC(mBq/m3) |
MDC(mBq/m3): |
-
+
|
- |
+ |
|
|
@@ -307,9 +308,9 @@
MDC |
NID Flag |
-
+
|
- |
+ |
|
|
|
diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveTxt.txt b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveTxt.txt
index cf1d8000..160cbc39 100644
--- a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveTxt.txt
+++ b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveTxt.txt
@@ -38,7 +38,7 @@
#SAMPLE: LIMITS PER ROI
Roi Beta Gamma
-${limitRoi}
+${sampleRoi}
#DET Old CALIBRATION
Old Beta Old Gamma
@@ -52,7 +52,7 @@ ${limitRoi}
#DET: LIMITS PER ROI
Roi Beta Gamma
-${limitRoi}
+${detRoi}
#GAS Old CALIBRATION
Old Beta Old Gamma
@@ -66,7 +66,7 @@ ${limitRoi}
#GAS: LIMITS PER ROI
Roi Beta Gamma
-${limitRoi}
+${gasRoi}
#GROSS COUNTS PER ROI
Roi Sample GasBkgnd DetBkgnd
diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java
index 91283fe1..83d76c1d 100644
--- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java
+++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java
@@ -994,9 +994,9 @@ public class PHDFileUtil {
Xe135.setConcErr(bgAnalyseResult.Xe135_uncer);
Xe135.setLc(bgAnalyseResult.LC_Xe135);
xeResultsSpectrumList.add(Xe135);
- result.put("roiChannelsSpectrum", roiChannelsSpectrumList);
- result.put("roiResultsSpectrum", roiResultsSpectrumList);
- result.put("xeResultsSpectrum", xeResultsSpectrumList);
+ result.put("roiChannels", roiChannelsSpectrumList);
+ result.put("roiResults", roiResultsSpectrumList);
+ result.put("xeResults", xeResultsSpectrumList);
return result;
}
}
diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java
index e0fac0c9..f7e000db 100644
--- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java
+++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java
@@ -216,18 +216,21 @@ public class SpectrumAnalysesController {
return spectrumAnalysisService.saveToDB(anlyseResultIn, request);
}
- @GetMapping("saveToHTML")
- public void saveToHTML(HttpServletResponse response){
- spectrumAnalysisService.saveToHTML(response);
+ @PostMapping("saveToHTML")
+ public void saveToHTML(HttpServletResponse response,
+ @RequestBody BgDataAnlyseResultIn anlyseResultIn){
+ spectrumAnalysisService.saveToHTML(anlyseResultIn, response);
}
- @GetMapping("saveToExcel")
- public void saveToExcel(HttpServletResponse response){
- spectrumAnalysisService.saveToExcel(response);
+ @PostMapping("saveToExcel")
+ public void saveToExcel(HttpServletResponse response,
+ @RequestBody BgDataAnlyseResultIn anlyseResultIn){
+ spectrumAnalysisService.saveToExcel(anlyseResultIn, response);
}
- @GetMapping("saveToTxt")
- public void saveToTxt(HttpServletResponse response){
- spectrumAnalysisService.saveToTxt(response);
+ @PostMapping("saveToTxt")
+ public void saveToTxt(HttpServletResponse response,
+ @RequestBody BgDataAnlyseResultIn anlyseResultIn){
+ spectrumAnalysisService.saveToTxt(anlyseResultIn, response);
}
}
diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java
index 31f48747..6789b42e 100644
--- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java
+++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java
@@ -74,9 +74,9 @@ public interface ISpectrumAnalysisService {
Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request);
- void saveToHTML(HttpServletResponse response);
+ void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
- void saveToExcel(HttpServletResponse response);
+ void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
- void saveToTxt(HttpServletResponse response);
+ void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
}
diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java
index 2f9be5ad..1c05a89c 100644
--- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java
+++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java
@@ -17,6 +17,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
+import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.BetaCache;
@@ -24,6 +25,7 @@ import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.bizVo.BetaRLR;
import org.jeecg.modules.base.dto.ESStructDto;
@@ -44,6 +46,7 @@ import org.jeecg.modules.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestBody;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine;
@@ -2879,23 +2882,171 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
return result;
}
- @Override
- public void saveToHTML(HttpServletResponse response) {
- /*EnergySpectrumStruct energySpectrumStruct = phdFileUtil.analyzeFileSourceData(null, null);
- Map analyze = phdFileUtil.analyze(null, null, null);
- analyze.putAll(BeanUtil.beanToMap(energySpectrumStruct));*/
+ /**
+ * 获取需要导出的数据 (saveToHtml|saveToTxt|saveToExcel)
+ */
+ private BgDataAnlyseResultIn getSaveData(BgDataAnlyseResultIn anlyseResultIn){
+ //根据请求体获取用户名
+ LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal();
+ String userName = user.getUsername();
+ //用户名赋值到 分析员
+ anlyseResultIn.setUserName(userName);
+ //从本地缓存获取beta gamma的数组
+ Cache> cache = betaCache.getBetaCache();
+ //根据qc文件名称-用户名-beta的方式获取beta的内容
+ Map betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta");
+ List betaList = new LinkedList<>();
+ List betaFittingPara = new LinkedList<>();
+ if (CollectionUtils.isNotEmpty(betaMap)) {
+ betaList = (List)betaMap.get("Series");
+ betaFittingPara = (List) betaMap.get("fittingPara");
+ }
+ //根据qc文件名称-用户名-gamma的方式获取gamma的内容
+ Map gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma");
+ List gammaList = new LinkedList<>();
+ List gammaFittingPara = new LinkedList<>();
+ if (CollectionUtils.isNotEmpty(gammaMap)) {
+ gammaList = (List)gammaMap.get("Series");
+ gammaFittingPara = (List) gammaMap.get("fittingPara");
+ }
- Map analyze = new HashMap<>();
+ if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) {
+ if (anlyseResultIn.getDbName().equals("auto")) {
+ anlyseResultIn.setDbName("RNAUTO");
+ } else if (anlyseResultIn.getDbName().equals("man")) {
+ anlyseResultIn.setDbName("RNMAN");
+ }
+ Integer sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName());
+ if (Objects.nonNull(sampleId)) {
+ SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(anlyseResultIn.getDbName(), sampleId);
+ if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){
+ anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)));
+ }
+ if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) {
+ anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)));
+ }
+ if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) {
+ anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)));
+ }
+ if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) {
+ String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss");
+ anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr));
+ }
+ }
+ } else {
+ anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
+ anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
+ anlyseResultIn.setDetFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
+ anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
+ }
+ //处理数据 获取对应的channel/energy值
+ getChannelAndEnergy(anlyseResultIn, betaList, gammaList);
+ //分析文件内容
+ analyzePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara);
+
+ // 返回需要Save的数据
+ return anlyseResultIn;
+ }
+
+ /*
+ * 对数据进行处理,变成真正可直接导出的数据
+ * */
+ private Map shiftSaveData(BgDataAnlyseResultIn anlyseResultIn){
+ Map result = new HashMap<>();
+ List roiChannels = anlyseResultIn.getRoiChannelsSpectrumList();
+ List roiResults = anlyseResultIn.getRoiResultsSpectrumList();
+ List xeResults = anlyseResultIn.getXeData();
+ roiChannels = ObjectUtil.isNotNull(roiChannels) ? roiChannels : new LinkedList<>();
+ roiResults = ObjectUtil.isNotNull(roiResults) ? roiResults : new LinkedList<>();
+ xeResults = ObjectUtil.isNotNull(xeResults) ? xeResults : new LinkedList<>();
+
+ // 转换ROIChannels数据
+ List roiChannelsDtosS = new LinkedList<>();
+ List roiChannelsDtosD = new LinkedList<>();
+ List roiChannelsDtosG = new LinkedList<>();
+ for (GardsROIChannelsSpectrum roiChannel : roiChannels) {
+ ROIChannelsDto roiChannelsDto = new ROIChannelsDto();
+ BeanUtil.copyProperties(roiChannel, roiChannelsDto);
+ roiChannelsDto.shift();
+ String dataType = roiChannel.getDataType();
+ if (StrUtil.isNotBlank(dataType)){
+ switch (dataType){
+ case "S":
+ roiChannelsDtosS.add(roiChannelsDto);
+ break;
+ case "D":
+ roiChannelsDtosD.add(roiChannelsDto);
+ break;
+ case "G":
+ roiChannelsDtosG.add(roiChannelsDto);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ // 转换ROIResults数据
+ List roiResultsDtos = new LinkedList<>();
+ for (GardsROIResultsSpectrum roiResult : roiResults) {
+ ROIResultsDto roiResultsDto = new ROIResultsDto();
+ BeanUtil.copyProperties(roiResult, roiResultsDto);
+ roiResultsDto.shift();
+ roiResultsDtos.add(roiResultsDto);
+ }
+ // 转换XeResults数据
+ List xeResultsDtos = new LinkedList<>();
+ for (GardsXeResults xeResult : xeResults) {
+ XeResultsDto xeResultsDto = new XeResultsDto();
+ BeanUtil.copyProperties(xeResult, xeResultsDto);
+ xeResultsDto.shift();
+ xeResultsDtos.add(xeResultsDto);
+ }
+
+ result.put("roiChannelsS", roiChannelsDtosS);
+ result.put("roiChannelsD", roiChannelsDtosD);
+ result.put("roiChannelsG", roiChannelsDtosG);
+ result.put("roiResults", roiResultsDtos);
+ result.put("xeResults", xeResultsDtos);
+ return result;
+ }
+
+ /*
+ * 使用模板引擎解析html模板
+ * */
+ private String parseHtml(Map variables) {
+ TemplateEngine templateEngine = new SpringTemplateEngine();
+ ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
+ resolver.setPrefix("excelTemplate/");
+ templateEngine.setTemplateResolver(resolver);
+
+ Context context = new Context();
+ context.setVariables(variables);
+
+ return templateEngine.process(SAVETOHTML.getName(), context);
+ }
+
+ /*
+ * 提取(saveToHtml|saveToTxt|saveToExcel)公共部分
+ * */
+ private Map exportData(BgDataAnlyseResultIn anlyseResultIn){
+ // 解析文件,生成导出数据
+ Map analyze = shiftSaveData(getSaveData(anlyseResultIn));
+ // 转换能谱结构数据
+ //EnergySpectrumStruct energySpectrumStruct = phdFileUtil.analyzeFileSourceData(null, null);
+ EnergySpectrumStruct energySpectrumStruct = new EnergySpectrumStruct();
+ ESStructDto esStructDto = new ESStructDto();
+ ClassUtil.copyProperties(energySpectrumStruct, esStructDto);
+ analyze.putAll(BeanUtil.beanToMap(esStructDto));
+ // 设置标题中的时间
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE_TIME_S);
analyze.put("now", LocalDateTime.now().format(formatter));
- List roiChannelsSpectrums = new LinkedList<>();
- List roiResultsSpectrumList = new LinkedList<>();
- List xeResultsSpectrumList = new LinkedList<>();
- analyze.put("roiChannelsSpectrum", roiChannelsSpectrums);
- analyze.put("roiResultsSpectrum", roiResultsSpectrumList);
- analyze.put("xeResultsSpectrum", xeResultsSpectrumList);
- EnergySpectrumStruct energySpectrumStruct = new EnergySpectrumStruct();
- analyze.putAll(BeanUtil.beanToMap(energySpectrumStruct));
+ return analyze;
+ }
+
+ @Override
+ public void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
+ // 解析文件,生成导出数据
+ Map analyze = exportData(anlyseResultIn);
// 解析生成Html字符串并导出为Html文件
String result = parseHtml(analyze);
@@ -2912,65 +3063,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
}
- private String parseHtml(Map variables) {
- TemplateEngine templateEngine = new SpringTemplateEngine();
- ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
- resolver.setPrefix("excelTemplate/");
- resolver.setSuffix(".html");
- templateEngine.setTemplateResolver(resolver);
-
- Context context = new Context();
- context.setVariables(variables);
-
- return templateEngine.process("SaveHtml", context);
- }
-
@Override
- public void saveToExcel(HttpServletResponse response) {
- Map analyze = new HashMap<>();
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE_TIME_S);
- analyze.put("now", LocalDateTime.now().format(formatter));
- // 转换ROIChannels数据
- List roiChannelsSpectrums = new LinkedList<>();
- List roiChannelsDtos = new LinkedList<>();
- GardsROIChannelsSpectrum roiChannelsSpectrum = new GardsROIChannelsSpectrum();
- roiChannelsSpectrum.setRoi(1);
- roiChannelsSpectrum.setBChanStart(1);
- roiChannelsSpectrum.setBChanStop(2);
- roiChannelsSpectrums.add(roiChannelsSpectrum);
- for (GardsROIChannelsSpectrum roiChannel : roiChannelsSpectrums) {
- ROIChannelsDto roiChannelsDto = new ROIChannelsDto();
- BeanUtil.copyProperties(roiChannel, roiChannelsDto);
- roiChannelsDto.setbChanStr();roiChannelsDto.setgChanStr();
- roiChannelsDtos.add(roiChannelsDto);
- }
- // 转换ROIResults数据
- List roiResultsSpectrums = new LinkedList<>();
- List roiResultsDtos = new LinkedList<>();
- for (GardsROIResultsSpectrum roiResult : roiResultsSpectrums) {
- ROIResultsDto roiResultsDto = new ROIResultsDto();
- BeanUtil.copyProperties(roiResult, roiResultsDto);
- roiResultsDto.setConcStr();roiResultsDto.setNetCount();
- roiResultsDtos.add(roiResultsDto);
- }
- // 转换XeResults数据
- List xeResultsSpectrums = new LinkedList<>();
- List xeResultsDtos = new LinkedList<>();
- for (GardsXeResultsSpectrum xeResult : xeResultsSpectrums) {
- XeResultsDto xeResultsDto = new XeResultsDto();
- BeanUtil.copyProperties(xeResult, xeResultsDto);
- xeResultsDto.setConcStr();
- xeResultsDtos.add(xeResultsDto);
- }
- // 转换能谱结构体数据
- EnergySpectrumStruct energySpectrumStruct = new EnergySpectrumStruct();
- ESStructDto esStructDto = new ESStructDto();
- ClassUtil.copyProperties(energySpectrumStruct ,esStructDto);
- // 填充到Map数据集中
- analyze.put("roiChannels", roiChannelsDtos);
- analyze.put("roiResults", roiResultsDtos);
- analyze.put("xeResults", xeResultsDtos);
- analyze.putAll(BeanUtil.beanToMap(esStructDto));
+ public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
+ // 解析文件,生成导出数据
+ Map analyze = exportData(anlyseResultIn);
// 将Null值替换为"",避免空指针异常(集合为空集合,不能为null)
analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
@@ -2980,18 +3076,21 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
@Override
- public void saveToTxt(HttpServletResponse response) {
- // 准备需要导出的数据
- List roiChannelsSpectrums = new LinkedList<>();
- GardsROIChannelsSpectrum roiChannelsSpectrum = new GardsROIChannelsSpectrum();
- roiChannelsSpectrum.setRoi(1);
- roiChannelsSpectrum.setBChanStart(1);
- roiChannelsSpectrum.setBChanStop(2);
- roiChannelsSpectrums.add(roiChannelsSpectrum);
- Map analyze = new HashMap<>();
- analyze.put("limitRoi", roiChannels(roiChannelsSpectrums));
- analyze.putAll(roiResults(null));
- analyze.put("resultSummary", xeResults(null));
+ public void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
+ // 解析文件,生成导出数据
+ Map analyze = exportData(anlyseResultIn);
+
+ // 生成指定格式的导出数据备用
+ List roiChannelsDtosS = (List) analyze.get("roiChannelsS");
+ List roiChannelsDtosD = (List) analyze.get("roiChannelsD");
+ List roiChannelsDtosG = (List) analyze.get("roiChannelsG");
+ List roiResultsDtos = (List) analyze.get("roiResults");
+ List xeResultsDtos = (List) analyze.get("xeResults");
+ analyze.put("sampleRoi", roiChannels(roiChannelsDtosS));
+ analyze.put("detRoi", roiChannels(roiChannelsDtosD));
+ analyze.put("gasRoi", roiChannels(roiChannelsDtosG));
+ analyze.putAll(roiResults(roiResultsDtos));
+ analyze.put("resultSummary", xeResults(xeResultsDtos));
// 使数据适配导出模板
String pathPrefix = "excelTemplate/";
String path = pathPrefix + SAVETOTXT.getName();
@@ -3000,10 +3099,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
// 正则表达式,匹配${}中的内容
String regex = "\\$\\{([^}]+)}";
List newLines = new ArrayList<>();
- List list = ListUtil.toList("limitRoi", "grossRoi",
+ List list = ListUtil.toList("sampleRoi", "detRoi", "gasRoi","grossRoi",
"netRoi", "concRoi", "resultSummary");
- List skip = ListUtil.toList("${limitRoi}", "${grossRoi}",
- "${netRoi}", "${concRoi}", "${resultSummary}");
+ List skip = ListUtil.toList("${sampleRoi}", "${detRoi}", "${gasRoi}",
+ "${grossRoi}", "${netRoi}", "${concRoi}", "${resultSummary}");
for (String line : lines) {
List fieldNames = ReUtil.findAllGroup1(regex, line);
if (CollUtil.isEmpty(fieldNames)){
@@ -3039,20 +3138,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
}
- private List roiChannels(List roiChannels){
+ private List roiChannels(List roiChannels){
int min = 49;
String space = StrUtil.SPACE;
List channelStrs = new ArrayList<>();
if (CollUtil.isEmpty(roiChannels))
return channelStrs;
- for (GardsROIChannelsSpectrum roiChannel : roiChannels) {
+ for (ROIChannelsDto roiChannel : roiChannels) {
String roi = StrUtil.toString(roiChannel.getRoi());
- Integer bChanStart = roiChannel.getBChanStart();
- Integer bChanStop = roiChannel.getBChanStop();
- String bChanStr = bChanStart + " to " + bChanStop;
- Integer gChanStart = roiChannel.getGChanStart();
- Integer gChanStop = roiChannel.getGChanStop();
- String gChanStr = gChanStart + " to " + gChanStop;
+ String bChanStr = roiChannel.getBChanStr();
+ String gChanStr = roiChannel.getGChanStr();
String channelStr = StrUtil.padAfter(roi, min, space) +
StrUtil.padAfter(bChanStr, min, space) +
@@ -3062,7 +3157,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
return channelStrs;
}
- private Map roiResults(List roiResults){
+ private Map roiResults(List roiResults){
int min1 = 49;
int min2 = 22;
String space = StrUtil.SPACE;
@@ -3076,17 +3171,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
roiResultsStr.put("concRoi", concStrs);
return roiResultsStr;
}
- for (GardsROIResultsSpectrum roiResult : roiResults) {
+ for (ROIResultsDto roiResult : roiResults) {
String roi = StrUtil.toString(roiResult.getRoi());
String sGross = StrUtil.toString(roiResult.getSGross());
String gGross = StrUtil.toString(roiResult.getGGross());
String bGross = StrUtil.toString(roiResult.getBGross());
- String net = StrUtil.toString(roiResult.getNet());
- double netErr = roiResult.getNetErr();
- String netCount = net + " +/- " + Math.sqrt(netErr);
- String conc = StrUtil.toString(roiResult.getConc());
- String concErr = StrUtil.toString(roiResult.getConcErr());
- String concStr = conc + " +/- " + concErr;
+ String netCount = roiResult.getNetCount();
+ String concStr = roiResult.getConcStr();
String lc = StrUtil.toString(roiResult.getLc());
String mdc = StrUtil.toString(roiResult.getMdc());
@@ -3110,18 +3201,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
return roiResultsStr;
}
- private List xeResults(List xeResults){
+ private List xeResults(List xeResults){
int min1 = 49;
int min2 = 22;
String space = StrUtil.SPACE;
List xeResultStrs = new ArrayList<>();
if (CollUtil.isEmpty(xeResults))
return xeResultStrs;
- for (GardsXeResultsSpectrum xeResult : xeResults) {
+ for (XeResultsDto xeResult : xeResults) {
String name = xeResult.getNuclideName();
- String conc = StrUtil.toString(xeResult.getConc());
- String concErr = StrUtil.toString(xeResult.getConcErr());
- String concStr = conc + " +/- " + concErr;
+ String concStr = xeResult.getConcStr();
String lc = StrUtil.toString(xeResult.getLc());
String mdc = StrUtil.toString(xeResult.getMdc());
String flag = StrUtil.toString(xeResult.getNidFlag());