增加值非空判断

This commit is contained in:
qiaoqinzheng 2023-07-26 10:18:24 +08:00
parent 81592abac1
commit dc39e67308

View File

@ -195,27 +195,57 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
if (Objects.nonNull(gardsSampleData)){
acquisition = new Acquisition();
//封装数据内容
generalInformation.setSiteCode(gardsSampleData.getStationName());
generalInformation.setDetectorCode(gardsSampleData.getSiteDetCode());
generalInformation.setSystemType(gardsSampleData.getSampleType());
generalInformation.setSampleGeometry(gardsSampleData.getGeometry());
generalInformation.setSpectrumQualifier(gardsSampleData.getSpectralQualifie());
generalInformation.setTransmitDate(DateUtils.formatDate(gardsSampleData.getTransmitDtg(), "yyyy-MM-dd HH:mm:ss"));
acquisition.setAcquisitionStartDate(DateUtils.formatDate(gardsSampleData.getAcquisitionStart(), "yyyy-MM-dd HH:mm:ss"));
acquisition.setAcquisitionRealTime(gardsSampleData.getAcquisitionRealSec());
acquisition.setAcquisitionLiveTime(gardsSampleData.getAcquisitionLiveSec());
if (StringUtils.isNotBlank(gardsSampleData.getStationName())){
generalInformation.setSiteCode(gardsSampleData.getStationName());
}
if (StringUtils.isNotBlank(gardsSampleData.getSiteDetCode())){
generalInformation.setDetectorCode(gardsSampleData.getSiteDetCode());
}
if (StringUtils.isNotBlank(gardsSampleData.getSampleType())){
generalInformation.setSystemType(gardsSampleData.getSampleType());
}
if (StringUtils.isNotBlank(gardsSampleData.getGeometry())){
generalInformation.setSampleGeometry(gardsSampleData.getGeometry());
}
if (StringUtils.isNotBlank(gardsSampleData.getSpectralQualifie())){
generalInformation.setSpectrumQualifier(gardsSampleData.getSpectralQualifie());
}
if (Objects.nonNull(gardsSampleData.getTransmitDtg())){
generalInformation.setTransmitDate(DateUtils.formatDate(gardsSampleData.getTransmitDtg(), "yyyy-MM-dd HH:mm:ss"));
}
if (Objects.nonNull(gardsSampleData.getAcquisitionStart())){
acquisition.setAcquisitionStartDate(DateUtils.formatDate(gardsSampleData.getAcquisitionStart(), "yyyy-MM-dd HH:mm:ss"));
}
if (Objects.nonNull(gardsSampleData.getAcquisitionRealSec())){
acquisition.setAcquisitionRealTime(gardsSampleData.getAcquisitionRealSec());
}
if (Objects.nonNull(gardsSampleData.getAcquisitionLiveSec())){
acquisition.setAcquisitionLiveTime(gardsSampleData.getAcquisitionLiveSec());
}
}
if (Objects.nonNull(gardsSampleAux)){
calibration = new Calibration();
generalInformation.setSampleReferenceIdentification(gardsSampleAux.getSampleRefId());
generalInformation.setMeasurementIdentification(gardsSampleAux.getMeasurementId());
generalInformation.setDetectorBackgroundMeasurementId(gardsSampleAux.getBkgdMeasurementId());
generalInformation.setGasBackgroundMeasurementId(gardsSampleAux.getGasBkgdMeasurementId());
calibration.setDateOfLastCalibration(DateUtils.formatDate(gardsSampleAux.getCalibrationDtg(), "yyyy-MM-dd HH:mm:ss"));
if (StringUtils.isNotBlank(gardsSampleAux.getSampleRefId())){
generalInformation.setSampleReferenceIdentification(gardsSampleAux.getSampleRefId());
}
if (StringUtils.isNotBlank(gardsSampleAux.getMeasurementId())){
generalInformation.setMeasurementIdentification(gardsSampleAux.getMeasurementId());
}
if (StringUtils.isNotBlank(gardsSampleAux.getBkgdMeasurementId())){
generalInformation.setDetectorBackgroundMeasurementId(gardsSampleAux.getBkgdMeasurementId());
}
if (StringUtils.isNotBlank(gardsSampleAux.getGasBkgdMeasurementId())){
generalInformation.setGasBackgroundMeasurementId(gardsSampleAux.getGasBkgdMeasurementId());
}
if (Objects.nonNull(gardsSampleAux.getCalibrationDtg())){
calibration.setDateOfLastCalibration(DateUtils.formatDate(gardsSampleAux.getCalibrationDtg(), "yyyy-MM-dd HH:mm:ss"));
}
}
if (Objects.nonNull(gardsSampleDescription)){
comment = new Comment();
comment.setText(gardsSampleDescription.getDescription());
if (StringUtils.isNotBlank(gardsSampleDescription.getDescription())){
comment.setText(gardsSampleDescription.getDescription());
}
}
report.setHeaderBlock(generalInformation);
report.setCommentBlock(comment);
@ -231,14 +261,16 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
calibrationPairsOrigQueryWrapper.orderByAsc(GardsCalibrationPairsOrig::getIdcalpoint);
List<GardsCalibrationPairsOrig> gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigMapper.selectList(calibrationPairsOrigQueryWrapper);
gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigs.stream().filter(item->item.getCaltype().trim().equals("energy")).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(gardsCalibrationPairsOrigs)){
if (CollectionUtils.isNotEmpty(gardsCalibrationPairsOrigs)){
gEnergySubBlock = new LinkedList<>();
for (GardsCalibrationPairsOrig orig:gardsCalibrationPairsOrigs) {
GEnergy gEnergy = new GEnergy();
gEnergy.setEnergy(orig.getYvalue());
gEnergy.setCentroid(orig.getXvalue());
gEnergy.setUncertainty(orig.getUncyvalue());
gEnergySubBlock.add(gEnergy);
if (Objects.nonNull(orig.getYvalue()) && Objects.nonNull(orig.getXvalue()) && Objects.nonNull(orig.getUncyvalue())){
gEnergy.setEnergy(orig.getYvalue());
gEnergy.setCentroid(orig.getXvalue());
gEnergy.setUncertainty(orig.getUncyvalue());
gEnergySubBlock.add(gEnergy);
}
}
}
report.setGEnergyBlock(gEnergySubBlock);
@ -256,11 +288,13 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
bEnergySubBlock = new LinkedList<>();
for (GardsCalibrationPairsOrig orig:gardsCalibrationPairsOrigs) {
BEnergy bEnergy = new BEnergy();
bEnergy.setElectronEnergy(orig.getYvalue());
bEnergy.setMaximumChannel(orig.getXvalue());
bEnergy.setUncertainty(orig.getUncyvalue());
bEnergy.setDecayModeDescriptor(orig.getDecayMode());
bEnergySubBlock.add(bEnergy);
if (Objects.nonNull(orig.getYvalue()) && Objects.nonNull(orig.getXvalue()) && Objects.nonNull(orig.getUncyvalue()) && Objects.nonNull(orig.getDecayMode())){
bEnergy.setElectronEnergy(orig.getYvalue());
bEnergy.setMaximumChannel(orig.getXvalue());
bEnergy.setUncertainty(orig.getUncyvalue());
bEnergy.setDecayModeDescriptor(orig.getDecayMode());
bEnergySubBlock.add(bEnergy);
}
}
}
report.setBEnergyBlock(bEnergySubBlock);
@ -278,10 +312,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
gResolutionSubBlock = new LinkedList<>();
for (GardsCalibrationPairsOrig orig:gardsCalibrationPairsOrigs) {
GResolution gResolution = new GResolution();
gResolution.setEnergy(orig.getXvalue());
gResolution.setFWHM(orig.getYvalue());
gResolution.setUncertainty(orig.getUncyvalue());
gResolutionSubBlock.add(gResolution);
if (Objects.nonNull(orig.getYvalue()) && Objects.nonNull(orig.getXvalue()) && Objects.nonNull(orig.getUncyvalue())){
gResolution.setEnergy(orig.getXvalue());
gResolution.setFWHM(orig.getYvalue());
gResolution.setUncertainty(orig.getUncyvalue());
gResolutionSubBlock.add(gResolution);
}
}
}
report.setGResolutionBlock(gResolutionSubBlock);
@ -299,10 +335,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
bResolutionSubBlock = new LinkedList<>();
for (GardsCalibrationPairsOrig orig:gardsCalibrationPairsOrigs) {
BResolution bResolution = new BResolution();
bResolution.setElectronEnergy(orig.getXvalue());
bResolution.setFWHM(orig.getYvalue());
bResolution.setUncertainty(orig.getUncyvalue());
bResolutionSubBlock.add(bResolution);
if (Objects.nonNull(orig.getYvalue()) && Objects.nonNull(orig.getXvalue()) && Objects.nonNull(orig.getUncyvalue())){
bResolution.setElectronEnergy(orig.getXvalue());
bResolution.setFWHM(orig.getYvalue());
bResolution.setUncertainty(orig.getUncyvalue());
bResolutionSubBlock.add(bResolution);
}
}
}
report.setBResolutionBlock(bResolutionSubBlock);
@ -320,10 +358,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
gEfficiencySubBlock = new LinkedList<>();
for (GardsCalibrationPairsOrig orig:gardsCalibrationPairsOrigs) {
GEfficiency gEfficiency = new GEfficiency();
gEfficiency.setEnergy(orig.getXvalue());
gEfficiency.setEfficiency(orig.getYvalue());
gEfficiency.setUncertainty(orig.getUncyvalue());
gEfficiencySubBlock.add(gEfficiency);
if (Objects.nonNull(orig.getYvalue()) && Objects.nonNull(orig.getXvalue()) && Objects.nonNull(orig.getUncyvalue())){
gEfficiency.setEnergy(orig.getXvalue());
gEfficiency.setEfficiency(orig.getYvalue());
gEfficiency.setUncertainty(orig.getUncyvalue());
gEfficiencySubBlock.add(gEfficiency);
}
}
}
report.setGEfficiencyBlock(gEfficiencySubBlock);
@ -338,11 +378,13 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
bgEfficiencySubBlock = new LinkedList<>();
for (GardsBgEfficiencyPairs pairs:gardsBgEfficiencyPairs) {
BEfficiency bEfficiency = new BEfficiency();
bEfficiency.setRoiNumber(pairs.getRoi());
bEfficiency.setNuclideName(pairs.getNuclideName());
bEfficiency.setCoincidenceEfficiency(pairs.getBgEfficiency());
bEfficiency.setUncertainty(pairs.getBgEfficError());
bgEfficiencySubBlock.add(bEfficiency);
if (Objects.nonNull(pairs.getRoi()) && Objects.nonNull(pairs.getNuclideName()) && Objects.nonNull(pairs.getBgEfficiency()) && Objects.nonNull(pairs.getBgEfficError())){
bEfficiency.setRoiNumber(pairs.getRoi());
bEfficiency.setNuclideName(pairs.getNuclideName());
bEfficiency.setCoincidenceEfficiency(pairs.getBgEfficiency());
bEfficiency.setUncertainty(pairs.getBgEfficError());
bgEfficiencySubBlock.add(bEfficiency);
}
}
}
report.setBgEfficiencyBlock(bgEfficiencySubBlock);
@ -358,12 +400,15 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
roiLimitsSubBlock = new LinkedList<>();
for (GardsRoiLimits roiLimits:gardsRoiLimitsList) {
Roi roi = new Roi();
roi.setRoiNumber(roiLimits.getRoi());
roi.setRoiGRangeStart(roiLimits.getGEnergyStart());
roi.setRoiGRangeStop(roiLimits.getGEnergyStop());
roi.setRoiBRangeStart(roiLimits.getBEnergyStart());
roi.setRoiBRangeStop(roiLimits.getBEnergyStop());
roiLimitsSubBlock.add(roi);
if (Objects.nonNull(roiLimits.getRoi()) && Objects.nonNull(roiLimits.getGEnergyStart()) && Objects.nonNull(roiLimits.getGEnergyStop())
&& Objects.nonNull(roiLimits.getBEnergyStart()) && Objects.nonNull(roiLimits.getBEnergyStop()) ){
roi.setRoiNumber(roiLimits.getRoi());
roi.setRoiGRangeStart(roiLimits.getGEnergyStart());
roi.setRoiGRangeStop(roiLimits.getGEnergyStop());
roi.setRoiBRangeStart(roiLimits.getBEnergyStart());
roi.setRoiBRangeStop(roiLimits.getBEnergyStop());
roiLimitsSubBlock.add(roi);
}
}
}
report.setRoiLimitsBlock(roiLimitsSubBlock);
@ -379,12 +424,15 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
ratiosSubBlock = new LinkedList<>();
for (GardsSampleRatios sampleRatios:sampleRatiosList) {
Ratios ratios = new Ratios();
ratios.setCountRatio(sampleRatios.getCountRatio());
ratios.setRatioId(sampleRatios.getRatioId());
ratios.setCountRatioUncertainty(sampleRatios.getCountRatioErr());
ratios.setRoiNumberLowerEnergy(sampleRatios.getLowerRoiNumber());
ratios.setRoiNumberHigherEnergy(sampleRatios.getUpperRoiNumber());
ratiosSubBlock.add(ratios);
if (Objects.nonNull(sampleRatios.getCountRatio()) && StringUtils.isNotBlank(sampleRatios.getRatioId()) && Objects.nonNull(sampleRatios.getCountRatioErr())
&& Objects.nonNull(sampleRatios.getLowerRoiNumber()) && Objects.nonNull(sampleRatios.getUpperRoiNumber()) ){
ratios.setCountRatio(sampleRatios.getCountRatio());
ratios.setRatioId(sampleRatios.getRatioId());
ratios.setCountRatioUncertainty(sampleRatios.getCountRatioErr());
ratios.setRoiNumberLowerEnergy(sampleRatios.getLowerRoiNumber());
ratios.setRoiNumberHigherEnergy(sampleRatios.getUpperRoiNumber());
ratiosSubBlock.add(ratios);
}
}
}
report.setRatiosBlock(ratiosSubBlock);
@ -404,8 +452,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
gSpectrumSubBlock = (List<Integer>)map.get(SampleFileHeader.GSPECTRUM.getMessage());
}
gSpectrumBlock.setGSpectrumSubBlock(gSpectrumSubBlock);
gSpectrumBlock.setEnergySpan(gardsSpectrum.getEnergySpan());
gSpectrumBlock.setNumberGChannels(gardsSpectrum.getChannels());
if (Objects.nonNull(gardsSpectrum.getEnergySpan())){
gSpectrumBlock.setEnergySpan(gardsSpectrum.getEnergySpan());
}
if (Objects.nonNull(gardsSpectrum.getChannels())){
gSpectrumBlock.setNumberGChannels(gardsSpectrum.getChannels());
}
}
report.setGSpectrumBlock(gSpectrumBlock);
}
@ -424,8 +476,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
bSpectrumSubBlock = (List<Integer>)map.get(SampleFileHeader.BSPECTRUM.getMessage());
}
bSpectrumBlock.setBSpectrumSubBlock(bSpectrumSubBlock);
bSpectrumBlock.setEnergySpan(gardsSpectrum.getEnergySpan());
bSpectrumBlock.setNumberBChannels(gardsSpectrum.getChannels());
if (Objects.nonNull(gardsSpectrum.getEnergySpan())){
bSpectrumBlock.setEnergySpan(gardsSpectrum.getEnergySpan());
}
if (Objects.nonNull(gardsSpectrum.getChannels())){
bSpectrumBlock.setNumberBChannels(gardsSpectrum.getChannels());
}
}
report.setBSpectrumBlock(bSpectrumBlock);
}
@ -443,10 +499,18 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
histogramSubBlock = (List<HistogramData>)map.get(SampleFileHeader.HISTOGRAM.getMessage());
}
histogramBlock.setHistogramSubBlock(histogramSubBlock);
histogramBlock.setBChannels(gardsHistogram.getBChannels());
histogramBlock.setBEnergySpan(gardsHistogram.getBEnergySpan());
histogramBlock.setGChannels(gardsHistogram.getGChannels());
histogramBlock.setGEnergySpan(gardsHistogram.getGEnergySpan());
if (Objects.nonNull(gardsHistogram.getBChannels())){
histogramBlock.setBChannels(gardsHistogram.getBChannels());
}
if (Objects.nonNull(gardsHistogram.getBEnergySpan())){
histogramBlock.setBEnergySpan(gardsHistogram.getBEnergySpan());
}
if (Objects.nonNull(gardsHistogram.getGChannels())){
histogramBlock.setGChannels(gardsHistogram.getGChannels());
}
if (Objects.nonNull(gardsHistogram.getGEnergySpan())){
histogramBlock.setGEnergySpan(gardsHistogram.getGEnergySpan());
}
}
report.setHistogramBlock(histogramBlock);
}
@ -458,9 +522,16 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
GardsSampleCert gardsSampleCert = gardsSampleCertMapper.selectOne(sampleCertQueryWrapper);
if (Objects.nonNull(gardsSampleCert)) {
certificateBlock = new Certificate();
certificateBlock.setTotalSourceActivity(gardsSampleCert.getQuantity());
certificateBlock.setAssayDate(DateUtils.formatDate(gardsSampleCert.getAssayDate(), "yyyy-MM-dd HH:mm:ss"));
certificateBlock.setUnitsOfActivity(gardsSampleCert.getUnit());
if (Objects.nonNull(gardsSampleCert.getQuantity())){
certificateBlock.setTotalSourceActivity(gardsSampleCert.getQuantity());
}
if (Objects.nonNull(gardsSampleCert.getAssayDate())){
certificateBlock.setAssayDate(DateUtils.formatDate(gardsSampleCert.getAssayDate(), "yyyy-MM-dd HH:mm:ss"));
}
if (StringUtils.isNotBlank(gardsSampleCert.getUnit())){
certificateBlock.setUnitsOfActivity(gardsSampleCert.getUnit());
}
}
LambdaQueryWrapper<GardsSampleCertLine> sampleCertLineQueryWrapper = new LambdaQueryWrapper<>();
sampleCertLineQueryWrapper.eq(GardsSampleCertLine::getSampleId, sampleId);
@ -472,15 +543,33 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
List<CertificateLine> certificateSubBlock = new LinkedList<>();
for (GardsSampleCertLine sampleCertLine:gardsSampleCertLines) {
CertificateLine certificateLine = new CertificateLine();
certificateLine.setNuclideName(sampleCertLine.getNuclName());
certificateLine.setHalfLife(sampleCertLine.getHalflife());
certificateLine.setNuclideActivity(sampleCertLine.getActivity());
certificateLine.setUncertainty(sampleCertLine.getError());
certificateLine.setGenergy(sampleCertLine.getEnergy());
certificateLine.setIntensity(sampleCertLine.getAbundance());
certificateLine.setElectronDecayModeDescriptor(sampleCertLine.getDecayMode());
certificateLine.setMaxBParticleEnergy(sampleCertLine.getBEnergy());
certificateLine.setParticleBIntensity(sampleCertLine.getBAbundance());
if (StringUtils.isNotBlank(sampleCertLine.getNuclName())){
certificateLine.setNuclideName(sampleCertLine.getNuclName());
}
if (StringUtils.isNotBlank(sampleCertLine.getHalflife())){
certificateLine.setHalfLife(sampleCertLine.getHalflife());
}
if (Objects.nonNull(sampleCertLine.getActivity())){
certificateLine.setNuclideActivity(sampleCertLine.getActivity());
}
if (Objects.nonNull(sampleCertLine.getError())){
certificateLine.setUncertainty(sampleCertLine.getError());
}
if (Objects.nonNull(sampleCertLine.getEnergy())){
certificateLine.setGenergy(sampleCertLine.getEnergy());
}
if (Objects.nonNull(sampleCertLine.getAbundance())){
certificateLine.setIntensity(sampleCertLine.getAbundance());
}
if (StringUtils.isNotBlank(sampleCertLine.getDecayMode())){
certificateLine.setElectronDecayModeDescriptor(sampleCertLine.getDecayMode());
}
if (Objects.nonNull(sampleCertLine.getBEnergy())){
certificateLine.setMaxBParticleEnergy(sampleCertLine.getBEnergy());
}
if (Objects.nonNull(sampleCertLine.getBAbundance())){
certificateLine.setParticleBIntensity(sampleCertLine.getBAbundance());
}
certificateSubBlock.add(certificateLine);
}
certificateBlock.setCertificateSubBlock(certificateSubBlock);
@ -495,7 +584,15 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
//获取redis中缓存的台站信息
Map<Integer, String> stationMap = (Map<Integer, String>)redisUtil.get("stationMap");
Page<GardsSampleData> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
if (Objects.isNull(startTime)){
result.error500("开始时间不能为空");
return result;
}
Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
if (Objects.isNull(endTime)){
result.error500("结束时间不能为空");
return result;
}
Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
LambdaQueryWrapper<GardsSampleData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(GardsSampleData::getStationId, stationIds);