fix:新beta谱自动处理 beta分析、数据存储
This commit is contained in:
parent
e155d51c79
commit
d4b0b849a5
jeecg-module-auto-process/src/main/java/org/jeecg/modules
jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util
jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util
|
@ -3,6 +3,7 @@ package org.jeecg.modules.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.native_jni.struct.SelfBgAnalyseResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,5 +22,8 @@ public interface GardsCalibrationService extends IService<GardsCalibration> {
|
|||
* @param anayId
|
||||
*/
|
||||
public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer anayId);
|
||||
|
||||
void create(SelfBgAnalyseResult analyseResult, Integer sampleId, Integer anayId);
|
||||
|
||||
public void createBatch( List<GardsCalibration> calibrations);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,11 @@ package org.jeecg.modules.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
|
||||
import org.jeecg.modules.entity.vo.SelfXeResults;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 存储β-γ符合谱最终分析结果。
|
||||
*/
|
||||
|
@ -17,4 +20,6 @@ public interface GardsXeResultsService extends IService<GardsXeResults> {
|
|||
* @param idAnalysis
|
||||
*/
|
||||
public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer idAnalysis);
|
||||
|
||||
void create(List<SelfXeResults> selfXeResults, Integer sampleId, Integer idAnalysis);
|
||||
}
|
||||
|
|
|
@ -3,8 +3,10 @@ package org.jeecg.modules.service.impl;
|
|||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
|
||||
import org.jeecg.modules.base.enums.FittingType;
|
||||
import org.jeecg.modules.mapper.GardsCalibrationMapper;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.native_jni.struct.SelfBgAnalyseResult;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
import org.jeecg.modules.service.GardsCalibrationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -38,11 +40,68 @@ public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMap
|
|||
this.saveDetG_EnergyRecord(analyseResult,detSampleId,anayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(SelfBgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
|
||||
this.saveSampleB_EnergyRecord(analyseResult,sampleId,anayId);
|
||||
this.saveSampleG_EnergyRecord(analyseResult,sampleId,anayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createBatch(List<GardsCalibration> calibrations) {
|
||||
this.baseMapper.createBatch(calibrations);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存 B_Energy 块信息
|
||||
* @param analyseResult
|
||||
* @param sampleId
|
||||
* @param anayId
|
||||
*/
|
||||
private void saveSampleB_EnergyRecord(SelfBgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
|
||||
GardsCalibration calibration = new GardsCalibration();
|
||||
calibration.setSampleId(sampleId);
|
||||
calibration.setIdAnalysis(anayId);
|
||||
calibration.setSampleType(SYSTEMTYPE_B);
|
||||
calibration.setCalType(ENERGY_CAL);
|
||||
calibration.setFunction(FittingType.POLY2.getCode());
|
||||
calibration.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibration.setStartOfRange(START_RANGE);
|
||||
calibration.setEndOfRange(END_RANGE);
|
||||
calibration.setCoeff1(analyseResult.getS_b_fitting_e_c().get(0));
|
||||
calibration.setCoeff2(analyseResult.getS_b_fitting_e_c().get(1));
|
||||
calibration.setCoeff3(analyseResult.getS_b_fitting_e_c().get(2));
|
||||
calibration.setModdate(new Date());
|
||||
|
||||
this.baseMapper.create(calibration);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储数据分析过程中能量、分辨率和效率刻度的拟合结果。
|
||||
* 不提交事务,由调用方手动统一提交事务
|
||||
* G_Energy能道存储
|
||||
* @param analyseResult
|
||||
* @param sampleId
|
||||
* @param anayId
|
||||
*/
|
||||
private void saveSampleG_EnergyRecord(SelfBgAnalyseResult analyseResult,Integer sampleId, Integer anayId) {
|
||||
GardsCalibration calibration = new GardsCalibration();
|
||||
calibration.setSampleId(sampleId);
|
||||
calibration.setIdAnalysis(anayId);
|
||||
calibration.setSampleType(SYSTEMTYPE_G);
|
||||
calibration.setCalType(ENERGY_CAL);
|
||||
calibration.setFunction(FittingType.POLY2.getCode());
|
||||
calibration.setFunctionDef(FittingType.POLY2.getDescription());
|
||||
calibration.setStartOfRange(START_RANGE);
|
||||
calibration.setEndOfRange(END_RANGE);
|
||||
calibration.setCoeff1(analyseResult.getS_g_fitting_e_c().get(0));
|
||||
calibration.setCoeff2(analyseResult.getS_g_fitting_e_c().get(1));
|
||||
calibration.setCoeff3(analyseResult.getS_g_fitting_e_c().get(2));
|
||||
calibration.setModdate(new Date());
|
||||
|
||||
this.baseMapper.create(calibration);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存 B_Energy 块信息
|
||||
* @param analyseResult
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
|
||||
import org.jeecg.modules.entity.vo.SelfXeResults;
|
||||
import org.jeecg.modules.mapper.GardsXeResultsMapper;
|
||||
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
|
||||
import org.jeecg.modules.service.BlockConstant;
|
||||
|
@ -38,6 +40,21 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(List<SelfXeResults> selfXeResults, Integer sampleId, Integer idAnalysis) {
|
||||
List<GardsXeResults> xeResultsList = Lists.newArrayList();
|
||||
for (SelfXeResults result : selfXeResults) {
|
||||
GardsXeResults gardsXeResults = new GardsXeResults();
|
||||
BeanUtil.copyProperties(result, gardsXeResults);
|
||||
gardsXeResults.setSampleId(sampleId);
|
||||
gardsXeResults.setIdAnalysis(idAnalysis);
|
||||
xeResultsList.add(gardsXeResults);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(xeResultsList)){
|
||||
this.saveBatch(xeResultsList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存XE_131m
|
||||
* @param analyseResult
|
||||
|
|
|
@ -3,17 +3,14 @@ package org.jeecg.modules.spectrum;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Table;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -40,6 +37,7 @@ 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.SelfBgAnalyseResult;
|
||||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
@ -146,10 +144,13 @@ public class Sample_C_Analysis {
|
|||
|
||||
private String detFileFinalPath;
|
||||
|
||||
protected ParsingProcessLog parsingProcessLog;
|
||||
protected ParsingProcessLog parsingProcessLog;
|
||||
|
||||
private SelfBgAnalyseResult analyseResult;
|
||||
|
||||
public Sample_C_Analysis(AbstractS_D_Q_G_SpectrumHandler spectrumHandler, EnergySpectrumStruct sampleStruct, SpectrumServiceQuotes serviceQuotes,
|
||||
GardsSampleData sampleData) {
|
||||
this.analyseResult = new SelfBgAnalyseResult();
|
||||
this.spectrumHandler = spectrumHandler;
|
||||
this.sampleData = sampleData;
|
||||
this.serviceQuotes = serviceQuotes;
|
||||
|
@ -213,18 +214,50 @@ public class Sample_C_Analysis {
|
|||
boolean analyFlag3 = gammaFileUtil.GetMiddleData(phdFile3, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData3, MiddleDataType.Auto.getType(), "");
|
||||
boolean analyFlag4 = gammaFileUtil.GetMiddleData(phdFile4, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData4, MiddleDataType.Auto.getType(), "");
|
||||
|
||||
boolean analyFlag = analyFlag1 && analyFlag2 && analyFlag3 && analyFlag4;
|
||||
// 获取自建台站参数
|
||||
SelfParameter selfParameter = (SelfParameter) redisUtil.get(RedisConstant.SELF_PARAMETER);
|
||||
|
||||
long numBChannel = this.sampleStruct.num_b_channel;
|
||||
List<Double> bChannel = this.sampleStruct.b_channel;
|
||||
List<Double> bElectronEnergy = this.sampleStruct.b_electron_energy;
|
||||
//计算得到C to E公式数据
|
||||
List<Double> fittingPara = EnergySpectrumHandler.GetFileFittingPara(bChannel, bElectronEnergy);
|
||||
List<Double> s_b_fitting_e_c = new LinkedList<>();
|
||||
for (Double para : fittingPara) {
|
||||
s_b_fitting_e_c.add(para);
|
||||
}
|
||||
this.analyseResult.setS_b_fitting_e_c(s_b_fitting_e_c);
|
||||
|
||||
List<Double> channel = new LinkedList<>();
|
||||
for (int i = 0; i < numBChannel - 1 ; ++i) {
|
||||
channel.add(Double.valueOf(i));
|
||||
}
|
||||
List<Double> energy = EnergySpectrumHandler.GetFileFittingData(channel, fittingPara);
|
||||
//E to C
|
||||
List<Double> fittingParaToUi = EnergySpectrumHandler.GetFileFittingPara(energy, channel);
|
||||
List<Double> s_g_fitting_e_c = new LinkedList<>();
|
||||
for (Double para:fittingParaToUi) {
|
||||
s_g_fitting_e_c.add(para);
|
||||
}
|
||||
analyseResult.setS_g_fitting_e_c(s_g_fitting_e_c);
|
||||
|
||||
// 执行beta分析
|
||||
List<SelfXeResults> selfXeResults = SelfStationUtil.betaAnalyse(selfParameter, sampleStruct.POI_G_y1,
|
||||
sampleStruct.POI_G_y2, sampleFilePathName, phdFile1, phdFile2, phdFile3, phdFile4);
|
||||
analyseResult.setXeResults(selfXeResults);
|
||||
|
||||
boolean analyFlag = analyFlag1 && analyFlag2 && analyFlag3 && analyFlag4 && !selfXeResults.isEmpty();
|
||||
|
||||
if (analyFlag) {
|
||||
this.endAnalysisTime = new Date();
|
||||
// 数据插入数据库
|
||||
this.storageDataToDatabase(mdcInfoMap, null,
|
||||
// gamma数据插入数据库
|
||||
this.storageDataToDatabase(mdcInfoMap,
|
||||
middleData1, middleData2, middleData3, middleData4);
|
||||
|
||||
// 生成日志文件
|
||||
// 生成gamma日志文件
|
||||
writeLog(middleData1, middleData2, middleData3, middleData4);
|
||||
|
||||
// 生成报告文件
|
||||
// 生成gamma报告文件
|
||||
writeReport(middleData1, middleData2, middleData3, middleData4);
|
||||
//发送数据到redis
|
||||
// middleData.setSample_id(String.valueOf(sampleId));
|
||||
|
@ -294,24 +327,24 @@ public class Sample_C_Analysis {
|
|||
// 根据ROI生成四个Gamma谱文件 文件命名格式为: 样品谱原名_ROI_x.PHD
|
||||
String saveFullPath = this.saveFullPath();
|
||||
String gammaOneName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_1.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPath, gammaOneName, this.sampleStruct, roiOneCounts);
|
||||
SelfStationUtil.createGammaFile(saveFullPath, gammaOneName, this.sampleStruct, roiOneCounts);
|
||||
|
||||
String gammaTwoName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_2.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPath, gammaTwoName, this.sampleStruct, roiTwoCounts);
|
||||
SelfStationUtil.createGammaFile(saveFullPath, gammaTwoName, this.sampleStruct, roiTwoCounts);
|
||||
|
||||
String gammaThreeName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_3.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPath, gammaThreeName, this.sampleStruct, roiThreeCounts);
|
||||
SelfStationUtil.createGammaFile(saveFullPath, gammaThreeName, this.sampleStruct, roiThreeCounts);
|
||||
|
||||
String gammaFourName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_4.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPath, gammaFourName, this.sampleStruct, roiFourCounts);
|
||||
SelfStationUtil.createGammaFile(saveFullPath, gammaFourName, this.sampleStruct, roiFourCounts);
|
||||
// 将生成的GammaPHD文件转换为PHDFile对象
|
||||
this.phdFile1 = selfStationUtil.getGammaPHD(gammaOneName, saveFullPath);
|
||||
this.phdFile1 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaOneName, saveFullPath, roiOneCounts);
|
||||
this.phdFile1.setRoiSuffix("_ROI_1");
|
||||
this.phdFile2 = selfStationUtil.getGammaPHD(gammaTwoName, saveFullPath);
|
||||
this.phdFile2 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaTwoName, saveFullPath, roiTwoCounts);
|
||||
this.phdFile2.setRoiSuffix("_ROI_2");
|
||||
this.phdFile3 = selfStationUtil.getGammaPHD(gammaThreeName, saveFullPath);
|
||||
this.phdFile3 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaThreeName, saveFullPath, roiThreeCounts);
|
||||
this.phdFile3.setRoiSuffix("_ROI_3");
|
||||
this.phdFile4 = selfStationUtil.getGammaPHD(gammaFourName, saveFullPath);
|
||||
this.phdFile4 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaFourName, saveFullPath, roiFourCounts);
|
||||
this.phdFile4.setRoiSuffix("_ROI_4");
|
||||
// 生成PHD的inputFileName
|
||||
// String saveRelativePath = this.spectrumHandler.getFileSaveRelativePath();
|
||||
|
@ -501,7 +534,7 @@ public class Sample_C_Analysis {
|
|||
}
|
||||
}
|
||||
|
||||
public void storageDataToDatabase(Map<String, CalMDCInfo> mdcInfoMap, Map<String, QcCheckItem> qcItems, GStoreMiddleProcessData... middleDatas){
|
||||
public void storageDataToDatabase(Map<String, CalMDCInfo> mdcInfoMap, GStoreMiddleProcessData... middleDatas){
|
||||
// 如果数据已经存储 不再重复存储
|
||||
Integer idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId());
|
||||
if(ObjectUtil.isNotNull(idAnalysis)) return;
|
||||
|
@ -534,6 +567,11 @@ public class Sample_C_Analysis {
|
|||
// saveQcCheckROI(sampleId, qcItems);
|
||||
/* GARDS_MDC_ROI 数据表保存 */
|
||||
saveMDCROI(sampleId, idAnalysis,mdcInfoMap);
|
||||
|
||||
/* 存储gards_calibration表数据sample谱B_Energy和G_Energy块数据 */
|
||||
saveGardsCalibration(sampleId, idAnalysis);
|
||||
/* gards_Xe_results数据表XE_131m、XE_133、XE_133m、XE_135数据 */
|
||||
saveXeResult(sampleId, idAnalysis);
|
||||
//提交事务
|
||||
serviceQuotes.getTransactionManager().commit(transactionStatus);
|
||||
} catch (Exception e) {
|
||||
|
@ -1235,6 +1273,14 @@ public class Sample_C_Analysis {
|
|||
this.serviceQuotes.getMdcRoiAutoService().saveBatch(mdcRois);
|
||||
}
|
||||
|
||||
public void saveXeResult(Integer sampleId, Integer IdAnalysis) {
|
||||
this.serviceQuotes.getXeResultsService().create(this.analyseResult.getXeResults(), sampleId, IdAnalysis);
|
||||
}
|
||||
|
||||
public void saveGardsCalibration(Integer sampleId, Integer IdAnalysis) {
|
||||
this.serviceQuotes.getGardsCalibrationService().create(this.analyseResult, sampleId, IdAnalysis);
|
||||
}
|
||||
|
||||
public Map<String, NuclideLines> getNuclideLinesG() {
|
||||
redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class);
|
||||
Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "G");
|
||||
|
|
|
@ -64,7 +64,7 @@ public class SelfUtil {
|
|||
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 + " C " +
|
||||
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");
|
||||
|
|
|
@ -857,7 +857,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 + " C " +
|
||||
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");
|
||||
|
|
Loading…
Reference in New Issue
Block a user