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

This commit is contained in:
nieziyan 2024-07-22 15:59:11 +08:00
commit 7cd16a77c2
3 changed files with 127 additions and 147 deletions

View File

@ -113,9 +113,13 @@ public class SelfStationUtil extends AbstractLogOrReport {
map.put("spectrumData", spectrumData);
//计算边界值
//gamma能量部分的计算参数 道值对应能量
List<Double> gEnergy = struct.g_energy;
//gamma能量部分的计算参数 道值
List<Double> gCentroidChannel = struct.g_centroid_channel;
//beta能量部分的计算参数 道值对应的能量
List<Double> bElectronEnergy = struct.b_electron_energy;
//beta能量部分的计算参数 道值
List<Double> bChannel = struct.b_channel;
CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam();
calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
@ -133,6 +137,8 @@ public class SelfStationUtil extends AbstractLogOrReport {
List<Integer> roiBBoundaryStart = bgBoundary.ROI_B_Boundary_start;
List<Integer> roiBBoundaryStop = bgBoundary.ROI_B_Boundary_stop;
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
SelfStationVueData detVueData = selfStationData.getDetVueData();
//根据范围1划分 范围1对应的折线图
Map<String, Object> oneMap = statisticsROIList(roiBBoundaryStart.get(0), roiBBoundaryStop.get(0), struct.b_channels, struct.g_channels, struct.h_counts);
@ -141,57 +147,56 @@ public class SelfStationUtil extends AbstractLogOrReport {
Integer endChannel = (Integer) oneMap.get("endChannel");
List<SeriseData> seriseDataList = (List<SeriseData>) oneMap.get("dataList");
if (systemType.equals("sample")) {
selfStationData.getSampleVueData().setROIOneBetaStart(startChannel);
selfStationData.getSampleVueData().setROIOneBetaStop(endChannel);
selfStationData.getSampleVueData().setROIOneList(seriseDataList);
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)oneMap.get("counts"));
sampleVueData.setROIOneBetaStart(startChannel);
sampleVueData.setROIOneBetaStop(endChannel);
sampleVueData.setROIOneList(seriseDataList);
sampleVueData.setROIOneCounts((List<Long>)oneMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROIOneBetaStart(startChannel);
selfStationData.getDetVueData().setROIOneBetaStop(endChannel);
selfStationData.getDetVueData().setROIOneList(seriseDataList);
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)oneMap.get("counts"));
detVueData.setROIOneBetaStart(startChannel);
detVueData.setROIOneBetaStop(endChannel);
detVueData.setROIOneList(seriseDataList);
}
map.put("ROIOneStart", roiBBoundaryStart.get(0));
map.put("ROIOneStop", roiBBoundaryStop.get(0));
map.put("ROIOneList", seriseDataList);
}
//根据范围2划分 范围2对应的折线图
Map<String, Object> twoMap = statisticsROIList(roiBBoundaryStart.get(1), roiBBoundaryStop.get(1), 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) ) {
Integer startChannel = (Integer) twoMap.get("startChannel");
Integer endChannel = (Integer) twoMap.get("endChannel");
List<SeriseData> seriseDataList = (List<SeriseData>) twoMap.get("dataList");
if (systemType.equals("sample")) {
selfStationData.getSampleVueData().setROITwoBetaStart(startChannel);
selfStationData.getSampleVueData().setROITwoBetaStop(endChannel);
selfStationData.getSampleVueData().setROITwoList(seriseDataList);
selfStationData.getSampleVueData().setROITwoCounts((List<Long>)twoMap.get("counts"));
sampleVueData.setROITwoBetaStart(startChannel);
sampleVueData.setROITwoBetaStop(endChannel);
sampleVueData.setROITwoList(seriseDataList);
sampleVueData.setROITwoCounts((List<Long>)twoMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROITwoBetaStart(startChannel);
selfStationData.getDetVueData().setROITwoBetaStop(endChannel);
selfStationData.getDetVueData().setROITwoList(seriseDataList);
selfStationData.getSampleVueData().setROITwoCounts((List<Long>)twoMap.get("counts"));
detVueData.setROITwoBetaStart(startChannel);
detVueData.setROITwoBetaStop(endChannel);
detVueData.setROITwoList(seriseDataList);
}
map.put("ROITwoStart", roiBBoundaryStart.get(1));
map.put("ROITwoStop", roiBBoundaryStop.get(1));
map.put("ROITwoList", seriseDataList);
}
//根据范围3划分 范围3对应的折线图
Map<String, Object> threeMap = statisticsROIList(roiBBoundaryStart.get(2), roiBBoundaryStop.get(2), 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) ) {
Integer startChannel = (Integer) threeMap.get("startChannel");
Integer endChannel = (Integer) threeMap.get("endChannel");
List<SeriseData> seriseDataList = (List<SeriseData>) threeMap.get("dataList");
if (systemType.equals("sample")) {
selfStationData.getSampleVueData().setROIThreeBetaStart(startChannel);
selfStationData.getSampleVueData().setROIThreeBetaStop(endChannel);
selfStationData.getSampleVueData().setROIThreeList(seriseDataList);
selfStationData.getSampleVueData().setROIThreeCounts((List<Long>)threeMap.get("counts"));
sampleVueData.setROIThreeBetaStart(startChannel);
sampleVueData.setROIThreeBetaStop(endChannel);
sampleVueData.setROIThreeList(seriseDataList);
sampleVueData.setROIThreeCounts((List<Long>)threeMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROIThreeBetaStart(startChannel);
selfStationData.getDetVueData().setROIThreeBetaStop(endChannel);
selfStationData.getDetVueData().setROIThreeList(seriseDataList);
selfStationData.getSampleVueData().setROIThreeCounts((List<Long>)threeMap.get("counts"));
detVueData.setROIThreeBetaStart(startChannel);
detVueData.setROIThreeBetaStop(endChannel);
detVueData.setROIThreeList(seriseDataList);
}
map.put("ROIThreeStart", roiBBoundaryStart.get(2));
map.put("ROIThreeStop", roiBBoundaryStop.get(2));
@ -204,15 +209,14 @@ public class SelfStationUtil extends AbstractLogOrReport {
Integer endChannel = (Integer) fourMap.get("endChannel");
List<SeriseData> seriseDataList = (List<SeriseData>) fourMap.get("dataList");
if (systemType.equals("sample")) {
selfStationData.getSampleVueData().setROIFourBetaStart(startChannel);
selfStationData.getSampleVueData().setROIFourBetaStop(endChannel);
selfStationData.getSampleVueData().setROIFourList(seriseDataList);
selfStationData.getSampleVueData().setROIFourCounts((List<Long>)fourMap.get("counts"));
sampleVueData.setROIFourBetaStart(startChannel);
sampleVueData.setROIFourBetaStop(endChannel);
sampleVueData.setROIFourList(seriseDataList);
sampleVueData.setROIFourCounts((List<Long>)fourMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROIFourBetaStart(startChannel);
selfStationData.getDetVueData().setROIFourBetaStop(endChannel);
selfStationData.getDetVueData().setROIFourList(seriseDataList);
selfStationData.getSampleVueData().setROIFourCounts((List<Long>)fourMap.get("counts"));
detVueData.setROIFourBetaStart(startChannel);
detVueData.setROIFourBetaStop(endChannel);
detVueData.setROIFourList(seriseDataList);
}
map.put("ROIFourStart", roiBBoundaryStart.get(3));
map.put("ROIFourStop", roiBBoundaryStop.get(3));
@ -234,15 +238,15 @@ public class SelfStationUtil extends AbstractLogOrReport {
Long count = hCounts.get(index.intValue());
if (count > 0){
HistogramData his = new HistogramData();
his.setG(j);
his.setB(i);
his.setG(i);
his.setB(j);
his.setC(count);
histogramDataList.add(his);
histogramDataDList.add(his);
}else {
HistogramData his = new HistogramData();
his.setG(j);
his.setB(i);
his.setG(i);
his.setB(j);
his.setC(count);
histogramDataDList.add(his);
}
@ -250,10 +254,6 @@ public class SelfStationUtil extends AbstractLogOrReport {
}
map.put("histogramDataList", histogramDataList);
// map.put("histogramDataDList", histogramDataDList);
//gamma能量部分的计算参数 道值
// List<Double> gCentroidChannel = struct.g_centroid_channel;
//gamma能量部分的计算参数 道值对应能量
// List<Double> gEnergy = struct.g_energy;
//调用算法 传入道值和道值对应的能量 得到计算gamma能量公式的参数
List<Double> gammaParam = EnergySpectrumHandler.GetFileFittingPara(gCentroidChannel, gEnergy);
//存储需要计算gamma能量的道值
@ -265,10 +265,6 @@ public class SelfStationUtil extends AbstractLogOrReport {
List<Double> gammaEnergyList = EnergySpectrumHandler.GetFileFittingData(gchannels, gammaParam);
//将gamma能量折线图进行赋值返回
map.put("gammaEnergyData", gammaEnergyList);
//beta能量部分的计算参数 道值
// List<Double> bChannel = struct.b_channel;
//beta能量部分的计算参数 道值对应的能量
// List<Double> bElectronEnergy = struct.b_electron_energy;
//调用算法 传入道值和道值对应的能量 得到计算beta能量公式的参数
List<Double> betaParam = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
List<Double> bchannels = new ArrayList<>();
@ -288,12 +284,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
gEnergyBlock.setUncertainty(struct.g_uncertainty);
gEnergyBlock.setRecord_count(struct.g_record_count);
selfStationData.getSampleVueData().getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
sampleVueData.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
//计算得到公式的参数
List<Double> calEnergyParam = CalValuesHandler.calFitPara("Cal_Energy", 2, struct.g_centroid_channel, struct.g_energy, struct.g_uncertainty);
ParameterInfo parameterInfo = new ParameterInfo();
parameterInfo.setP(calEnergyParam);
selfStationData.getSampleVueData().getMapEnerPara().put(CalName.CalPHD.getType(), parameterInfo);
sampleVueData.getMapEnerPara().put(CalName.CalPHD.getType(), parameterInfo);
}
}
//g_Resolution
@ -304,12 +300,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
gResolutionBlock.setFWHM(struct.g_r_FWHM);
gResolutionBlock.setUncertainty(struct.g_r_uncertainty);
gResolutionBlock.setRecord_count(struct.g_r_record_count);
selfStationData.getSampleVueData().getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
sampleVueData.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
//计算得到公式的参数
List<Double> calEnergyParam = CalValuesHandler.calFitPara("Cal_Resolution", 4, struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty);
ParameterInfo parameterInfo = new ParameterInfo();
parameterInfo.setP(calEnergyParam);
selfStationData.getSampleVueData().getMapResoPara().put(CalName.CalPHD.getType(), parameterInfo);
sampleVueData.getMapResoPara().put(CalName.CalPHD.getType(), parameterInfo);
}
}
//g_Efficiency
@ -320,12 +316,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty);
gEfficiencyBlock.setRecord_count(struct.g_e_record_count);
selfStationData.getSampleVueData().getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
sampleVueData.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
//计算得到公式的参数
List<Double> calEnergyParam = CalValuesHandler.calFitPara("Cal_Efficiency", 1, struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty);
ParameterInfo parameterInfo = new ParameterInfo();
parameterInfo.setP(calEnergyParam);
selfStationData.getSampleVueData().getMapEffiPara().put(CalName.CalPHD.getType(), parameterInfo);
sampleVueData.getMapEffiPara().put(CalName.CalPHD.getType(), parameterInfo);
}
}
} catch (ParseException e) {
@ -921,7 +917,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
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 " +
out.println(struct.site_code + " " + struct.detector_code + " C " +
struct.sample_geometry + " " + struct.spectrum_quantity);
out.println(struct.sample_ref_id);
out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0");
@ -951,9 +947,9 @@ public class SelfStationUtil extends AbstractLogOrReport {
String str = g_counts.get(i).toString();
if(i % 5 == 0) {
if (i == 0) {
out.printf(i+"");
out.printf((i+1)+"");
} else {
out.printf("\n" + i );
out.printf("\n" + (i+1) );
}
beforeStr = i+"";
}

View File

@ -5666,6 +5666,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
redisUtil.set("mdcInfoMap-G", mdcInfoMap);
// todo 暂时和气体使用一样的
redisUtil.set("mdcInfoMap-C", mdcInfoMap);
}
}
}

