fix: 1.新beta增加#b_self_attenuation数据入库;2.修改新beta加载本地能谱保存到数据库报错问题;3.修改SpectrumType类型

This commit is contained in:
xiaoguangbin 2024-12-13 10:44:13 +08:00
parent 0c8a49713a
commit 4b7c2837ad
15 changed files with 222 additions and 14 deletions

View File

@ -32,7 +32,36 @@ public class GardsSelfAttenuation implements Serializable {
@TableField(value = "NUCLIDE_NAME")
private String nuclideName;
// todo 补充三个 氙参数三个 氮参数
/**
* 拟合系数1
*/
@TableField(value = "COEFF1")
private Double coeff1;
/**
* 拟合系数2
*/
@TableField(value = "COEFF2")
private Double coeff2;
/**
* 拟合系数3
*/
@TableField(value = "COEFF3")
private Double coeff3;
/**
* 拟合系数4
*/
@TableField(value = "COEFF4")
private Double coeff4;
/**
* 拟合系数5
*/
@TableField(value = "COEFF5")
private Double coeff5;
/**
* 拟合系数6
*/
@TableField(value = "COEFF6")
private Double coeff6;
@TableField(value = "MODDATE")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -27,7 +27,8 @@ public enum SampleFileHeader {
CERTIFICATE(19,"#Certificate"),
STOP(20,"STOP"),
BEGIN(21,"BEGIN"),
SPECTRUM(22,"#Spectrum");
SPECTRUM(22,"#Spectrum"),
SELF_ATTENUATION(23,"#b_self_Attenuation");
private Integer code;

View File

@ -3,7 +3,10 @@ package org.jeecg.modules.base.enums;
* 谱类型
* */
public enum SpectrumType {
BETA("Beta"), GAMMA("Gamma");
SAMPLE("sample"),
GAS("gas"),
QC("qc"),
DET("det");
SpectrumType(String type) {
this.type = type;

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSelfAttenuation;
public interface GardsSelfAttenuationMapper extends BaseMapper<GardsSelfAttenuation> {
}

View File

@ -0,0 +1,51 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
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.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsSelfAttenuation;
import org.jeecg.modules.mapper.GardsSelfAttenuationMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.BlockConstant;
import org.jeecg.modules.service.ISpectrumBlockService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@DS("ora")
@Service("#b_self_Attenuation")
public class GardsSelfAttenuationServiceImpl extends ServiceImpl<GardsSelfAttenuationMapper, GardsSelfAttenuation> implements ISpectrumBlockService, BlockConstant {
@Override
public void create(EnergySpectrumStruct struct, GardsSampleData sampleData) {
if(struct.b_s_a_nuclide_name.isEmpty()){
return;
}
try {
List<GardsSelfAttenuation> datas = Lists.newLinkedList();
for (int i = 0; i < struct.b_s_a_nuclide_name.size(); i++) {
GardsSelfAttenuation attenuation = new GardsSelfAttenuation();
attenuation.setSampleId(sampleData.getSampleId());
attenuation.setNuclideName(struct.b_s_a_nuclide_name.get(i));
attenuation.setCoeff1(struct.b_s_a_coeff1.get(i));
attenuation.setCoeff2(struct.b_s_a_coeff2.get(i));
attenuation.setCoeff3(struct.b_s_a_coeff3.get(i));
attenuation.setCoeff4(struct.b_s_a_coeff4.get(i));
attenuation.setCoeff5(struct.b_s_a_coeff5.get(i));
attenuation.setCoeff6(struct.b_s_a_coeff6.get(i));
attenuation.setModdate(new Date());
datas.add(attenuation);
}
if(CollectionUtils.isNotEmpty(datas)){
this.saveBatch(datas);
}
} catch (NullPointerException e) {
log.error("#b_self_Attenuation there is empty data present");
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.NumberFormatUtil;
@ -341,7 +342,7 @@ public class Sample_B_Analysis implements BlockConstant {
info.setCollectionDate(collectTime);
info.setDatasource(DSType.ARMDARR.getType());
info.setFullOrPrel(this.sampleData.getSpectralQualifie());
info.setBetaOrGamma(SpectrumType.BETA.getType());
info.setBetaOrGamma(SampleType.BETA.getType());
Map<String,String> nuclides = Maps.newHashMap();
nuclides.put(XE_131m,String.valueOf(analyseResult.Xe131m_con));
nuclides.put(XE_133,String.valueOf(analyseResult.Xe133_con));

View File

@ -15,6 +15,7 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.constant.enums.SpectrumSystemType;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
@ -524,7 +525,8 @@ public class Sample_C_Analysis {
info.setCollectionDate(collectTime);
info.setDatasource(DSType.ARMDARR.getType());
info.setFullOrPrel(this.sampleData.getSpectralQualifie());
info.setBetaOrGamma(SpectrumType.GAMMA.getType());
// todo 需要更换为自建台站类型
info.setBetaOrGamma(SampleType.GAMMA.getType());
Map<String,String> nuclides = Maps.newHashMap();
for (int i=0; i<middleData.nucl_ided_Nuclidename.size(); i++) {
nuclides.put(middleData.nucl_ided_Nuclidename.get(i), middleData.nucl_ided_Concentration.get(i));

View File

@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.constant.enums.SpectrumSystemType;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
@ -300,7 +301,7 @@ public class Sample_G_Analysis {
info.setCollectionDate(collectTime);
info.setDatasource(DSType.ARMDARR.getType());
info.setFullOrPrel(this.sampleData.getSpectralQualifie());
info.setBetaOrGamma(SpectrumType.GAMMA.getType());
info.setBetaOrGamma(SampleType.GAMMA.getType());
Map<String,String> nuclides = Maps.newHashMap();
for (int i=0; i<middleData.nucl_ided_Nuclidename.size(); i++) {
nuclides.put(middleData.nucl_ided_Nuclidename.get(i), middleData.nucl_ided_Concentration.get(i));

View File

@ -473,6 +473,23 @@ public class EnergySpectrumStruct {
public int t_record_count;
/************************* b_self_Attenuation Block ******************/
/**
* 核素名称
*/
public List<String> b_s_a_nuclide_name;
/**
* 系数
*/
public List<Double> b_s_a_coeff1;
public List<Double> b_s_a_coeff2;
public List<Double> b_s_a_coeff3;
public List<Double> b_s_a_coeff4;
public List<Double> b_s_a_coeff5;
public List<Double> b_s_a_coeff6;
public EnergySpectrumStruct() {
super();
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.original.GardsSelfAttenuation;
public interface GardsSelfAttenuationMapper extends BaseMapper<GardsSelfAttenuation> {
}

View File

@ -0,0 +1,9 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.original.GardsSelfAttenuation;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
public interface IGardsSelfAttenuationService extends IService<GardsSelfAttenuation> {
void create(EnergySpectrumStruct struct, Integer sampleId);
}

View File

@ -26,6 +26,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.constant.RedisConstant;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.properties.TaskProperties;
@ -4890,7 +4891,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
info.setCollectionDate(collectTime);
info.setDatasource(DSType.ARMDRRR.getType());
info.setFullOrPrel(phd.getHeader().getSpectrum_quantity());
info.setBetaOrGamma(SpectrumType.GAMMA.getType());
info.setBetaOrGamma(SampleType.GAMMA.getType());
Map<String,String> nuclides = Maps.newHashMap();
for (int i=0; i<middleData.nucl_ided_Nuclidename.size(); i++) {
nuclides.put(middleData.nucl_ided_Nuclidename.get(i), middleData.nucl_ided_Concentration.get(i));

View File

@ -0,0 +1,50 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
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.GardsSampleData;
import org.jeecg.modules.base.entity.original.GardsSelfAttenuation;
import org.jeecg.modules.mapper.GardsSelfAttenuationMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.IGardsSelfAttenuationService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@DS("ora")
@Service
public class GardsSelfAttenuationServiceImpl extends ServiceImpl<GardsSelfAttenuationMapper, GardsSelfAttenuation> implements IGardsSelfAttenuationService {
@Override
public void create(EnergySpectrumStruct struct, Integer sampleId) {
if(struct.b_s_a_nuclide_name.isEmpty()){
return;
}
try {
List<GardsSelfAttenuation> datas = Lists.newLinkedList();
for (int i = 0; i < struct.b_s_a_nuclide_name.size(); i++) {
GardsSelfAttenuation attenuation = new GardsSelfAttenuation();
attenuation.setSampleId(sampleId);
attenuation.setNuclideName(struct.b_s_a_nuclide_name.get(i));
attenuation.setCoeff1(struct.b_s_a_coeff1.get(i));
attenuation.setCoeff2(struct.b_s_a_coeff2.get(i));
attenuation.setCoeff3(struct.b_s_a_coeff3.get(i));
attenuation.setCoeff4(struct.b_s_a_coeff4.get(i));
attenuation.setCoeff5(struct.b_s_a_coeff5.get(i));
attenuation.setCoeff6(struct.b_s_a_coeff6.get(i));
attenuation.setModdate(new Date());
datas.add(attenuation);
}
if(CollectionUtils.isNotEmpty(datas)){
this.saveBatch(datas);
}
} catch (NullPointerException e) {
log.error("#b_self_Attenuation there is empty data present");
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -26,6 +26,8 @@ import org.jeecg.common.constant.RedisConstant;
import org.jeecg.common.constant.SelfStationConstant;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.constant.enums.FileTypeEnum;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.constant.enums.SpectrumSystemType;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
@ -125,6 +127,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
@Autowired
private IGardsSpectrumSpectrumService spectrumService;
@Autowired
private IGardsSelfAttenuationService gardsSelfAttenuationService;
@Autowired
private IGardsCalibrationPairsSpectrumService calibrationPairsSpectrumService;
@Autowired
private IGardsCalibrationSpectrumService calibrationSpectrumService;
@ -5524,22 +5528,24 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
BeanUtils.copyProperties(phdFiles.get(0), phd);
GardsSampleDataSpectrum sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleInputFileName);
phd.setId_sample(sampleData.getSampleId().toString());
if (null != sampleData) {
phd.setId_sample(sampleData.getSampleId().toString());
}
// 判断文件是否存储过 如果没有则解析文件并进行存储
if (!this.OriginalDataStore(sampleStruct, sampleFilePathName) ){
if (!this.OriginalDataStore(selfStationData, SpectrumType.SAMPLE.getType(), sampleFilePathName) ){
result.error500("sampleFile save failed");
return result;
}
if (StrUtil.isNotBlank(detFilePathName)){
if (!this.OriginalDataStore(detStruct, detFilePathName) ){
if (!this.OriginalDataStore(selfStationData, SpectrumType.DET.getType(), detFilePathName) ){
result.error500("detFile save failed");
return result;
}
detId = spectrumAnalysisMapper.getSampleId(detFilePathName);
}
if (StringUtils.isNotBlank(qcFilePathName)) {
if (!this.OriginalDataStore(qcStruct, qcFilePathName) ){
if (!this.OriginalDataStore(selfStationData, SpectrumType.QC.getType(), qcFilePathName) ){
result.error500("qcFile save failed");
return result;
}
@ -5730,7 +5736,8 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
}
@Transactional
public boolean OriginalDataStore(EnergySpectrumStruct sourceData, String filePathName) {
public boolean OriginalDataStore(SelfStationData selfStationData, String type, String filePathName) {
//根据新的文件路径名称查询数据是否存在
GardsSampleData isExist = spectrumAnalysisMapper.findSampleByFile(filePathName);
//如果数据已经存入过数据库 修改状态后返回
@ -5740,7 +5747,25 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
return true;
}
//读取文件内容
File file = new File(filePathName);
File file = null;
EnergySpectrumStruct sourceData = null;
switch (type) {
case "sample" :
sourceData = selfStationData.getSampleStruct();
file = new File(selfStationData.getSampleTmpPath());
break;
case "qc":
sourceData = selfStationData.getQcStruct();
file = new File(selfStationData.getQcFileName());
break;
case "det":
sourceData = selfStationData.getDetStruct();
file = new File(selfStationData.getDetFileName());
break;
default:
throw new RuntimeException();
}
try {
//获取文件中块名信息
List<String> readLines = getFileBlockList(file);
@ -5784,6 +5809,9 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf
histogramService.saveHistogram(sourceData, sampleId, filePathName);
}
// todo beta 卡出来的gammaROi数据是否要存入表中
if (readLines.contains(SampleFileHeader.SELF_ATTENUATION.getMessage())){
gardsSelfAttenuationService.create(sourceData, sampleId);
}
return true;
} catch (Exception e) {
throw new RuntimeException(e);

View File

@ -23,6 +23,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.BetaCache;
import org.jeecg.common.constant.DateConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.constant.enums.SampleType;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
@ -4607,7 +4608,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
info.setCollectionDate(collectTime);
info.setDatasource(DSType.ARMDRRR.getType());
info.setFullOrPrel(betaDataFile.getSampleStruct().spectrum_quantity);
info.setBetaOrGamma(SpectrumType.BETA.getType());
info.setBetaOrGamma(SampleType.BETA.getType());
Map<String,String> nuclides = Maps.newHashMap();
for (int i=0; i< betaDataFile.getXeDataList().size(); i++) {
GardsXeResults xeResults = betaDataFile.getXeDataList().get(i);