Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
nieziyan 2023-09-26 19:19:28 +08:00
commit 6b171b737d
21 changed files with 990 additions and 403 deletions

View File

@ -514,7 +514,7 @@ public interface CommonConstant {
/**
* 自动处理Gamma报告前缀
*/
String REPORT_PREFIX_AUTO = "RNAUTO_";
String REPORT_PREFIX_AUTO = "RNAUTO";
/**
* 自动处理报告后缀

View File

@ -1,20 +1,28 @@
package org.jeecg.common.util;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.entity.vo.BaseControls;
import org.jeecgframework.core.util.ApplicationContextUtil;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.List;
import java.util.Objects;
public class GammaReportUtil {
private static FTPUtil ftpUtil = ApplicationContextUtil.getContext().getBean(FTPUtil.class);
public static void writeFile(BaseControls baseCtrl, String path){
// 获取系统的临时目录
String tempDir = System.getProperty("java.io.tmpdir");
// 创建文件
File file = new File(path);
File file = new File(tempDir += System.currentTimeMillis());
// 创建PrintWriter对象
PrintWriter out = null;
try {
// 创建PrintWriter对象
PrintWriter out = new PrintWriter(file);
out = new PrintWriter(file);
out.println("#AnalyseRange");
String low = String.valueOf(baseCtrl.getRg_low());
String high = String.valueOf(baseCtrl.getRg_high());
@ -35,22 +43,41 @@ public class GammaReportUtil {
out.println("#StepCounts");
format(baseCtrl.getStepCounts(), out);
String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH);
String targetName = StringUtils.substringAfterLast(path, StringPool.SLASH);
ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (null != out) {
out.close();
}
}
}
public static void writeFile(List<Double> data, String fileType, String path){
// 获取系统的临时目录
String tempDir = System.getProperty("java.io.tmpdir");
// 创建文件
File file = new File(path);
File file = new File(tempDir + System.currentTimeMillis());
// 创建PrintWriter对象
PrintWriter out = null;
try {
// 创建PrintWriter对象
PrintWriter out = new PrintWriter(file);
out = new PrintWriter(file);
out.println("#" + fileType);
out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n");
format(data, out);
String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH);
String targetName = StringUtils.substringAfterLast(path, StringPool.SLASH);
ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (null != out) {
out.close();
}
}
}
@ -69,8 +96,8 @@ public class GammaReportUtil {
for(i = 0; i < nGroupBL; i++)
{
String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i));
out.printf("%" + (columnWidths[i] + 15) + "s", col);
System.out.print(i+">>>>"+data.get(i));
out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i)));
if((i+1) % numPerLine == 0) {
out.println("");
}
@ -78,10 +105,20 @@ public class GammaReportUtil {
if(i < n)
{
for(; i<n; ++i){
String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i));
out.printf("%" + (columnWidths[i] + 15) + "s", col);
out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i)));
}
}
out.println("");
}
private static String getValue(Double val){
BigDecimal divisor = BigDecimal.ONE;
MathContext mc = new MathContext(6);
String col = Objects.isNull(val) ? "nan" : String.valueOf(val);
if (!"nan".equals(col)) {
BigDecimal b = new BigDecimal(col);
col = String.valueOf(b.divide(divisor, mc));
}
return col;
}
}

View File

@ -35,7 +35,7 @@ public class GardsNuclLinesIded implements Serializable {
/**
* 核素名称
*/
@TableField(value = "NUCLIDE_NAME")
@TableField(value = "NUCLIDENAME")
private String nuclideName;
@TableField(value = "MODDATE")

View File

@ -1,9 +1,15 @@
package org.jeecg.common;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Console;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
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.ejml.simple.SimpleMatrix;
@ -11,6 +17,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.util.GammaReportUtil;
import org.jeecg.common.util.NameStandUtil;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
@ -27,6 +34,8 @@ import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -37,10 +46,13 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
@ -61,7 +73,7 @@ public class GammaFileUtil {
@Autowired
private NameStandUtil nameStandUtil;
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result){
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) {
phd.setFilepath(pathName);
phd.setFilename(fileName);
//连接ftp
@ -70,6 +82,7 @@ public class GammaFileUtil {
result.error500("ftp连接失败");
return false;
}
InputStream inputStream = null;
//加载dll工具库
System.loadLibrary("ReadPHDFile");
try {
@ -80,15 +93,8 @@ public class GammaFileUtil {
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
ftpFiles = ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList());
if (ftpFiles.size() == 0) {
result.error500("ftp获取文件数据失败");
return false;
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)) {
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
inputStream = ftpClient.retrieveFileStream(fileName);
if (Objects.nonNull(inputStream)) {
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -115,7 +121,7 @@ public class GammaFileUtil {
//Comment
phd.setOriTotalCmt(struct.comment);
//Collection
if (StringUtils.isNotBlank(struct.collection_start_date) || StringUtils.isNotBlank(struct.collection_start_time) || StringUtils.isNotBlank(struct.collection_stop_date) || StringUtils.isNotBlank(struct.collection_stop_time) || Objects.nonNull(struct.air_volume)) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) {
phd.getCollect().setCollection_start_date(struct.collection_start_date);
phd.getCollect().setCollection_start_time(struct.collection_start_time);
phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
@ -131,7 +137,7 @@ public class GammaFileUtil {
phd.getCollect().setAir_volume(0.0);
}
//Acquisition
if (StringUtils.isNotBlank(struct.acquisition_start_date) || StringUtils.isNotBlank(struct.acquisition_start_time) || Objects.nonNull(struct.acquisition_real_time) || Objects.nonNull(struct.acquisition_live_time)) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) {
phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date);
phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time);
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
@ -144,7 +150,7 @@ public class GammaFileUtil {
phd.getAcq().setAcquisition_real_time(0.0);
}
//Processing
if (Objects.nonNull(struct.sample_volume_of_Xe) || Objects.nonNull(struct.uncertainty_1) || Objects.nonNull(struct.Xe_collection_yield) || Objects.nonNull(struct.uncertainty_2) || StringUtils.isNotBlank(struct.archive_bottle_id)) {
if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.archive_bottle_id)) {
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
phd.getProcess().setUncertainty_1(struct.uncertainty_1);
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
@ -157,7 +163,7 @@ public class GammaFileUtil {
phd.getProcess().setUncertainty_2(0.0);
}
//Sample
if (Objects.nonNull(struct.dimension_1) || Objects.nonNull(struct.dimension_2)) {
if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
phd.getSampleBlock().setDimension_1(struct.dimension_1);
phd.getSampleBlock().setDimension_2(struct.dimension_2);
} else {
@ -165,14 +171,14 @@ public class GammaFileUtil {
phd.getSampleBlock().setDimension_2(0.0);
}
//Calibration
if (StringUtils.isNotBlank(struct.date_calibration) || StringUtils.isNotBlank(struct.time_calibration)) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.date_calibration) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.time_calibration)) {
phd.getCalibration().setDate_calibration(struct.date_calibration);
phd.getCalibration().setTime_calibration(struct.time_calibration);
}
//Certificate
if (Objects.nonNull(struct.total_source_activity) || StringUtils.isNotBlank(struct.assay_date) || StringUtils.isNotBlank(struct.assay_time) || StringUtils.isNotBlank(struct.units_activity) || CollectionUtils.isNotEmpty(struct.nuclide_name)
|| CollectionUtils.isNotEmpty(struct.half_life_time) || CollectionUtils.isNotEmpty(struct.time_unit) || CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) || CollectionUtils.isNotEmpty(struct.uncertainty)
|| CollectionUtils.isNotEmpty(struct.cer_g_energy) || CollectionUtils.isNotEmpty(struct.g_intensity) || CollectionUtils.isNotEmpty(struct.electron_decay_mode) || CollectionUtils.isNotEmpty(struct.maximum_energy) || CollectionUtils.isNotEmpty(struct.intensity_b_particle) || Objects.nonNull(struct.record_count)) {
if (Objects.nonNull(struct.total_source_activity) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name)
&& CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty)
&& CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) {
phd.getCertificate().setTotal_source_activity(struct.total_source_activity);
phd.getCertificate().setAssay_date(struct.assay_date);
phd.getCertificate().setAssay_time(struct.assay_time);
@ -190,7 +196,7 @@ public class GammaFileUtil {
phd.getCertificate().setRecord_count(struct.record_count);
}
//g_Spectrum
if (Objects.nonNull(struct.num_g_channel) || Objects.nonNull(struct.g_energy_span) || Objects.nonNull(struct.g_begin_channel) || CollectionUtils.isNotEmpty(struct.g_counts)) {
if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) {
phd.getSpec().setNum_g_channel(struct.num_g_channel);
phd.getSpec().setG_energy_span(struct.g_energy_span);
phd.getSpec().setBegin_channel(struct.g_begin_channel);
@ -206,7 +212,7 @@ public class GammaFileUtil {
}
}
//g_Energy
if (CollectionUtils.isNotEmpty(struct.g_energy) || CollectionUtils.isNotEmpty(struct.g_centroid_channel) || CollectionUtils.isNotEmpty(struct.g_uncertainty) || Objects.nonNull(struct.g_record_count)) {
if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) {
GEnergyBlock gEnergyBlock = new GEnergyBlock();
gEnergyBlock.setG_energy(struct.g_energy);
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
@ -215,7 +221,7 @@ public class GammaFileUtil {
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
}
//g_Resolution
if (CollectionUtils.isNotEmpty(struct.g_r_energy) || CollectionUtils.isNotEmpty(struct.g_r_FWHM) || CollectionUtils.isNotEmpty(struct.g_r_uncertainty) || Objects.nonNull(struct.g_r_record_count)) {
if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) {
GResolutionBlock gResolutionBlock = new GResolutionBlock();
gResolutionBlock.setG_energy(struct.g_r_energy);
gResolutionBlock.setFWHM(struct.g_r_FWHM);
@ -224,7 +230,7 @@ public class GammaFileUtil {
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
}
//g_Efficiency
if (CollectionUtils.isNotEmpty(struct.g_e_energy) || CollectionUtils.isNotEmpty(struct.g_e_efficiency) || CollectionUtils.isNotEmpty(struct.g_e_uncertainty) || Objects.nonNull(struct.g_e_record_count)) {
if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) {
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
gEfficiencyBlock.setG_energy(struct.g_e_energy);
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
@ -233,7 +239,7 @@ public class GammaFileUtil {
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
}
//TotalEff
if (CollectionUtils.isNotEmpty(struct.t_g_energy) || CollectionUtils.isNotEmpty(struct.total_efficiency) || CollectionUtils.isNotEmpty(struct.t_uncertainty) || Objects.nonNull(struct.t_record_count)) {
if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) {
TotaleffBlock totaleffBlock = new TotaleffBlock();
totaleffBlock.setG_energy(struct.t_g_energy);
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
@ -247,9 +253,11 @@ public class GammaFileUtil {
phd.getSetting().setECutAnalysis_Low(35.0);
phd.getSetting().setBUpdateCal(true);
}
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
phd.setUsedSetting(phd.getSetting());
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
SpecSetup usedSetting = new SpecSetup();
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
phd.setUsedSetting(usedSetting);
phd.setBAnalyed(false);
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
@ -264,6 +272,9 @@ public class GammaFileUtil {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -1517,8 +1528,246 @@ public class GammaFileUtil {
return true;
}
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> map){
return false;
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
System.loadLibrary("GammaAnaly");
//解析获取临时文件信息
File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename());
ObjectMapper mapper = new ObjectMapper();
try {
String phdStr = mapper.writeValueAsString(phd);
String nuclideLinesMap = mapper.writeValueAsString(mapLines);
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath());
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class);
phd.setBAnalyed(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapEffiPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapTotEPara")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapTotEPara(value);
}
if (entry.getKey().equalsIgnoreCase("para_stepRatio")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_stepRatio(value);
}
if (entry.getKey().equalsIgnoreCase("para_tail")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tail(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRight")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRight(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRightAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("newEner")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setNewEner(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerKD")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, GEnergyBlock> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
GEnergyBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GEnergyBlock.class);
value.put(key, entryValue);
}
phd.setMapEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoKD")) {
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, GResolutionBlock> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
GResolutionBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GResolutionBlock.class);
value.put(key, entryValue);
}
phd.setMapResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("vEnergy")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVEnergy(value);
}
if (entry.getKey().equalsIgnoreCase("vBase")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVBase(value);
}
if (entry.getKey().equalsIgnoreCase("vLc")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVLc(value);
}
if (entry.getKey().equalsIgnoreCase("vScac")) {
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVScac(value);
}
if (entry.getKey().equalsIgnoreCase("vPeak")) {
List<PeakInfo> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class);
phd.setVPeak(value);
}
if (entry.getKey().equalsIgnoreCase("baseCtrls")) {
BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class);
phd.setBaseCtrls(value);
}
if (entry.getKey().equalsIgnoreCase("usedEner")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedEner(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerKD")) {
GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class);
phd.setUsedEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedReso")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedReso(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoKD")) {
GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class);
phd.setUsedResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffi")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedEffi(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiKD")) {
GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class);
phd.setUsedEffiKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotE")) {
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedTotE(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEKD")) {
TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class);
phd.setUsedTotEKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedTotEPara(value);
}
}
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
if(CollectionUtils.isNotEmpty(phd.getMapEnerKD())) {
String key = "";
key = phd.getNewEner();
phd.setUsedEner(key);
GEnergyBlock source = new GEnergyBlock();
GEnergyBlock gEnergyBlock = phd.getMapEnerKD().get(phd.getNewEner());
BeanUtils.copyProperties(gEnergyBlock, source);
phd.setUsedEnerKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = phd.getMapEnerPara().get(phd.getNewEner());
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedEnerPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapResoKD())) {
String key = "";
key = phd.getNewReso();
phd.setUsedReso(key);
GResolutionBlock source = new GResolutionBlock();
GResolutionBlock gResolutionBlock = phd.getMapResoKD().get(phd.getNewReso());
BeanUtils.copyProperties(gResolutionBlock, source);
phd.setUsedResoKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = phd.getMapResoPara().get(phd.getNewReso());
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedResoPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapEffiKD())) {
String key = "";
key = phd.getNewEffi();
phd.setUsedEffi(key);
GEfficiencyBlock source = new GEfficiencyBlock();
GEfficiencyBlock gEfficiencyBlock = phd.getMapEffiKD().get(phd.getNewEffi());
BeanUtils.copyProperties(gEfficiencyBlock, source);
phd.setUsedEffiKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = Objects.nonNull(phd.getMapEffiPara().get(phd.getNewEffi()))?phd.getMapEffiPara().get(phd.getNewEffi()):new ParameterInfo();
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedEffiPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapTotEKD())) {
String key = "";
key = phd.getNewTotE();
phd.setUsedTotE(key);
TotaleffBlock source = new TotaleffBlock();
TotaleffBlock totaleffBlock = phd.getMapTotEKD().get(phd.getNewTotE());
BeanUtils.copyProperties(totaleffBlock, source);
phd.setUsedTotEKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = Objects.nonNull(phd.getMapTotEPara().get(phd.getNewTotE()))?phd.getMapTotEPara().get(phd.getNewTotE()):new ParameterInfo();
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedTotEPara(info);
}
for (PeakInfo peak:phd.getVPeak()) {
if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilBetaChan)) {
peak.recoilBetaChan = "1";
}
if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilDeltaChan)) {
peak.recoilDeltaChan = "1";
}
}
//重新分析各峰值对应的核素信息
NuclidesIdent(phd, mapLines);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return true;
}
public int SettingChanged(PHDFile phd) {
@ -1705,7 +1954,7 @@ public class GammaFileUtil {
private void ReadSpecialNuclides(Map<String, Double> mapHalflife, List<String> vNuclides) {
try {
String fileName = parameterFilePath+"/setup/nuclide_ActMdc.txt";
String fileName = parameterFilePath+"/nuclide_ActMdc.txt";
File t_file = new File(fileName);
List<String> readLines = FileUtils.readLines(t_file, "UTF-8");
for (int i=0;i< readLines.size();i++){
@ -2783,7 +3032,6 @@ public class GammaFileUtil {
public boolean GetMiddleData(PHDFile fileAnlyse, String userName,Map<String, NuclideLines> nucline,GStoreMiddleProcessData middleData, String type) throws ParseException {
boolean bRet=true;
//标准名称规范化
String dataType = fileAnlyse.getMsgInfo().getData_type();
String subDirSavePath = "";
@ -2834,9 +3082,11 @@ public class GammaFileUtil {
String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsBaseLinePath;
String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsLcPath;
String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsScacPath;
middleData.analyses_baseline_filePath = qsSaveBaseLine;
middleData.analyses_lc_filePath = qsSaveLc;
middleData.analyses_scac_filePath = qsSaveScac;
GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), qsSaveBaseLine);
GammaReportUtil.writeFile(fileAnlyse.getVLc(), "LC", qsSaveLc);
GammaReportUtil.writeFile(fileAnlyse.getVScac(), "SCSC", qsSaveScac);
// ftpUtil.saveFile(org.apache.commons.lang3.StringUtils.substringBeforeLast(qsSaveBaseLine, StringPool.SLASH), baselineName, new FileInputStream(fileAnlyse.getBaseCtrls()));
// WriteBaseInfo(fileAnlyse.getBaseCtrls(),qsSaveBaseLine);
// WriteLcScac(fileAnlyse.getVLc(),"Lc",qsSaveLc);
// WriteLcScac(fileAnlyse.getVScac(),"Scac",qsSaveScac);
@ -2855,6 +3105,16 @@ public class GammaFileUtil {
middleData.analyses_searchThreshold = fileAnlyse.getUsedSetting().getEnergyTolerance();
middleData.analyses_numberOfPeaks = fileAnlyse.getVPeak().size();
middleData.analyses_totalCounts = totalNumber;
middleData.analyses_baseline_filePath = qsBaseLinePath;
middleData.analyses_lc_filePath = qsLcPath;
middleData.analyses_scac_filePath = qsScacPath;
middleData.analyses_baseline_absolute_filePath =qsSaveLc;
middleData.analyses_lc_absolute_filePath=qsSaveLc;
middleData.analyses_scac_absolute_filePath=qsSaveScac;
middleData.analyses_save_absolute_filePath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsSaveFile;
middleData.analyses_absolute_LogPath=spectrumPathProperties.getLogPath()+StringPool.SLASH+qsLogPath;
middleData.analyses_absolute_ReportPath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsReportPath;
if(fileAnlyse.getUsedEnerKD() != null && fileAnlyse.getUsedEnerKD().getG_energy().size() != 0) {
middleData.calibration_pairs_E_Caltype = CalType.ENERGY_CAL.getType();
@ -2865,13 +3125,13 @@ public class GammaFileUtil {
for(int pos=0;pos<fileAnlyse.getUsedEnerKD().getG_energy().size();pos++) {
temp.add(String.valueOf(pos));
}
middleData.calibration_pairs_E_idCalPoint = DoubleLimit(temp);
middleData.calibration_pairs_E_idCalPoint = temp;
middleData.calibration_pairs_E_xValue = DoubleLimit(fileAnlyse.getUsedEnerKD().getCentroid_channel());
middleData.calibration_pairs_E_yValue = DoubleLimit(fileAnlyse.getUsedEnerKD().getG_energy());
middleData.calibration_pairs_E_uncYValue =DoubleLimit(fileAnlyse.getUsedEnerKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_E_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_S_E_idCalPoint =temp;
middleData.calibration_pairs_S_E_xValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getCentroid_channel());
middleData.calibration_pairs_S_E_yValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_E_uncYValue =DoubleLimit(fileAnlyse.getMapEnerKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2890,13 +3150,13 @@ public class GammaFileUtil {
{
temp.add(String.valueOf(pos));
}
middleData.calibration_pairs_EF_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_EF_idCalPoint =temp;
middleData.calibration_pairs_EF_xValue =DoubleLimit(fileAnlyse.getUsedEffiKD().getG_energy());
middleData.calibration_pairs_EF_yValue =DoubleLimit(fileAnlyse.getUsedEffiKD().getEfficiency());
middleData.calibration_pairs_EF_uncYValue=DoubleLimit(fileAnlyse.getUsedEffiKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_EF_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_S_EF_idCalPoint =temp;
middleData.calibration_pairs_S_EF_xValue =DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_EF_yValue =DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getEfficiency());
middleData.calibration_pairs_S_EF_uncYValue=DoubleLimit(fileAnlyse.getMapEffiKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2914,13 +3174,13 @@ public class GammaFileUtil {
for(int pos=0;pos<fileAnlyse.getUsedResoKD().getFWHM().size();pos++) {
temp.add(String.valueOf(pos));
}
middleData.calibration_pairs_R_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_R_idCalPoint =temp;
middleData.calibration_pairs_R_xValue =DoubleLimit(fileAnlyse.getUsedResoKD().getG_energy());
middleData.calibration_pairs_R_yValue =DoubleLimit(fileAnlyse.getUsedResoKD().getFWHM());
middleData.calibration_pairs_R_uncYValue =DoubleLimit(fileAnlyse.getUsedResoKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_R_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_S_R_idCalPoint =temp;
middleData.calibration_pairs_S_R_xValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_R_yValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getFWHM());
middleData.calibration_pairs_S_R_uncYValue =DoubleLimit(fileAnlyse.getMapResoKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2938,12 +3198,12 @@ public class GammaFileUtil {
temp.add(String.valueOf(pos));
}
middleData.calibration_pairs_T_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_T_idCalPoint =temp;
middleData.calibration_pairs_T_xValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getG_energy());
middleData.calibration_pairs_T_yValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getTotal_efficiency());
middleData.calibration_pairs_T_uncYValue =DoubleLimit(fileAnlyse.getUsedTotEKD().getUncertainty());
if(Objects.nonNull(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()))) {
middleData.calibration_pairs_S_T_idCalPoint =DoubleLimit(temp);
middleData.calibration_pairs_S_T_idCalPoint =temp;
middleData.calibration_pairs_S_T_xValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy());
middleData.calibration_pairs_S_T_yValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getTotal_efficiency());
middleData.calibration_pairs_S_T_uncYValue =DoubleLimit(fileAnlyse.getMapTotEKD().get(CalName.CalPHD.getType()).getUncertainty());
@ -2954,7 +3214,6 @@ public class GammaFileUtil {
//拼写刻度字符串
//获取刻度描述字符串
middleData.calibration_sample_type = fileAnlyse.getHeader().getSystem_type();
NumberFormat numberFormat = new DecimalFormat("0.######E0");
String coeffEnergy = "";
String uncerEnergy = "";
String funcDefEnergy = "";
@ -2967,18 +3226,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedEnerPara().getP().get(0).intValue();
}
for(int m=1;m<coeffNumber-1;m++) {
coeffEnergy += numberFormat.format(fileAnlyse.getUsedEnerPara().getP().get(m))+',';
coeffEnergy += String.format("%e", fileAnlyse.getUsedEnerPara().getP().get(m))+ ",";
}
if(coeffNumber>0) {
coeffEnergy+=numberFormat.format(fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1));
coeffEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1));
}
uncerNumber = fileAnlyse.getUsedEnerPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) {
uncerEnergy += numberFormat.format(fileAnlyse.getUsedEnerPara().getPerr().get(m))+',';
uncerEnergy += String.format("%e", fileAnlyse.getUsedEnerPara().getPerr().get(m))+ ",";
}
if(uncerNumber>0) {
uncerEnergy+=numberFormat.format(fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1));
uncerEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1));
}
funcDefEnergy = EquationDescription(funcType);
funcTypeDefEnergy = EquationName(funcType);
@ -3000,18 +3259,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedEffiPara().getP().get(0).intValue();
}
for(int m=1;m<coeffNumber-1;m++) {
coeffEffi += numberFormat.format(fileAnlyse.getUsedEffiPara().getP().get(m))+',';
coeffEffi += String.format("%e", fileAnlyse.getUsedEffiPara().getP().get(m))+ ",";
}
if(coeffNumber>0) {
coeffEffi+=numberFormat.format(fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1));
coeffEffi+=String.format("%e", fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1));
}
uncerNumber = fileAnlyse.getUsedEffiPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) {
uncerEffi += numberFormat.format(fileAnlyse.getUsedEffiPara().getPerr().get(m))+',';
uncerEffi += String.format("%e", fileAnlyse.getUsedEffiPara().getPerr().get(m))+ ",";
}
if(uncerNumber>0) {
uncerEffi+= numberFormat.format(fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1));
uncerEffi+= String.format("%e", fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1));
}
funcDefEffi = EquationDescription(funcType);
funcTypeDefEffi = EquationName(funcType);
@ -3032,18 +3291,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedResoPara().getP().get(0).intValue();
}
for(int m=1;m<coeffNumber-1;m++) {
coeffReso += numberFormat.format(fileAnlyse.getUsedResoPara().getP().get(m))+',';
coeffReso += String.format("%e", fileAnlyse.getUsedResoPara().getP().get(m))+ ",";
}
if(coeffNumber>0) {
coeffReso+= numberFormat.format(fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1));
coeffReso+= String.format("%e", fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1));
}
uncerNumber = fileAnlyse.getUsedResoPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) {
uncerReso += numberFormat.format(fileAnlyse.getUsedResoPara().getPerr().get(m))+',';
uncerReso += String.format("%e", fileAnlyse.getUsedResoPara().getPerr().get(m))+ ",";
}
if(uncerNumber>0) {
uncerReso+= numberFormat.format(fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1));
uncerReso+= String.format("%e", fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1));
}
funcDefReso = EquationDescription(funcType);
funcTypeDefReso = EquationName(funcType);
@ -3064,18 +3323,18 @@ public class GammaFileUtil {
funcType = fileAnlyse.getUsedTotEPara().getP().get(0).intValue();
}
for(int m=1;m<coeffNumber-1;m++) {
coeffTotE += numberFormat.format(fileAnlyse.getUsedTotEPara().getP().get(m))+',';
coeffTotE += String.format("%e", fileAnlyse.getUsedTotEPara().getP().get(m))+ ",";
}
if(coeffNumber>0) {
coeffTotE+= numberFormat.format(fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1));
coeffTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1));
}
uncerNumber = fileAnlyse.getUsedTotEPara().getPerr().size();
for(int m=0;m<uncerNumber-1;m++) {
uncerTotE += numberFormat.format(fileAnlyse.getUsedTotEPara().getPerr().get(m))+',';
uncerTotE += String.format("%e", fileAnlyse.getUsedTotEPara().getPerr().get(m))+ ",";
}
if(uncerNumber>0) {
uncerTotE+= numberFormat.format(fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1));
uncerTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1));
}
funcDefTotE = EquationDescription(funcType);
funcTypeDefTotE = EquationName(funcType);
@ -3090,7 +3349,7 @@ public class GammaFileUtil {
//gards_ peaks数据表
if(fileAnlyse.getVPeak().size() != 0) {
List<Double> dvctIDPEAK = new LinkedList<>();
List<String> dvctIDPEAK = new LinkedList<>();
List<Double> dvctCENTROIDCHANNEL = new LinkedList<>();
List<Double> dvctUNCCENTROIDCHANNEL = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
@ -3122,8 +3381,8 @@ public class GammaFileUtil {
List<Double> dvctLD = new LinkedList<>();
List<String> dvctNuclide_name = new LinkedList<>();
List<String> dvctComments = new LinkedList<>();
for(int m=0;m<fileAnlyse.getVPeak().size();m++) {
dvctIDPEAK.add(Double.valueOf(m+1));
for(int m=0; m<fileAnlyse.getVPeak().size(); m++) {
dvctIDPEAK.add(String.valueOf(m+1));
dvctCENTROIDCHANNEL.add(fileAnlyse.getVPeak().get(m).peakCentroid);
dvctENERGY.add(fileAnlyse.getVPeak().get(m).energy);
dvctAREA.add(fileAnlyse.getVPeak().get(m).area);
@ -3150,21 +3409,14 @@ public class GammaFileUtil {
dvctMEANBACKCOUNT.add(fileAnlyse.getVPeak().get(m).meanBackCount);
dvctLC.add(fileAnlyse.getVPeak().get(m).lc);
dvctLD.add(fileAnlyse.getVPeak().get(m).ld);
String t_comment = fileAnlyse.getVPeak().get(m).comments==null?"":fileAnlyse.getVPeak().get(m).comments.replace("\'", "\'\'").trim();
if(t_comment.length() > 1024){
t_comment = t_comment.substring(0, 1025);
}
dvctComments.add(t_comment);
String qsName = "";
for(int n=0;n<fileAnlyse.getVPeak().get(m).nuclides.size();n++) {
qsName = qsName+fileAnlyse.getVPeak().get(m).nuclides.get(n)+";";
}
dvctNuclide_name.add(qsName);
dvctNuclide_name.add(org.apache.commons.lang3.StringUtils.join(fileAnlyse.getVPeak().get(m).nuclides, ";"));
}
middleData.peaks_idPeak =DoubleLimit_G(dvctIDPEAK);
middleData.peaks_idPeak =dvctIDPEAK;
middleData.peaks_peakCentroid =DoubleLimit_G(dvctCENTROIDCHANNEL);
middleData.peaks_uncpeakCentroid =DoubleLimit_G(dvctUNCCENTROIDCHANNEL);
middleData.peaks_Energy =DoubleLimit_G(dvctENERGY);
@ -3194,28 +3446,27 @@ public class GammaFileUtil {
middleData.peaks_Ld =DoubleLimit_G(dvctLD);
middleData.peaks_comments = dvctComments;
middleData.peaks_Nuclide_name = dvctNuclide_name;
}
// gards_ nucl_lines_ided数据表
GStoreMiddleProcessDataNuclLinesIded nucl_lines_ided_data = new GStoreMiddleProcessDataNuclLinesIded();
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<Double> dvctIDPEAK = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
List<Double> dvctUNCENERGY = new LinkedList<>();
List<Double> dvctABUNDANCE = new LinkedList<>();
List<Double> dvctUNCABUNDANCE = new LinkedList<>();
List<String> dvctACTIVITY = new LinkedList<>();
List<Double> dvctUNCACTIVITY = new LinkedList<>();
List<Double> dvctEFFIC = new LinkedList<>();
List<Double> dvctUNEFFIC = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctKEY_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
for(Map.Entry<String, NuclideActMda> itor:fileAnlyse.getMapNucActMda().entrySet()) {
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<String> dvctIDPEAK = new LinkedList<>();
List<Double> dvctENERGY = new LinkedList<>();
List<Double> dvctUNCENERGY = new LinkedList<>();
List<Double> dvctABUNDANCE = new LinkedList<>();
List<Double> dvctUNCABUNDANCE = new LinkedList<>();
List<String> dvctACTIVITY = new LinkedList<>();
List<Double> dvctUNCACTIVITY = new LinkedList<>();
List<Double> dvctEFFIC = new LinkedList<>();
List<Double> dvctUNEFFIC = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctKEY_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
int first=itor.getValue().getFullNames().size();
int second=itor.getValue().getVPeakIdx().size();
first = first<second?first:second;
@ -3227,19 +3478,18 @@ public class GammaFileUtil {
first = first<second?first:second;
second = itor.getValue().getVUncertY().size();
first = first<second?first:second;
for(int m=0;m<first;m++) {
svctNUCLIDEFULLNAME.add( itor.getValue().getFullNames().get(m).replace("\'", "\'\'") );
dvctIDPEAK.add(itor.getValue().getVPeakIdx().get(m).doubleValue());
dvctIDPEAK.add(itor.getValue().getVPeakIdx().get(m).toString());
dvctENERGY.add(itor.getValue().getVEnergy().get(m));
dvctUNCENERGY.add(itor.getValue().getVUncertE().get(m));
dvctABUNDANCE.add(itor.getValue().getVYield().get(m));
dvctUNCABUNDANCE.add(itor.getValue().getVUncertY().get(m));
dvctACTIVITY.add(numberFormat.format(itor.getValue().getActivity()));
dvctACTIVITY.add(String.format("%e", itor.getValue().getActivity()));
dvctUNCACTIVITY.add(itor.getValue().getAct_err());
dvctEFFIC.add(itor.getValue().getEfficiency());
dvctUNEFFIC.add(itor.getValue().getEffi_err());
dvctMDA.add(numberFormat.format(itor.getValue().getMda()));
dvctMDA.add(itor.getValue().getMda()>0?String.format("%e", itor.getValue().getMda()):"0.0");
// dvctKEY_FLAG.add(itor.value().vYield.get(m));
dvctCSC_RATIO.add(1.0);
dvctCSC_RATIO_ERR.add(0.0);
@ -3249,11 +3499,11 @@ public class GammaFileUtil {
} else {
dvctKEY_FLAG.add(0.0);
}
dvctMDC.add(numberFormat.format(itor.getValue().getMdc()));
dvctCONCENTRATION.add(numberFormat.format(itor.getValue().getConcentration()));
dvctMDC.add(String.format("%e", itor.getValue().getMdc()));
dvctCONCENTRATION.add(String.format("%e", itor.getValue().getConcentration()));
}
nucl_lines_ided_data.nuclideFullname = svctNUCLIDEFULLNAME;
nucl_lines_ided_data.idPeak =DoubleLimit_G(dvctIDPEAK);
nucl_lines_ided_data.idPeak =dvctIDPEAK;
nucl_lines_ided_data.Energy =DoubleLimit_G(dvctENERGY);
nucl_lines_ided_data.uncEnergy =DoubleLimit_G(dvctUNCENERGY);
nucl_lines_ided_data.Abundance =DoubleLimit_G(dvctABUNDANCE);
@ -3272,36 +3522,35 @@ public class GammaFileUtil {
middleData.getNucl_lines_ided_data().put(itor.getKey(), nucl_lines_ided_data);
}
// gards_ nucl_ided数据表
List<String> svctNUCLIDEFULLNAME1 = new LinkedList<>();
List<String> svctTYPE = new LinkedList<>();
List<Double> dvctHALFLIFE = new LinkedList<>();
List<String> dvctAVE_ACTIV = new LinkedList<>();
List<Double> dvctAVE_ACTIV_ERR = new LinkedList<>();
List<Double> dvctACTIV_KEY = new LinkedList<>();
List<Double> dvctACTIV_KEY_ERR = new LinkedList<>();
List<String> dvctMDA1 = new LinkedList<>();
List<Double> dvctMDA_ERR = new LinkedList<>();
List<Double> dvctNID_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO1 = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR1 = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG1 = new LinkedList<>();
List<String> dvctMDC1 = new LinkedList<>();
List<String> dvctCONCENTRATION1 = new LinkedList<>();
List<Double> dvctKey_Energy = new LinkedList<>();
List<Double> dvctKey_Yield = new LinkedList<>();
if( fileAnlyse.getMapNucActMda().size() != 0) {
List<String> svctNUCLIDEFULLNAME = new LinkedList<>();
List<String> svctTYPE = new LinkedList<>();
List<Double> dvctHALFLIFE = new LinkedList<>();
List<String> dvctAVE_ACTIV = new LinkedList<>();
List<Double> dvctAVE_ACTIV_ERR = new LinkedList<>();
List<Double> dvctACTIV_KEY = new LinkedList<>();
List<Double> dvctACTIV_KEY_ERR = new LinkedList<>();
List<String> dvctMDA = new LinkedList<>();
List<Double> dvctMDA_ERR = new LinkedList<>();
List<Double> dvctNID_FLAG = new LinkedList<>();
List<Double> dvctCSC_RATIO = new LinkedList<>();
List<Double> dvctCSC_RATIO_ERR = new LinkedList<>();
List<Double> dvctCSC_MOD_FLAG = new LinkedList<>();
List<String> dvctMDC = new LinkedList<>();
List<String> dvctCONCENTRATION = new LinkedList<>();
List<Double> dvctKey_Energy = new LinkedList<>();
List<Double> dvctKey_Yield = new LinkedList<>();
for(Map.Entry<String, NuclideActMda> itor_v: fileAnlyse.getMapNucActMda().entrySet()) {
String nuclideName = itor_v.getKey();
svctNUCLIDEFULLNAME1.add(nuclideName);
svctNUCLIDEFULLNAME.add(nuclideName);
dvctHALFLIFE.add(itor_v.getValue().getHalflife());
dvctACTIV_KEY.add(itor_v.getValue().getActivity());
dvctACTIV_KEY_ERR.add(itor_v.getValue().getAct_err());
dvctMDA1.add(numberFormat.format(itor_v.getValue().getMda()));
dvctMDC1.add(numberFormat.format(itor_v.getValue().getMdc()));
dvctCONCENTRATION1.add(numberFormat.format(itor_v.getValue().getConcentration()));
dvctCSC_RATIO1.add(1.0);
dvctCSC_RATIO_ERR1.add(0.0);
dvctMDA.add(String.format("%e", itor_v.getValue().getMda()));
dvctMDC.add(itor_v.getValue().getMdc()>0?String.format("%e", itor_v.getValue().getMdc()):"0.0");
dvctCONCENTRATION.add(String.format("%e", itor_v.getValue().getConcentration()));
dvctCSC_RATIO.add(1.0);
dvctCSC_RATIO_ERR.add(0.0);
if(itor_v.getValue().getCalculateIdx() >= 0 && itor_v.getValue().getCalculateIdx()<itor_v.getValue().getVEnergy().size()) {
dvctKey_Energy.add(itor_v.getValue().getVEnergy().get(itor_v.getValue().getCalculateIdx()));
}
@ -3309,32 +3558,30 @@ public class GammaFileUtil {
dvctKey_Yield.add(itor_v.getValue().getVYield().get(itor_v.getValue().getCalculateIdx()));
}
}
middleData.nucl_ided_Nuclidename = svctNUCLIDEFULLNAME1;
middleData.nucl_ided_Nuclidename = svctNUCLIDEFULLNAME;
middleData.nucl_ided_Type= svctTYPE;
middleData.nucl_ided_Halflife =DoubleLimit_G(dvctHALFLIFE);
middleData.nucl_ided_ave_activ = dvctAVE_ACTIV;
middleData.nucl_ided_ave_activ_err =DoubleLimit_G(dvctAVE_ACTIV_ERR);
middleData.nucl_ided_activ_key =DoubleLimit_G(dvctACTIV_KEY);
middleData.nucl_ided_activ_key_err =DoubleLimit_G(dvctACTIV_KEY_ERR);
middleData.nucl_ided_mda = dvctMDA1;
middleData.nucl_ided_mda = dvctMDA;
middleData.nucl_ided_mda_err =DoubleLimit_G(dvctMDA_ERR);
middleData.nucl_ided_nid_flag =DoubleLimit_G(dvctNID_FLAG);
middleData.nucl_ided_csc_ratio =DoubleLimit_G(dvctCSC_RATIO1);
middleData.nucl_ided_csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR1);
middleData.nucl_ided_csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG1);
middleData.nucl_ided_MDC = dvctMDC1;
middleData.nucl_ided_csc_ratio =DoubleLimit_G(dvctCSC_RATIO);
middleData.nucl_ided_csc_ratio_err =DoubleLimit_G(dvctCSC_RATIO_ERR);
middleData.nucl_ided_csc_mod_flag =DoubleLimit_G(dvctCSC_MOD_FLAG);
middleData.nucl_ided_MDC = dvctMDC;
middleData.nucl_ided_Concentration = dvctCONCENTRATION;
middleData.nucl_ided_Key_Energy = DoubleLimit_G(dvctKey_Energy);
middleData.nucl_ided_Key_Yield = DoubleLimit_G(dvctKey_Yield);
}
// GARDS_QC_CHECK数据表
List<String> qvctQC_NAME = new LinkedList<>();
List<Double> dvctQC_VALUE = new LinkedList<>();
List<String> qvctQC_STANDARD = new LinkedList<>();
List<Double> dvctQC_RESULT = new LinkedList<>();
if( fileAnlyse.getQcItems().size() != 0) {
List<String> qvctQC_NAME = new LinkedList<>();
List<Double> dvctQC_VALUE = new LinkedList<>();
List<String> qvctQC_STANDARD = new LinkedList<>();
List<Double> dvctQC_RESULT = new LinkedList<>();
for(Map.Entry<String, QcCheckItem> itor_q:fileAnlyse.getQcItems().entrySet()) {
String nuclideName = itor_q.getKey();
qvctQC_NAME.add(nuclideName);
@ -3347,11 +3594,9 @@ public class GammaFileUtil {
middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD;
middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE);
}
//sample info
middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+" "+fileAnlyse.getCollect().getCollection_start_time();
middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+" "+fileAnlyse.getCollect().getCollection_stop_time();
middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time();
middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time();
if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) {
middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue());
if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) {
@ -3365,18 +3610,16 @@ public class GammaFileUtil {
middleData.sample_acquistion_time = String.format("%.5f", fileAnlyse.getQcItems().get("acq_time").getValue());
}
middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume());
middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+" "+fileAnlyse.getAcq().getAcquisition_start_time();
middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time();
String acquisition_start = middleData.sample_acquisiton_start;
Date dataTime = DateUtils.parseDate(acquisition_start.substring(0, acquisition_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
acquisition_start = DateUtils.formatDate(dataTime, "yyyy/MM/dd HH:mm:ss");
middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())), "yyyy/MM/dd HH:mm:ss");
Date dataTime = DateUtils.parseDate(acquisition_start);
middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())) , "yyyy/MM/dd HH:mm:ss");
middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ;
middleData.sample_stationID = fileAnlyse.getHeader().getSite_code();
middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code();
middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry();
middleData.sample_Type = fileAnlyse.getHeader().getSystem_type();
middleData.setting_specSetup = fileAnlyse.getUsedSetting();
middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt();
middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt();
return bRet;
@ -4027,4 +4270,41 @@ public class GammaFileUtil {
}
}
public File analyzeFile(String path, String fileName) {
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
InputStream inputStream = null;
File file = null;
try {
//被动模式
ftpClient.enterLocalPassiveMode();
//设置文件类型--二进制文件
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
//
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
//切换文件路径
ftpClient.changeWorkingDirectory(path);
inputStream = ftpClient.retrieveFileStream(fileName);
if (Objects.nonNull(inputStream)){
file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return file;
}
}

View File

@ -5,8 +5,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
import java.util.List;
public interface GardsCalibrationMapper extends BaseMapper<GardsCalibration> {
@InterceptorIgnore(tenantLine = "true")
public int create(@Param("calibration") GardsCalibration calibration);
@InterceptorIgnore(tenantLine = "true")
public int createBatch(@Param("calibrations") List<GardsCalibration> calibration);
}

View File

@ -31,5 +31,34 @@
#{calibration.moddate})
</insert>
<insert id="createBatch" parameterType="org.jeecg.modules.base.entity.rnauto.GardsCalibration">
begin
<foreach collection="calibrations" separator=";" close=";" item="calibration">
insert into RNAUTO.GARDS_CALIBRATION(
SAMPLE_ID,
IDANALYSIS,
SAMPLE_TYPE,
CALTYPE,
FUNCTION,
FUNCTIONDEF,
STARTOFRANGE,
ENDOFRANGE,
COEFF_STRING,
moddate)
values
(#{calibration.sampleId},
#{calibration.idAnalysis},
#{calibration.sampleType},
#{calibration.calType},
#{calibration.function},
#{calibration.functionDef},
#{calibration.startOfRange},
#{calibration.endOfRange},
#{calibration.coeffString},
#{calibration.moddate})
</foreach>
end;
</insert>
</mapper>

View File

@ -1,8 +1,8 @@
package org.jeecg.modules.native_jni;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.eneity.vo.StructInsertInput;
import org.jeecg.modules.eneity.vo.StructInsertOutput;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import java.util.List;
@ -25,22 +25,6 @@ public class CalValuesHandler {
public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List<Double> vCentroid, List<Double> vFwhmCh, List<Double> vTail, List<Double> vUpperTail);
public static native List<Double> calValues(int cal, int m_nChans);
public static native List<Double> GetFwhmcAll(int m_nChans);
public static native List<Double> calculateLC(List<Double> BaseLine, List<Double> FwhmcAll, double RiskLevelK);
public static native List<Double> calculateSCAC(List<Double> Spectrum, List<Double> BaseLine, List<Double> FwhmcAll);
public static native boolean armaAny(List<Double> Spectrum);
public static native String calUpdate(String dataType, List<Double> certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta);
public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta);
public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta);
public static native String fitPeakFull();
public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath);
}

