fix:修改新beta savetodb接口,完成beta刻度和结果保存

This commit is contained in:
xiaoguangbin 2024-10-09 15:21:05 +08:00
parent 9a403638f6
commit 489eb4cf81
8 changed files with 131 additions and 18 deletions

View File

@ -3,7 +3,6 @@ package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs;
import org.jeecg.modules.mapper.GardsCalibrationPairsMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;

View File

@ -1,10 +1,8 @@
package org.jeecg.modules.service;
import org.jeecg.modules.base.entity.rnman.GardsXeResults;
import org.jeecg.modules.entity.vo.CalMDCInfo;
import org.jeecg.modules.entity.vo.GStoreMiddleProcessData;
import org.jeecg.modules.entity.vo.PHDFile;
import org.jeecg.modules.entity.vo.QcCheckItem;
import org.jeecg.modules.entity.GardsXeResultsSpectrum;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.native_jni.struct.SelfBgAnalyseResult;
import java.util.List;
import java.util.Map;
@ -55,5 +53,11 @@ public interface AnalysisManService {
void saveAnalySettingROI(Integer sampleId, Integer idAnalysis, List<PHDFile> phdFiles);
void saveGardsXeResults(Integer sampleId, Integer idAnalysis, List<GardsXeResults> xeResultsList);
void saveBetaCalibration(SelfBgAnalyseResult analyseResult, Integer sampleId, Integer idAnalysis);
void saveSampleB_EnergyRecord(List<Double> list, Integer sampleId, Integer anayId);
void saveSampleG_EnergyRecord(List<Double> list, Integer sampleId, Integer anayId);
void saveGardsXeResults(Integer sampleId, Integer idAnalysis, List<GardsXeResultsSpectrum> xeResultsList);
}

View File

