feat:saveTo*

This commit is contained in:
nieziyan 2023-09-18 19:58:08 +08:00
parent ed7493423b
commit 5835ef9543
18 changed files with 801 additions and 11 deletions

View File

@ -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";

View File

@ -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 <T> void exportXls(HttpServletResponse response, Class<T> target,
List<T> data, String fileName){
ExportParams params = new ExportParams();

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -0,0 +1,321 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<h4 align="center">CNL06 GENERATED REPORT
<br>REVIEWED RADIONUCLIDE REPORT
<br>(Noble Gas Version)
<br th:text="'Creation Date ' + ${now}">
<br>
</h4>
<table border="1" align="center" bordercolor="black" cellspacing="0">
<tr>
<td colspan="5" height="40">#FILE INFORMATION</td>
</tr>
<tr>
<td width="463" height="40"> SampleMeasID:</td>
<td width="453" height="40" colspan="4" th:text="${measurement_id}"></td>
</tr>
<tr>
<td width="463" height="40"> GASBKMeasID:</td>
<td width="453" height="40" colspan="4" th:text="${gas_bk_measurement_id}"></td>
</tr>
<tr>
<td width="463" height="40"> SRID:</td>
<td width="453" height="40" colspan="4" th:text="${sample_ref_id}"></td>
</tr>
<tr>
<td width="463" height="40"> Detector Type:</td>
<td width="453" height="40" colspan="4">3D b-g</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#COLLECTION INFORMATION</td>
</tr>
<tr>
<td width="463" height="40"> Station CODE:</td>
<td width="453" height="40" colspan="4" th:text="${site_code}"></td>
</tr>
<tr>
<td width="463" height="40"> Detector CODE:</td>
<td width="453" height="40" colspan="4" th:text="${detector_code}"></td>
</tr>
<tr>
<td width="463" height="40"> Collection Start:</td>
<td width="453" height="40" colspan="4" th:text="${collection_start_date + ' ' +collection_start_time}"></td>
</tr>
<tr>
<td width="463" height="40"> Collection Stop:</td>
<td width="453" height="40" colspan="4" th:text="${collection_stop_date + ' ' + collection_stop_time}"></td>
</tr>
<tr>
<td width="463" height="40"> Collection TIME(h):</td>
<td width="453" height="40" colspan="4" th:text="${collection_time}"></td>
</tr>
<tr>
<td width="463" height="40"> Air Volume[cm3]:</td>
<td width="453" height="40" colspan="4" th:text="${air_volume}"></td>
</tr>
<tr>
<td width="463" height="40"> Xe Volume[cm3]:</td>
<td width="453" height="40" colspan="4" th:text="${sample_volume_of_Xe}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#ACQUISITION INFORMATION</td>
</tr>
<tr>
<td width="463" height="40"> Acquisition Start:</td>
<td width="453" height="40" colspan="4" th:text="${acquisition_start_date + ' ' + acquisition_start_time}"></td>
</tr>
<tr>
<td width="463" height="40"> Acq Real Time(s):</td>
<td width="453" height="40" colspan="4" th:text="${acquisition_real_time}"></td>
</tr>
<tr>
<td width="463" height="40"> Acq Live Time:</td>
<td width="453" height="40" colspan="4" th:text="${acquisition_live_time}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#SOFTWARE</td>
</tr>
<tr>
<td width="463" height="40"> version:</td>
<td width="453" height="40" colspan="4">1.0.1</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#SAMPLE Old CALIBRATION</td>
</tr>
<tr>
<td width="463" height="40"> Old Beta</td>
<td width="453" height="40">Old Gamma</td>
</tr>
<tr>
<td width="463" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td width="463" height="40"> E(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> E(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#SAMPLE New CALIBRATION</td>
</tr>
<tr>
<td width="463" height="40"> New Beta</td>
<td width="453" height="40">New Gamma</td>
</tr>
<tr>
<td width="463" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td width="463" height="40"> E(x) = (-3.33443)+(0.398048)*x+(-0.000124)x*x</td>
<td width="453" height="40"> E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#SAMPLE: LIMITS PER ROI</td>
</tr>
<tr>
<td width="463" height="40"> Roi</td>
<td width="453" height="40">Beta</td>
<td width="103" height="40"> Gamma</td>
</tr>
<tr th:each="roiChannel : ${roiChannelsSpectrum}">
<td width="463" height="40" th:text="${roiChannel.roi}"></td>
<td width="453" height="40" th:text="${roiChannel.bChanStart + ' to ' + roiChannel.bChanStop}"></td>
<td width="103" height="40" th:text="${roiChannel.gChanStart + ' to ' + roiChannel.gChanStop}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#DET Old CALIBRATION</td>
</tr>
<tr>
<td width="463" height="40"> Old Beta</td>
<td width="453" height="40">Old Gamma</td>
</tr>
<tr>
<td width="463" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td width="463" height="40"> E(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> E(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#DET New CALIBRATION</td>
</tr>
<tr>
<td width="463" height="40"> New Beta</td>
<td width="453" height="40">New Gamma</td>
</tr>
<tr>
<td width="463" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td width="463" height="40"> E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x</td>
<td width="453" height="40"> E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#DET: LIMITS PER ROI</td>
</tr>
<tr>
<td width="463" height="40"> Roi</td>
<td width="453" height="40">Beta</td>
<td width="103" height="40"> Gamma</td>
</tr>
<tr th:each="roiChannel : ${roiChannelsSpectrum}">
<td width="463" height="40" th:text="${roiChannel.roi}"></td>
<td width="453" height="40" th:text="${roiChannel.bChanStart + ' to ' + roiChannel.bChanStop}"></td>
<td width="103" height="40" th:text="${roiChannel.gChanStart + ' to ' + roiChannel.gChanStop}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#GAS Old CALIBRATION</td>
</tr>
<tr>
<td width="463" height="40"> Old Beta</td>
<td width="453" height="40">Old Gamma</td>
</tr>
<tr>
<td width="463" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td width="463" height="40"> E(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> E(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#GAS New CALIBRATION</td>
</tr>
<tr>
<td width="463" height="40"> New Beta</td>
<td width="453" height="40">New Gamma</td>
</tr>
<tr>
<td width="463" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
<td width="453" height="40"> CH(x) = (?1)+(?2)*x+(?3)x*x</td>
</tr>
<tr>
<td width="463" height="40"> E(x) = (-3.33443)+(0.398048)*x+(-0.000124)x*x</td>
<td width="453" height="40"> E(x) = (0.879727)+(0.365551)*x+(-2.8e-05)x*x</td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#GAS: LIMITS PER ROI</td>
</tr>
<tr>
<td width="463" height="40"> Roi</td>
<td width="453" height="40">Beta</td>
<td width="103" height="40"> Gamma</td>
</tr>
<tr th:each="roiChannel : ${roiChannelsSpectrum}">
<td width="463" height="40" th:text="${roiChannel.roi}"></td>
<td width="453" height="40" th:text="${roiChannel.bChanStart + ' to ' + roiChannel.bChanStop}"></td>
<td width="103" height="40" th:text="${roiChannel.gChanStart + ' to ' + roiChannel.gChanStop}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#GROSS COUNTS PER ROI</td>
</tr>
<tr>
<td width="463" height="40"> Roi</td>
<td width="453" height="40">Sample</td>
<td width="103" height="40">GasBkgnd</td>
<td width="123" height="40">DetBkgnd</td>
</tr>
<tr th:each="roiResult : ${roiResultsSpectrum}">
<td width="463" height="40" th:text="${roiResult.roi}"></td>
<td width="453" height="40" th:text="${roiResult.sGross}"></td>
<td width="103" height="40" th:text="${roiResult.gGross}"></td>
<td width="123" height="40" th:text="${roiResult.bGross}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#NET COUNTS AND LC PER ROI</td>
</tr>
<tr>
<td width="463" height="40"> Roi</td>
<td width="453" height="40">Net count</td>
</tr>
<tr th:each="roiResult : ${roiResultsSpectrum}">
<td width="463" height="40" th:text="${roiResult.roi}"></td>
<td width="453" height="40" th:text="${roiResult.net + ' +/- ' + #numbers.sqrt(roiResult.netErr)}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#CONCENTRATION AND LC PER ROI</td>
</tr>
<tr>
<td width="463" height="40"> Roi</td>
<td width="453" height="40">Conc(mBq/m3)</td>
<td width="103" height="40">LC(mBq/m3)</td>
<td width="123" height="40">MDC(mBq/m3):</td>
</tr>
<tr th:each="roiResult : ${roiResultsSpectrum}">
<td width="463" height="40" th:text="${roiResult.roi}"></td>
<td width="453" height="40" th:text="${roiResult.concErr + ' +/- ' + roiResult.concErr}"></td>
<td width="453" height="40" th:text="${roiResult.lc}"></td>
<td width="453" height="40" th:text="${roiResult.mdc}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
<tr>
<td colspan="5" height="40">#RESULT SUMMARY</td>
</tr>
<tr>
<td width="463" height="40"> Nuclide Name</td>
<td width="453" height="40">Conc</td>
<td width="103" height="40">LC</td>
<td width="123" height="40">MDC</td>
<td width="83" height="40">NID Flag</td>
</tr>
<tr th:each="xeResult : ${xeResultsSpectrum}">
<td width="463" height="40" th:text="${xeResult.nuclideName}"></td>
<td width="453" height="40" th:text="${xeResult.conc + ' +/- ' +xeResult.concErr}"></td>
<td width="103" height="40" th:text="${xeResult.lc}"></td>
<td width="123" height="40" th:text="${xeResult.mdc}"></td>
<td width="83" height="40" th:text="${xeResult.nidFlag}"></td>
</tr>
<tr>
<td colspan="5" height="40">&nbsp</td>
</tr>
</table>
</html>

View File

@ -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}

View File

@ -42,6 +42,11 @@
<artifactId>sqlite-jdbc</artifactId>
<version>3.34.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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) {

View File

@ -999,4 +999,99 @@ public class PHDFileUtil {
return xeResultsSpectrumList;
}
public Map<String, Object> analyze(File sampleTmp, File gasTmp, File detTmp){
Map<String, Object> result = new HashMap<>();
//加载dll工具库
System.loadLibrary("ReadPHDFile");
//调用动态库解析文件
BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath());
/* GardsROIChannelsSpectrum集合 */
List<GardsROIChannelsSpectrum> roiChannelsSpectrumList = new LinkedList<>();
for (int i=0; i<bgAnalyseResult.S_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.S_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.S_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.S_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.S_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
for (int i=0; i<bgAnalyseResult.G_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.G_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.G_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.G_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
for (int i=0; i<bgAnalyseResult.D_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.D_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.D_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.D_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.D_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
/* GardsROIResultsSpectrum集合 */
List<GardsROIResultsSpectrum> roiResultsSpectrumList = new LinkedList<>();
for (int i=0; i<bgAnalyseResult.s_roi_cts.size(); i++) {
GardsROIResultsSpectrum roiResults = new GardsROIResultsSpectrum();
roiResults.setRoi(i+1);
bgAnalyseResult.LC.add(0, 0.0);
roiResults.setLc(bgAnalyseResult.LC.get(i));
roiResults.setSGross(bgAnalyseResult.s_roi_cts.get(i));
roiResults.setGGross(bgAnalyseResult.g_roi_cts.get(i));
roiResults.setBGross(bgAnalyseResult.d_roi_cts.get(i));
roiResults.setSNet(bgAnalyseResult.s_deduct_d_cts.get((i+1)*3));
roiResults.setGNet(bgAnalyseResult.g_deduct_d_cts.get((i+1)*3));
roiResults.setNet(bgAnalyseResult.ROI_net_coutns.get(i));
roiResults.setNetErr(bgAnalyseResult.ROI_net_coutns_err.get(i));
roiResults.setConc(bgAnalyseResult.ROI_con_uncer.get(i));
roiResults.setConcErr(bgAnalyseResult.ROI_con_uncer_err.get(i));
bgAnalyseResult.MDC.add(0, 0.0);
roiResults.setMdc(bgAnalyseResult.MDC.get(i));
if(bgAnalyseResult.ROI_con_uncer.get(i)>bgAnalyseResult.MDC.get(i)) {
roiResults.setNidFlag(1);
} else {
roiResults.setNidFlag(0);
}
roiResultsSpectrumList.add(roiResults);
}
/* GardsXeResultsSpectrum集合 */
List<GardsXeResultsSpectrum> 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;
}
}

View File

@ -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() {

View File

@ -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);
}
}

View File

@ -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<InputData> KorSumInput(CoeffData coeffData);

View File

@ -74,4 +74,9 @@ public interface ISpectrumAnalysisService {
Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request);
void saveToHTML(HttpServletResponse response);
void saveToExcel(HttpServletResponse response);
void saveToTxt();
}

View File

@ -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<Map<String, Object>> result = ZeroTimeAnalyse(nuclide1, nuclide2,
product1, product2, target, energyTFH, date, time);
Map<String, Object> 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<String> lines = FileUtil.readUtf8Lines(template);
// 正则表达式匹配${}中的内容
String regex = "\\$\\{([^}]+)}";
List<String> newLines = new ArrayList<>();
for (String line : lines) {
List<String> 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;
//建立数据库连接

View File

@ -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<String,Object> 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<String, Object> analyze = phdFileUtil.analyze(null, null, null);
analyze.putAll(BeanUtil.beanToMap(energySpectrumStruct));*/
Map<String, Object> analyze = new HashMap<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE_TIME_S);
analyze.put("now", LocalDateTime.now().format(formatter));
List<GardsROIChannelsSpectrum> roiChannelsSpectrums = new LinkedList<>();
List<GardsROIResultsSpectrum> roiResultsSpectrumList = new LinkedList<>();
List<GardsXeResultsSpectrum> 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<String, Object> 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<String, Object> analyze = new HashMap<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateConstant.DATE_TIME_S);
analyze.put("now", LocalDateTime.now().format(formatter));
List<GardsROIChannelsSpectrum> roiChannelsSpectrums = new LinkedList<>();
List<ROIChannelsDto> 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<GardsROIResultsSpectrum> roiResultsSpectrums = new LinkedList<>();
List<GardsXeResultsSpectrum> 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());