feat:back
This commit is contained in:
parent
b1abdedf89
commit
055147f72d
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
|
@ -9,10 +10,8 @@ import org.springframework.core.io.ResourceLoader;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ClassUtil {
|
||||
|
||||
|
@ -33,6 +32,12 @@ public class ClassUtil {
|
|||
return fieldValue;
|
||||
}
|
||||
|
||||
public static <T> Map<String,Object> fieldValue(T obj){
|
||||
List<String> fields = Arrays.stream(obj.getClass().getDeclaredFields())
|
||||
.map(Field::getName).collect(Collectors.toList());
|
||||
return fieldValue(obj, fields);
|
||||
}
|
||||
|
||||
public static <T> List<String> objsStr(List<T> objs){
|
||||
String sapce5 = " ";
|
||||
List<String> objsStr = new ArrayList<>();
|
||||
|
@ -65,4 +70,35 @@ public class ClassUtil {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static <T1,T2> void copyProperties(T1 source, T2 target){
|
||||
Class<?> sourceClass = source.getClass();
|
||||
Class<?> targetClass = target.getClass();
|
||||
|
||||
// 获取源对象的所有字段
|
||||
Field[] sourceFields = sourceClass.getDeclaredFields();
|
||||
|
||||
for (Field sourceField : sourceFields) {
|
||||
// 设置可访问私有字段
|
||||
sourceField.setAccessible(true);
|
||||
|
||||
// 获取字段的名称
|
||||
String fieldName = sourceField.getName();
|
||||
|
||||
try {
|
||||
// 获取目标对象中同名的字段
|
||||
Field targetField = targetClass.getDeclaredField(fieldName);
|
||||
|
||||
// 设置可访问私有字段
|
||||
targetField.setAccessible(true);
|
||||
|
||||
// 将源对象的属性值赋值给目标对象的同名属性
|
||||
targetField.set(target, sourceField.get(source));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// 当目标对象中无法找到同名的字段时,忽略该属性
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package org.jeecg.modules.base.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ESStructDto {
|
||||
|
||||
private String measurement_id;
|
||||
|
||||
private String gas_bk_measurement_id;
|
||||
|
||||
private String sample_ref_id;
|
||||
|
||||
private String site_code;
|
||||
|
||||
private String detector_code;
|
||||
|
||||
/**
|
||||
* collection start date (yyyy / mm / dd)
|
||||
*/
|
||||
public String collection_start_date;
|
||||
/**
|
||||
* collection start time (hh : mm : ss . s)
|
||||
*/
|
||||
public String collection_start_time;
|
||||
/**
|
||||
* collection stop date (yyyy / mm / dd)
|
||||
*/
|
||||
public String collection_stop_date;
|
||||
/**
|
||||
* collection stop time (hh : mm : ss . s)
|
||||
*/
|
||||
public String collection_stop_time;
|
||||
|
||||
// 自己计算
|
||||
private String collection_time;
|
||||
|
||||
private double air_volume;
|
||||
|
||||
private double sample_volume_of_Xe;
|
||||
|
||||
public String acquisition_start_date;
|
||||
/**
|
||||
* acquisition start time (hh : mm : ss . s)
|
||||
*/
|
||||
public String acquisition_start_time;
|
||||
/**
|
||||
* acquisition real time (s)
|
||||
*/
|
||||
public double acquisition_real_time;
|
||||
/**
|
||||
* acquisition live time (s)
|
||||
*/
|
||||
public double acquisition_live_time;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,85 @@
|
|||
CNL06 GENERATED REPORT
|
||||
REVIEWED RADIONUCLIDE REPORT
|
||||
(Noble Gas Version)
|
||||
Creation Date ${now}
|
||||
|
||||
#FILE INFORMATION
|
||||
SampleMeasID: ${measurement_id}
|
||||
GASBKMeasID: ${gas_bk_measurement_id}
|
||||
SRID: ${sample_ref_id}
|
||||
Detector Type: 3D b-g
|
||||
|
||||
#COLLECTION INFORMATION
|
||||
Station CODE: ${site_code}
|
||||
Detector CODE: ${detector_code}
|
||||
Collection Start: ${collection_start_date} ${collection_start_time}
|
||||
Collection Stop: ${collection_stop_date} ${collection_stop_time}
|
||||
Collection TIME(h): ${collection_time}
|
||||
Air Volume[cm3]: ${air_volume}
|
||||
Xe Volume[cm3]: ${sample_volume_of_Xe}
|
||||
|
||||
#ACQUISITION INFORMATION
|
||||
Acquisition Start: ${acquisition_start_date} ${acquisition_start_time}
|
||||
Acq Real Time(s): ${acquisition_real_time}
|
||||
Acq Live Time: ${acquisition_live_time}
|
||||
|
||||
#SOFTWARE
|
||||
version: 1.0.1
|
||||
|
||||
#SAMPLE Old CALIBRATION
|
||||
Old Beta Old 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 Beta New 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
|
||||
Roi Beta Gamma
|
||||
${limitRoi}
|
||||
|
||||
#DET Old CALIBRATION
|
||||
Old Beta Old 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 Beta New 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
|
||||
Roi Beta Gamma
|
||||
${limitRoi}
|
||||
|
||||
#GAS Old CALIBRATION
|
||||
Old Beta Old 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 Beta New 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
|
||||
Roi Beta Gamma
|
||||
${limitRoi}
|
||||
|
||||
#GROSS COUNTS PER ROI
|
||||
Roi Sample GasBkgnd DetBkgnd
|
||||
${grossRoi}
|
||||
|
||||
#NET COUNTS AND LC PER ROI
|
||||
Roi Net count
|
||||
${netRoi}
|
||||
|
||||
#CONCENTRATION AND LC PER ROI
|
||||
Roi Conc(mBq/m3) LC(mBq/m3) MDC(mBq/m3)
|
||||
${concRoi}
|
||||
|
||||
#RESULT SUMMARY
|
||||
Nuclide Name Conc LC MDC NID Flag
|
||||
${resultSummary}
|
|
@ -225,4 +225,9 @@ public class SpectrumAnalysesController {
|
|||
public void saveToExcel(HttpServletResponse response){
|
||||
spectrumAnalysisService.saveToExcel(response);
|
||||
}
|
||||
|
||||
@GetMapping("saveToTxt")
|
||||
public void saveToTxt(HttpServletResponse response){
|
||||
spectrumAnalysisService.saveToTxt(response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,5 +78,5 @@ public interface ISpectrumAnalysisService {
|
|||
|
||||
void saveToExcel(HttpServletResponse response);
|
||||
|
||||
void saveToTxt();
|
||||
void saveToTxt(HttpServletResponse response);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
|
@ -23,7 +26,10 @@ 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.ESStructDto;
|
||||
import org.jeecg.modules.base.dto.ROIChannelsDto;
|
||||
import org.jeecg.modules.base.dto.ROIResultsDto;
|
||||
import org.jeecg.modules.base.dto.XeResultsDto;
|
||||
import org.jeecg.modules.base.entity.configuration.GardsDetectors;
|
||||
import org.jeecg.modules.base.entity.original.*;
|
||||
import org.jeecg.modules.base.entity.rnman.*;
|
||||
|
@ -2948,28 +2954,49 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
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);
|
||||
}
|
||||
GardsROIChannelsSpectrum roiChannelsSpectrum = new GardsROIChannelsSpectrum();
|
||||
roiChannelsSpectrum.setRoi(1);
|
||||
roiChannelsSpectrum.setBChanStart(1);
|
||||
roiChannelsSpectrum.setBChanStop(2);
|
||||
roiChannelsSpectrums.add(roiChannelsSpectrum);
|
||||
// 转换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<>();
|
||||
analyze.put("roiChannelsSpectrum", roiChannelsDtos);
|
||||
analyze.put("roiResultsSpectrum", roiResultsSpectrums);
|
||||
analyze.put("xeResultsSpectrum", xeResultsSpectrums);
|
||||
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();
|
||||
analyze.putAll(BeanUtil.beanToMap(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));
|
||||
|
||||
// 将Null值替换为"",避免空指针异常(或者在模板中进行判断)
|
||||
// 将Null值替换为"",避免空指针异常(集合为空集合,不能为null)
|
||||
analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
|
||||
String export = "SaveToExcel.xls";
|
||||
String template = SAVETOEXCEL.getName();
|
||||
|
@ -2977,8 +3004,160 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveToTxt() {
|
||||
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));
|
||||
// 使数据适配导出模板
|
||||
String pathPrefix = "excelTemplate/";
|
||||
String path = pathPrefix + SAVETOTXT.getName();
|
||||
String template = ClassUtil.classPath(path);
|
||||
List<String> lines = FileUtil.readUtf8Lines(template);
|
||||
// 正则表达式,匹配${}中的内容
|
||||
String regex = "\\$\\{([^}]+)}";
|
||||
List<String> newLines = new ArrayList<>();
|
||||
List<String> list = ListUtil.toList("limitRoi", "grossRoi",
|
||||
"netRoi", "concRoi", "resultSummary");
|
||||
List<String> skip = ListUtil.toList("${limitRoi}", "${grossRoi}",
|
||||
"${netRoi}", "${concRoi}", "${resultSummary}");
|
||||
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 = analyze.get(fieldName);
|
||||
if (CollUtil.contains(list, fieldName)){
|
||||
newLines.addAll((List<String>)value);
|
||||
}else {
|
||||
String search = "${" + fieldName + "}";
|
||||
String replacement = StrUtil.toString(value);
|
||||
replacement = StrUtil.isBlank(replacement) ? "null" : replacement;
|
||||
line = StrUtil.replace(line, search, replacement);
|
||||
}
|
||||
}
|
||||
if (!CollUtil.contains(skip, line))
|
||||
newLines.add(line);
|
||||
}
|
||||
PrintWriter writer = null;
|
||||
try {
|
||||
String export = "SaveToTxt.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();
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> roiChannels(List<GardsROIChannelsSpectrum> roiChannels){
|
||||
int min = 49;
|
||||
String space = StrUtil.SPACE;
|
||||
List<String> channelStrs = new ArrayList<>();
|
||||
if (CollUtil.isEmpty(roiChannels))
|
||||
return channelStrs;
|
||||
for (GardsROIChannelsSpectrum 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 channelStr = StrUtil.padAfter(roi, min, space) +
|
||||
StrUtil.padAfter(bChanStr, min, space) +
|
||||
gChanStr;
|
||||
channelStrs.add(channelStr);
|
||||
}
|
||||
return channelStrs;
|
||||
}
|
||||
|
||||
private Map<String, Object> roiResults(List<GardsROIResultsSpectrum> roiResults){
|
||||
int min1 = 49;
|
||||
int min2 = 22;
|
||||
String space = StrUtil.SPACE;
|
||||
List<String> grossStrs = new ArrayList<>();
|
||||
List<String> netStrs = new ArrayList<>();
|
||||
List<String> concStrs = new ArrayList<>();
|
||||
Map<String, Object> roiResultsStr = new HashMap<>();
|
||||
if (CollUtil.isEmpty(roiResults)){
|
||||
roiResultsStr.put("grossRoi", grossStrs);
|
||||
roiResultsStr.put("netRoi", netStrs);
|
||||
roiResultsStr.put("concRoi", concStrs);
|
||||
return roiResultsStr;
|
||||
}
|
||||
for (GardsROIResultsSpectrum 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 lc = StrUtil.toString(roiResult.getLc());
|
||||
String mdc = StrUtil.toString(roiResult.getMdc());
|
||||
|
||||
String grossStr = StrUtil.padAfter(roi, min1, space) +
|
||||
StrUtil.padAfter(sGross, min1, space) +
|
||||
StrUtil.padAfter(gGross, min2, space) +
|
||||
bGross;
|
||||
grossStrs.add(grossStr);
|
||||
String netStr = StrUtil.padAfter(roi, min1, space) +
|
||||
netCount;
|
||||
netStrs.add(netStr);
|
||||
String concentration = StrUtil.padAfter(roi, min1, space) +
|
||||
StrUtil.padAfter(concStr, min1, space) +
|
||||
StrUtil.padAfter(lc, min2, space) +
|
||||
mdc;
|
||||
concStrs.add(concentration);
|
||||
}
|
||||
roiResultsStr.put("grossRoi", grossStrs);
|
||||
roiResultsStr.put("netRoi", netStrs);
|
||||
roiResultsStr.put("concRoi", concStrs);
|
||||
return roiResultsStr;
|
||||
}
|
||||
|
||||
private List<String> xeResults(List<GardsXeResultsSpectrum> 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) {
|
||||
String name = xeResult.getNuclideName();
|
||||
String conc = StrUtil.toString(xeResult.getConc());
|
||||
String concErr = StrUtil.toString(xeResult.getConcErr());
|
||||
String concStr = conc + " +/- " + concErr;
|
||||
String lc = StrUtil.toString(xeResult.getLc());
|
||||
String mdc = StrUtil.toString(xeResult.getMdc());
|
||||
String flag = StrUtil.toString(xeResult.getNidFlag());
|
||||
|
||||
String xeResultStr = StrUtil.padAfter(name, min1, space) +
|
||||
StrUtil.padAfter(concStr, min1, space) +
|
||||
StrUtil.padAfter(lc, min2, space) +
|
||||
StrUtil.padAfter(mdc, min2, space) +
|
||||
flag;
|
||||
xeResultStrs.add(xeResultStr);
|
||||
}
|
||||
return xeResultStrs;
|
||||
}
|
||||
|
||||
public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List<SeriseData> betaList, List<SeriseData> gammaList) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user