@ -2,9 +2,9 @@ package org.jeecg.modules.entity.vo;
import lombok.Data;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.native_jni.struct.SelfBgAnalyseResult;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
@Data
@ -132,6 +132,8 @@ public class SelfStationData implements Serializable {
* */
private boolean bAnalyed;
private SelfBgAnalyseResult analyseResult;
public SelfStationData() {
sampleVueData = new SelfStationVueData();
@ -147,6 +149,8 @@ public class SelfStationData implements Serializable {
betaDataFile = new BetaDataFile();
analyseResult = new SelfBgAnalyseResult();
}
}

View File

@ -11,7 +11,12 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
import org.jeecg.modules.base.dto.*;
import org.jeecg.modules.base.entity.rnman.*;
import org.jeecg.modules.base.enums.CalType;
import org.jeecg.modules.base.enums.FittingType;
import org.jeecg.modules.base.enums.SystemType;
import org.jeecg.modules.entity.GardsXeResultsSpectrum;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.native_jni.struct.SelfBgAnalyseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -53,6 +58,10 @@ public class AnalysisManServiceImpl implements AnalysisManService {
private final Map<String,String> fieldMap = fieldMap();
private final static int START_RANGE = 0;
private final static int END_RANGE = 1;
@Override
public void middleDataTable(Integer idAnalysis, List<GStoreMiddleProcessData> middleDatas) {
List<GardsAnalysisRoi> analysisRois = analysisRoiManService.analysisRoi(idAnalysis);
@ -742,15 +751,77 @@ public class AnalysisManServiceImpl implements AnalysisManService {
analySettingRoiService.saveBatch(analySettingRois);
}
@Override
public void saveBetaCalibration(SelfBgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
// this.saveSampleB_EnergyRecord(analyseResult,sampleId,anayId);
// this.saveSampleG_EnergyRecord(analyseResult,sampleId,anayId);
}
/**
* 保存 B_Energy 块信息
* @param sampleId
* @param anayId
*/
@Override
public void saveSampleB_EnergyRecord(List<Double> list, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SystemType.BETA.getType());
calibration.setCalType(CalType.ENERGY_CAL.getType());
calibration.setFunction(FittingType.POLY2.getCode());
calibration.setFunctionDef(FittingType.POLY2.getDescription());
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(list.get(0));
calibration.setCoeff2(list.get(1));
calibration.setCoeff3(list.get(2));
calibration.setModdate(new Date());
calibrationSpectrumService.insertCalibrationBeta(calibration);
}
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* G_Energy能道存储
* @param sampleId
* @param anayId
*/
@Override
public void saveSampleG_EnergyRecord(List<Double> list, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SystemType.GAMMA.getType());
calibration.setCalType(CalType.ENERGY_CAL.getType());
calibration.setFunction(FittingType.POLY2.getCode());
calibration.setFunctionDef(FittingType.POLY2.getDescription());
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(list.get(0));
calibration.setCoeff2(list.get(1));
calibration.setCoeff3(list.get(2));
calibration.setModdate(new Date());
calibrationSpectrumService.insertCalibrationBeta(calibration);
}
@Override
@Transactional
public void saveGardsXeResults(Integer sampleId, Integer idAnalysis, List<GardsXeResults> xeResultsList) {
for (GardsXeResults xeResults:xeResultsList) {
xeResults.setIdAnalysis(idAnalysis);
xeResults.setSampleId(sampleId);
public void saveGardsXeResults(Integer sampleId, Integer idAnalysis, List<GardsXeResultsSpectrum> xeResultsList) {
List<GardsXeResults> results = Lists.newArrayList();
for (GardsXeResultsSpectrum result : xeResultsList) {
GardsXeResults gardsXeResults = new GardsXeResults();
BeanUtil.copyProperties(result, gardsXeResults);
gardsXeResults.setSampleId(sampleId);
gardsXeResults.setIdAnalysis(idAnalysis);
results.add(gardsXeResults);
}
if (CollectionUtils.isNotEmpty(xeResultsList)) {
xeResultsSpectrumService.saveBatch(xeResultsList);
if (CollectionUtils.isNotEmpty(results)) {
xeResultsSpectrumService.saveBatch(results);
}
}

View File

@ -9,6 +9,8 @@ public interface IGardsCalibrationSpectrumService extends IService<GardsCalibrat
void insertCalibrationGamma(GardsCalibration calibration);
void insertCalibrationBeta(GardsCalibration calibration);
int saveGardsCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis);
int saveCalibrationGamma(GStoreMiddleProcessData middleData, Integer sampleId, String idAnalysis);

View File

@ -31,6 +31,11 @@ public class GardsCalibrationSpectrumServiceImpl extends ServiceImpl<GardsCalibr
this.baseMapper.insertCalibrationGamma(calibration);
}
@Override
public void insertCalibrationBeta(GardsCalibration calibration) {
this.baseMapper.insertCalibration(calibration);
}
@Override
@Transactional
public int saveGardsCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {

View File

@ -155,8 +155,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
List<GardsCalibrationSpectrum> gammaCalibrationSpectrumList= new LinkedList<>();
List<GardsCalibrationSpectrum> betaCalibrationSpectrumList = new LinkedList<>();
List<GardsROIChannelsSpectrum> roiChannelsSpectrumList = new LinkedList<>();
List<GardsROIResultsSpectrum> roiResultsSpectrumList = new LinkedList<>();
List<GardsCalibrationPairsSpectrum> gammaCalibrationPairsList = new LinkedList<>();
List<GardsCalibrationPairsSpectrum> betaCalibrationPairsList = new LinkedList<>();
@ -329,7 +327,6 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
// 从数据库加载 Gamma ROI信息
this.getROIResultFromDB(dbName, sampleId, sampleVueData, analysisID);
map.put("ROI1", loadROI(phd1, analyst, colorMap));
map.put("ROI2", loadROI(phd2, analyst, colorMap));
map.put("ROI3", loadROI(phd3, analyst, colorMap));
@ -675,6 +672,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
String T_nuc_act = "";
String T_qc = "";
String T_mdc = "";
String T_xe_result = "";
if (dbName.equals("RNAUTO")) {
T_analy = "RNAUTO.GARDS_ANALYSIS_ROI";
T_calib = "RNAUTO.GARDS_CALIBRATION_PAIRS";
@ -684,6 +682,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
T_nuc_act = "RNAUTO.GARDS_NUCL_IDED_ROI";
T_qc = "RNAUTO.GARDS_QC_CHECK_ROI";
T_mdc = "RNAUTO.GARDS_MDC_ROI";
T_xe_result = "RNAUTO.GARDS_XE_RESULTS";
} else if (dbName.equals("RNMAN")) {
T_analy = "RNMAN.GARDS_ANALYSIS_ROI";
T_calib = "RNMAN.GARDS_CALIBRATION_PAIRS";
@ -693,6 +692,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
T_nuc_act = "RNMAN.GARDS_NUCL_IDED_ROI";
T_qc = "RNMAN.GARDS_QC_CHECK_ROI";
T_mdc = "RNMAN.GARDS_MDC_ROI";
T_xe_result = "RNMAN.GARDS_XE_RESULTS";
} else {
return false;
}
@ -5612,8 +5612,36 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
// RNMAN.GARDS_MDC 表写入 MDC计算结果
analysisManService.saveMDCROI(sampleId, mdcInfoMaps, idAnalysis);
// todo 逻辑不对 需要重写,用户修改QC刻度更新数据之后需要变更 20241009
// analysisManService.saveBetaCalibration(selfStationData.getBetaDataFile(), sampleId, idAnalysis);
long numBChannel = sampleStruct.num_b_channel;
List<Double> bChannel = sampleStruct.b_channel;
List<Double> bElectronEnergy = 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);
}
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);
}
List<Double> g_e_c = betaDataFile.getGammaFittingParaToUi().stream().map(Double::valueOf).collect(Collectors.toList());
analysisManService.saveSampleB_EnergyRecord(s_b_fitting_e_c, sampleId, idAnalysis);
analysisManService.saveSampleG_EnergyRecord(s_g_fitting_e_c, sampleId, idAnalysis);
//新增gards_Xe_results数据表数据
analysisManService.saveGardsXeResults(sampleId, idAnalysis, betaDataFile.getXeDataList());
analysisManService.saveGardsXeResults(sampleId, idAnalysis, selfStationData.getBetaDataFile().getXeResultsSpectrumList());
try {
// 存储PHD文件
if (StringUtils.isNotBlank(sampleFilePathName)){