feat:saveTo*
This commit is contained in:
parent
f20fdb4271
commit
80f3a55812
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -135,10 +135,10 @@
|
|||
<td width="453" height="40">Beta</td>
|
||||
<td width="103" height="40"> Gamma</td>
|
||||
</tr>
|
||||
<tr th:each="roiChannel : ${roiChannelsSpectrum}">
|
||||
<tr th:each="roiChannel : ${roiChannelsS}">
|
||||
<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>
|
||||
<td width="453" height="40" th:text="${roiChannel.bChanStr}"></td>
|
||||
<td width="103" height="40" th:text="${roiChannel.gChanStr}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" height="40"> </td>
|
||||
|
@ -187,10 +187,11 @@
|
|||
<td width="453" height="40">Beta</td>
|
||||
<td width="103" height="40"> Gamma</td>
|
||||
</tr>
|
||||
<tr th:each="roiChannel : ${roiChannelsSpectrum}">
|
||||
<tr th:each="roiChannel : ${roiChannelsD}">
|
||||
<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>
|
||||
<td width="453" height="40" th:text="${roiChannel.bChanStr}"></td>
|
||||
<td width="103" height="40" th:text="${roiChannel.gChanStr}"></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" height="40"> </td>
|
||||
|
@ -239,10 +240,10 @@
|
|||
<td width="453" height="40">Beta</td>
|
||||
<td width="103" height="40"> Gamma</td>
|
||||
</tr>
|
||||
<tr th:each="roiChannel : ${roiChannelsSpectrum}">
|
||||
<tr th:each="roiChannel : ${roiChannelsG}">
|
||||
<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>
|
||||
<td width="453" height="40" th:text="${roiChannel.bChanStr}"></td>
|
||||
<td width="103" height="40" th:text="${roiChannel.gChanStr}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" height="40"> </td>
|
||||
|
@ -256,7 +257,7 @@
|
|||
<td width="103" height="40">GasBkgnd</td>
|
||||
<td width="123" height="40">DetBkgnd</td>
|
||||
</tr>
|
||||
<tr th:each="roiResult : ${roiResultsSpectrum}">
|
||||
<tr th:each="roiResult : ${roiResults}">
|
||||
<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>
|
||||
|
@ -272,9 +273,9 @@
|
|||
<td width="463" height="40"> Roi</td>
|
||||
<td width="453" height="40">Net count</td>
|
||||
</tr>
|
||||
<tr th:each="roiResult : ${roiResultsSpectrum}">
|
||||
<tr th:each="roiResult : ${roiResults}">
|
||||
<td width="463" height="40" th:text="${roiResult.roi}"></td>
|
||||
<td width="453" height="40" th:text="${roiResult.net + ' +/- ' + #numbers.sqrt(roiResult.netErr)}"></td>
|
||||
<td width="453" height="40" th:text="${roiResult.netCount}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" height="40"> </td>
|
||||
|
@ -288,9 +289,9 @@
|
|||
<td width="103" height="40">LC(mBq/m3)</td>
|
||||
<td width="123" height="40">MDC(mBq/m3):</td>
|
||||
</tr>
|
||||
<tr th:each="roiResult : ${roiResultsSpectrum}">
|
||||
<tr th:each="roiResult : ${roiResults}">
|
||||
<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.concStr}"></td>
|
||||
<td width="453" height="40" th:text="${roiResult.lc}"></td>
|
||||
<td width="453" height="40" th:text="${roiResult.mdc}"></td>
|
||||
</tr>
|
||||
|
@ -307,9 +308,9 @@
|
|||
<td width="123" height="40">MDC</td>
|
||||
<td width="83" height="40">NID Flag</td>
|
||||
</tr>
|
||||
<tr th:each="xeResult : ${xeResultsSpectrum}">
|
||||
<tr th:each="xeResult : ${xeResults}">
|
||||
<td width="463" height="40" th:text="${xeResult.nuclideName}"></td>
|
||||
<td width="453" height="40" th:text="${xeResult.conc + ' +/- ' +xeResult.concErr}"></td>
|
||||
<td width="453" height="40" th:text="${xeResult.concStr}"></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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<String, Object> 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<String, Map<String, Object>> cache = betaCache.getBetaCache();
|
||||
//根据qc文件名称-用户名-beta的方式获取beta的内容
|
||||
Map<String, Object> betaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-beta");
|
||||
List<SeriseData> betaList = new LinkedList<>();
|
||||
List<String> betaFittingPara = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(betaMap)) {
|
||||
betaList = (List<SeriseData>)betaMap.get("Series");
|
||||
betaFittingPara = (List<String>) betaMap.get("fittingPara");
|
||||
}
|
||||
//根据qc文件名称-用户名-gamma的方式获取gamma的内容
|
||||
Map<String, Object> gammaMap = cache.getIfPresent(anlyseResultIn.getQcFileName() + "-" + userName + "-gamma");
|
||||
List<SeriseData> gammaList = new LinkedList<>();
|
||||
List<String> gammaFittingPara = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(gammaMap)) {
|
||||
gammaList = (List<SeriseData>)gammaMap.get("Series");
|
||||
gammaFittingPara = (List<String>) gammaMap.get("fittingPara");
|
||||
}
|
||||
|
||||
Map<String, Object> 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<String, Object> shiftSaveData(BgDataAnlyseResultIn anlyseResultIn){
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<GardsROIChannelsSpectrum> roiChannels = anlyseResultIn.getRoiChannelsSpectrumList();
|
||||
List<GardsROIResultsSpectrum> roiResults = anlyseResultIn.getRoiResultsSpectrumList();
|
||||
List<GardsXeResults> 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<ROIChannelsDto> roiChannelsDtosS = new LinkedList<>();
|
||||
List<ROIChannelsDto> roiChannelsDtosD = new LinkedList<>();
|
||||
List<ROIChannelsDto> 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<ROIResultsDto> roiResultsDtos = new LinkedList<>();
|
||||
for (GardsROIResultsSpectrum roiResult : roiResults) {
|
||||
ROIResultsDto roiResultsDto = new ROIResultsDto();
|
||||
BeanUtil.copyProperties(roiResult, roiResultsDto);
|
||||
roiResultsDto.shift();
|
||||
roiResultsDtos.add(roiResultsDto);
|
||||
}
|
||||
// 转换XeResults数据
|
||||
List<XeResultsDto> 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<String, Object> 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<String, Object> exportData(BgDataAnlyseResultIn anlyseResultIn){
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> 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<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));
|
||||
return analyze;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn);
|
||||
|
||||
// 解析生成Html字符串并导出为Html文件
|
||||
String result = parseHtml(analyze);
|
||||
|
@ -2912,65 +3063,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
}
|
||||
}
|
||||
|
||||
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));
|
||||
// 转换ROIChannels数据
|
||||
List<GardsROIChannelsSpectrum> roiChannelsSpectrums = new LinkedList<>();
|
||||
List<ROIChannelsDto> 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<GardsROIResultsSpectrum> roiResultsSpectrums = new LinkedList<>();
|
||||
List<ROIResultsDto> roiResultsDtos = new LinkedList<>();
|
||||
for (GardsROIResultsSpectrum roiResult : roiResultsSpectrums) {
|
||||
ROIResultsDto roiResultsDto = new ROIResultsDto();
|
||||
BeanUtil.copyProperties(roiResult, roiResultsDto);
|
||||
roiResultsDto.setConcStr();roiResultsDto.setNetCount();
|
||||
roiResultsDtos.add(roiResultsDto);
|
||||
}
|
||||
// 转换XeResults数据
|
||||
List<GardsXeResultsSpectrum> xeResultsSpectrums = new LinkedList<>();
|
||||
List<XeResultsDto> 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<String, Object> 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<GardsROIChannelsSpectrum> roiChannelsSpectrums = new LinkedList<>();
|
||||
GardsROIChannelsSpectrum roiChannelsSpectrum = new GardsROIChannelsSpectrum();
|
||||
roiChannelsSpectrum.setRoi(1);
|
||||
roiChannelsSpectrum.setBChanStart(1);
|
||||
roiChannelsSpectrum.setBChanStop(2);
|
||||
roiChannelsSpectrums.add(roiChannelsSpectrum);
|
||||
Map<String, Object> 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<String, Object> analyze = exportData(anlyseResultIn);
|
||||
|
||||
// 生成指定格式的导出数据备用
|
||||
List<ROIChannelsDto> roiChannelsDtosS = (List<ROIChannelsDto>) analyze.get("roiChannelsS");
|
||||
List<ROIChannelsDto> roiChannelsDtosD = (List<ROIChannelsDto>) analyze.get("roiChannelsD");
|
||||
List<ROIChannelsDto> roiChannelsDtosG = (List<ROIChannelsDto>) analyze.get("roiChannelsG");
|
||||
List<ROIResultsDto> roiResultsDtos = (List<ROIResultsDto>) analyze.get("roiResults");
|
||||
List<XeResultsDto> xeResultsDtos = (List<XeResultsDto>) 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<String> newLines = new ArrayList<>();
|
||||
List<String> list = ListUtil.toList("limitRoi", "grossRoi",
|
||||
List<String> list = ListUtil.toList("sampleRoi", "detRoi", "gasRoi","grossRoi",
|
||||
"netRoi", "concRoi", "resultSummary");
|
||||
List<String> skip = ListUtil.toList("${limitRoi}", "${grossRoi}",
|
||||
"${netRoi}", "${concRoi}", "${resultSummary}");
|
||||
List<String> skip = ListUtil.toList("${sampleRoi}", "${detRoi}", "${gasRoi}",
|
||||
"${grossRoi}", "${netRoi}", "${concRoi}", "${resultSummary}");
|
||||
for (String line : lines) {
|
||||
List<String> fieldNames = ReUtil.findAllGroup1(regex, line);
|
||||
if (CollUtil.isEmpty(fieldNames)){
|
||||
|
@ -3039,20 +3138,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
}
|
||||
}
|
||||
|
||||
private List<String> roiChannels(List<GardsROIChannelsSpectrum> roiChannels){
|
||||
private List<String> roiChannels(List<ROIChannelsDto> roiChannels){
|
||||
int min = 49;
|
||||
String space = StrUtil.SPACE;
|
||||
List<String> 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<String, Object> roiResults(List<GardsROIResultsSpectrum> roiResults){
|
||||
private Map<String, Object> roiResults(List<ROIResultsDto> 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<String> xeResults(List<GardsXeResultsSpectrum> xeResults){
|
||||
private List<String> xeResults(List<XeResultsDto> xeResults){
|
||||
int min1 = 49;
|
||||
int min2 = 22;
|
||||
String space = StrUtil.SPACE;
|
||||
List<String> 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());
|
||||
|
|
Loading…
Reference in New Issue
Block a user