diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java index 21ad4bae..eb04f2cc 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java @@ -8,6 +8,8 @@ public interface DateConstant { String DATE_TIME = "yyyy-MM-dd HH:mm:ss"; + String DATE_TIME_S = "yyyy/MM/dd-HH:mm:ss"; + String DATE_BIAS = "yyyy/MM/dd"; String DATE_BIAS_TIME = "yyyy/MM/dd HH:mm:ss"; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java index c8e72adb..70063e96 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java @@ -56,6 +56,14 @@ public class ExportUtil { return response.getWriter(); } + public static PrintWriter htmlWriter(HttpServletResponse response, String fileName) throws IOException { + response.setCharacterEncoding(UTF_8); + response.setContentType("text/html"); + String name = URLEncoder.encode(fileName, UTF_8); + response.setHeader("Content-disposition", "attachment;filename=" + name); + return response.getWriter(); + } + public static void exportXls(HttpServletResponse response, Class target, List data, String fileName){ ExportParams params = new ExportParams(); 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 new file mode 100644 index 00000000..6e386e85 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIChannelsDto.java @@ -0,0 +1,47 @@ +package org.jeecg.modules.base.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +public class ROIChannelsDto { + /** + * 感兴趣区ID号 + */ + private Integer roi; + + /** + * 感兴趣区的β能量起始值 + */ + private Integer bChanStart; + + /** + * 感兴趣区的β能量结束值 + */ + private Integer bChanStop; + + /** + * 感兴趣区的γ能量起始值 + */ + private Integer gChanStart; + + /** + * 感兴趣区的γ能量结束值 + */ + private Integer gChanStop; + + private String bChanStr; + + private String gChanStr; + + public void setbChanStr() { + 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 new file mode 100644 index 00000000..3cbb170a --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/ROIResultsDto.java @@ -0,0 +1,74 @@ +package org.jeecg.modules.base.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +public class ROIResultsDto { + + /** + * 感兴趣区ID号 + */ + private Integer roi; + + + /** + * 样品谱感兴趣区总计数 + */ + private Double sGross; + + /** + * 气体本底谱感兴趣区总计数 + */ + private Double gGross; + + /** + * 探测器本底谱感兴趣区总计数 + */ + private Double bGross; + + /** + * 感兴趣区净计数 + */ + private Double net; + + /** + * 感兴趣区净计数不确定度 + */ + private Double netErr; + + /** + * 感兴趣区活度浓度 + */ + private Double conc; + + /** + * 感兴趣区活度浓度不确定度 + */ + private Double concErr; + + /** + * 感兴趣区LC + */ + private Double lc; + + /** + * 感兴趣区MDC + */ + private Double mdc; + + private String netCount; + + private String concStr; + + public void setNetCount() { + this.netCount = this.net + " +/- " + Math.sqrt(this.netErr); + } + + public void setConcStr() { + 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 new file mode 100644 index 00000000..cc3a6d5d --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/XeResultsDto.java @@ -0,0 +1,41 @@ +package org.jeecg.modules.base.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; +import java.util.Date; + +@Data +public class XeResultsDto { + /** + * 核素名称 + */ + private String nuclideName; + /** + * 感兴趣区活度浓度 + */ + private Double conc; + + /** + * 感兴趣区活度浓度不确定度 + */ + private Double concErr; + /** + * 感兴趣区MDC + */ + private Double mdc; + /** + * 感兴趣区LC + */ + private Double lc; + /** + * 感兴趣区识别标示;1:识别到,0,未识别到 + */ + private Integer nidFlag; + + private String concStr; + + public void setConcStr() { + this.concStr = this.conc + " +/- " + this.concErr; + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java index 23b2e163..4c068c88 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java @@ -13,7 +13,11 @@ public enum ExportTemplate { RadionuclideActivity_G("RadionuclideActivity-G.xls"), SampleInfo_B("SampleInformation-B.xls"), QcResult_B("QcResult-B.xls"), - RLR_B("RLR-B.xls"),RLR_G("Gamma.RLR"); + RLR_B("RLR-B.xls"),RLR_G("Gamma.RLR"), + ZEROTIME_G("ZeroTime.txt"), + SAVETOHTML("SaveHtml.html"), + SAVETOEXCEL("SaveExcel.xls"), + SAVETOTXT("SaveTxt.txt"); ExportTemplate(String name) { this.name = name; diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveExcel.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveExcel.xls new file mode 100644 index 00000000..e27a650e Binary files /dev/null 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 new file mode 100644 index 00000000..5c933aa1 --- /dev/null +++ b/jeecg-boot-base-core/src/main/resources/excelTemplate/SaveHtml.html @@ -0,0 +1,321 @@ + + +

CNL06 GENERATED REPORT +
REVIEWED RADIONUCLIDE REPORT +
(Noble Gas Version) +
+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#FILE INFORMATION
SampleMeasID:
GASBKMeasID:
SRID:
Detector Type:3D b-g
 
#COLLECTION INFORMATION
Station CODE:
Detector CODE:
Collection Start:
Collection Stop:
Collection TIME(h):
Air Volume[cm3]:
Xe Volume[cm3]:
 
#ACQUISITION INFORMATION
Acquisition Start:
Acq Real Time(s):
Acq Live Time:
 
#SOFTWARE
version:1.0.1
 
#SAMPLE Old CALIBRATION
Old BetaOld Gamma
CH(x) = (?1)+(?2)*x+(?3)x*x CH(x) = (?1)+(?2)*x+(?3)x*x
E(x) = (?1)+(?2)*x+(?3)x*x E(x) = (?1)+(?2)*x+(?3)x*x
 
#SAMPLE New CALIBRATION
New BetaNew Gamma
CH(x) = (?1)+(?2)*x+(?3)x*x CH(x) = (?1)+(?2)*x+(?3)x*x
E(x) = (-3.33443)+(0.398048)*x+(-0.000124)x*x E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x
 
#SAMPLE: LIMITS PER ROI
RoiBeta Gamma
 
#DET Old CALIBRATION
Old BetaOld Gamma
CH(x) = (?1)+(?2)*x+(?3)x*x CH(x) = (?1)+(?2)*x+(?3)x*x
E(x) = (?1)+(?2)*x+(?3)x*x E(x) = (?1)+(?2)*x+(?3)x*x
 
#DET New CALIBRATION
New BetaNew Gamma
CH(x) = (?1)+(?2)*x+(?3)x*x CH(x) = (?1)+(?2)*x+(?3)x*x
E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x
 
#DET: LIMITS PER ROI
RoiBeta Gamma
 
#GAS Old CALIBRATION
Old BetaOld Gamma
CH(x) = (?1)+(?2)*x+(?3)x*x CH(x) = (?1)+(?2)*x+(?3)x*x
E(x) = (?1)+(?2)*x+(?3)x*x E(x) = (?1)+(?2)*x+(?3)x*x
 
#GAS New CALIBRATION
New BetaNew Gamma
CH(x) = (?1)+(?2)*x+(?3)x*x CH(x) = (?1)+(?2)*x+(?3)x*x
E(x) = (-3.33443)+(0.398048)*x+(-0.000124)x*x E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x
 
#GAS: LIMITS PER ROI
RoiBeta Gamma
 
#GROSS COUNTS PER ROI
RoiSampleGasBkgndDetBkgnd
 
#NET COUNTS AND LC PER ROI
RoiNet count
 
#CONCENTRATION AND LC PER ROI
RoiConc(mBq/m3)LC(mBq/m3)MDC(mBq/m3):
 
#RESULT SUMMARY
Nuclide NameConcLCMDCNID Flag
 
+ \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/ZeroTime.txt b/jeecg-boot-base-core/src/main/resources/excelTemplate/ZeroTime.txt new file mode 100644 index 00000000..f4c03cce --- /dev/null +++ b/jeecg-boot-base-core/src/main/resources/excelTemplate/ZeroTime.txt @@ -0,0 +1,19 @@ +#### nuclide1: ${nuclide1} #### +HalfLife: ${halflife1} +Activity(Bq) : ${product1} +Fission_Yield(C): ${FY_N1_C} +Fission_Yield(I): ${FY_N1_I} + +#### nuclide2: ${nuclide2} #### +HalfLife: ${halflife2} +Activity(Bq) : ${product2} +Fission_Yield(C): ${FY_N2_C} +Fission_Yield(I): ${FY_N2_I} + +#### Other Information #### +Fission Target: ${target} +Energy: ${energyTFH}->Thermal_spectrum +Reference Time: ${date} ${time} + +#### Zero Time #### +${zeroTime} \ No newline at end of file diff --git a/jeecg-module-spectrum-analysis/pom.xml b/jeecg-module-spectrum-analysis/pom.xml index 225876d4..1496c748 100644 --- a/jeecg-module-spectrum-analysis/pom.xml +++ b/jeecg-module-spectrum-analysis/pom.xml @@ -42,6 +42,11 @@ sqlite-jdbc 3.34.0 + + + org.springframework.boot + spring-boot-starter-thymeleaf + \ No newline at end of file diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/DBUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/DBUtil.java index 2844baad..5391ba23 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/DBUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/DBUtil.java @@ -25,7 +25,8 @@ public class DBUtil implements Serializable { e.printStackTrace(); } //sqlite3文件的绝对路径 - String db = dbFilePath + StringPool.SLASH + "GammaDatabase.db"; + //String db = dbFilePath + StringPool.SLASH + "GammaDatabase.db"; + String db = "E:\\Code\\RadionuclideAnalysis\\AnalysisSystemForRadionuclide\\jeecg-module-spectrum-analysis\\src\\main\\java\\org\\jeecg\\common\\db\\GammaDatabase.db"; try { conn = DriverManager.getConnection("jdbc:sqlite:" + db); } catch (SQLException throwables) { 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 6185b705..03d12aca 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 @@ -999,4 +999,99 @@ public class PHDFileUtil { return xeResultsSpectrumList; } + public Map analyze(File sampleTmp, File gasTmp, File detTmp){ + Map result = new HashMap<>(); + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + //调用动态库解析文件 + BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath()); + /* GardsROIChannelsSpectrum集合 */ + List roiChannelsSpectrumList = new LinkedList<>(); + for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); + for (int i=0; ibgAnalyseResult.MDC.get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); + } + roiResultsSpectrumList.add(roiResults); + } + /* GardsXeResultsSpectrum集合 */ + List xeResultsSpectrumList = new LinkedList<>(); + GardsXeResultsSpectrum Xe131m = new GardsXeResultsSpectrum(); + Xe131m.setNuclideName(XeNuclideName.XE_131m.getType()); + Xe131m.setMdc(bgAnalyseResult.MDC_Xe131m); + Xe131m.setConc(bgAnalyseResult.Xe131m_con); + Xe131m.setConcErr(bgAnalyseResult.Xe131m_uncer); + Xe131m.setLc(bgAnalyseResult.LC_Xe131m); + xeResultsSpectrumList.add(Xe131m); + GardsXeResultsSpectrum Xe133 = new GardsXeResultsSpectrum(); + Xe133.setNuclideName(XeNuclideName.XE_133.getType()); + Xe133.setMdc(bgAnalyseResult.MDC_Xe133); + Xe133.setConc(bgAnalyseResult.Xe133_con); + Xe133.setConcErr(bgAnalyseResult.Xe133_uncer); + Xe133.setLc(bgAnalyseResult.LC_Xe133); + xeResultsSpectrumList.add(Xe133); + GardsXeResultsSpectrum Xe133m = new GardsXeResultsSpectrum(); + Xe133m.setNuclideName(XeNuclideName.XE_133m.getType()); + Xe133m.setMdc(bgAnalyseResult.MDC_Xe133m); + Xe133m.setConc(bgAnalyseResult.Xe133m_con); + Xe133m.setConcErr(bgAnalyseResult.Xe133m_uncer); + Xe133m.setLc(bgAnalyseResult.LC_Xe133m); + xeResultsSpectrumList.add(Xe133m); + GardsXeResultsSpectrum Xe135 = new GardsXeResultsSpectrum(); + Xe135.setNuclideName(XeNuclideName.XE_135.getType()); + Xe135.setMdc(bgAnalyseResult.MDC_Xe135); + Xe135.setConc(bgAnalyseResult.Xe135_con); + 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); + return result; + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index d4b7c751..47ef9ffe 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -146,6 +146,17 @@ public class GammaController { return gammaService.ZeroTimeAnalyse(nuclide1, nuclide2, product1, product2, target, energyTFH, date, time); } + @GetMapping("exportZeroTimeAnalyse") + @ApiOperation(value = "Zero Time分析导出", notes = "Zero Time分析导出") + public void exportZeroTimeAnalyse(String nuclide1, String nuclide2, + Double product1, Double product2, + String target, String energyTFH, + String date, String time, + HttpServletResponse response) { + gammaService.exportZeroTimeAnalyse(nuclide1, nuclide2, product1, product2, + target, energyTFH, date, time, response); + } + @GetMapping("Korsum") @ApiOperation(value = "Korsum页面数据", notes = "Korsum页面数据") public Result Korsum() { 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 826f8636..d2c33f2b 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,4 +216,13 @@ public class SpectrumAnalysesController { return spectrumAnalysisService.saveToDB(anlyseResultIn, request); } + @GetMapping("saveToHTML") + public void saveToHTML(HttpServletResponse response){ + spectrumAnalysisService.saveToHTML(response); + } + + @GetMapping("saveToExcel") + public void saveToExcel(HttpServletResponse response){ + spectrumAnalysisService.saveToExcel(response); + } } 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 abffbb44..cf7c824c 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 @@ -53,6 +53,12 @@ public interface IGammaService{ Result ZeroTimeAnalyse(String nuclide1, String nuclide2, Double product1, Double product2, String target, String energyTFH, String date, String time); + void exportZeroTimeAnalyse(String nuclide1, String nuclide2, + Double product1, Double product2, + String target, String energyTFH, + String date, String time, + HttpServletResponse response); + Result Korsum(); List KorSumInput(CoeffData coeffData); 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 72ed5eb2..fba99be4 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,4 +74,9 @@ public interface ISpectrumAnalysisService { Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request); + void saveToHTML(HttpServletResponse response); + + void saveToExcel(HttpServletResponse response); + + void saveToTxt(); } 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 da9bfc23..83312b08 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 @@ -48,8 +48,7 @@ import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; -import static org.jeecg.modules.base.enums.ExportTemplate.RLR_G; -import static org.jeecg.modules.base.enums.ExportTemplate.SampleInfo_G; +import static org.jeecg.modules.base.enums.ExportTemplate.*; @Service(value = "gammaService") @DS("ora") @@ -989,6 +988,63 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public void exportZeroTimeAnalyse(String nuclide1, String nuclide2, + Double product1, Double product2, + String target, String energyTFH, + String date, String time, + HttpServletResponse response) { + Result> result = ZeroTimeAnalyse(nuclide1, nuclide2, + product1, product2, target, energyTFH, date, time); + Map annlyse = result.getResult(); + annlyse.put("nuclide1", nuclide1); + annlyse.put("nuclide2", nuclide2); + annlyse.put("product1", product1); + annlyse.put("product2", product2); + annlyse.put("target", target); + annlyse.put("energyTFH", energyTFH); + annlyse.put("date", date); + annlyse.put("time", time); + + String pathPrefix = "excelTemplate/"; + String path = pathPrefix + ZEROTIME_G.getName(); + String template = ClassUtil.classPath(path); + List lines = FileUtil.readUtf8Lines(template); + // 正则表达式,匹配${}中的内容 + String regex = "\\$\\{([^}]+)}"; + List newLines = new ArrayList<>(); + + for (String line : lines) { + List fieldNames = ReUtil.findAllGroup1(regex, line); + if (CollUtil.isEmpty(fieldNames)){ + newLines.add(line); + continue; + } + // 一行内可能有多个需要替换的变量 + for (String fieldName : fieldNames) { + Object value = annlyse.get(fieldName); + String search = "${" + fieldName + "}"; + String replacement = StrUtil.toString(value); + replacement = StrUtil.isBlank(replacement) ? "null" : replacement; + line = StrUtil.replace(line, search, replacement); + } + newLines.add(line); + } + PrintWriter writer = null; + try { + String export = "ZeroTime-G.txt"; + writer = ExportUtil.streamWriter(response, export); + for (String newLine : newLines) { + writer.println(newLine); + } + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (ObjectUtil.isNotNull(writer)) + writer.close(); + } + } + public long fission_changed(String name) { long halflife = 0; //建立数据库连接 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 650d87c3..ef57c2b4 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 @@ -15,11 +15,13 @@ import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; +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.util.*; import org.jeecg.modules.base.bizVo.BetaRLR; +import org.jeecg.modules.base.dto.ROIChannelsDto; import org.jeecg.modules.base.entity.configuration.GardsDetectors; import org.jeecg.modules.base.entity.original.*; import org.jeecg.modules.base.entity.rnman.*; @@ -33,12 +35,18 @@ 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.thymeleaf.TemplateEngine; +import org.thymeleaf.context.Context; +import org.thymeleaf.spring5.SpringTemplateEngine; +import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.text.ParseException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -98,6 +106,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Autowired private IGardsHistogramSpectrumService histogramService; + @Override public Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String dbName, String[] menuTypes) { Result result = new Result(); @@ -1333,13 +1342,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { ExportUtil.exportXls(response, template, dataMap,export); } - public static void main(String[] args) { - BetaRLR betaRLR = new BetaRLR(); - Map dataMap = BeanUtil.beanToMap(betaRLR); - dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); - dataMap.forEach((key, value) -> System.out.println(key + "---" + value)); - } - @Override public Result viewGammaDetectorCalibration(Integer sampleId, String qcFileName, HttpServletRequest request) { Result result = new Result(); @@ -2844,6 +2846,90 @@ 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));*/ + + Map analyze = new HashMap<>(); + 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)); + + // 解析生成Html字符串并导出为Html文件 + String result = parseHtml(analyze); + PrintWriter writer = null; + try { + String export = "saveToHtml.html"; + writer = ExportUtil.htmlWriter(response, export); + writer.write(result); + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (ObjectUtil.isNotNull(writer)) + writer.close(); + } + } + + 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)); + List roiChannelsSpectrums = new LinkedList<>(); + List roiChannelsDtos = new LinkedList<>(); + for (GardsROIChannelsSpectrum roiChannel : roiChannelsSpectrums) { + ROIChannelsDto roiChannelsDto = new ROIChannelsDto(); + BeanUtil.copyProperties(roiChannel, roiChannelsDto); + roiChannelsDto.setbChanStr();roiChannelsDto.setgChanStr(); + roiChannelsDtos.add(roiChannelsDto); + } + GardsROIChannelsSpectrum roiChannelsSpectrum = new GardsROIChannelsSpectrum(); + roiChannelsSpectrum.setRoi(1); + roiChannelsSpectrum.setBChanStart(1); + roiChannelsSpectrum.setBChanStop(2); + roiChannelsSpectrums.add(roiChannelsSpectrum); + List roiResultsSpectrums = new LinkedList<>(); + List xeResultsSpectrums = new LinkedList<>(); + analyze.put("roiChannelsSpectrum", roiChannelsDtos); + analyze.put("roiResultsSpectrum", roiResultsSpectrums); + analyze.put("xeResultsSpectrum", xeResultsSpectrums); + EnergySpectrumStruct energySpectrumStruct = new EnergySpectrumStruct(); + analyze.putAll(BeanUtil.beanToMap(energySpectrumStruct)); + + // 将Null值替换为"",避免空指针异常(或者在模板中进行判断) + analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); + String export = "SaveToExcel.xls"; + String template = SAVETOEXCEL.getName(); + ExportUtil.exportXls(response, template, analyze,export); + } + + @Override + public void saveToTxt() { + + } + public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn) { //获取ftp文件路径下临时文件 File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());