fix:1.修改roi卡gamma数据代码,改为两个x点卡数据;
2.点击分析按钮根据卡出来的数据生成gammaPHD文件
This commit is contained in:
parent
5a8f20362a
commit
2e10465bfe
|
@ -1,5 +1,7 @@
|
||||||
package org.jeecg.common.util;
|
package org.jeecg.common.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
@ -9,11 +11,17 @@ import org.jeecg.modules.base.enums.CalName;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
import org.jeecg.modules.native_jni.CalValuesHandler;
|
import org.jeecg.modules.native_jni.CalValuesHandler;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
|
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
||||||
|
import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam;
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -97,8 +105,31 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
spectrumData.setDetectorBkMeasurementId(detectorBkMeasurementId);
|
spectrumData.setDetectorBkMeasurementId(detectorBkMeasurementId);
|
||||||
spectrumData.setMeasurementId(measurementId);
|
spectrumData.setMeasurementId(measurementId);
|
||||||
map.put("spectrumData", spectrumData);
|
map.put("spectrumData", spectrumData);
|
||||||
|
|
||||||
|
//计算边界值
|
||||||
|
List<Double> gEnergy = struct.g_energy;
|
||||||
|
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||||
|
List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||||
|
List<Double> bChannel = struct.b_channel;
|
||||||
|
CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam();
|
||||||
|
calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
|
||||||
|
calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel);
|
||||||
|
calcBgBoundaryParam.b_energy = struct.b_electron_energy;
|
||||||
|
calcBgBoundaryParam.b_channel = struct.b_channel;
|
||||||
|
calcBgBoundaryParam.g_channel = struct.g_centroid_channel;
|
||||||
|
calcBgBoundaryParam.g_energy = struct.g_energy;
|
||||||
|
calcBgBoundaryParam.ROI_B_start_x1 = struct.POI_B_x1;
|
||||||
|
calcBgBoundaryParam.ROI_B_stop_x2 = struct.POI_B_x2;
|
||||||
|
calcBgBoundaryParam.ROI_G_start_y1 = struct.POI_G_y1;
|
||||||
|
calcBgBoundaryParam.ROI_G_stop_y2 = struct.POI_G_y2;
|
||||||
|
BgBoundary bgBoundary = EnergySpectrumHandler.CalcBgBoundary(calcBgBoundaryParam);
|
||||||
|
// 新beta谱:只取X轴数据从Y轴0的位置开始连成一条线,一直到顶画出矩形框 这个矩形框内的数据就是Gamma谱数据
|
||||||
|
List<Integer> roiBBoundaryStart = bgBoundary.ROI_B_Boundary_start;
|
||||||
|
List<Integer> roiBBoundaryStop = bgBoundary.ROI_B_Boundary_stop;
|
||||||
|
|
||||||
|
|
||||||
//根据范围1划分 范围1对应的折线图
|
//根据范围1划分 范围1对应的折线图
|
||||||
Map<String, Object> oneMap = statisticsROIList(struct.POI_B_x1.get(0).intValue(), struct.POI_B_x2.get(0).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
|
Map<String, Object> oneMap = statisticsROIList(roiBBoundaryStart.get(0), roiBBoundaryStop.get(0), struct.b_channels, struct.g_channels, struct.h_counts);
|
||||||
if (CollectionUtils.isNotEmpty(oneMap) ) {
|
if (CollectionUtils.isNotEmpty(oneMap) ) {
|
||||||
Integer startChannel = (Integer) oneMap.get("startChannel");
|
Integer startChannel = (Integer) oneMap.get("startChannel");
|
||||||
Integer endChannel = (Integer) oneMap.get("endChannel");
|
Integer endChannel = (Integer) oneMap.get("endChannel");
|
||||||
|
@ -107,17 +138,18 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
selfStationData.getSampleVueData().setROIOneBetaStart(startChannel);
|
selfStationData.getSampleVueData().setROIOneBetaStart(startChannel);
|
||||||
selfStationData.getSampleVueData().setROIOneBetaStop(endChannel);
|
selfStationData.getSampleVueData().setROIOneBetaStop(endChannel);
|
||||||
selfStationData.getSampleVueData().setROIOneList(seriseDataList);
|
selfStationData.getSampleVueData().setROIOneList(seriseDataList);
|
||||||
|
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)oneMap.get("counts"));
|
||||||
} else if (systemType.equals("det")) {
|
} else if (systemType.equals("det")) {
|
||||||
selfStationData.getDetVueData().setROIOneBetaStart(startChannel);
|
selfStationData.getDetVueData().setROIOneBetaStart(startChannel);
|
||||||
selfStationData.getDetVueData().setROIOneBetaStop(endChannel);
|
selfStationData.getDetVueData().setROIOneBetaStop(endChannel);
|
||||||
selfStationData.getDetVueData().setROIOneList(seriseDataList);
|
selfStationData.getDetVueData().setROIOneList(seriseDataList);
|
||||||
}
|
}
|
||||||
map.put("ROIOneStart", startChannel);
|
map.put("ROIOneStart", roiBBoundaryStart.get(0));
|
||||||
map.put("ROIOneStop", endChannel);
|
map.put("ROIOneStop", roiBBoundaryStop.get(0));
|
||||||
map.put("ROIOneList", seriseDataList);
|
map.put("ROIOneList", seriseDataList);
|
||||||
}
|
}
|
||||||
//根据范围2划分 范围2对应的折线图
|
//根据范围2划分 范围2对应的折线图
|
||||||
Map<String, Object> twoMap = statisticsROIList(struct.POI_B_x1.get(1).intValue(), struct.POI_B_x2.get(1).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
|
Map<String, Object> twoMap = statisticsROIList(roiBBoundaryStart.get(1), roiBBoundaryStop.get(1), struct.b_channels, struct.g_channels, struct.h_counts);
|
||||||
if ( CollectionUtils.isNotEmpty(twoMap) ) {
|
if ( CollectionUtils.isNotEmpty(twoMap) ) {
|
||||||
Integer startChannel = (Integer) twoMap.get("startChannel");
|
Integer startChannel = (Integer) twoMap.get("startChannel");
|
||||||
Integer endChannel = (Integer) twoMap.get("endChannel");
|
Integer endChannel = (Integer) twoMap.get("endChannel");
|
||||||
|
@ -131,12 +163,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
selfStationData.getDetVueData().setROITwoBetaStop(endChannel);
|
selfStationData.getDetVueData().setROITwoBetaStop(endChannel);
|
||||||
selfStationData.getDetVueData().setROITwoList(seriseDataList);
|
selfStationData.getDetVueData().setROITwoList(seriseDataList);
|
||||||
}
|
}
|
||||||
map.put("ROITwoStart", startChannel);
|
map.put("ROITwoStart", roiBBoundaryStart.get(1));
|
||||||
map.put("ROITwoStop", endChannel);
|
map.put("ROITwoStop", roiBBoundaryStop.get(1));
|
||||||
map.put("ROITwoList", seriseDataList);
|
map.put("ROITwoList", seriseDataList);
|
||||||
}
|
}
|
||||||
//根据范围3划分 范围3对应的折线图
|
//根据范围3划分 范围3对应的折线图
|
||||||
Map<String, Object> threeMap = statisticsROIList(struct.POI_B_x1.get(2).intValue(), struct.POI_B_x2.get(2).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
|
Map<String, Object> threeMap = statisticsROIList(roiBBoundaryStart.get(2), roiBBoundaryStop.get(2), struct.b_channels, struct.g_channels, struct.h_counts);
|
||||||
if ( CollectionUtils.isNotEmpty(threeMap) ) {
|
if ( CollectionUtils.isNotEmpty(threeMap) ) {
|
||||||
Integer startChannel = (Integer) threeMap.get("startChannel");
|
Integer startChannel = (Integer) threeMap.get("startChannel");
|
||||||
Integer endChannel = (Integer) threeMap.get("endChannel");
|
Integer endChannel = (Integer) threeMap.get("endChannel");
|
||||||
|
@ -149,13 +181,14 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
selfStationData.getDetVueData().setROIThreeBetaStart(startChannel);
|
selfStationData.getDetVueData().setROIThreeBetaStart(startChannel);
|
||||||
selfStationData.getDetVueData().setROIThreeBetaStop(endChannel);
|
selfStationData.getDetVueData().setROIThreeBetaStop(endChannel);
|
||||||
selfStationData.getDetVueData().setROIThreeList(seriseDataList);
|
selfStationData.getDetVueData().setROIThreeList(seriseDataList);
|
||||||
|
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)threeMap.get("counts"));
|
||||||
}
|
}
|
||||||
map.put("ROIThreeStart", startChannel);
|
map.put("ROIThreeStart", roiBBoundaryStart.get(2));
|
||||||
map.put("ROIThreeStop", endChannel);
|
map.put("ROIThreeStop", roiBBoundaryStop.get(2));
|
||||||
map.put("ROIThreeList", seriseDataList);
|
map.put("ROIThreeList", seriseDataList);
|
||||||
}
|
}
|
||||||
//根据范围4划分 范围4对应的折线图
|
//根据范围4划分 范围4对应的折线图
|
||||||
Map<String, Object> fourMap = statisticsROIList(struct.POI_B_x1.get(3).intValue(), struct.POI_B_x2.get(3).intValue(), struct.b_channels, struct.g_channels, struct.h_counts);
|
Map<String, Object> fourMap = statisticsROIList(roiBBoundaryStart.get(3), roiBBoundaryStop.get(3), struct.b_channels, struct.g_channels, struct.h_counts);
|
||||||
if ( CollectionUtils.isNotEmpty(fourMap) ) {
|
if ( CollectionUtils.isNotEmpty(fourMap) ) {
|
||||||
Integer startChannel = (Integer) fourMap.get("startChannel");
|
Integer startChannel = (Integer) fourMap.get("startChannel");
|
||||||
Integer endChannel = (Integer) fourMap.get("endChannel");
|
Integer endChannel = (Integer) fourMap.get("endChannel");
|
||||||
|
@ -169,8 +202,8 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
selfStationData.getDetVueData().setROIFourBetaStop(endChannel);
|
selfStationData.getDetVueData().setROIFourBetaStop(endChannel);
|
||||||
selfStationData.getDetVueData().setROIFourList(seriseDataList);
|
selfStationData.getDetVueData().setROIFourList(seriseDataList);
|
||||||
}
|
}
|
||||||
map.put("ROIFourStart", startChannel);
|
map.put("ROIFourStart", roiBBoundaryStart.get(3));
|
||||||
map.put("ROIFourStop", endChannel);
|
map.put("ROIFourStop", roiBBoundaryStop.get(3));
|
||||||
map.put("ROIFourList", seriseDataList);
|
map.put("ROIFourList", seriseDataList);
|
||||||
}
|
}
|
||||||
//散点图
|
//散点图
|
||||||
|
@ -206,9 +239,9 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
map.put("histogramDataList", histogramDataList);
|
map.put("histogramDataList", histogramDataList);
|
||||||
// map.put("histogramDataDList", histogramDataDList);
|
// map.put("histogramDataDList", histogramDataDList);
|
||||||
//gamma能量部分的计算参数 道值
|
//gamma能量部分的计算参数 道值
|
||||||
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
// List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||||
//gamma能量部分的计算参数 道值对应能量
|
//gamma能量部分的计算参数 道值对应能量
|
||||||
List<Double> gEnergy = struct.g_energy;
|
// List<Double> gEnergy = struct.g_energy;
|
||||||
//调用算法 传入道值和道值对应的能量 得到计算gamma能量公式的参数
|
//调用算法 传入道值和道值对应的能量 得到计算gamma能量公式的参数
|
||||||
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
|
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
|
||||||
//存储需要计算gamma能量的道值
|
//存储需要计算gamma能量的道值
|
||||||
|
@ -221,9 +254,9 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
//将gamma能量折线图进行赋值返回
|
//将gamma能量折线图进行赋值返回
|
||||||
map.put("gammaEnergyData", gammaEnergyList);
|
map.put("gammaEnergyData", gammaEnergyList);
|
||||||
//beta能量部分的计算参数 道值
|
//beta能量部分的计算参数 道值
|
||||||
List<Double> bChannel = struct.b_channel;
|
// List<Double> bChannel = struct.b_channel;
|
||||||
//beta能量部分的计算参数 道值对应的能量
|
//beta能量部分的计算参数 道值对应的能量
|
||||||
List<Double> bElectronEnergy = struct.b_electron_energy;
|
// List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||||
//调用算法 传入道值和道值对应的能量 得到计算beta能量公式的参数
|
//调用算法 传入道值和道值对应的能量 得到计算beta能量公式的参数
|
||||||
List<Double> betaParam = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
|
List<Double> betaParam = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
|
||||||
List<Double> bchannels = new ArrayList<>();
|
List<Double> bchannels = new ArrayList<>();
|
||||||
|
@ -300,7 +333,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
File file = null;
|
File file = null;
|
||||||
try {
|
try {
|
||||||
//根据完整的文件路径 获取临时文件
|
//根据完整的文件路径 获取临时文件
|
||||||
file = ftpUtil.downloadFile(filePathName, "betaGamma");
|
file = ftpUtil.downloadFile(filePathName);
|
||||||
if (Objects.nonNull(file)) {
|
if (Objects.nonNull(file)) {
|
||||||
if (type.equalsIgnoreCase("sample")) {
|
if (type.equalsIgnoreCase("sample")) {
|
||||||
selfStationData.setSampleTmpPath(file.getAbsolutePath());
|
selfStationData.setSampleTmpPath(file.getAbsolutePath());
|
||||||
|
@ -326,6 +359,8 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> statisticsROIList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
|
public Map<String, Object> statisticsROIList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
// g_counts
|
||||||
|
List<Long> counts = new LinkedList<>();
|
||||||
//存储同一列不同行加和后的数量
|
//存储同一列不同行加和后的数量
|
||||||
List<Integer> sumList = new LinkedList<>();
|
List<Integer> sumList = new LinkedList<>();
|
||||||
List<SeriseData> seriseDataList = new LinkedList<>();
|
List<SeriseData> seriseDataList = new LinkedList<>();
|
||||||
|
@ -340,18 +375,21 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
int index = (int) (i * betaChannels + j);
|
int index = (int) (i * betaChannels + j);
|
||||||
long count = 0;
|
long count = 0;
|
||||||
//判断下标是否在h_counts范围内
|
//判断下标是否在h_counts范围内
|
||||||
if (index < h_counts.size()) {
|
if (index > 0 && index < h_counts.size()) {
|
||||||
count = h_counts.get(index);
|
count = h_counts.get(index);
|
||||||
}
|
}
|
||||||
sum+=count;
|
sum+=count;
|
||||||
}
|
}
|
||||||
seriseData.setY(sum);
|
seriseData.setY(sum);
|
||||||
sumList.add(sum);
|
sumList.add(sum);
|
||||||
|
counts.add((long) sum);
|
||||||
seriseDataList.add(seriseData);
|
seriseDataList.add(seriseData);
|
||||||
}
|
}
|
||||||
map.put("startChannel", startChannel);
|
map.put("startChannel", startChannel);
|
||||||
map.put("endChannel", endChannel);
|
map.put("endChannel", endChannel);
|
||||||
map.put("dataList", seriseDataList);
|
map.put("dataList", seriseDataList);
|
||||||
|
map.put("counts", counts);
|
||||||
|
Console.log(counts.toString());
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,5 +660,303 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
||||||
map.put("AllData", datalist);
|
map.put("AllData", datalist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据DLL解析GammaPHD内容 得到PHDFile实体
|
||||||
|
* @param fileName
|
||||||
|
* @param pathName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public PHDFile getGammaPHD(String fileName, String pathName) {
|
||||||
|
PHDFile phd = new PHDFile();
|
||||||
|
phd.setFilepath(pathName);
|
||||||
|
phd.setFilename(fileName);
|
||||||
|
File file = new File(pathName + StringPool.SLASH + fileName);
|
||||||
|
phd.setTmpFilePath(file.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
//读取文件信息
|
||||||
|
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||||
|
//MsgInfo
|
||||||
|
phd.getMsgInfo().setMsg_id(struct.msg_id);
|
||||||
|
phd.getMsgInfo().setMsg_type(struct.msg_type);
|
||||||
|
phd.getMsgInfo().setData_type(struct.data_type);
|
||||||
|
//Header
|
||||||
|
phd.getHeader().setDesignator(struct.designator);
|
||||||
|
phd.getHeader().setSite_code(struct.site_code);
|
||||||
|
phd.getHeader().setDetector_code(struct.detector_code);
|
||||||
|
phd.getHeader().setSystem_type(struct.system_type);
|
||||||
|
phd.getHeader().setSample_geometry(struct.sample_geometry);
|
||||||
|
phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity);
|
||||||
|
phd.getHeader().setSample_ref_id(struct.sample_ref_id);
|
||||||
|
phd.getHeader().setMeasurement_id(struct.measurement_id);
|
||||||
|
phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id);
|
||||||
|
phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id);
|
||||||
|
phd.getHeader().setTransmit_date(struct.transmit_date);
|
||||||
|
phd.getHeader().setTransmit_time(struct.transmit_time);
|
||||||
|
//Comment
|
||||||
|
phd.setOriTotalCmt(struct.comment);
|
||||||
|
//Collection
|
||||||
|
if (StrUtil.isNotBlank(struct.collection_start_date) && StrUtil.isNotBlank(struct.collection_start_time)
|
||||||
|
&& StrUtil.isNotBlank(struct.collection_stop_date) && StrUtil.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);
|
||||||
|
phd.getCollect().setCollection_stop_time(struct.collection_stop_time);
|
||||||
|
phd.getCollect().setAir_volume(struct.air_volume);
|
||||||
|
if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) {
|
||||||
|
phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0");
|
||||||
|
}
|
||||||
|
if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) {
|
||||||
|
phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
phd.getCollect().setAir_volume(0.0);
|
||||||
|
}
|
||||||
|
//Acquisition
|
||||||
|
if (StrUtil.isNotBlank(struct.acquisition_start_date) && StrUtil.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);
|
||||||
|
phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time);
|
||||||
|
if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) {
|
||||||
|
phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
phd.getAcq().setAcquisition_live_time(0.0);
|
||||||
|
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)
|
||||||
|
&& StrUtil.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);
|
||||||
|
phd.getProcess().setUncertainty_2(struct.uncertainty_2);
|
||||||
|
phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id);
|
||||||
|
} else {
|
||||||
|
phd.getProcess().setSample_volume_of_Xe(0.0);
|
||||||
|
phd.getProcess().setXe_collection_yield(0.0);
|
||||||
|
phd.getProcess().setUncertainty_1(0.0);
|
||||||
|
phd.getProcess().setUncertainty_2(0.0);
|
||||||
|
}
|
||||||
|
//Sample
|
||||||
|
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 {
|
||||||
|
phd.getSampleBlock().setDimension_1(0.0);
|
||||||
|
phd.getSampleBlock().setDimension_2(0.0);
|
||||||
|
}
|
||||||
|
//Calibration
|
||||||
|
if (StrUtil.isNotBlank(struct.date_calibration) && StrUtil.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) && StrUtil.isNotBlank(struct.assay_date)
|
||||||
|
&& StrUtil.isNotBlank(struct.assay_time) && StrUtil.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);
|
||||||
|
phd.getCertificate().setUnits_activity(struct.units_activity);
|
||||||
|
phd.getCertificate().setNuclide_name(struct.nuclide_name);
|
||||||
|
phd.getCertificate().setHalf_life_time(struct.half_life_time);
|
||||||
|
phd.getCertificate().setTime_unit(struct.time_unit);
|
||||||
|
phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay);
|
||||||
|
phd.getCertificate().setUncertainty(struct.uncertainty);
|
||||||
|
phd.getCertificate().setG_energy(struct.cer_g_energy);
|
||||||
|
phd.getCertificate().setG_intensity(struct.g_intensity);
|
||||||
|
phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode);
|
||||||
|
phd.getCertificate().setMaximum_energy(struct.maximum_energy);
|
||||||
|
phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle);
|
||||||
|
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)) {
|
||||||
|
phd.getSpec().setNum_g_channel(struct.g_counts.size()); // todo 原Num_g_channel有误
|
||||||
|
phd.getSpec().setG_energy_span(struct.g_energy_span);
|
||||||
|
phd.getSpec().setBegin_channel(struct.g_begin_channel);
|
||||||
|
phd.getSpec().setCounts(struct.g_counts);
|
||||||
|
int i = 0;
|
||||||
|
for (; i < phd.getSpec().getNum_g_channel(); i++) {
|
||||||
|
if (phd.getSpec().getCounts().get(i) > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == phd.getSpec().getNum_g_channel()) {
|
||||||
|
phd.setValid(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//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)) {
|
||||||
|
GEnergyBlock gEnergyBlock = new GEnergyBlock();
|
||||||
|
gEnergyBlock.setG_energy(struct.g_energy);
|
||||||
|
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
|
||||||
|
gEnergyBlock.setUncertainty(struct.g_uncertainty);
|
||||||
|
gEnergyBlock.setRecord_count(struct.g_record_count);
|
||||||
|
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)) {
|
||||||
|
GResolutionBlock gResolutionBlock = new GResolutionBlock();
|
||||||
|
gResolutionBlock.setG_energy(struct.g_r_energy);
|
||||||
|
gResolutionBlock.setFWHM(struct.g_r_FWHM);
|
||||||
|
gResolutionBlock.setUncertainty(struct.g_r_uncertainty);
|
||||||
|
gResolutionBlock.setRecord_count(struct.g_r_record_count);
|
||||||
|
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)) {
|
||||||
|
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
|
||||||
|
gEfficiencyBlock.setG_energy(struct.g_e_energy);
|
||||||
|
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
|
||||||
|
gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty);
|
||||||
|
gEfficiencyBlock.setRecord_count(struct.g_e_record_count);
|
||||||
|
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)) {
|
||||||
|
TotaleffBlock totaleffBlock = new TotaleffBlock();
|
||||||
|
totaleffBlock.setG_energy(struct.t_g_energy);
|
||||||
|
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
|
||||||
|
totaleffBlock.setUncertainty(struct.t_uncertainty);
|
||||||
|
totaleffBlock.setRecord_count(struct.t_record_count);
|
||||||
|
phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化默认分析设置
|
||||||
|
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
|
||||||
|
phd.getSetting().setECutAnalysis_Low(35.0);
|
||||||
|
phd.getSetting().setBUpdateCal(true);
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(phd.getCollect().getCollection_start_date())
|
||||||
|
&& StrUtil.isNotBlank(phd.getCollect().getCollection_start_time())) {
|
||||||
|
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date()
|
||||||
|
+ StringPool.SPACE + phd.getCollect().getCollection_start_time()));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_time())) {
|
||||||
|
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date()
|
||||||
|
+ StringPool.SPACE + phd.getAcq().getAcquisition_start_time()));
|
||||||
|
}
|
||||||
|
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"));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return phd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ROI卡出来的Gamma数据生成新的GammaPHD文件
|
||||||
|
* @param pathName 文件存储路径
|
||||||
|
* @param fileName GammaPHD名称
|
||||||
|
* @param struct BetaPHD内容
|
||||||
|
* @param g_counts ROI卡出来的Gamma数据
|
||||||
|
*/
|
||||||
|
public void createGammaFile(String pathName,String fileName, EnergySpectrumStruct struct, List<Long> g_counts) {
|
||||||
|
File file = new File(pathName + "\\" + fileName);
|
||||||
|
// 创建PrintWriter对象
|
||||||
|
PrintWriter out = null;
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("0.000000");
|
||||||
|
try {
|
||||||
|
out = new PrintWriter(file);
|
||||||
|
out.println("BEGIN IMS2.0");
|
||||||
|
out.println("MSG_TYPE DATA");
|
||||||
|
// todo msg_type用的不对,dll没解析出这个字段
|
||||||
|
out.println("MSG_ID " + struct.msg_id + " " + struct.msg_type + "\n" + "DATA_TYPE " + struct.data_type);
|
||||||
|
out.println("#Header 3");
|
||||||
|
// 解析出的Gamma谱 系统类型暂时使用G
|
||||||
|
out.println(struct.site_code + " " + struct.detector_code + " G " +
|
||||||
|
struct.sample_geometry + " " + struct.spectrum_quantity);
|
||||||
|
out.println(struct.sample_ref_id);
|
||||||
|
out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0");
|
||||||
|
out.println(struct.transmit_date + " " + struct.transmit_time);
|
||||||
|
out.println("#Collection");
|
||||||
|
out.println(struct.collection_start_date + " " + struct.collection_start_time + " " +
|
||||||
|
struct.collection_stop_date + " " + struct.collection_stop_time + " "
|
||||||
|
+ decimalFormat.format(struct.air_volume));
|
||||||
|
out.println("#Acquisition");
|
||||||
|
out.println(struct.acquisition_start_date + " " + struct.acquisition_start_time + " " +
|
||||||
|
decimalFormat.format(struct.acquisition_real_time) + " " +
|
||||||
|
decimalFormat.format(struct.acquisition_live_time));
|
||||||
|
out.println("#g_Energy");
|
||||||
|
|
||||||
|
|
||||||
|
format(struct.g_energy, struct.g_centroid_channel, struct.g_uncertainty, out);
|
||||||
|
out.println("#g_Resolution");
|
||||||
|
format(struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty, out);
|
||||||
|
out.println("#g_Efficiency");
|
||||||
|
format(struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty, out);
|
||||||
|
out.println("#g_Spectrum");
|
||||||
|
// num_g_channel 根据g_counts数量得来和PHD写的数字没有关系;g_energy_span是PHD写的值
|
||||||
|
out.println(struct.num_g_channel + " " + struct.g_energy_span);
|
||||||
|
// 存储前一个数字
|
||||||
|
String beforeStr = "";
|
||||||
|
for (int i = 0; i < g_counts.size(); i++) {
|
||||||
|
String str = g_counts.get(i).toString();
|
||||||
|
if(i % 5 == 0) {
|
||||||
|
if (i == 0) {
|
||||||
|
out.printf(i+"");
|
||||||
|
} else {
|
||||||
|
out.printf("\n" + i );
|
||||||
|
}
|
||||||
|
beforeStr = i+"";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StrUtil.isEmpty(beforeStr)){
|
||||||
|
beforeStr = str;
|
||||||
|
}
|
||||||
|
// 根据前一个字符长度计算需要的空格
|
||||||
|
out.printf("%" + (str.length() + (6 - beforeStr.length()))+ "s" , g_counts.get(i));
|
||||||
|
if(i == g_counts.size() - 1) {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
beforeStr = str;
|
||||||
|
}
|
||||||
|
out.print("STOP");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
if (null != out) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据格式化
|
||||||
|
* @param aList 第一列数据
|
||||||
|
* @param bList 第二列数据
|
||||||
|
* @param cList 第三列数据
|
||||||
|
* @param out
|
||||||
|
*/
|
||||||
|
private static void format(List<Double> aList, List<Double> bList,List<Double> cList,PrintWriter out) {
|
||||||
|
for (int i = 0; i < aList.size(); i++) {
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("0.000000");
|
||||||
|
String a = decimalFormat.format(aList.get(i));
|
||||||
|
String b = decimalFormat.format(bList.get(i));
|
||||||
|
String c = decimalFormat.format(cList.get(i));
|
||||||
|
out.print(a);
|
||||||
|
out.printf("%" + ( b.length() + (17 - a.length())) + "s", b);
|
||||||
|
out.printf("%" + ( c.length() + (17 - b.length())) + "s", c+"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,5 +157,22 @@ public class SelfStationController {
|
||||||
return selfStationService.setCurrentEfficiency(fileName, currentName, request);
|
return selfStationService.setCurrentEfficiency(fileName, currentName, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("viewGammaDetectorCalibration")
|
||||||
|
@ApiOperation(value = "查询GammaDetectorCalibration数据", notes = "查询GammaDetectorCalibration数据")
|
||||||
|
public Result viewGammaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
|
||||||
|
return selfStationService.viewGammaDetectorCalibration(sampleId, sampleFileName, qcFileName, fittingBtn, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("viewBetaDetectorCalibration")
|
||||||
|
@ApiOperation(value = "查询BetaDetectorCalibration数据", notes = "查询BetaDetectorCalibration数据")
|
||||||
|
public Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
|
||||||
|
return selfStationService.viewBetaDetectorCalibration(sampleId, sampleFileName, qcFileName, fittingBtn, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("Reprocessing")
|
||||||
|
@ApiOperation(value = "analyze菜单下Reprocessing页面数据", notes = "analyze菜单下Reprocessing页面数据")
|
||||||
|
public Result Reprocessing(String fileName, String processKey, HttpServletRequest request) {
|
||||||
|
return selfStationService.Reprocessing(fileName, processKey, request);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,11 @@ public class SelfStationData implements Serializable {
|
||||||
*/
|
*/
|
||||||
private EnergySpectrumStruct detStruct;
|
private EnergySpectrumStruct detStruct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qc文件分析内容
|
||||||
|
*/
|
||||||
|
private EnergySpectrumStruct qcStruct;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sample对应的操作数据
|
* sample对应的操作数据
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +46,69 @@ public class SelfStationData implements Serializable {
|
||||||
*/
|
*/
|
||||||
private SelfStationVueData detVueData;
|
private SelfStationVueData detVueData;
|
||||||
|
|
||||||
|
private List<List<Double>> gammaNewEnergyListNow;
|
||||||
|
|
||||||
|
private List<List<Double>> betaNewEnergyListNow;
|
||||||
|
|
||||||
|
|
||||||
|
//分析用到的信息
|
||||||
|
private BgCalibratePara bgPara;
|
||||||
|
|
||||||
|
private List<SeriseData> betaList;
|
||||||
|
|
||||||
|
private List<String> betaFittingPara;
|
||||||
|
|
||||||
|
private List<String> betaFittingParaToUi;
|
||||||
|
|
||||||
|
private List<SeriseData> gammaList;
|
||||||
|
|
||||||
|
private List<String> gammaFittingPara;
|
||||||
|
|
||||||
|
private List<String> gammaFittingParaToUi;
|
||||||
|
|
||||||
|
private List<SeriseData> betaListNow;
|
||||||
|
|
||||||
|
private List<String> betaFittingParaNow;
|
||||||
|
|
||||||
|
private List<String> betaFittingParaToUiNow;
|
||||||
|
|
||||||
|
private List<SeriseData> gammaListNow;
|
||||||
|
|
||||||
|
private List<String> gammaFittingParaNow;
|
||||||
|
|
||||||
|
private List<String> gammaFittingParaToUiNow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮
|
||||||
|
*/
|
||||||
|
private boolean bGammaEnergyValidSample;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮
|
||||||
|
*/
|
||||||
|
private boolean bBetaEnergyValidSample;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮
|
||||||
|
*/
|
||||||
|
private boolean bGammaEnergyValidGas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮
|
||||||
|
*/
|
||||||
|
private boolean bBetaEnergyValidGas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否点击过Energy Calibration页面下Gamma Detector Calibration的fitting按钮
|
||||||
|
*/
|
||||||
|
private boolean bGammaEnergyValidDet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否点击过Energy Calibration页面下Beta Detector Calibration的fitting按钮
|
||||||
|
*/
|
||||||
|
private boolean bBetaEnergyValidDet;
|
||||||
|
|
||||||
|
|
||||||
public SelfStationData() {
|
public SelfStationData() {
|
||||||
sampleVueData = new SelfStationVueData();
|
sampleVueData = new SelfStationVueData();
|
||||||
detVueData = new SelfStationVueData();
|
detVueData = new SelfStationVueData();
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class SelfStationVueData implements Serializable {
|
||||||
*/
|
*/
|
||||||
//折线图横纵坐标数组
|
//折线图横纵坐标数组
|
||||||
private List<SeriseData> ROIOneList;
|
private List<SeriseData> ROIOneList;
|
||||||
|
private List<Long> ROIOneCounts;
|
||||||
//ROI-1范围矩形框起始道值
|
//ROI-1范围矩形框起始道值
|
||||||
private Integer ROIOneBetaStart;
|
private Integer ROIOneBetaStart;
|
||||||
//ROI-1范围矩形框终止道值
|
//ROI-1范围矩形框终止道值
|
||||||
|
@ -25,6 +26,7 @@ public class SelfStationVueData implements Serializable {
|
||||||
*/
|
*/
|
||||||
//折线图横纵坐标数组
|
//折线图横纵坐标数组
|
||||||
private List<SeriseData> ROITwoList;
|
private List<SeriseData> ROITwoList;
|
||||||
|
private List<Long> ROITwoCounts;
|
||||||
//ROI-2范围矩形框起始道值
|
//ROI-2范围矩形框起始道值
|
||||||
private Integer ROITwoBetaStart;
|
private Integer ROITwoBetaStart;
|
||||||
//ROI-2范围矩形框终止道值
|
//ROI-2范围矩形框终止道值
|
||||||
|
@ -35,6 +37,7 @@ public class SelfStationVueData implements Serializable {
|
||||||
*/
|
*/
|
||||||
//折线图横纵坐标数组
|
//折线图横纵坐标数组
|
||||||
private List<SeriseData> ROIThreeList;
|
private List<SeriseData> ROIThreeList;
|
||||||
|
private List<Long> ROIThreeCounts;
|
||||||
//ROI-3范围矩形框起始道值
|
//ROI-3范围矩形框起始道值
|
||||||
private Integer ROIThreeBetaStart;
|
private Integer ROIThreeBetaStart;
|
||||||
//ROI-3范围矩形框终止道值
|
//ROI-3范围矩形框终止道值
|
||||||
|
@ -45,6 +48,7 @@ public class SelfStationVueData implements Serializable {
|
||||||
*/
|
*/
|
||||||
//折线图横纵坐标数组
|
//折线图横纵坐标数组
|
||||||
private List<SeriseData> ROIFourList;
|
private List<SeriseData> ROIFourList;
|
||||||
|
private List<Long> ROIFourCounts;
|
||||||
//ROI-4范围矩形框起始道值
|
//ROI-4范围矩形框起始道值
|
||||||
private Integer ROIFourBetaStart;
|
private Integer ROIFourBetaStart;
|
||||||
//ROI-4范围矩形框终止道值
|
//ROI-4范围矩形框终止道值
|
||||||
|
|
|
@ -56,4 +56,9 @@ public interface ISelfStationService {
|
||||||
|
|
||||||
Result setCurrentEfficiency(String fileName, String currentName, HttpServletRequest request);
|
Result setCurrentEfficiency(String fileName, String currentName, HttpServletRequest request);
|
||||||
|
|
||||||
|
Result viewGammaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request);
|
||||||
|
|
||||||
|
Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request);
|
||||||
|
|
||||||
|
Result Reprocessing(String fileName, String processKey, HttpServletRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.cache.LocalCache;
|
||||||
import org.jeecg.common.cache.SelfCache;
|
import org.jeecg.common.cache.SelfCache;
|
||||||
|
import org.jeecg.common.properties.ParameterProperties;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
import org.jeecg.common.system.util.JwtUtil;
|
||||||
import org.jeecg.common.util.FTPUtil;
|
import org.jeecg.common.util.*;
|
||||||
import org.jeecg.common.util.PHDFileUtil;
|
|
||||||
import org.jeecg.common.util.SelfStationUtil;
|
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
|
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
|
||||||
|
@ -20,6 +20,7 @@ import org.jeecg.modules.native_jni.CalValuesHandler;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
import org.jeecg.modules.service.ISelfStationService;
|
import org.jeecg.modules.service.ISelfStationService;
|
||||||
|
import org.jeecg.modules.service.ISysUserColorService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -34,9 +35,17 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class SelfStationServiceImpl implements ISelfStationService {
|
public class SelfStationServiceImpl implements ISelfStationService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GammaFileUtil gammaFileUtil;
|
||||||
|
@Autowired
|
||||||
|
private ParameterProperties parameterProperties;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FTPUtil ftpUtil;
|
private FTPUtil ftpUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
@Autowired
|
||||||
|
private ISysUserColorService sysUserColorService;
|
||||||
|
@Autowired
|
||||||
private SpectrumPathProperties spectrumPathProperties;
|
private SpectrumPathProperties spectrumPathProperties;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SelfStationUtil selfStationUtil;
|
private SelfStationUtil selfStationUtil;
|
||||||
|
@ -233,13 +242,13 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
||||||
if (StringUtils.isNotBlank(selfStationData.getSampleTmpPath())) {
|
if (StringUtils.isNotBlank(selfStationData.getSampleTmpPath())) {
|
||||||
File file = new File(selfStationData.getSampleTmpPath());
|
File file = new File(selfStationData.getSampleTmpPath());
|
||||||
if (Objects.nonNull(file)) {
|
if (Objects.nonNull(file)) {
|
||||||
file.delete();
|
// file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(selfStationData.getDetTmpPath())) {
|
if (StringUtils.isNotBlank(selfStationData.getDetTmpPath())) {
|
||||||
File file = new File(selfStationData.getDetTmpPath());
|
File file = new File(selfStationData.getDetTmpPath());
|
||||||
if (Objects.nonNull(file)) {
|
if (Objects.nonNull(file)) {
|
||||||
file.delete();
|
// file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 删除指定key的Cache
|
// 删除指定key的Cache
|
||||||
|
@ -1160,4 +1169,551 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result viewGammaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
|
||||||
|
Result result = new Result();
|
||||||
|
//接收返回结果内容
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
//根据请求头获取用户名称
|
||||||
|
String userName = JwtUtil.getUserNameByToken(request);
|
||||||
|
//获取beta的缓存数据
|
||||||
|
Cache<String, SelfStationData> cache = selfStationCache.getSelfCache();
|
||||||
|
SelfStationData betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
if (Objects.isNull(betaDataFile)) {
|
||||||
|
result.error500("Load basic file information first!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//如果gamma的计算标识是false 则将gamma当前缓存数据进行重置
|
||||||
|
if (!fittingBtn) {
|
||||||
|
betaDataFile.setGammaListNow(Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setGammaFittingParaNow(Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setGammaFittingParaToUiNow(Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setGammaNewEnergyListNow(Collections.EMPTY_LIST);
|
||||||
|
}
|
||||||
|
//获取qc的分析结果数据
|
||||||
|
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
|
||||||
|
//判断qc文件的解析结果是否为空
|
||||||
|
if (Objects.nonNull(struct)){
|
||||||
|
//读取Gamma Detector Calibration所需要的参数
|
||||||
|
long numGChannel = struct.num_g_channel;
|
||||||
|
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||||
|
List<Double> gEnergy = struct.g_energy;
|
||||||
|
int gRecordCount = struct.g_record_count;
|
||||||
|
List<Long> gCounts = struct.g_counts;
|
||||||
|
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
|
||||||
|
//根据道值和能量的对应关系 存储表单数据
|
||||||
|
List<SeriseData> oldScatterSeries = new LinkedList<>();
|
||||||
|
for (int i=0; i<gRecordCount; i++) {
|
||||||
|
SeriseData temp = new SeriseData();
|
||||||
|
double p1 = gCentroidChannel.get(i);
|
||||||
|
double p2 = gEnergy.get(i);
|
||||||
|
temp.setX(p1);
|
||||||
|
temp.setY(p2);
|
||||||
|
oldScatterSeries.add(temp);
|
||||||
|
}
|
||||||
|
map.put("oldScatterSeries", oldScatterSeries);
|
||||||
|
//计算C to E公式参数
|
||||||
|
List<Double> fittingPara = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
|
||||||
|
List<String> fittingParaStr = new LinkedList<>();
|
||||||
|
for (Double para:fittingPara) {
|
||||||
|
fittingParaStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("CToE", fittingParaStr);
|
||||||
|
List<Double> channel = new LinkedList<>();
|
||||||
|
for (int i=0; i<255; ++i) {
|
||||||
|
channel.add(Double.valueOf(i));
|
||||||
|
}
|
||||||
|
//计算出新的道值对应能量值
|
||||||
|
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
|
||||||
|
//根据道值和能量对应关系 封装折线图数据
|
||||||
|
List<SeriseData> oldLineSeries = new LinkedList<>();
|
||||||
|
for (int i=0; i<channel.size(); i++) {
|
||||||
|
SeriseData tmp = new SeriseData();
|
||||||
|
tmp.setX(channel.get(i));
|
||||||
|
tmp.setY(energy.get(i));
|
||||||
|
oldLineSeries.add(tmp);
|
||||||
|
}
|
||||||
|
map.put("oldLineSeries", oldLineSeries);
|
||||||
|
//计算E to C公式参数
|
||||||
|
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
|
||||||
|
List<String> fittingParaToUiStr = new LinkedList<>();
|
||||||
|
for (Double para:fittingParaToUi) {
|
||||||
|
fittingParaToUiStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("EToC", fittingParaToUiStr);
|
||||||
|
//计算道值对应能量值参数
|
||||||
|
List<Double> gchannels = new ArrayList<>();
|
||||||
|
List<List<Double>> gammaEnergyList = new LinkedList<>();
|
||||||
|
for (int i=0; i<numGChannel; i++){
|
||||||
|
gchannels.clear();
|
||||||
|
gchannels.add(Double.valueOf(i));
|
||||||
|
List<Double> gammaEnergy = EnergySpectrumHandler.GetFileFittingData(gchannels, gammaParam);
|
||||||
|
gammaEnergyList.add(gammaEnergy);
|
||||||
|
}
|
||||||
|
map.put("gammaEnergy", gammaEnergyList);
|
||||||
|
//Gamma Spectrum: QC
|
||||||
|
List<SeriseData> seriseDataList = new LinkedList<>();
|
||||||
|
long min =0;
|
||||||
|
double max =0;
|
||||||
|
for ( int i=1; i<numGChannel; i++ ) {
|
||||||
|
long count = gCounts.get(i);
|
||||||
|
SeriseData temp = new SeriseData();
|
||||||
|
temp.setX(i);
|
||||||
|
temp.setY(count);
|
||||||
|
seriseDataList.add(temp);
|
||||||
|
if (count<min){
|
||||||
|
min = count;
|
||||||
|
}
|
||||||
|
if (count>max){
|
||||||
|
max = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (max<10) {
|
||||||
|
max += max*0.5;
|
||||||
|
} else if (max<50) {
|
||||||
|
max += max*0.2;
|
||||||
|
} else if (max<100) {
|
||||||
|
max += max*0.1;
|
||||||
|
} else {
|
||||||
|
max += max*0.05;
|
||||||
|
}
|
||||||
|
map.put("min", min);
|
||||||
|
map.put("max", max);
|
||||||
|
map.put("gammaSpectrum", seriseDataList);
|
||||||
|
|
||||||
|
//判断人工交互的道值与能量对应参数数组是否为空
|
||||||
|
if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getGammaList())) {
|
||||||
|
//存储计算参数道值
|
||||||
|
List<Double> xs = new LinkedList();
|
||||||
|
//存储计算参数能量值
|
||||||
|
List<Double> ys = new LinkedList<>();
|
||||||
|
//存储所有道值
|
||||||
|
List<Double> channels = new LinkedList<>();
|
||||||
|
//存储所有的能量值
|
||||||
|
List<List<Double>> energyList = new LinkedList<>();
|
||||||
|
//存储新的线点能量值
|
||||||
|
List<SeriseData> newLineSeries = new LinkedList<>();
|
||||||
|
//存储新的表单能量值
|
||||||
|
List<TableWidget> tableWidgets = new LinkedList();
|
||||||
|
//存储新的公式参数C TO E
|
||||||
|
List<String> newFittingParaStr = new LinkedList<>();
|
||||||
|
//存储新的公式参数E TO C
|
||||||
|
List<String> newFittingParaToUiStr = new LinkedList<>();
|
||||||
|
//记录点值数组
|
||||||
|
List<SeriseData> newSeriseDataList = new LinkedList<>();
|
||||||
|
//遍历临时点数组 将点位的横坐标以及纵坐标封装到对应的数组
|
||||||
|
for (int i=0; i<betaDataFile.getGammaList().size(); i++){
|
||||||
|
xs.add(betaDataFile.getGammaList().get(i).getX());
|
||||||
|
ys.add(betaDataFile.getGammaList().get(i).getY());
|
||||||
|
}
|
||||||
|
//计算C to E公式参数
|
||||||
|
List<Double> newFittingPara = EnergySpectrumHandler.GetFileFittingPara(xs, ys);
|
||||||
|
for (Double para:newFittingPara) {
|
||||||
|
newFittingParaStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("newCToE", newFittingParaStr);
|
||||||
|
//填充道值数组的数据
|
||||||
|
for (int i=0; i<255; i++) {
|
||||||
|
channels.add(Double.valueOf(i));
|
||||||
|
}
|
||||||
|
//计算道值的能量
|
||||||
|
List<Double> energys = EnergySpectrumHandler.GetFileFittingData(channels,newFittingPara);
|
||||||
|
//根据临时点的道值修改对应能量值
|
||||||
|
//遍历所有道值
|
||||||
|
for (int i=0; i< channels.size(); i++) {
|
||||||
|
//获取道值
|
||||||
|
double newChannel = channels.get(i).doubleValue();
|
||||||
|
//遍历临时点数据
|
||||||
|
for (int j=0; j<betaDataFile.getGammaList().size(); j++) {
|
||||||
|
SeriseData seriseData = betaDataFile.getGammaList().get(j);
|
||||||
|
double tempChannel = seriseData.getX();
|
||||||
|
//如果道值等于临时点的道值
|
||||||
|
if (newChannel == tempChannel) {
|
||||||
|
energys.set(i, seriseData.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将新计算的能量封装到数组
|
||||||
|
for (Double calEnergy:energys) {
|
||||||
|
List<Double> newEnergy = new LinkedList<>();
|
||||||
|
newEnergy.add(calEnergy);
|
||||||
|
energyList.add(newEnergy);
|
||||||
|
}
|
||||||
|
//遍历道值添加各道值对应点数据到数组
|
||||||
|
for (int i=0; i<channels.size(); ++i) {
|
||||||
|
SeriseData seriseData = new SeriseData();
|
||||||
|
seriseData.setX(channels.get(i));
|
||||||
|
seriseData.setY(energys.get(i));
|
||||||
|
newLineSeries.add(seriseData);
|
||||||
|
}
|
||||||
|
map.put("newLineSeries", newLineSeries);
|
||||||
|
//遍历点 缓存到表单数组以及折线图点位数组
|
||||||
|
for (int i=0; i<betaDataFile.getGammaList().size(); i++) {
|
||||||
|
//表单数据信息
|
||||||
|
TableWidget tableWidget = new TableWidget();
|
||||||
|
tableWidget.setRowCount(i+1);
|
||||||
|
tableWidget.setChannel(betaDataFile.getGammaList().get(i).getX());
|
||||||
|
tableWidget.setEnergy(betaDataFile.getGammaList().get(i).getY());
|
||||||
|
tableWidgets.add(tableWidget);
|
||||||
|
//折线图位置信息
|
||||||
|
SeriseData seriseData = new SeriseData();
|
||||||
|
seriseData.setX(betaDataFile.getGammaList().get(i).getX());
|
||||||
|
seriseData.setY(betaDataFile.getGammaList().get(i).getY());
|
||||||
|
newSeriseDataList.add(seriseData);
|
||||||
|
}
|
||||||
|
map.put("tableWidgets", tableWidgets);
|
||||||
|
map.put("newScatterSeriesData", newSeriseDataList);
|
||||||
|
//计算E to C公式参数
|
||||||
|
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(ys, xs);
|
||||||
|
for (Double para:newFittingParaToUi) {
|
||||||
|
newFittingParaToUiStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("newEToC", newFittingParaToUiStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算得到的
|
||||||
|
if (betaDataFile.getGammaList().size() <= 0 ) {
|
||||||
|
betaDataFile.setGammaList(oldScatterSeries);
|
||||||
|
}
|
||||||
|
if (betaDataFile.getGammaFittingPara().size() <= 0 ) {
|
||||||
|
betaDataFile.setGammaFittingPara(fittingParaStr);
|
||||||
|
}
|
||||||
|
if (betaDataFile.getGammaFittingParaToUi().size() <= 0 ) {
|
||||||
|
betaDataFile.setGammaFittingParaToUi(fittingParaToUiStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(map);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result viewBetaDetectorCalibration(Integer sampleId, String sampleFileName, String qcFileName, boolean fittingBtn, HttpServletRequest request) {
|
||||||
|
Result result = new Result();
|
||||||
|
//返回结果内容
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
//获取用户名
|
||||||
|
String userName = JwtUtil.getUserNameByToken(request);
|
||||||
|
//获取本地缓存
|
||||||
|
Cache<String, SelfStationData> cache = selfStationCache.getSelfCache();
|
||||||
|
SelfStationData betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
if (Objects.isNull(betaDataFile)) {
|
||||||
|
result.error500("Load basic file information first!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//判断是否进行过计算标识为false时 清空当前beta对应的缓存数据
|
||||||
|
if (!fittingBtn) {
|
||||||
|
betaDataFile.setBetaListNow(Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setBetaFittingParaNow(Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setBetaFittingParaToUiNow(Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setBetaNewEnergyListNow(Collections.EMPTY_LIST);
|
||||||
|
}
|
||||||
|
//判断qc的分析结果是否为空
|
||||||
|
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
|
||||||
|
if (Objects.nonNull(struct)){
|
||||||
|
//Figure of Beta Detector Calibration
|
||||||
|
long numBChannel = struct.num_b_channel;
|
||||||
|
List<Double> bChannel = struct.b_channel;
|
||||||
|
List<Double> bElectronEnergy = struct.b_electron_energy;
|
||||||
|
long numGChannel = struct.num_g_channel;
|
||||||
|
List<Double> gCentroidChannel = struct.g_centroid_channel;
|
||||||
|
List<Double> gEnergy = struct.g_energy;
|
||||||
|
long bChannels = struct.b_channels;
|
||||||
|
long gChannels = struct.g_channels;
|
||||||
|
List<Long> hCounts = struct.h_counts;
|
||||||
|
int bRecordCount = struct.b_record_count;
|
||||||
|
//散点图坐标点关联beta部分相关数据
|
||||||
|
List<List<Double>> betaEnergyList = new LinkedList<>();
|
||||||
|
List<Double> betaParam = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
|
||||||
|
List<Double> bchannels = new ArrayList<>();
|
||||||
|
for (int i=0; i<numBChannel; i++){
|
||||||
|
bchannels.clear();
|
||||||
|
bchannels.add(Double.valueOf(i));
|
||||||
|
List<Double> betaEnergy = EnergySpectrumHandler.GetFileFittingData(bchannels, betaParam);
|
||||||
|
betaEnergyList.add(betaEnergy);
|
||||||
|
}
|
||||||
|
map.put("betaEnergy", betaEnergyList);
|
||||||
|
//gamma Energy 散点图坐标点关联gamma部分相关数据
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyListNow())) {
|
||||||
|
map.put("gammaEnergy", betaDataFile.getGammaNewEnergyListNow());
|
||||||
|
} else {
|
||||||
|
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
|
||||||
|
List<Double> gchannels = new ArrayList<>();
|
||||||
|
List<List<Double>> gammaEnergyList = new LinkedList<>();
|
||||||
|
for (int i=0; i<numGChannel; i++){
|
||||||
|
gchannels.clear();
|
||||||
|
gchannels.add(Double.valueOf(i));
|
||||||
|
List<Double> gammaEnergy = EnergySpectrumHandler.GetFileFittingData(gchannels, gammaParam);
|
||||||
|
gammaEnergyList.add(gammaEnergy);
|
||||||
|
}
|
||||||
|
map.put("gammaEnergy", gammaEnergyList);
|
||||||
|
}
|
||||||
|
//Beta-Gamma Spectrum: QC 散点图相关数据
|
||||||
|
List<HistogramData> histogramDataList = new LinkedList<>();
|
||||||
|
for (int column=0; column<bChannels; column++) {
|
||||||
|
for (int row=0; row<gChannels; row++) {
|
||||||
|
Long index = column * gChannels + row;
|
||||||
|
long count = hCounts.get(index.intValue());
|
||||||
|
if (count>0) {
|
||||||
|
HistogramData histogramData = new HistogramData();
|
||||||
|
histogramData.setB(row);
|
||||||
|
histogramData.setG(column);
|
||||||
|
histogramDataList.add(histogramData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("histogramData", histogramDataList);
|
||||||
|
//计算Calibration Parameter Of Gamma Detector 拟合线图数据
|
||||||
|
List<SeriseData> oldScatterSeries = new LinkedList<>();
|
||||||
|
for (int i=0; i<bRecordCount; i++) {
|
||||||
|
SeriseData temp = new SeriseData();
|
||||||
|
double p1 = bChannel.get(i);
|
||||||
|
double p2 = bElectronEnergy.get(i);
|
||||||
|
temp.setX(p1);
|
||||||
|
temp.setY(p2);
|
||||||
|
oldScatterSeries.add(temp);
|
||||||
|
}
|
||||||
|
map.put("oldScatterSeries", oldScatterSeries);
|
||||||
|
//计算得到C to E公式数据
|
||||||
|
List<Double> fittingPara = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
|
||||||
|
List<String> fittingParaStr = new LinkedList<>();
|
||||||
|
for (Double para:fittingPara) {
|
||||||
|
fittingParaStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("CToE", fittingParaStr);
|
||||||
|
List<Double> channel = new LinkedList<>();
|
||||||
|
for (int i=0; i<255; ++i) {
|
||||||
|
channel.add(Double.valueOf(i));
|
||||||
|
}
|
||||||
|
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
|
||||||
|
List<SeriseData> oldLineSeries = new LinkedList<>();
|
||||||
|
for (int i=0; i<channel.size(); i++) {
|
||||||
|
SeriseData tmp = new SeriseData();
|
||||||
|
tmp.setX(channel.get(i));
|
||||||
|
tmp.setY(energy.get(i));
|
||||||
|
oldLineSeries.add(tmp);
|
||||||
|
}
|
||||||
|
map.put("oldLineSeries", oldLineSeries);
|
||||||
|
//E to C
|
||||||
|
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(energy, channel);
|
||||||
|
List<String> fittingParaToUiStr = new LinkedList<>();
|
||||||
|
for (Double para:fittingParaToUi) {
|
||||||
|
fittingParaToUiStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("EToC", fittingParaToUiStr);
|
||||||
|
|
||||||
|
//判断人工交互的道值与能量对应参数数组是否为空
|
||||||
|
if (Objects.nonNull(betaDataFile.getBgPara()) && CollectionUtils.isNotEmpty(betaDataFile.getBetaList())) {
|
||||||
|
//存储计算参数道值
|
||||||
|
List<Double> xs = new LinkedList();
|
||||||
|
//存储计算参数能量值
|
||||||
|
List<Double> ys = new LinkedList<>();
|
||||||
|
//存储所有道值
|
||||||
|
List<Double> channels = new LinkedList<>();
|
||||||
|
//存储所有的能量值
|
||||||
|
List<List<Double>> energyList = new LinkedList<>();
|
||||||
|
//存储新的线点能量值
|
||||||
|
List<SeriseData> newLineSeries = new LinkedList<>();
|
||||||
|
//存储新的表单能量值
|
||||||
|
List<TableWidget> tableWidgets = new LinkedList();
|
||||||
|
//存储新的公式参数C TO E
|
||||||
|
List<String> newFittingParaStr = new LinkedList<>();
|
||||||
|
//存储新的公式参数E TO C
|
||||||
|
List<String> newFittingParaToUiStr = new LinkedList<>();
|
||||||
|
//记录点值数组
|
||||||
|
List<SeriseData> newSeriseDataList = new LinkedList<>();
|
||||||
|
//遍历临时点数组 将点位的横坐标以及纵坐标封装到对应的数组
|
||||||
|
for (int i=0; i<betaDataFile.getBetaList().size(); i++){
|
||||||
|
xs.add(betaDataFile.getBetaList().get(i).getX());
|
||||||
|
ys.add(betaDataFile.getBetaList().get(i).getY());
|
||||||
|
}
|
||||||
|
//计算C to E公式参数
|
||||||
|
List<Double> newFittingPara = EnergySpectrumHandler.GetFileFittingPara(xs, ys);
|
||||||
|
for (Double para:newFittingPara) {
|
||||||
|
newFittingParaStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("newCToE", newFittingParaStr);
|
||||||
|
//填充道值数组的数据
|
||||||
|
for (int i=0; i<255; i++) {
|
||||||
|
channels.add(Double.valueOf(i));
|
||||||
|
}
|
||||||
|
//计算道值的能量
|
||||||
|
List<Double> energys = EnergySpectrumHandler.GetFileFittingData(channels,newFittingPara);
|
||||||
|
//根据临时点的道值修改对应能量值
|
||||||
|
//遍历所有道值
|
||||||
|
for (int i=0; i< channels.size(); i++) {
|
||||||
|
//获取道值
|
||||||
|
double newChannel = channels.get(i).doubleValue();
|
||||||
|
//遍历临时点数据
|
||||||
|
for (int j=0; j<betaDataFile.getGammaList().size(); j++) {
|
||||||
|
SeriseData seriseData = betaDataFile.getGammaList().get(j);
|
||||||
|
double tempChannel = seriseData.getX();
|
||||||
|
//如果道值等于临时点的道值
|
||||||
|
if (newChannel == tempChannel) {
|
||||||
|
energys.set(i, seriseData.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将新计算的能量封装到数组
|
||||||
|
for (Double calEnergy:energys) {
|
||||||
|
List<Double> newEnergy = new LinkedList<>();
|
||||||
|
newEnergy.add(calEnergy);
|
||||||
|
energyList.add(newEnergy);
|
||||||
|
}
|
||||||
|
//遍历道值添加各道值对应点数据到数组
|
||||||
|
for (int i=0; i<channels.size(); ++i) {
|
||||||
|
SeriseData seriseData = new SeriseData();
|
||||||
|
seriseData.setX(channels.get(i));
|
||||||
|
seriseData.setY(energys.get(i));
|
||||||
|
newLineSeries.add(seriseData);
|
||||||
|
}
|
||||||
|
map.put("newLineSeries", newLineSeries);
|
||||||
|
//遍历点 缓存到表单数组以及折线图点位数组
|
||||||
|
for (int i=0; i<betaDataFile.getGammaList().size(); i++) {
|
||||||
|
//表单数据信息
|
||||||
|
TableWidget tableWidget = new TableWidget();
|
||||||
|
tableWidget.setRowCount(i+1);
|
||||||
|
tableWidget.setChannel(betaDataFile.getGammaList().get(i).getX());
|
||||||
|
tableWidget.setEnergy(betaDataFile.getGammaList().get(i).getY());
|
||||||
|
tableWidgets.add(tableWidget);
|
||||||
|
//折线图位置信息
|
||||||
|
SeriseData seriseData = new SeriseData();
|
||||||
|
seriseData.setX(betaDataFile.getGammaList().get(i).getX());
|
||||||
|
seriseData.setY(betaDataFile.getGammaList().get(i).getY());
|
||||||
|
newSeriseDataList.add(seriseData);
|
||||||
|
}
|
||||||
|
map.put("tableWidgets", tableWidgets);
|
||||||
|
map.put("newScatterSeriesData", newSeriseDataList);
|
||||||
|
//计算E to C公式参数
|
||||||
|
List<Double> newFittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(ys, xs);
|
||||||
|
for (Double para:newFittingParaToUi) {
|
||||||
|
newFittingParaToUiStr.add(String.valueOf(para));
|
||||||
|
}
|
||||||
|
map.put("newEToC", newFittingParaToUiStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (betaDataFile.getBetaList().size()<=0) {
|
||||||
|
betaDataFile.setBetaList(oldScatterSeries);
|
||||||
|
}
|
||||||
|
if (betaDataFile.getBetaFittingPara().size()<=0) {
|
||||||
|
betaDataFile.setBetaFittingPara(fittingParaStr);
|
||||||
|
}
|
||||||
|
if (betaDataFile.getBetaFittingParaToUi().size()<=0) {
|
||||||
|
betaDataFile.setBetaFittingParaToUi(fittingParaToUiStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(map);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result Reprocessing(String fileName, String processKey, HttpServletRequest request) {
|
||||||
|
Result result = new Result();
|
||||||
|
String userName = JwtUtil.getUserNameByToken(request);
|
||||||
|
|
||||||
|
//获取自建台站缓存信息
|
||||||
|
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||||
|
SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||||
|
|
||||||
|
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||||
|
// 根据ROI生成四个Gamma谱文件
|
||||||
|
// 文件命名为Beta名称后面_ROI_x.PHD
|
||||||
|
|
||||||
|
// 生成Gamma文件名
|
||||||
|
String gammaOneName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_1.PHD";
|
||||||
|
// 创建Gamma文件
|
||||||
|
selfStationUtil.createGammaFile(pathName, gammaOneName, selfStationData.getSampleStruct(),
|
||||||
|
selfStationData.getSampleVueData().getROIOneCounts());
|
||||||
|
|
||||||
|
String gammaTwoName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_2.PHD";
|
||||||
|
selfStationUtil.createGammaFile(pathName, gammaTwoName, selfStationData.getSampleStruct(),
|
||||||
|
selfStationData.getSampleVueData().getROITwoCounts());
|
||||||
|
|
||||||
|
String gammaThreeName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_3.PHD";
|
||||||
|
selfStationUtil.createGammaFile(pathName, gammaThreeName, selfStationData.getSampleStruct(),
|
||||||
|
selfStationData.getSampleVueData().getROIThreeCounts());
|
||||||
|
|
||||||
|
String gammaFourName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_4.PHD";
|
||||||
|
selfStationUtil.createGammaFile(pathName, gammaFourName, selfStationData.getSampleStruct(),
|
||||||
|
selfStationData.getSampleVueData().getROIFourCounts());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Gamma文件内容转换为PHD实体
|
||||||
|
PHDFile phd = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
|
||||||
|
|
||||||
|
// Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||||
|
// PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||||
|
if (Objects.isNull(phd)) {
|
||||||
|
result.error500("Please select the parse file first!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
phd.setUserId(processKey);
|
||||||
|
// 赋值xml文件存放路径
|
||||||
|
phd.setXmlFilePath(parameterProperties.getFilePath());
|
||||||
|
// 获取当前角色的颜色配置
|
||||||
|
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||||
|
// 分析文件数据
|
||||||
|
int flag = gammaFileUtil.AnalyseData(phd);
|
||||||
|
if (flag == 0) {
|
||||||
|
String warning = "The spectrum needn't Analyed. Maybe:\n" +
|
||||||
|
"1. It has already Analyed.\n" +
|
||||||
|
"2. You didn't change any setting or calibration.";
|
||||||
|
result.error500(warning);
|
||||||
|
} else if (flag == -1) {
|
||||||
|
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||||
|
//分析时将phd的核素map重置
|
||||||
|
phd.setPhdNuclideMap(nuclideLinesMap);
|
||||||
|
//重新计算核素的活度浓度
|
||||||
|
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
|
||||||
|
// todo 不要qcflags
|
||||||
|
// gammaFileUtil.RunQC(phd);
|
||||||
|
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
|
||||||
|
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
|
||||||
|
phd.setEfficiencyCurRow(0);
|
||||||
|
// 重新计算峰值
|
||||||
|
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
|
||||||
|
gammaFileUtil.getNuclideMDCValue(phd, phd.getMdcInfoMap(), nuclideLinesMDCMap);
|
||||||
|
String warning = "Finish three tasks:\n" +
|
||||||
|
"\t1.Update efficiencies of all peaks;\n" +
|
||||||
|
"\t2.Identify nuclides again;\n" +
|
||||||
|
"\t3.Test QC again.";
|
||||||
|
result.error500(warning);
|
||||||
|
} else {
|
||||||
|
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||||
|
//分析时将phd的核素map重置
|
||||||
|
phd.setPhdNuclideMap(nuclideLinesMap);
|
||||||
|
//调用分析算法
|
||||||
|
boolean analyseSpectrum = gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
|
||||||
|
if (analyseSpectrum) {
|
||||||
|
// 重新分析各峰值对应的核素信息
|
||||||
|
// gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
|
||||||
|
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
|
||||||
|
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
|
||||||
|
phd.setEfficiencyCurRow(0);
|
||||||
|
// 重新计算峰值
|
||||||
|
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
|
||||||
|
gammaFileUtil.getNuclideMDCValue(phd, phd.getMdcInfoMap(), nuclideLinesMDCMap);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
gammaFileUtil.UpdateChart(phd, map, colorMap);
|
||||||
|
// 更新 ‘QC Flags’ 状态
|
||||||
|
phd.getQcItems().clear();
|
||||||
|
// List<String> qcstate = gammaFileUtil.Qcstate(phd);
|
||||||
|
// todo 不要qcflags
|
||||||
|
// map.put("QCFlag", qcstate);
|
||||||
|
map.put("bAnalyed", phd.isBAnalyed());
|
||||||
|
map.put("peak", phd.getVPeak());
|
||||||
|
map.put("BaseCtrls", phd.getBaseCtrls());
|
||||||
|
// Bar Chart 柱状图
|
||||||
|
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
|
||||||
|
map.put("barChart", differance);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(map);
|
||||||
|
} else {
|
||||||
|
result.error500("There is a problem with the current phd file, Analysis failure!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user