fix:解决新beta谱自动处理 gamma业务代码
This commit is contained in:
parent
544747a400
commit
e155d51c79
|
@ -231,7 +231,7 @@ public class GStoreMiddleProcessData implements Serializable {
|
||||||
//SpecSetup
|
//SpecSetup
|
||||||
public SpecSetup setting_specSetup;
|
public SpecSetup setting_specSetup;
|
||||||
|
|
||||||
public GStoreMiddleProcessData(){
|
{
|
||||||
dbWriteFlag = false;
|
dbWriteFlag = false;
|
||||||
dbWriteStatusFlag = "";
|
dbWriteStatusFlag = "";
|
||||||
ErrorInfo = "";
|
ErrorInfo = "";
|
||||||
|
@ -420,5 +420,13 @@ public class GStoreMiddleProcessData implements Serializable {
|
||||||
NDC_Analysis_General_Comments = "";
|
NDC_Analysis_General_Comments = "";
|
||||||
setting_specSetup = new SpecSetup();
|
setting_specSetup = new SpecSetup();
|
||||||
}
|
}
|
||||||
|
public GStoreMiddleProcessData(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GStoreMiddleProcessData(String analyses_save_filePath){
|
||||||
|
new GStoreMiddleProcessData();
|
||||||
|
this.analyses_save_filePath = analyses_save_filePath;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.logging.log4j.util.Strings;
|
||||||
import org.jeecg.common.constant.StringConstant;
|
import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.util.DateUtils;
|
import org.jeecg.common.util.DateUtils;
|
||||||
|
import org.jeecg.common.util.SelfUtil;
|
||||||
import org.jeecg.modules.ErrorLogManager;
|
import org.jeecg.modules.ErrorLogManager;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.enums.SampleStatus;
|
import org.jeecg.modules.base.enums.SampleStatus;
|
||||||
|
@ -88,7 +89,13 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void parseingEmail() throws Exception {
|
protected void parseingEmail() throws Exception {
|
||||||
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(super.spectrumFile.getAbsolutePath());
|
// 如果是自建台站能谱,需要单独处理Histogram数据,避免性能问题
|
||||||
|
EnergySpectrumStruct sourceData = null;
|
||||||
|
if (super.spectrumFile.length() > (1024 * 1024 * 4L)) {
|
||||||
|
sourceData = SelfUtil.getSourceDataNotHis(super.spectrumFile.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
sourceData = EnergySpectrumHandler.getSourceData(super.spectrumFile.getAbsolutePath());
|
||||||
|
}
|
||||||
if(Objects.isNull(sourceData) || StringUtils.isBlank(sourceData.data_type)){
|
if(Objects.isNull(sourceData) || StringUtils.isBlank(sourceData.data_type)){
|
||||||
//发送格式化错误事件,后续统计报告使用
|
//发送格式化错误事件,后续统计报告使用
|
||||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
|
|
@ -188,38 +188,17 @@ public class Sample_C_Analysis {
|
||||||
|
|
||||||
/* 准备Gamma分析需要的数据 */
|
/* 准备Gamma分析需要的数据 */
|
||||||
Integer sampleId = sampleData.getSampleId();
|
Integer sampleId = sampleData.getSampleId();
|
||||||
// 获取配置文件
|
|
||||||
GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class);
|
|
||||||
parameterProperties = ApplicationContextUtil.getContext().getBean(ParameterProperties.class);
|
|
||||||
phdFile1.setXmlFilePath(parameterProperties.getFilePath());
|
|
||||||
phdFile2.setXmlFilePath(parameterProperties.getFilePath());
|
|
||||||
phdFile3.setXmlFilePath(parameterProperties.getFilePath());
|
|
||||||
phdFile4.setXmlFilePath(parameterProperties.getFilePath());
|
|
||||||
|
|
||||||
// 获取数据库 Gamma 默认参数
|
|
||||||
getSettingFromDB(phdFile1, phdFile2, phdFile3, phdFile4);
|
|
||||||
|
|
||||||
// 文件路径
|
// 文件路径
|
||||||
GStoreMiddleProcessData middleData1 = new GStoreMiddleProcessData();
|
GStoreMiddleProcessData middleData1 = new GStoreMiddleProcessData(this.sampleInputFilename);
|
||||||
GStoreMiddleProcessData middleData2 = new GStoreMiddleProcessData();
|
GStoreMiddleProcessData middleData2 = new GStoreMiddleProcessData(this.sampleInputFilename);
|
||||||
GStoreMiddleProcessData middleData3 = new GStoreMiddleProcessData();
|
GStoreMiddleProcessData middleData3 = new GStoreMiddleProcessData(this.sampleInputFilename);
|
||||||
GStoreMiddleProcessData middleData4 = new GStoreMiddleProcessData();
|
GStoreMiddleProcessData middleData4 = new GStoreMiddleProcessData(this.sampleInputFilename);
|
||||||
middleData1.setAnalyses_save_filePath(this.sampleInputFilename);
|
|
||||||
middleData2.setAnalyses_save_filePath(this.sampleInputFilename);
|
|
||||||
middleData3.setAnalyses_save_filePath(this.sampleInputFilename);
|
|
||||||
middleData4.setAnalyses_save_filePath(this.sampleInputFilename);
|
|
||||||
|
|
||||||
// 读取文件内容并附值
|
// 读取文件内容并附值
|
||||||
this.setPHDFile(phdFile1, phdFile2, phdFile3, phdFile4);
|
this.setPHDFile(phdFile1, phdFile2, phdFile3, phdFile4);
|
||||||
|
// 获取数据库 Gamma 默认参数
|
||||||
phdFile1.getSetting().setRefTime_act(DateUtils.parseDate(phdFile1.getAcq().getAcquisition_start_date()+" "+phdFile1.getAcq().getAcquisition_start_time()));
|
getSettingFromDB(phdFile1, phdFile2, phdFile3, phdFile4);
|
||||||
phdFile2.getSetting().setRefTime_act(DateUtils.parseDate(phdFile2.getAcq().getAcquisition_start_date()+" "+phdFile2.getAcq().getAcquisition_start_time()));
|
|
||||||
phdFile3.getSetting().setRefTime_act(DateUtils.parseDate(phdFile3.getAcq().getAcquisition_start_date()+" "+phdFile3.getAcq().getAcquisition_start_time()));
|
|
||||||
phdFile4.getSetting().setRefTime_act(DateUtils.parseDate(phdFile4.getAcq().getAcquisition_start_date()+" "+phdFile4.getAcq().getAcquisition_start_time()));
|
|
||||||
phdFile1.getSetting().setRefTime_conc(DateUtils.parseDate(phdFile1.getCollect().getCollection_start_date()+" "+phdFile1.getCollect().getCollection_start_time()));
|
|
||||||
phdFile2.getSetting().setRefTime_conc(DateUtils.parseDate(phdFile2.getCollect().getCollection_start_date()+" "+phdFile2.getCollect().getCollection_start_time()));
|
|
||||||
phdFile3.getSetting().setRefTime_conc(DateUtils.parseDate(phdFile3.getCollect().getCollection_start_date()+" "+phdFile3.getCollect().getCollection_start_time()));
|
|
||||||
phdFile4.getSetting().setRefTime_conc(DateUtils.parseDate(phdFile4.getCollect().getCollection_start_date()+" "+phdFile4.getCollect().getCollection_start_time()));
|
|
||||||
|
|
||||||
// 根据能谱的系统类型传入不同的核素参数
|
// 根据能谱的系统类型传入不同的核素参数
|
||||||
Map<String, NuclideLines> nuclideLibs = this.getNuclideLinesG();
|
Map<String, NuclideLines> nuclideLibs = this.getNuclideLinesG();
|
||||||
|
@ -227,7 +206,8 @@ public class Sample_C_Analysis {
|
||||||
//读取参数内容
|
//读取参数内容
|
||||||
Map<String, CalMDCInfo> mdcInfoMap = readMDCParameter(phdFile1, phdFile2, phdFile3, phdFile4);
|
Map<String, CalMDCInfo> mdcInfoMap = readMDCParameter(phdFile1, phdFile2, phdFile3, phdFile4);
|
||||||
|
|
||||||
// 执行分析业务代码
|
// 执行gamma分析业务代码
|
||||||
|
GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class);
|
||||||
boolean analyFlag1 = gammaFileUtil.GetMiddleData(phdFile1, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData1, MiddleDataType.Auto.getType(), "");
|
boolean analyFlag1 = gammaFileUtil.GetMiddleData(phdFile1, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData1, MiddleDataType.Auto.getType(), "");
|
||||||
boolean analyFlag2 = gammaFileUtil.GetMiddleData(phdFile2, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData2, MiddleDataType.Auto.getType(), "");
|
boolean analyFlag2 = gammaFileUtil.GetMiddleData(phdFile2, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData2, MiddleDataType.Auto.getType(), "");
|
||||||
boolean analyFlag3 = gammaFileUtil.GetMiddleData(phdFile3, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData3, MiddleDataType.Auto.getType(), "");
|
boolean analyFlag3 = gammaFileUtil.GetMiddleData(phdFile3, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData3, MiddleDataType.Auto.getType(), "");
|
||||||
|
@ -279,6 +259,7 @@ public class Sample_C_Analysis {
|
||||||
long bChannels = sampleStruct.b_channels;
|
long bChannels = sampleStruct.b_channels;
|
||||||
long gChannels = sampleStruct.g_channels;
|
long gChannels = sampleStruct.g_channels;
|
||||||
List<Long> hCounts = sampleStruct.h_counts;
|
List<Long> hCounts = sampleStruct.h_counts;
|
||||||
|
long[][] hCountArr = sampleStruct.getH_count_arr();
|
||||||
CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam();
|
CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam();
|
||||||
calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
|
calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
|
||||||
calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel);
|
calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel);
|
||||||
|
@ -299,16 +280,16 @@ public class Sample_C_Analysis {
|
||||||
|
|
||||||
// 根据范围1划分 范围1对应的折线图
|
// 根据范围1划分 范围1对应的折线图
|
||||||
List<Long> roiOneCounts = selfStationUtil.roiList(roiBBoundaryStart.get(0), roiBBoundaryStop.get(0),
|
List<Long> roiOneCounts = selfStationUtil.roiList(roiBBoundaryStart.get(0), roiBBoundaryStop.get(0),
|
||||||
bChannels, gChannels, hCounts);
|
bChannels, gChannels, hCountArr);
|
||||||
// 根据范围2划分 范围2对应的折线图
|
// 根据范围2划分 范围2对应的折线图
|
||||||
List<Long> roiTwoCounts = selfStationUtil.roiList(roiBBoundaryStart.get(1), roiBBoundaryStop.get(1),
|
List<Long> roiTwoCounts = selfStationUtil.roiList(roiBBoundaryStart.get(1), roiBBoundaryStop.get(1),
|
||||||
bChannels, gChannels, hCounts);
|
bChannels, gChannels, hCountArr);
|
||||||
// 根据范围3划分 范围3对应的折线图
|
// 根据范围3划分 范围3对应的折线图
|
||||||
List<Long> roiThreeCounts = selfStationUtil.roiList(roiBBoundaryStart.get(2), roiBBoundaryStop.get(2),
|
List<Long> roiThreeCounts = selfStationUtil.roiList(roiBBoundaryStart.get(2), roiBBoundaryStop.get(2),
|
||||||
bChannels, gChannels, hCounts);
|
bChannels, gChannels, hCountArr);
|
||||||
// 根据范围4划分 范围4对应的折线图
|
// 根据范围4划分 范围4对应的折线图
|
||||||
List<Long> roiFourCounts = selfStationUtil.roiList(roiBBoundaryStart.get(3), roiBBoundaryStop.get(3),
|
List<Long> roiFourCounts = selfStationUtil.roiList(roiBBoundaryStart.get(3), roiBBoundaryStop.get(3),
|
||||||
bChannels, gChannels, hCounts);
|
bChannels, gChannels, hCountArr);
|
||||||
|
|
||||||
// 根据ROI生成四个Gamma谱文件 文件命名格式为: 样品谱原名_ROI_x.PHD
|
// 根据ROI生成四个Gamma谱文件 文件命名格式为: 样品谱原名_ROI_x.PHD
|
||||||
String saveFullPath = this.saveFullPath();
|
String saveFullPath = this.saveFullPath();
|
||||||
|
@ -340,6 +321,13 @@ public class Sample_C_Analysis {
|
||||||
gammaThreeName = saveRelativePath + StrUtil.SLASH + gammaThreeName;
|
gammaThreeName = saveRelativePath + StrUtil.SLASH + gammaThreeName;
|
||||||
gammaFourName = saveRelativePath + StrUtil.SLASH + gammaFourName;
|
gammaFourName = saveRelativePath + StrUtil.SLASH + gammaFourName;
|
||||||
phdFilePaths = ListUtil.toList(gammaOneName, gammaTwoName, gammaThreeName, gammaFourName);
|
phdFilePaths = ListUtil.toList(gammaOneName, gammaTwoName, gammaThreeName, gammaFourName);
|
||||||
|
|
||||||
|
// 获取配置文件
|
||||||
|
parameterProperties = ApplicationContextUtil.getContext().getBean(ParameterProperties.class);
|
||||||
|
phdFile1.setXmlFilePath(parameterProperties.getFilePath());
|
||||||
|
phdFile2.setXmlFilePath(parameterProperties.getFilePath());
|
||||||
|
phdFile3.setXmlFilePath(parameterProperties.getFilePath());
|
||||||
|
phdFile4.setXmlFilePath(parameterProperties.getFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String savePath(){
|
public String savePath(){
|
||||||
|
@ -902,7 +890,7 @@ public class Sample_C_Analysis {
|
||||||
PairsEDto pairsEDto = new PairsEDto();
|
PairsEDto pairsEDto = new PairsEDto();
|
||||||
BeanUtil.copyProperties(middleData, pairsEDto);
|
BeanUtil.copyProperties(middleData, pairsEDto);
|
||||||
List<GardsCalibrationPairsRoi> pairsE = Lists.newArrayList();
|
List<GardsCalibrationPairsRoi> pairsE = Lists.newArrayList();
|
||||||
if (pairsEDto.getCalibration_pairs_E_idCalPoint().size() > 0) {
|
if (!pairsEDto.getCalibration_pairs_E_idCalPoint().isEmpty()) {
|
||||||
pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap);
|
pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap);
|
||||||
String pairsECaltype = middleData.getCalibration_pairs_E_Caltype();
|
String pairsECaltype = middleData.getCalibration_pairs_E_Caltype();
|
||||||
String pairsEInput = middleData.getCalibration_pairs_E_Input();
|
String pairsEInput = middleData.getCalibration_pairs_E_Input();
|
||||||
|
@ -920,7 +908,7 @@ public class Sample_C_Analysis {
|
||||||
PairsEFDto pairsEFDto = new PairsEFDto();
|
PairsEFDto pairsEFDto = new PairsEFDto();
|
||||||
BeanUtil.copyProperties(middleData, pairsEFDto);
|
BeanUtil.copyProperties(middleData, pairsEFDto);
|
||||||
List<GardsCalibrationPairsRoi> pairsEF = Lists.newArrayList();
|
List<GardsCalibrationPairsRoi> pairsEF = Lists.newArrayList();
|
||||||
if (pairsEFDto.getCalibration_pairs_EF_idCalPoint().size() > 0) {
|
if (!pairsEFDto.getCalibration_pairs_EF_idCalPoint().isEmpty()) {
|
||||||
pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap);
|
pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap);
|
||||||
String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype();
|
String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype();
|
||||||
String pairsEFInput = middleData.getCalibration_pairs_EF_Input();
|
String pairsEFInput = middleData.getCalibration_pairs_EF_Input();
|
||||||
|
@ -938,7 +926,7 @@ public class Sample_C_Analysis {
|
||||||
PairsRDto pairsRDto = new PairsRDto();
|
PairsRDto pairsRDto = new PairsRDto();
|
||||||
BeanUtil.copyProperties(middleData,pairsRDto);
|
BeanUtil.copyProperties(middleData,pairsRDto);
|
||||||
List<GardsCalibrationPairsRoi> pairsR = Lists.newArrayList();
|
List<GardsCalibrationPairsRoi> pairsR = Lists.newArrayList();
|
||||||
if (pairsRDto.getCalibration_pairs_R_idCalPoint().size() > 0) {
|
if (!pairsRDto.getCalibration_pairs_R_idCalPoint().isEmpty()) {
|
||||||
pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap);
|
pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap);
|
||||||
String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype();
|
String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype();
|
||||||
String pairsRInput = middleData.getCalibration_pairs_R_Input();
|
String pairsRInput = middleData.getCalibration_pairs_R_Input();
|
||||||
|
@ -956,7 +944,7 @@ public class Sample_C_Analysis {
|
||||||
PairsTDto pairsTDto = new PairsTDto();
|
PairsTDto pairsTDto = new PairsTDto();
|
||||||
BeanUtil.copyProperties(middleData,pairsTDto);
|
BeanUtil.copyProperties(middleData,pairsTDto);
|
||||||
List<GardsCalibrationPairsRoi> pairsT = Lists.newArrayList();
|
List<GardsCalibrationPairsRoi> pairsT = Lists.newArrayList();
|
||||||
if (pairsTDto.getCalibration_pairs_T_idCalPoint().size() > 0) {
|
if (!pairsTDto.getCalibration_pairs_T_idCalPoint().isEmpty()) {
|
||||||
pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap);
|
pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap);
|
||||||
String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype();
|
String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype();
|
||||||
String pairsTInput = middleData.getCalibration_pairs_T_Input();
|
String pairsTInput = middleData.getCalibration_pairs_T_Input();
|
||||||
|
@ -1348,7 +1336,7 @@ public class Sample_C_Analysis {
|
||||||
return fieldMap;
|
return fieldMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSettingFromDB(PHDFile... phdFiles){
|
public void getSettingFromDB(PHDFile... phdFiles) throws ParseException {
|
||||||
Map<String, String> mapSetting = serviceQuotes.getGammaDefaultParamsService()
|
Map<String, String> mapSetting = serviceQuotes.getGammaDefaultParamsService()
|
||||||
.mapSetting();
|
.mapSetting();
|
||||||
for (PHDFile phdFile : phdFiles) {
|
for (PHDFile phdFile : phdFiles) {
|
||||||
|
@ -1402,6 +1390,10 @@ public class Sample_C_Analysis {
|
||||||
String RiskLevelK = mapSetting.get(Setting.RISKLEVELK);
|
String RiskLevelK = mapSetting.get(Setting.RISKLEVELK);
|
||||||
if (StrUtil.isNotBlank(RiskLevelK))
|
if (StrUtil.isNotBlank(RiskLevelK))
|
||||||
setting.setRiskLevelK(Double.parseDouble(RiskLevelK));
|
setting.setRiskLevelK(Double.parseDouble(RiskLevelK));
|
||||||
|
|
||||||
|
setting.setRefTime_act(DateUtils.parseDate(phdFile.getAcq().getAcquisition_start_date()+" "+phdFile.getAcq().getAcquisition_start_time()));
|
||||||
|
setting.setRefTime_conc(DateUtils.parseDate(phdFile.getCollect().getCollection_start_date()+" "+phdFile.getCollect().getCollection_start_time()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,32 @@
|
||||||
package org.jeecg.common.util;
|
package org.jeecg.common.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.util.StrUtil;
|
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.google.common.collect.Maps;
|
||||||
import org.jeecg.modules.base.enums.CalName;
|
import org.jeecg.modules.base.enums.CalName;
|
||||||
|
import org.jeecg.modules.base.enums.SampleFileHeader;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
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.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SelfUtil {
|
public class SelfUtil {
|
||||||
|
|
||||||
public List<Long> roiList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
|
private static final Logger log = LoggerFactory.getLogger(SelfUtil.class);
|
||||||
|
|
||||||
|
public List<Long> roiList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, long[][] h_counts) {
|
||||||
// g_counts
|
// g_counts
|
||||||
List<Long> counts = new LinkedList<>();
|
List<Long> counts = new LinkedList<>();
|
||||||
//存储同一列不同行加和后的数量
|
//存储同一列不同行加和后的数量
|
||||||
|
@ -33,13 +37,7 @@ public class SelfUtil {
|
||||||
//根据起始道值和结束道值 获取这一列的所有对应道值的数据
|
//根据起始道值和结束道值 获取这一列的所有对应道值的数据
|
||||||
for (int j=startChannel; j <= endChannel; j++) {
|
for (int j=startChannel; j <= endChannel; j++) {
|
||||||
//列数 * 总行数 + 当前行下标 获取对应的数据数组下标
|
//列数 * 总行数 + 当前行下标 获取对应的数据数组下标
|
||||||
int index = (int) (i * betaChannels + j);
|
sum += h_counts[i][j];
|
||||||
long count = 0;
|
|
||||||
//判断下标是否在h_counts范围内
|
|
||||||
if (index > 0 && index < h_counts.size()) {
|
|
||||||
count = h_counts.get(index);
|
|
||||||
}
|
|
||||||
sum+=count;
|
|
||||||
}
|
}
|
||||||
counts.add(sum);
|
counts.add(sum);
|
||||||
}
|
}
|
||||||
|
@ -345,4 +343,85 @@ public class SelfUtil {
|
||||||
}
|
}
|
||||||
return phd;
|
return phd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用dll解析phd文件,dll不解析histogram块数据
|
||||||
|
* @param filePathName 文件地址
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static EnergySpectrumStruct getSourceDataNotHis(String filePathName) {
|
||||||
|
EnergySpectrumStruct struct = null;
|
||||||
|
try {
|
||||||
|
if (Objects.nonNull(filePathName)) {
|
||||||
|
//解析文件内容
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
struct = EnergySpectrumHandler.getSourceDataNotHis(filePathName);
|
||||||
|
Console.log("getsource:{}", (System.currentTimeMillis() - start));
|
||||||
|
start = System.currentTimeMillis();
|
||||||
|
HashMap<String, Object> hisMap = readPHDFile(filePathName);
|
||||||
|
Console.log("readPHDFile:{}", (System.currentTimeMillis() - start));
|
||||||
|
struct.setH_count_arr((long[][]) hisMap.get("h_count"));
|
||||||
|
struct.setG_channels((long) hisMap.get("g_channels"));
|
||||||
|
struct.setB_channels((long) hisMap.get("b_channels"));
|
||||||
|
struct.setG_energy_span((long) hisMap.get("g_energy_span"));
|
||||||
|
struct.setB_energy_span((long) hisMap.get("b_energy_span"));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("getSourceDataNotHis Error:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
return struct;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析 #histogram块数据
|
||||||
|
* @param phdPath 文件地址
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static HashMap<String, Object> readPHDFile(String phdPath) {
|
||||||
|
try {
|
||||||
|
File file = new File(phdPath);
|
||||||
|
HashMap<String, Object> result = Maps.newHashMap();
|
||||||
|
BufferedReader reader = FileUtil.getReader(file, "utf8");
|
||||||
|
String currentName = "";
|
||||||
|
long [][] hCountArr = null;
|
||||||
|
int row = 0;
|
||||||
|
String blockHis = SampleFileHeader.HISTOGRAM.getMessage();
|
||||||
|
while (reader.ready()) {
|
||||||
|
// 当前行
|
||||||
|
String line = reader.readLine();
|
||||||
|
if (line.equals(blockHis)) {
|
||||||
|
currentName = line;
|
||||||
|
// 首行
|
||||||
|
String s = reader.readLine();
|
||||||
|
String[] split = s.split(" ");
|
||||||
|
hCountArr = new long[Integer.parseInt(split[0])][Integer.parseInt(split[1])];
|
||||||
|
result.put("g_channels", Long.parseLong(split[0]));
|
||||||
|
result.put("b_channels", Long.parseLong(split[1]));
|
||||||
|
result.put("g_energy_span", Long.parseLong(split[2]));
|
||||||
|
result.put("b_energy_span", Long.parseLong(split[3]));
|
||||||
|
Console.log(s);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!line.equals(blockHis) && !currentName.equals(blockHis)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (line.equals("STOP")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String[] split = line.split(" ");
|
||||||
|
for (int i = 0; i < split.length; i++) {
|
||||||
|
hCountArr[row][i] = Long.parseLong(split[i]);
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
result.put("h_count", hCountArr);
|
||||||
|
return result;
|
||||||
|
} catch (IORuntimeException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user