View File

@ -1,11 +1,14 @@
package org.jeecg.modules.native_jni.struct;
import lombok.Data;
import java.util.List;
import java.util.Objects;
/**
* 能谱结构体字段信息
*/
@Data
public class EnergySpectrumStruct {
/************************* Infomations ******************/

View File

@ -3,7 +3,8 @@ package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.util.List;
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
@ -20,4 +21,5 @@ public interface GardsCalibrationService extends IService<GardsCalibration> {
* @param anayId
*/
public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer anayId);
public void createBatch( List<GardsCalibration> calibrations);
}

View File

@ -9,6 +9,7 @@ import org.jeecg.modules.service.BlockConstant;
import org.jeecg.modules.service.GardsCalibrationService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
@DS("ora")
@ -37,6 +38,11 @@ public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMap
this.saveDetG_EnergyRecord(analyseResult,detSampleId,anayId);
}
@Override
public void createBatch(List<GardsCalibration> calibrations) {
this.baseMapper.createBatch(calibrations);
}
/**
* 保存 B_Energy 块信息
* @param analyseResult

View File

@ -18,8 +18,8 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl<GardsGammaDe
@Override
public Map<String, String> mapSetting() {
Map<String, String> paramsMap = list().stream()
.collect(Collectors.toMap(GardsGammaDefaultParams::getName,
v->v.getValue() == null ? "" : v.getValue()));
.collect(Collectors.toMap(v-> v.getName().trim(),
v->v.getValue() == null ? "-9999" : v.getValue()));
return paramsMap;
}
}

View File

@ -7,10 +7,14 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.GammaFileUtil;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.SpectrumSystemType;
import org.jeecg.common.properties.SpectrumPathProperties;
@ -20,13 +24,19 @@ import org.jeecg.common.util.MyLogFormatUtil;
import org.jeecg.modules.base.dto.*;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.rnauto.*;
import org.jeecg.modules.base.enums.MiddleDataType;
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.ftp.FTPUtils;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.springframework.transaction.TransactionStatus;
import java.lang.reflect.Field;
import java.util.*;
@Data
@Slf4j
public class Sample_G_Analysis {
private final Map<String,String> fieldMap = fieldMap();
@ -82,8 +92,10 @@ public class Sample_G_Analysis {
*/
private String arrFileName;
private FTPUtils ftpUtil;
public Sample_G_Analysis(EnergySpectrumStruct energySpectrumStruct,SpectrumServiceQuotes serviceQuotes,
GardsSampleData sampleData) {
GardsSampleData sampleData, FTPUtils ftpUtil) {
this.sampleData = sampleData;
this.serviceQuotes = serviceQuotes;
this.energySpectrumStruct = energySpectrumStruct;
@ -92,6 +104,7 @@ public class Sample_G_Analysis {
this.sampleInputFilename = sampleData.getInputFileName();
this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(),
sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH)+1));
this.ftpUtil = ftpUtil;
}
public void analysis(){
@ -100,11 +113,17 @@ public class Sample_G_Analysis {
GStoreMiddleProcessData middleData = new GStoreMiddleProcessData();
Integer sampleId = sampleData.getSampleId();
GammaFileUtil gammaFileUtil = new GammaFileUtil();
GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class);
PHDFile phdFile = new PHDFile();
// 解析PHD文件
spectrumPathProperties = ApplicationContextUtil.getContext().getBean(SpectrumPathProperties.class);
String sampleFilePath = sampleData.getInputFileName();
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phdFile, new Result());
// 获取数据库 Gamma 默认参数
getSettingFromDB(phdFile);
// getSettingFromDB(phdFile);
// 文件路径
middleData.setAnalyses_save_filePath(this.sampleInputFilename);
// 读取文件内容并附值
@ -117,28 +136,13 @@ public class Sample_G_Analysis {
if (this.systemType.equals(SpectrumSystemType.G.name())) {
nuclideLibs = this.getNuclideLinesG();
}
gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, "1");
gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType());
// 数据插入数据库
this.storageDataToDatabase(middleData, phdFile.getQcItems());
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
saveAnalysis(middleData,sampleId);
// 获取分析结果ID ==> SELECT IDANALYSIS
Integer IdAnalysis = getIdAnalysis(sampleId);
// 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA
serviceQuotes.getSampleDataService().updateStatus(null,null);
/* GARDS_CALIBRATION_PAIRS 数据表保存 */
saveCalibrationPairs(middleData, sampleId, IdAnalysis);
/* GARDS_CALIBRATION 数据表保存 */
saveCalibration(middleData, sampleId, IdAnalysis);
/* Gards_Peaks 数据表保存 */
savePeaks(middleData);
/* Gards_Nucl_Lines_Ided 数据表保存 */
saveNuclLinesIded(middleData, sampleId, IdAnalysis);
/* Gards_Nucl_Ided 数据表保存 */
saveNuclIded(middleData, sampleId, IdAnalysis);
/* Gards_Qc_Check 数据表保存 */
saveQcCheck(middleData, sampleId, IdAnalysis, phdFile.getQcItems());
// 生成日志文件
writeLog(middleData.getAnalyses_LogPath(), middleData);
// writeLog(middleData.getAnalyses_LogPath(), middleData);
// todo 报告文件
}catch (Exception e){
e.printStackTrace();
@ -148,6 +152,47 @@ public class Sample_G_Analysis {
}
}
private void storageDataToDatabase(GStoreMiddleProcessData middleData, Map<String, QcCheckItem> qcItems){
//如果数据已经存储不在重复存储
final Integer idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId());
if(Objects.nonNull(idAnalysis)){
// log.warn("{} file analysis data has been stored",new File(this.sampleTempFilePath).getName());
return;
}
DataSourceSwitcher.switchToOracle();
final TransactionStatus transactionStatus = serviceQuotes.getTransactionManager().getTransaction(serviceQuotes.getTransactionDefinition());
try {
Integer sampleId = this.sampleData.getSampleId();
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES
saveAnalysis(middleData, sampleId);
// 获取分析结果ID ==> SELECT IDANALYSIS
Integer IdAnalysis = getIdAnalysis(sampleId);
// 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA
// serviceQuotes.getSampleDataService().updateStatus(null,null);
/* GARDS_CALIBRATION_PAIRS 数据表保存 */
saveCalibrationPairs(middleData, sampleId, IdAnalysis);
/* GARDS_CALIBRATION 数据表保存 */
saveCalibration(middleData, sampleId, IdAnalysis);
/* Gards_Peaks 数据表保存 */
savePeaks(middleData, sampleId, IdAnalysis);
/* Gards_Nucl_Lines_Ided 数据表保存 */
saveNuclLinesIded(middleData, sampleId, IdAnalysis);
/* Gards_Nucl_Ided 数据表保存 */
saveNuclIded(middleData, sampleId, IdAnalysis);
/* Gards_Qc_Check 数据表保存 */
saveQcCheck(middleData, sampleId, IdAnalysis, qcItems);
//提交事务
serviceQuotes.getTransactionManager().commit(transactionStatus);
} catch (Exception e) {
//设置分析数据存储失败标记
// this.parsingProcessLog.setAnalysisDataStoreFlag(false);
//回滚事务
serviceQuotes.getTransactionManager().rollback(transactionStatus);
throw e;
} finally {
DataSourceSwitcher.clearDataSource();
}
}
/**
* 生成日志文件
* @param logFilePath
@ -434,57 +479,69 @@ public class Sample_G_Analysis {
String base_E_Paris = "calibration_pairs_E_idCalPoint";
PairsEDto pairsEDto = new PairsEDto();
BeanUtil.copyProperties(middleData,pairsEDto);
List<GardsCalibrationPairs> pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap);
String pairsECaltype = middleData.getCalibration_pairs_E_Caltype();
String pairsEInput = middleData.getCalibration_pairs_E_Input();
for (GardsCalibrationPairs onePairs : pairsE) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsECaltype);
onePairs.setInput(pairsEInput);
List<GardsCalibrationPairs> pairsE = Lists.newArrayList();
if (pairsEDto.getCalibration_pairs_E_idCalPoint().size() > 0) {
pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap);
String pairsECaltype = middleData.getCalibration_pairs_E_Caltype();
String pairsEInput = middleData.getCalibration_pairs_E_Input();
for (GardsCalibrationPairs onePairs : pairsE) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsECaltype);
onePairs.setInput(pairsEInput);
}
}
// GARDS_CALIBRATION_PAIRS (Efficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS
String base_EF_Paris = "calibration_pairs_EF_idCalPoint";
PairsEFDto pairsEFDto = new PairsEFDto();
BeanUtil.copyProperties(middleData,pairsEFDto);
List<GardsCalibrationPairs> pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap);
String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype();
String pairsEFInput = middleData.getCalibration_pairs_EF_Input();
for (GardsCalibrationPairs onePairs : pairsEF) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsEFCaltype);
onePairs.setInput(pairsEFInput);
List<GardsCalibrationPairs> pairsEF = Lists.newArrayList();
if (pairsEFDto.getCalibration_pairs_EF_idCalPoint().size() > 0) {
pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap);
String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype();
String pairsEFInput = middleData.getCalibration_pairs_EF_Input();
for (GardsCalibrationPairs onePairs : pairsEF) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsEFCaltype);
onePairs.setInput(pairsEFInput);
}
}
// GARDS_CALIBRATION_PAIRS (Resolution) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS
String base_R_Paris = "calibration_pairs_R_idCalPoint";
PairsRDto pairsRDto = new PairsRDto();
BeanUtil.copyProperties(middleData,pairsRDto);
List<GardsCalibrationPairs> pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap);
String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype();
String pairsRInput = middleData.getCalibration_pairs_R_Input();
for (GardsCalibrationPairs onePairs : pairsR) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsRCaltype);
onePairs.setInput(pairsRInput);
List<GardsCalibrationPairs> pairsR = Lists.newArrayList();
if (pairsRDto.getCalibration_pairs_R_idCalPoint().size() > 0) {
pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap);
String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype();
String pairsRInput = middleData.getCalibration_pairs_R_Input();
for (GardsCalibrationPairs onePairs : pairsR) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsRCaltype);
onePairs.setInput(pairsRInput);
}
}
// GARDS_CALIBRATION_PAIRS (TotalEfficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS
String base_T_Paris = "calibration_pairs_T_idCalPoint";
PairsTDto pairsTDto = new PairsTDto();
BeanUtil.copyProperties(middleData,pairsTDto);
List<GardsCalibrationPairs> pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap);
String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype();
String pairsTInput = middleData.getCalibration_pairs_T_Input();
for (GardsCalibrationPairs onePairs : pairsT) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsTCaltype);
onePairs.setInput(pairsTInput);
List<GardsCalibrationPairs> pairsT = Lists.newArrayList();
if (pairsTDto.getCalibration_pairs_T_idCalPoint().size() > 0) {
pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap);
String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype();
String pairsTInput = middleData.getCalibration_pairs_T_Input();
for (GardsCalibrationPairs onePairs : pairsT) {
onePairs.setSampleId(sampleId);
onePairs.setIdAnalysis(IdAnalysis);
onePairs.setSampleType(pairsSampleType);
onePairs.setCaltype(pairsTCaltype);
onePairs.setInput(pairsTInput);
}
}
// GARDS_CALIBRATION_PAIRS 汇总保存
List<GardsCalibrationPairs> allPairs = new ArrayList<>();
@ -492,7 +549,6 @@ public class Sample_G_Analysis {
allPairs.addAll(pairsR);allPairs.addAll(pairsT);
serviceQuotes.getGardsCalibrationPairsService().saveBatch(allPairs);
}
public void saveCalibration(GStoreMiddleProcessData middleData,
Integer sampleId, Integer IdAnalysis){
String calibrationSampleType = middleData.getCalibration_sample_type();
@ -513,6 +569,7 @@ public class Sample_G_Analysis {
calibration.setStartOfRange((int)middleData.getCalibration_E_startOfRange());
calibration.setEndOfRange((int)middleData.getCalibration_E_endOfRange());
calibration.setCoeffString(middleData.getCalibration_E_coeff_string());
calibration.setModdate(new Date());
calibrations.add(calibration);
}
// GARDS_CALIBRATION (EF) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION
@ -532,7 +589,9 @@ public class Sample_G_Analysis {
calibration.setFunctionDef(efFunctionDef);
calibration.setStartOfRange((int)efStartOfRange);
calibration.setEndOfRange((int)efEndOfRange);
calibration.setCoeffString(efCoeffString);
// todo 暂时固定
calibration.setCoeffString("1,2,3");
calibration.setModdate(new Date());
calibrations.add(calibration);
}
// GARDS_CALIBRATION (R) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION
@ -553,6 +612,7 @@ public class Sample_G_Analysis {
calibration.setStartOfRange((int)rStartOfRange);
calibration.setEndOfRange((int)rEndOfRange);
calibration.setCoeffString(rCoeffString);
calibration.setModdate(new Date());
calibrations.add(calibration);
}
// GARDS_CALIBRATION (T) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION
@ -573,19 +633,26 @@ public class Sample_G_Analysis {
calibration.setStartOfRange((int)tStartOfRange);
calibration.setEndOfRange((int)tEndOfRange);
calibration.setCoeffString(tCoeffString);
calibration.setModdate(new Date());
calibrations.add(calibration);
}
serviceQuotes.getGardsCalibrationService().saveBatch(calibrations);
serviceQuotes.getGardsCalibrationService().createBatch(calibrations);
}
public void savePeaks(GStoreMiddleProcessData middleData){
public void savePeaks(GStoreMiddleProcessData middleData,Integer sampleId, Integer IdAnalysis){
// Gards_Peaks数据表 ==> INSERT INTO RNAUTO.GARDS_PEAKS
String base_P_IdPeak = "peaks_idPeak";
GardsPeaksDto gardsPeaksDto = new GardsPeaksDto();
BeanUtil.copyProperties(middleData,gardsPeaksDto);
GardsPeaks gardsPeaks = new GardsPeaks();
List<GardsPeaks> peaks = mapFields(gardsPeaksDto, gardsPeaks, base_P_IdPeak, fieldMap);
serviceQuotes.getGardsPeaksAutoService().saveBatch(peaks);
if (gardsPeaksDto.getPeaks_idPeak().size() > 0) {
List<GardsPeaks> peaks = mapFields(gardsPeaksDto, gardsPeaks, base_P_IdPeak, fieldMap);
peaks.forEach(ided -> {
ided.setSampleId(sampleId);
ided.setIdAnalysis(IdAnalysis);
});
serviceQuotes.getGardsPeaksAutoService().saveBatch(peaks);
}
}
public void saveNuclLinesIded(GStoreMiddleProcessData middleData,
@ -618,12 +685,15 @@ public class Sample_G_Analysis {
GardsNuclIdedDto gardsNuclIdedDto = new GardsNuclIdedDto();
GardsNuclIded gardsNuclIded = new GardsNuclIded();
BeanUtil.copyProperties(middleData,gardsNuclIdedDto);
String base_NuclideName = "nucl_ided_Nuclidename";
List<GardsNuclIded> gardsNuclIdeds =
mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap);
for (GardsNuclIded ided : gardsNuclIdeds) {
ided.setSampleId(sampleId);
ided.setIdAnalysis(IdAnalysis);
if (gardsNuclIdedDto.getNucl_ided_Nuclidename().size() > 0) {
String base_NuclideName = "nucl_ided_Nuclidename";
List<GardsNuclIded> gardsNuclIdeds =
mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap);
for (GardsNuclIded ided : gardsNuclIdeds) {
ided.setSampleId(sampleId);
ided.setIdAnalysis(IdAnalysis);
}
serviceQuotes.getGardsNuclIdedAutoService().saveBatch(gardsNuclIdeds);
}
// serviceQuotes.get
}
@ -635,22 +705,26 @@ public class Sample_G_Analysis {
String base_QC = String.valueOf(qcItems.size());
QcCheckDto qcCheckDto = new QcCheckDto();
BeanUtil.copyProperties(middleData,qcCheckDto);
GardsQcCheck gardsQcCheck = new GardsQcCheck();
List<GardsQcCheck> gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap);
for (GardsQcCheck qcCheck : gardsQcChecks) {
qcCheck.setSampleId(sampleId);
qcCheck.setIdanalysis(IdAnalysis);
if (qcItems.size() > 0) {
GardsQcCheck gardsQcCheck = new GardsQcCheck();
List<GardsQcCheck> gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap);
for (GardsQcCheck qcCheck : gardsQcChecks) {
qcCheck.setSampleId(sampleId);
qcCheck.setIdanalysis(IdAnalysis);
}
serviceQuotes.getGardsQcCheckAutoService().saveBatch(gardsQcChecks);
}
serviceQuotes.getGardsQcCheckAutoService().saveBatch(gardsQcChecks);
}
}
public Map<String, NuclideLines> getNuclideLinesG() {
redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class);
Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "G");
return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map<String, NuclideLines>) nuclideLibs;
}
public Map<String, NuclideLines> getNuclideLinesP(){
redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class);
Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "P");
return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map<String, NuclideLines>) nuclideLibs;
}
@ -788,7 +862,7 @@ public class Sample_G_Analysis {
private GardsAnalyses toAnalysis(GStoreMiddleProcessData middleData){
GardsAnalyses gardsAnalyses = new GardsAnalyses();
String dateTime = DateConstant.DATE_TIME;
String dateTime = DateConstant.DATE_BIAS_TIME;
String analysisBegin = middleData.getAnalyses_analysisBegin();
Date analysis_Begin = DateUtil.parse(analysisBegin, dateTime)
.toJdkDate();
@ -824,7 +898,9 @@ public class Sample_G_Analysis {
if (isNumber){
total = Integer.parseInt(baseLine);
}else {
List<String> baseList = (List<String>) sourceClass.getDeclaredField(baseLine).get(source);
Field declaredField = sourceClass.getDeclaredField(baseLine);
declaredField.setAccessible(true);
List<String> baseList = (List<String>) declaredField.get(source);
if (CollUtil.isEmpty(baseList))
return result;
total = baseList.size();

View File

@ -58,6 +58,7 @@ public class SpectrumServiceQuotes {
private final GardsPeaksAutoService gardsPeaksAutoService;
private final GardsNuclLinesIdedAutoService gardsNuclLinesIdedAutoService;
private final GardsNuclIdedAutoService gardsNuclIdedAutoService;
private final GardsQcCheckAutoService gardsQcCheckAutoService;

View File

@ -1,7 +1,6 @@
package org.jeecg.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -38,12 +37,12 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class GammaFileUtil {
@ -986,32 +985,41 @@ public class GammaFileUtil {
qcItems.put("Xe133-MDC", Xe133);
}
}
//遍历QcItems
for(Map.Entry<String, QcCheckItem> iter:qcItems.entrySet()){
//判断 QcItems的Standard是否为空
if(iter.getValue().getStandard().isEmpty()){
continue;
}
//根据英文分割standard数据
String[] lists = iter.getValue().getStandard().split(StringPool.COMMA);
//声明一个boolean类型 记录是否符合要求
boolean bSatisfy = true;
//遍历标准数据
for(String str : lists) {
//判断标准数据是否含有 / 如果含有跳过本次循环
if(str.contains(StringPool.DASH)){
continue;
} else if(str.contains(StringPool.LEFT_BRACKET)) {
} else if(str.contains(StringPool.LEFT_BRACKET)) {//判断标准数据是否包含(
//判断当前QcItem的值 是否 小于等于 去掉(后的标准值
if(iter.getValue().getValue() <= Double.valueOf(str.replace(StringPool.LEFT_BRACKET,""))) {
bSatisfy = false;
break;
}
} else if(str.contains(StringPool.RIGHT_BRACKET)) {
} else if(str.contains(StringPool.RIGHT_BRACKET)) {//判断标准数据是否包含)
//判断当前QcItem的值 是否 大于等于 去掉)后的标准值
if(iter.getValue().getValue() >= Double.valueOf(str.replace(StringPool.RIGHT_BRACKET,""))) {
bSatisfy = false;
break;
}
} else if(str.contains(StringPool.LEFT_SQ_BRACKET)) {
} else if(str.contains(StringPool.LEFT_SQ_BRACKET)) {//判断标准数据是否包含[
//判断当前QcItem的值 是否 小于 去掉[后的标准值
if(iter.getValue().getValue() < Double.valueOf(str.replace(StringPool.LEFT_SQ_BRACKET,""))) {
bSatisfy = false;
break;
}
} else if(str.contains(StringPool.RIGHT_SQ_BRACKET)) {
} else if(str.contains(StringPool.RIGHT_SQ_BRACKET)) {//判断标准数据是否包含]
//判断当前QcItem的值 是否 大于 去掉]后的标准值
if(iter.getValue().getValue() > Double.valueOf(str.replace(StringPool.RIGHT_SQ_BRACKET,""))) {
bSatisfy = false;
break;
@ -1029,29 +1037,47 @@ public class GammaFileUtil {
public Double CalculateMDC(PHDFile phd, List<Double> vMdcInfo, Double CCF) {
try {
System.loadLibrary("GammaAnaly");
//判断用于计算的数据大小是否小于3 判断集合中最后一个数值是否等于0
if(vMdcInfo.size() < 3 || vMdcInfo.get(2) == 0) {
return 0.0;
}
//获取采集开始时间
Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
//获取采样结束时间
Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
//获取能谱获取时间
Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0,phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
double Ts = (collectStart.getTime()/1000 - collectStop.getTime()/1000); // 采样时间
double Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000); // 衰变时间
double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间
double Tl = phd.getAcq().getAcquisition_live_time(); // 能谱获取活时间
double Svol = phd.getCollect().getAir_volume(); // 样品采样体积
//计算采样时间
double Ts = (collectStart.getTime()/1000 - collectStop.getTime()/1000);
//计算衰变时间
double Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000);
//获取能谱获取实时间
double Ta = phd.getAcq().getAcquisition_real_time();
//获取能谱获取活时间
double Tl = phd.getAcq().getAcquisition_live_time();
//获取样品采样体积
double Svol = phd.getCollect().getAir_volume();
double DCF1, DCF2, DCF3;
//计算得到lamda计算值
double lambda = Math.log(2.0) / (vMdcInfo.get(2) * 86400);
if ( Ts == 0 ) DCF1 = 1;
else DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts));
if ( Td == 0 ) DCF2 = 1;
else DCF2 = Math.exp(lambda*Td);
if ( Ta == 0 ) DCF3 = 1;
else DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta));
if ( Ts == 0 ) {
DCF1 = 1;
} else {
DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts));
}
if ( Td == 0 ) {
DCF2 = 1;
} else {
DCF2 = Math.exp(lambda*Td);
}
if ( Ta == 0 ) {
DCF3 = 1;
} else {
DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta));
}
//计算得到DCF_conc
double DCF_conc = Math.exp(lambda * (phd.getUsedSetting().getRefTime_conc().getTime()/1000 - collectStart.getTime()/1000));
//声明一个集合
List<Double> energy = new LinkedList<>();
energy.add(vMdcInfo.get(0));
//使用energyToChannel方法计算
@ -1063,26 +1089,28 @@ public class GammaFileUtil {
double[] array = dE.stream().mapToDouble(Double::doubleValue).toArray();
SimpleMatrix dEMatrix = new SimpleMatrix(calDerivEval.rowNum, calDerivEval.colNum, true, array);
//calFcnEval计算得到矩阵数据
CalValuesOut calFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedEnerPara().getP());
List<Double> counts = calFcnEval.counts;
CalValuesOut fwhmcCalFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP());
List<Double> fwhmcCounts = fwhmcCalFcnEval.counts;
//计算后的矩阵的集合转换成数组
double[] array2 = counts.stream().mapToDouble(Double::doubleValue).toArray();
double[] array2 = fwhmcCounts.stream().mapToDouble(Double::doubleValue).toArray();
//按照行数 列数 实际数据 生成矩阵
SimpleMatrix calMatrix = new SimpleMatrix(calFcnEval.rowNum, calFcnEval.colNum, true, array2);
SimpleMatrix calMatrix = new SimpleMatrix(fwhmcCalFcnEval.rowNum, fwhmcCalFcnEval.colNum, true, array2);
//计算后的矩阵 / dE矩阵 得到除后的矩阵
SimpleMatrix matrixC = calMatrix.elementDiv(dEMatrix);
//声明一个集合接收除后的矩阵数据
List<Double> values = new LinkedList<>();
// List<Double> values = new LinkedList<>();
//遍历相除后的矩阵 行数
for (int i=0; i<matrixC.numRows(); i++) {
//遍历相除后的矩阵 列数
for (int j=0; j<matrixC.numCols(); i++){
values.add(matrixC.get(i, j));
}
}
// for (int i=0; i<matrixC.numRows(); i++) {
// //遍历相除后的矩阵 列数
// for (int j=0; j<matrixC.numCols(); i++){
// values.add(matrixC.get(i, j));
// }
// }
//取除后矩阵的第一个数据
double fwhmc = values.get(0);
double fwhmc = matrixC.get(0, 0);
//取计算后的矩阵第一个数据
CalValuesOut calFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedEffiPara().getP());
List<Double> counts = calFcnEval.counts;
double effi = counts.get(0);
int index = 0;
for(int i=1; i<phd.getVEnergy().size(); ++i) {
@ -1255,9 +1283,11 @@ public class GammaFileUtil {
// SRID, Sample_Status, Collect_Start, Sampling_Time, Quantity, Flow_Rate,
// Acq_Start, Acq_Real, Acq_Live, Decay_Time, Auto_Cat, Category
List<String> detailInfo = new LinkedList<>();
//Detail Info的所有数据初始化为
for (int i=0; i<18; i++){
detailInfo.add("");
}
//读取phdFile的数据 修改detailInfo的数据
detailInfo.set(0, Objects.nonNull(sampleId)?sampleId.toString():""); // Sample_Id
detailInfo.set(1, phd.getHeader().getSite_code()); // Station_Code
detailInfo.set(2, phd.getHeader().getDetector_code()); // Detector_Code
@ -1291,10 +1321,11 @@ public class GammaFileUtil {
}
public void UpdateChart(PHDFile phd, Map<String, Object> map, Map<String, String> colorMap) {
//声明一个数组
List<Long> m_vCount = new LinkedList<>();
//获取 phdFile的Spec的num_g_channel
long m_nCount = phd.getSpec().getNum_g_channel();
long m_nSChan = phd.getSpec().getBegin_channel();
// 确保绘制曲线时所有谱都是从1道开始
int i = 0;
if(m_nSChan == 0){
@ -1590,7 +1621,9 @@ public class GammaFileUtil {
}
public int AnalyseData(PHDFile phd, List<String> nuclides) {
//判断phdFile内容是否有进行改变
int change = SettingChanged(phd);
//change == 0 vPeak的集合大小大于0 说明内容没有变化
if(change == 0 && phd.getVPeak().size() > 0) {
return change;
} else if(change == -1) {
@ -1620,23 +1653,47 @@ public class GammaFileUtil {
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
boolean value = (boolean) entry.getValue();
boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class);
phd.setBAnalyed(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapEffiPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapTotEPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, ParameterInfo> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class);
value.put(key, entryValue);
}
phd.setMapTotEPara(value);
}
if (entry.getKey().equalsIgnoreCase("para_stepRatio")) {
@ -1660,35 +1717,47 @@ public class GammaFileUtil {
phd.setPara_tailRightAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("newEner")) {
String value = (String) entry.getValue();
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setNewEner(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerKD")) {
Map<String, GEnergyBlock> value = (Map<String, GEnergyBlock>) entry.getValue();
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, GEnergyBlock> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
GEnergyBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GEnergyBlock.class);
value.put(key, entryValue);
}
phd.setMapEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoKD")) {
Map<String, GResolutionBlock> value = (Map<String, GResolutionBlock>) entry.getValue();
HashMap<String, Object> jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class);
Map<String, GResolutionBlock> value = new HashMap<>();
for (Map.Entry<String, Object> objectEntry:jsonMap.entrySet()) {
String key = objectEntry.getKey();
GResolutionBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GResolutionBlock.class);
value.put(key, entryValue);
}
phd.setMapResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("vEnergy")) {
List<Double> value = (List<Double>) entry.getValue();
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVEnergy(value);
}
if (entry.getKey().equalsIgnoreCase("vBase")) {
List<Double> value = (List<Double>) entry.getValue();
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVBase(value);
}
if (entry.getKey().equalsIgnoreCase("vLc")) {
List<Double> value = (List<Double>) entry.getValue();
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVLc(value);
}
if (entry.getKey().equalsIgnoreCase("vScac")) {
List<Double> value = (List<Double>) entry.getValue();
List<Double> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
phd.setVScac(value);
}
if (entry.getKey().equalsIgnoreCase("vPeak")) {
List<PeakInfo> value = (List<PeakInfo>) entry.getValue();
List<PeakInfo> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class);
phd.setVPeak(value);
}
if (entry.getKey().equalsIgnoreCase("baseCtrls")) {
@ -1696,7 +1765,7 @@ public class GammaFileUtil {
phd.setBaseCtrls(value);
}
if (entry.getKey().equalsIgnoreCase("usedEner")) {
String value = (String) entry.getValue();
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedEner(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerKD")) {
@ -1708,7 +1777,7 @@ public class GammaFileUtil {
phd.setUsedEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedReso")) {
String value = (String) entry.getValue();
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedReso(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoKD")) {
@ -1720,7 +1789,7 @@ public class GammaFileUtil {
phd.setUsedResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffi")) {
String value = (String) entry.getValue();
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedEffi(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiKD")) {
@ -1732,7 +1801,7 @@ public class GammaFileUtil {
phd.setUsedEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotE")) {
String value = (String) entry.getValue();
String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class);
phd.setUsedTotE(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEKD")) {
@ -1745,6 +1814,58 @@ public class GammaFileUtil {
}
}
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
if(CollectionUtils.isNotEmpty(phd.getMapEnerKD())) {
String key = "";
key = phd.getNewEner();
phd.setUsedEner(key);
GEnergyBlock source = new GEnergyBlock();
GEnergyBlock gEnergyBlock = phd.getMapEnerKD().get(phd.getNewEner());
BeanUtils.copyProperties(gEnergyBlock, source);
phd.setUsedEnerKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = phd.getMapEnerPara().get(phd.getNewEner());
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedEnerPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapResoKD())) {
String key = "";
key = phd.getNewReso();
phd.setUsedReso(key);
GResolutionBlock source = new GResolutionBlock();
GResolutionBlock gResolutionBlock = phd.getMapResoKD().get(phd.getNewReso());
BeanUtils.copyProperties(gResolutionBlock, source);
phd.setUsedResoKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = phd.getMapResoPara().get(phd.getNewReso());
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedResoPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapEffiKD())) {
String key = "";
key = phd.getNewEffi();
phd.setUsedEffi(key);
GEfficiencyBlock source = new GEfficiencyBlock();
GEfficiencyBlock gEfficiencyBlock = phd.getMapEffiKD().get(phd.getNewEffi());
BeanUtils.copyProperties(gEfficiencyBlock, source);
phd.setUsedEffiKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = Objects.nonNull(phd.getMapEffiPara().get(phd.getNewEffi()))?phd.getMapEffiPara().get(phd.getNewEffi()):new ParameterInfo();
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedEffiPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapTotEKD())) {
String key = "";
key = phd.getNewTotE();
phd.setUsedTotE(key);
TotaleffBlock source = new TotaleffBlock();
TotaleffBlock totaleffBlock = phd.getMapTotEKD().get(phd.getNewTotE());
BeanUtils.copyProperties(totaleffBlock, source);
phd.setUsedTotEKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = Objects.nonNull(phd.getMapTotEPara().get(phd.getNewTotE()))?phd.getMapTotEPara().get(phd.getNewTotE()):new ParameterInfo();
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedTotEPara(info);
}
for (PeakInfo peak:phd.getVPeak()) {
if (StringUtils.isBlank(peak.recoilBetaChan)) {
@ -1782,7 +1903,7 @@ public class GammaFileUtil {
}
List<Double> old_ener = phd.getUsedEnerPara().getP();
List<Double> new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP();
List<Double> new_ener = CollectionUtils.isNotEmpty(phd.getMapEnerPara())?phd.getMapEnerPara().get(phd.getNewEner()).getP():new LinkedList<>();
if(old_ener.size() != new_ener.size()) {
return 1;
}
@ -1793,7 +1914,7 @@ public class GammaFileUtil {
}
List<Double> old_reso = phd.getUsedResoPara().getP();
List<Double> new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP();
List<Double> new_reso = CollectionUtils.isNotEmpty(phd.getMapResoPara())?phd.getMapResoPara().get(phd.getNewReso()).getP():new LinkedList<>();
if(old_reso.size() != new_reso.size()) {
return 1;
}
@ -1804,7 +1925,7 @@ public class GammaFileUtil {
}
List<Double> old_effi = phd.getUsedEffiPara().getP();
List<Double> new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP();
List<Double> new_effi = CollectionUtils.isNotEmpty(phd.getMapEffiPara())?phd.getMapEffiPara().get(phd.getNewEffi()).getP():new LinkedList<>();
if(old_effi.size() != new_effi.size()) {
return -1;
}

View File

@ -36,8 +36,8 @@ public class GammaController {
@GetMapping("initValue")
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
return gammaService.initValue(sampleId, dbName, request);
public Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request) {
return gammaService.initValue(sampleId, dbName, fileName, request);
}
@GetMapping("analysisProcess")
@ -350,6 +350,12 @@ public class GammaController {
return gammaService.viewComment(sampleId, fileName);
}
@PutMapping("addComment")
@ApiOperation(value = "修改Comment数据", notes = "修改Comment数据")
public Result addComment(String fileName, String comment) {
return gammaService.addComment(fileName, comment);
}
@GetMapping("peakInformation")
@ApiOperation(value = "查看Peak Information页面数据", notes = "查看Peak Information页面数据")
public Result<?> peakInformation(Integer sampleId, String fileName){

View File

@ -12,7 +12,7 @@ import java.util.List;
public interface IGammaService{
Result initValue(Integer sampleId, String dbName, HttpServletRequest request);
Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request);
Result testFun(String fileName, HttpServletRequest request);
@ -116,6 +116,8 @@ public interface IGammaService{
Result viewComment(Integer sampleId, String fileName);
Result addComment(String fileName, String comment);
Result<?> peakInformation(Integer sampleId, String fileName);
void exportPeakInformation(Integer sampleId, String fileName, HttpServletResponse response);

View File

@ -120,33 +120,45 @@ public class GammaServiceImpl implements IGammaService {
private IGardsAnalySettingSpectrumService analySettingSpectrumService;
@Override
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
public Result initValue(Integer sampleId, String dbName, String samfileName, HttpServletRequest request) {
Result result = new Result();
//
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = new PHDFile();
//读取文件内容
//根据sampleId获取sample文件路径
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
if (StringUtils.isBlank(sampleFilePath)){
result.error500("样品文件不存在!");
return result;
String lastName = "";
if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) {
//根据sampleId获取sample文件路径
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
if (StringUtils.isBlank(sampleFilePath)){
result.error500("样品文件不存在!");
return result;
}
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!flag){
return result;
}
//声明基础数组信息
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
if (!bRet){
return result;
}
lastName = fileName;
} else {
String pathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String fileName = samfileName;
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!flag){
return result;
}
lastName = fileName;
}
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!flag){
return result;
}
//声明基础数组信息
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
if (!bRet){
return result;
}
phdCache.put(fileName, phd);
phdCache.put(lastName, phd);
localCache.setPHDCache(phdCache);
result.setSuccess(true);
result.setResult(phd);
@ -174,7 +186,6 @@ public class GammaServiceImpl implements IGammaService {
}
Map<String, NuclideLines> nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides);
//解析获取临时文件信息
File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName);
ObjectMapper mapper = new ObjectMapper();
try {
@ -1057,7 +1068,9 @@ public class GammaServiceImpl implements IGammaService {
result.error500("请先选择解析文件!");
return result;
}
phd.setTotalCmt(comments);
if (StringUtils.isNotBlank(comments)) {
phd.setTotalCmt(comments);
}
return Result.ok();
}
@ -2342,6 +2355,22 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public Result addComment(String fileName, String comment) {
Result result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
if(StringUtils.isNotBlank(comment)) {
phd.setTotalCmt(comment);
}
result.success("修改成功");
return result;
}
public Result<List<TablePeak>> peakInformation(Integer sampleId, String fileName){
Result<List<TablePeak>> result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();

View File

@ -112,57 +112,63 @@ public class GardsCalibrationPairsOrigSpectrumServiceImpl extends ServiceImpl<Ga
@Transactional
public Integer saveCalibrationPairsOrigGamma(PHDFile phd, Integer sampleId) {
List<GardsCalibrationPairsOrig> calibrationPairsOrigList = new LinkedList<>();
if (Objects.nonNull(phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy())) {
int t_size = phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy().size();
if(t_size > 0) {
GEnergyBlock g_ener = phd.getMapEnerKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++) {
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleId);
calibrationPairsOrig.setSampleType(SystemType.GAMMA.getType());
calibrationPairsOrig.setCaltype(CalType.ENERGY_CAL.getType());
calibrationPairsOrig.setInput(CalName.CalPHD.getType());
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(g_ener.getCentroid_channel().get(i));
calibrationPairsOrig.setYValue(g_ener.getG_energy().get(i));
calibrationPairsOrig.setUncYValue(g_ener.getUncertainty().get(i));
calibrationPairsOrigList.add(calibrationPairsOrig);
if (CollectionUtils.isNotEmpty(phd.getMapEnerKD())) {
if (Objects.nonNull(phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy())) {
int t_size = phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy().size();
if(t_size > 0) {
GEnergyBlock g_ener = phd.getMapEnerKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++) {
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleId);
calibrationPairsOrig.setSampleType(SystemType.GAMMA.getType());
calibrationPairsOrig.setCaltype(CalType.ENERGY_CAL.getType());
calibrationPairsOrig.setInput(CalName.CalPHD.getType());
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(g_ener.getCentroid_channel().get(i));
calibrationPairsOrig.setYValue(g_ener.getG_energy().get(i));
calibrationPairsOrig.setUncYValue(g_ener.getUncertainty().get(i));
calibrationPairsOrigList.add(calibrationPairsOrig);
}
}
}
}
if (Objects.nonNull(phd.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy())) {
int t_size = phd.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy().size();
if(t_size > 0) {
GResolutionBlock g_reso = phd.getMapResoKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++) {
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleId);
calibrationPairsOrig.setSampleType(SystemType.GAMMA.getType());
calibrationPairsOrig.setCaltype(CalType.RESOLUTION_CAL.getType());
calibrationPairsOrig.setInput(CalName.CalPHD.getType());
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(g_reso.getG_energy().get(i));
calibrationPairsOrig.setYValue(g_reso.getFWHM().get(i));
calibrationPairsOrig.setUncYValue(g_reso.getUncertainty().get(i));
calibrationPairsOrigList.add(calibrationPairsOrig);
if (CollectionUtils.isNotEmpty(phd.getMapResoKD())) {
if (Objects.nonNull(phd.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy())) {
int t_size = phd.getMapResoKD().get(CalName.CalPHD.getType()).getG_energy().size();
if(t_size > 0) {
GResolutionBlock g_reso = phd.getMapResoKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++) {
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleId);
calibrationPairsOrig.setSampleType(SystemType.GAMMA.getType());
calibrationPairsOrig.setCaltype(CalType.RESOLUTION_CAL.getType());
calibrationPairsOrig.setInput(CalName.CalPHD.getType());
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(g_reso.getG_energy().get(i));
calibrationPairsOrig.setYValue(g_reso.getFWHM().get(i));
calibrationPairsOrig.setUncYValue(g_reso.getUncertainty().get(i));
calibrationPairsOrigList.add(calibrationPairsOrig);
}
}
}
}
if (Objects.nonNull(phd.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy())) {
int t_size = phd.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy().size();
if(t_size > 0) {
GEfficiencyBlock g_effi = phd.getMapEffiKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleId);
calibrationPairsOrig.setSampleType(SystemType.GAMMA.getType());
calibrationPairsOrig.setCaltype(CalType.EFFICIENCY_CAL.getType());
calibrationPairsOrig.setInput(CalName.CalPHD.getType());
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(g_effi.getG_energy().get(i));
calibrationPairsOrig.setYValue(g_effi.getEfficiency().get(i));
calibrationPairsOrig.setUncYValue(g_effi.getUncertainty().get(i));
calibrationPairsOrigList.add(calibrationPairsOrig);
if (CollectionUtils.isNotEmpty(phd.getMapEffiKD())) {
if (Objects.nonNull(phd.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy())) {
int t_size = phd.getMapEffiKD().get(CalName.CalPHD.getType()).getG_energy().size();
if(t_size > 0) {
GEfficiencyBlock g_effi = phd.getMapEffiKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++){
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
calibrationPairsOrig.setSampleId(sampleId);
calibrationPairsOrig.setSampleType(SystemType.GAMMA.getType());
calibrationPairsOrig.setCaltype(CalType.EFFICIENCY_CAL.getType());
calibrationPairsOrig.setInput(CalName.CalPHD.getType());
calibrationPairsOrig.setIdCalPoint(i);
calibrationPairsOrig.setXValue(g_effi.getG_energy().get(i));
calibrationPairsOrig.setYValue(g_effi.getEfficiency().get(i));
calibrationPairsOrig.setUncYValue(g_effi.getUncertainty().get(i));
calibrationPairsOrigList.add(calibrationPairsOrig);
}
}
}
}

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.rnman.GardsNuclIded;
import org.jeecg.modules.entity.vo.GStoreMiddleProcessData;
import org.jeecg.modules.entity.GardsNuclIdedSpectrum;
import org.jeecg.modules.mapper.GardsNuclIdedSpectrumMapper;
import org.jeecg.modules.service.IGardsNuclIdedSpectrumService;
import org.springframework.stereotype.Service;
@ -30,18 +29,18 @@ public class GardsNuclIdedSpectrumServiceImpl extends ServiceImpl<GardsNuclIdedS
nuclIded.setSampleId(sampleId);
nuclIded.setIdAnalysis(Integer.valueOf(idAnalysis));
nuclIded.setNuclideName(middleData.nucl_ided_Nuclidename.get(i));
nuclIded.setType(middleData.nucl_ided_Type.get(i));
nuclIded.setType(null);
nuclIded.setHalflife(middleData.nucl_ided_Halflife.get(i));
nuclIded.setAveActiv(middleData.nucl_ided_ave_activ.get(i));
nuclIded.setAveActivErr(Double.valueOf(middleData.nucl_ided_ave_activ_err.get(i)));
nuclIded.setAveActiv(null);
nuclIded.setAveActivErr(null);
nuclIded.setActivKey(Double.valueOf(middleData.nucl_ided_activ_key.get(i)));
nuclIded.setActivKeyErr(Double.valueOf(middleData.nucl_ided_activ_key_err.get(i)));
nuclIded.setMda(middleData.nucl_ided_mda.get(i));
nuclIded.setMdaErr(Double.valueOf(middleData.nucl_ided_mda_err.get(i)));
nuclIded.setNidFlag(Integer.valueOf(middleData.nucl_ided_nid_flag.get(i)));
nuclIded.setMdaErr(null);
nuclIded.setNidFlag(null);
nuclIded.setCscRatio(Double.valueOf(middleData.nucl_ided_csc_ratio.get(i)));
nuclIded.setCscRatioErr(Double.valueOf(middleData.nucl_ided_csc_ratio_err.get(i)));
nuclIded.setCscModFlag(Integer.valueOf(middleData.nucl_ided_csc_mod_flag.get(i)));
nuclIded.setCscModFlag(null);
nuclIded.setMdc(middleData.nucl_ided_MDC.get(i));
nuclIded.setConcentration(middleData.nucl_ided_Concentration.get(i));
nuclIded.setKeyEnergy(middleData.nucl_ided_Key_Energy.get(i));

View File

@ -49,15 +49,15 @@ public class GardsPeaksSpectrumServiceImpl extends ServiceImpl<GardsPeaksSpectru
peaks.setUpperTail(Double.valueOf(middleData.peaks_upperTail.get(i)));
peaks.setUpperTailAlpha(Double.valueOf(middleData.peaks_upperTailAlpha.get(i)));
peaks.setBwwidthchan(Double.valueOf(middleData.peaks_BWWidthChan.get(i)));
peaks.setRecoilbetachan(Double.valueOf(middleData.peaks_recoilBetaChan.get(i)));
peaks.setRecoildeltachan(Double.valueOf(middleData.peaks_recoilDeltaChan.get(i)));
peaks.setRecoilbetachan(null);
peaks.setRecoildeltachan(null);
peaks.setStepraio(Double.valueOf(middleData.peaks_stepRatio.get(i)));
peaks.setBackgroundarea(Double.valueOf(middleData.peaks_backgroundArea.get(i)));
peaks.setMeanbackcount(Double.valueOf(middleData.peaks_meanBackCount.get(i)));
peaks.setLc(Double.valueOf(middleData.peaks_Lc.get(i)));
peaks.setLd(Double.valueOf(middleData.peaks_Ld.get(i)));
peaks.setNetCountRate(Double.valueOf(middleData.peaks_netCountRate.get(i)));
peaks.setUncNetCountRate(Double.valueOf(middleData.peaks_uncNetCountRate.get(i)));
peaks.setNetCountRate(null);
peaks.setUncNetCountRate(null);
peaks.setPeakcomments(middleData.peaks_comments.get(i));
peaksList.add(peaks);
}

View File

@ -43,20 +43,22 @@ public class GardsTotalEfficiencyPairsSpectrumServiceImpl extends ServiceImpl<Ga
@Transactional
public Integer saveTotalEfficiencyPairsGamma(PHDFile phd, Integer sampleId) {
List<GardsTotalEfficiencyPairs> totalEfficiencyPairsList = new LinkedList<>();
int t_size = Objects.nonNull(phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy())?phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy().size():0;
if(t_size > 0) {
TotaleffBlock g_tote = phd.getMapTotEKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++){
GardsTotalEfficiencyPairs totalEfficiencyPairs = new GardsTotalEfficiencyPairs();
totalEfficiencyPairs.setSampleId(sampleId);
totalEfficiencyPairs.setEfficEnergy(String.valueOf(g_tote.getG_energy().get(i)));
totalEfficiencyPairs.setTotalEfficiency(g_tote.getTotal_efficiency().get(i));
totalEfficiencyPairs.setTotalEfficError(g_tote.getUncertainty().get(i));
totalEfficiencyPairsList.add(totalEfficiencyPairs);
if (CollectionUtils.isNotEmpty(phd.getMapTotEKD())) {
int t_size = Objects.nonNull(phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy())?phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy().size():0;
if(t_size > 0) {
TotaleffBlock g_tote = phd.getMapTotEKD().get(CalName.CalPHD.getType());
for (int i=0; i<t_size; i++){
GardsTotalEfficiencyPairs totalEfficiencyPairs = new GardsTotalEfficiencyPairs();
totalEfficiencyPairs.setSampleId(sampleId);
totalEfficiencyPairs.setEfficEnergy(String.valueOf(g_tote.getG_energy().get(i)));
totalEfficiencyPairs.setTotalEfficiency(g_tote.getTotal_efficiency().get(i));
totalEfficiencyPairs.setTotalEfficError(g_tote.getUncertainty().get(i));
totalEfficiencyPairsList.add(totalEfficiencyPairs);
}
}
if (CollectionUtils.isNotEmpty(totalEfficiencyPairsList)) {
this.saveBatch(totalEfficiencyPairsList);
}
}
if (CollectionUtils.isNotEmpty(totalEfficiencyPairsList)) {
this.saveBatch(totalEfficiencyPairsList);
}
return totalEfficiencyPairsList.size();
}