View File

@ -263,13 +263,13 @@ public class SelfStationServiceImpl implements ISelfStationService {
// Gamma文件内容转换为PHD实体
sampleVueData.setROIOneFileName(gammaOneName);
sampleVueData.setROIOnePHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
sampleVueData.setROIOnePHDFile(selfStationUtil.getGammaPHD(gammaOneName, path));
sampleVueData.setROITwoFileName(gammaTwoName);
sampleVueData.setROITwoPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
sampleVueData.setROIThreeFileName(gammaThreeName);
sampleVueData.setROIThreePHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
sampleVueData.setROIThreePHDFile(selfStationUtil.getGammaPHD(gammaThreeName, path));
sampleVueData.setROIFourFileName(gammaFourName);
sampleVueData.setROIFourPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
sampleVueData.setROIFourPHDFile(selfStationUtil.getGammaPHD(gammaFourName, path));
resultMap.put("sample", map);
// 初始化Configure
@ -1857,6 +1857,9 @@ public class SelfStationServiceImpl implements ISelfStationService {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
// 获取当前角色的颜色配置
Map<String, String> colorMap = sysUserColorService.initColor(userName);
//获取自建台站缓存信息
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName);
@ -1865,77 +1868,25 @@ public class SelfStationServiceImpl implements ISelfStationService {
return result;
}
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
// Gamma文件内容转换为PHD实体
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
PHDFile phdOne = sampleVueData.getROIOnePHDFile();
PHDFile phdTwo = sampleVueData.getROITwoPHDFile();
PHDFile phdThree = sampleVueData.getROIThreePHDFile();
PHDFile phdFour = sampleVueData.getROIFourPHDFile();
phdOne.setUserId(processKey);
// 赋值xml文件存放路径
phdOne.setXmlFilePath(parameterProperties.getFilePath());
// 获取当前角色的颜色配置
Map<String, String> colorMap = sysUserColorService.initColor(userName);
// 分析文件数据
int flag = gammaFileUtil.AnalyseData(phdOne);
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 {
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self");
if (flag == -1) {
//分析时将phd的核素map重置
phdOne.setPhdNuclideMap(nuclideLinesMap);
//重新计算核素的活度浓度
gammaFileUtil.NuclidesIdent(phdOne, nuclideLinesMap);
phdOne.setEfficiencyParam(phdOne.getUsedEffiPara().getP());
phdOne.setEfficiencyEnergy(phdOne.getUsedEffiKD().getG_energy());
phdOne.setEfficiencyCurRow(0);
// 重新计算峰值
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
gammaFileUtil.getNuclideMDCValue(phdOne, phdOne.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, Object> roiMap = new HashMap<>();
try {
Map<String, Object> gammaResult = Maps.newHashMap();
Map<String, Object> map1 = this.gammaAnalyse(phdOne, nuclideLinesMap, colorMap);
Map<String, Object> map2 = this.gammaAnalyse(phdTwo, nuclideLinesMap, colorMap);
Map<String, Object> map3 = this.gammaAnalyse(phdThree, nuclideLinesMap, colorMap);
Map<String, Object> map4 = this.gammaAnalyse(phdFour, nuclideLinesMap, colorMap);
gammaResult.put("ROI1", map1);
gammaResult.put("ROI2", map2);
gammaResult.put("ROI3", map3);
gammaResult.put("ROI4", map4);
sampleVueData.setUsedEnerKD(phdOne.getUsedEnerKD());
sampleVueData.setUsedEffiKD(phdOne.getUsedEffiKD());
sampleVueData.setUsedResoKD(phdOne.getUsedResoKD());
sampleVueData.setMapEnerKD(phdOne.getMapEnerKD());
sampleVueData.setMapResoKD(phdOne.getMapResoKD());
sampleVueData.setMapEffiKD(phdOne.getMapEffiKD());
sampleVueData.setUsedEnerPara(phdOne.getUsedEnerPara());
sampleVueData.setUsedEffiPara(phdOne.getUsedEffiPara());
sampleVueData.setUsedResoPara(phdOne.getUsedResoPara());
sampleVueData.setMapEnerPara(phdOne.getMapEnerPara());
sampleVueData.setMapResoPara(phdOne.getMapResoPara());
sampleVueData.setMapEffiPara(phdOne.getMapEffiPara());
roiMap.put("ROI1", this.gammaAnalyse(processKey, phdOne, nuclideLinesMap, colorMap));
roiMap.put("ROI2", this.gammaAnalyse(processKey, phdTwo, nuclideLinesMap, colorMap));
roiMap.put("ROI3", this.gammaAnalyse(processKey, phdThree, nuclideLinesMap, colorMap));
roiMap.put("ROI4", this.gammaAnalyse(processKey, phdFour, nuclideLinesMap, colorMap));
result.setSuccess(true);
result.setResult(gammaResult);
result.setResult(roiMap);
} catch (RuntimeException e) {
result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI"));
}
}
}
return result;
}
@ -3340,18 +3291,47 @@ public class SelfStationServiceImpl implements ISelfStationService {
* @return
* @throws RuntimeException
*/
private Map<String, Object> gammaAnalyse(PHDFile phd, Map<String, NuclideLines> nuclideLinesMap,
private Map<String, Object> gammaAnalyse(String processKey, PHDFile phd, Map<String, NuclideLines> nuclideLinesMap,
Map<String, String> colorMap) throws RuntimeException{
Map<String, Object> map = new HashMap<>();
phd.setUserId(processKey);
// 赋值xml文件存放路径
phd.setXmlFilePath(parameterProperties.getFilePath());
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.";
throw new RuntimeException(warning);
} else {
if (flag == -1) {
//分析时将phd的核素map重置
phd.setPhdNuclideMap(nuclideLinesMap);
//重新计算核素的活度浓度
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);
String warning = "Finish three tasks:\n" +
"\t1.Update efficiencies of all peaks;\n" +
"\t2.Identify nuclides again;\n" +
"\t3.Test QC again.";
throw new RuntimeException(warning);
} else {
Map<String, Object> map = new HashMap<>();
//分析时将phd的核素map重置
phd.setPhdNuclideMap(nuclideLinesMap);
//读取redis缓存的计算mdc信息
Map<String, CalMDCInfo> mdcInfoMap = (Map<String, CalMDCInfo>) redisUtil.get("mdcInfoMap-"+phd.getHeader().getSystem_type());
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
phd.setMdcInfoMap(mdcInfoMap);
}
//调用分析算法
boolean analyseSpectrum = gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
if (analyseSpectrum) {
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
phd.setEfficiencyCurRow(0);
@ -3365,9 +3345,11 @@ public class SelfStationServiceImpl implements ISelfStationService {
// Bar Chart 柱状图
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
map.put("barChart", differance);
return map;
} else {
throw new RuntimeException("There is a problem with the current %s phd file, Analysis failure!");
}
return map;
}
}
}
}