Merge remote-tracking branch 'origin/SelfStation' into SelfStation
# Conflicts: # jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java
This commit is contained in:
commit
bead8100e7
|
@ -4,10 +4,30 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
public enum SampleFileHeader {
|
||||
|
||||
HEADER(0,"#Header"),COMMENT(1,"#Comment"),COLLECTION(2,"#Collection"),ACQUISITION(3,"#Acquisition"),PROCESSING(4,"#Processing"),SAMPLE(5,"#Sample"),
|
||||
GENERGY(6,"#g_Energy"),BENERGY(7,"#b_Energy"),GRESOLUTION(8,"#g_Resolution"),BRESOLUTION(9,"#b_Resolution"),GEFFICIENCY(10,"#g_Efficiency"),
|
||||
ROILIMITS(11,"#ROI_Limits"),BGEFFICIENCY(12,"#b-gEfficiency"),TOTALEFF(13,"#TotalEff"),RATIOS(14,"#Ratios"),GSPECTRUM(15,"#g_Spectrum"),BSPECTRUM(16,"#b_Spectrum"),
|
||||
HISTOGRAM(17,"#Histogram"),CALIBRATION(18,"#Calibration"),CERTIFICATE(19,"#Certificate"),STOP(20,"STOP"),BEGIN(21,"BEGIN"),SPECTRUM(22,"#Spectrum");
|
||||
HEADER(0,"#Header"),
|
||||
COMMENT(1,"#Comment"),
|
||||
COLLECTION(2,"#Collection"),
|
||||
ACQUISITION(3,"#Acquisition"),
|
||||
PROCESSING(4,"#Processing"),
|
||||
SAMPLE(5,"#Sample"),
|
||||
GENERGY(6,"#g_Energy"),
|
||||
BENERGY(7,"#b_Energy"),
|
||||
GRESOLUTION(8,"#g_Resolution"),
|
||||
BRESOLUTION(9,"#b_Resolution"),
|
||||
GEFFICIENCY(10,"#g_Efficiency"),
|
||||
BEFFICIENCY(23,"#b_Efficiency"), // 20240801 自建台站增加
|
||||
ROILIMITS(11,"#ROI_Limits"),
|
||||
BGEFFICIENCY(12,"#b-gEfficiency"),
|
||||
TOTALEFF(13,"#TotalEff"),
|
||||
RATIOS(14,"#Ratios"),
|
||||
GSPECTRUM(15,"#g_Spectrum"),
|
||||
BSPECTRUM(16,"#b_Spectrum"),
|
||||
HISTOGRAM(17,"#Histogram"),
|
||||
CALIBRATION(18,"#Calibration"),
|
||||
CERTIFICATE(19,"#Certificate"),
|
||||
STOP(20,"STOP"),
|
||||
BEGIN(21,"BEGIN"),
|
||||
SPECTRUM(22,"#Spectrum");
|
||||
|
||||
private Integer code;
|
||||
|
||||
|
|
|
@ -248,6 +248,22 @@ public class EnergySpectrumStruct {
|
|||
|
||||
public int g_e_record_count;
|
||||
|
||||
/************************* g_Efficiency Block ******************/
|
||||
/**
|
||||
* β -energy (keV)
|
||||
*/
|
||||
public List<Double> b_e_energy;
|
||||
/**
|
||||
* efficiency (counts in peak/photon emitted)
|
||||
*/
|
||||
public List<Double> b_e_efficiency;
|
||||
/**
|
||||
* uncertainty (counts in peak/photon emitted)
|
||||
*/
|
||||
public List<Double> b_e_uncertainty;
|
||||
|
||||
public int b_e_record_count;
|
||||
|
||||
/************************* ROI_Limits Block ******************/
|
||||
/**
|
||||
* ROI number
|
||||
|
|
|
@ -1079,7 +1079,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
|||
detailedMap.put("systemType", struct.system_type);
|
||||
detailedMap.put("dataType", dataType);
|
||||
detailedMap.put("spectralQualifier", struct.spectrum_quantity);
|
||||
detailedMap.put("SRID", struct.sample_ref_id);
|
||||
// detailedMap.put("SRID", struct.sample_ref_id);
|
||||
detailedMap.put("status", status);
|
||||
detailedMap.put("collectionStart", CollectionStart);
|
||||
detailedMap.put("collectionStop", CollectionStop);
|
||||
|
@ -1088,7 +1088,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
|||
if (Objects.nonNull(CollectionStart) && Objects.nonNull(CollectionStop)) {
|
||||
timeSpan = (CollectionStop.getTime()/1000 - CollectionStart.getTime()/1000) / 3600.0;
|
||||
}
|
||||
detailedMap.put("samplingTime", String.format("%.2f", timeSpan));
|
||||
// detailedMap.put("samplingTime", String.format("%.2f", timeSpan));
|
||||
detailedMap.put("airVolume", String.format("%.5f", airVolume));
|
||||
detailedMap.put("xeVolume", String.format("%.5f", xeVolume));
|
||||
detailedMap.put("yeild", xeCollectionYield);
|
||||
|
@ -1101,9 +1101,11 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
|||
if (Objects.nonNull(AcquisitionStart) && Objects.nonNull(CollectionStop)) {
|
||||
timespan = (AcquisitionStart.getTime()/1000 - CollectionStop.getTime()/1000);
|
||||
}
|
||||
detailedMap.put("acquisitionDecayTime", String.format("%.2f", timespan / 3600.0));
|
||||
// detailedMap.put("acquisitionDecayTime", String.format("%.2f", timespan / 3600.0));
|
||||
// todo 分级暂时定为1
|
||||
detailedMap.put("category", "1");
|
||||
detailedMap.put("lat", struct.lat);
|
||||
detailedMap.put("lon", struct.lon);
|
||||
return detailedMap;
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -58,12 +58,13 @@ public class SelfStationController {
|
|||
|
||||
@PutMapping("updateROI")
|
||||
@ApiOperation(value = "更新ROI范围", notes = "更新ROI范围")
|
||||
public Result updateROI(@RequestParam String roiParams, @RequestParam String sampleFileName, HttpServletRequest request) {
|
||||
public Result updateROI(@RequestParam String roiParams, @RequestParam String sampleFileName,
|
||||
@RequestParam String dataType, HttpServletRequest request) {
|
||||
if (StrUtil.isBlank(roiParams)) {
|
||||
return Result.error("roiParams cannot be empty!");
|
||||
}
|
||||
List<ROIParam> roiParamList = JSONArray.parseArray(roiParams, ROIParam.class);
|
||||
return selfStationService.updateROI(roiParamList, sampleFileName, request);
|
||||
return selfStationService.updateROI(roiParamList, sampleFileName, dataType, request);
|
||||
}
|
||||
|
||||
@GetMapping("energyCalibration")
|
||||
|
|
|
@ -9,12 +9,11 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
public class SelfStationData implements Serializable {
|
||||
|
||||
/********************************* 基本数据信息 *********************************/
|
||||
/**
|
||||
* sample临时文件路径
|
||||
*/
|
||||
private String sampleTmpPath;
|
||||
|
||||
/**
|
||||
* det临时文件路径
|
||||
*/
|
||||
|
@ -25,6 +24,32 @@ public class SelfStationData implements Serializable {
|
|||
*/
|
||||
private String qcTmpPath;
|
||||
|
||||
private String sampleFilePathName;
|
||||
|
||||
private String sampleFileName;
|
||||
|
||||
private String gasFilePathName;
|
||||
|
||||
private String gasFileName;
|
||||
|
||||
private String detFilePathName;
|
||||
|
||||
private String detFileName;
|
||||
|
||||
private String qcFilePathName;
|
||||
|
||||
private String qcFileName;
|
||||
|
||||
private String sampleId;
|
||||
|
||||
private String stationId;
|
||||
|
||||
private String detectorId;
|
||||
|
||||
private boolean bProcessed;
|
||||
|
||||
private boolean saveAnalysisResult;
|
||||
|
||||
/**
|
||||
* sample文件分析内容
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,7 @@ public interface ISelfStationService {
|
|||
|
||||
Result updateROI(Integer startChannel, Integer endChannel, Integer ROINum, String sampleFileName, HttpServletRequest request);
|
||||
|
||||
Result updateROI(List<ROIParam> roiParams, String sampleFileName, HttpServletRequest request);
|
||||
Result updateROI(List<ROIParam> roiParams, String sampleFileName, String dataType, HttpServletRequest request);
|
||||
|
||||
Result energyCalibration(String fileName, String currentText, Double width, HttpServletRequest request);
|
||||
|
||||
|
|
|
@ -74,6 +74,20 @@ public class GardsCalibrationPairsOrigSpectrumServiceImpl extends ServiceImpl<Ga
|
|||
calibrationPairsOrigList.add(calibrationPairsOrig);
|
||||
}
|
||||
}
|
||||
if (readLines.contains(SampleFileHeader.BEFFICIENCY.getMessage())){
|
||||
for (int i=0; i<sourceData.g_e_record_count; i++){
|
||||
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
|
||||
calibrationPairsOrig.setSampleId(sampleId);
|
||||
calibrationPairsOrig.setSampleType(SystemType.BETA.getType());
|
||||
calibrationPairsOrig.setCaltype(CalType.EFFICIENCY_CAL.getType());
|
||||
calibrationPairsOrig.setInput("PHD");
|
||||
calibrationPairsOrig.setIdCalPoint(i);
|
||||
calibrationPairsOrig.setXValue(sourceData.b_e_energy.get(i));
|
||||
calibrationPairsOrig.setYValue(sourceData.b_e_efficiency.get(i));
|
||||
calibrationPairsOrig.setUncYValue(sourceData.b_e_uncertainty.get(i));
|
||||
calibrationPairsOrigList.add(calibrationPairsOrig);
|
||||
}
|
||||
}
|
||||
if (readLines.contains(SampleFileHeader.BRESOLUTION.getMessage())){
|
||||
for (int i=0; i<sourceData.b_r_record_count; i++){
|
||||
GardsCalibrationPairsOrig calibrationPairsOrig = new GardsCalibrationPairsOrig();
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jeecg.modules.base.entity.original.GardsSampleData;
|
|||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalysisRoi;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsAnalySetting;
|
||||
import org.jeecg.modules.base.enums.SampleFileHeader;
|
||||
import org.jeecg.modules.entity.GardsSampleDataSpectrum;
|
||||
import org.jeecg.modules.entity.GardsXeResultsSpectrum;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
|
@ -107,6 +108,10 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
@Autowired
|
||||
private IGardsTotalEfficiencyPairsSpectrumService totalEfficiencyPairsSpectrumService;
|
||||
@Autowired
|
||||
private IGardsRoiLimitsSpectrumService roiLimitsSpectrumService;
|
||||
@Autowired
|
||||
private IGardsHistogramSpectrumService histogramService;
|
||||
@Autowired
|
||||
private IGardsSpectrumSpectrumService spectrumService;
|
||||
@Autowired
|
||||
private IGardsCalibrationPairsSpectrumService calibrationPairsSpectrumService;
|
||||
|
@ -311,12 +316,15 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + StringPool.DASH + userName);
|
||||
//判断缓存是否为空
|
||||
if (Objects.isNull(selfStationData)) {
|
||||
//拼接sample文件路径
|
||||
String sampleFilePath = path + StringPool.SLASH + sampleFileName;
|
||||
//初始化自建台站数据对象
|
||||
selfStationData = new SelfStationData();
|
||||
// 是否存储过beta数据
|
||||
BetaDataFile betaDataFile = Objects.isNull(selfStationData.getBetaDataFile()) ? new BetaDataFile() : selfStationData.getBetaDataFile();
|
||||
|
||||
//判断sample文件名是否为空
|
||||
if (StringUtils.isNotBlank(sampleFileName)) {
|
||||
//拼接sample文件路径
|
||||
String sampleFilePath = path + StringPool.SLASH + sampleFileName;
|
||||
//返回结果map
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//获取sample分析后的对象
|
||||
|
@ -324,6 +332,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
if (Objects.nonNull(struct)) {
|
||||
selfStationData.setSampleStruct(struct);
|
||||
selfStationData.setSampleTmpPath(sampleFilePath);
|
||||
selfStationData.setSampleFileName(sampleFileName);
|
||||
selfStationUtil.loadFile(selfStationData, null, null, "sample", map);
|
||||
|
||||
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
|
||||
|
@ -370,6 +379,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
if (Objects.nonNull(struct)) {
|
||||
selfStationData.setDetStruct(struct);
|
||||
selfStationData.setDetTmpPath(detFilePath);
|
||||
selfStationData.setDetFileName(detFileName);
|
||||
selfStationUtil.loadFile(selfStationData, null, null, "det", map);
|
||||
resultMap.put("det", map);
|
||||
}
|
||||
|
@ -385,6 +395,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
if (Objects.nonNull(struct)) {
|
||||
selfStationData.setQcStruct(struct);
|
||||
selfStationData.setQcTmpPath(qcFilePath);
|
||||
selfStationData.setQcFileName(qcFileName);
|
||||
selfStationUtil.loadFile(selfStationData, null, null, "qc", map);
|
||||
resultMap.put("qc", map);
|
||||
}
|
||||
|
@ -622,7 +633,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result updateROI(List<ROIParam> roiParams, String sampleFileName, HttpServletRequest request) {
|
||||
public Result updateROI(List<ROIParam> roiParams, String sampleFileName, String dataType, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//获取用户名
|
||||
|
@ -635,7 +646,24 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
result.error500("Load basic file information first!");
|
||||
return result;
|
||||
}
|
||||
EnergySpectrumStruct struct = selfStationData.getSampleStruct();
|
||||
if (StrUtil.isBlank(dataType)) {
|
||||
result.error500("Update failed!");
|
||||
return result;
|
||||
}
|
||||
EnergySpectrumStruct struct = null;
|
||||
switch (dataType) {
|
||||
case "SAMPLEPHD":
|
||||
struct = selfStationData.getSampleStruct();
|
||||
break;
|
||||
case "QCPHD":
|
||||
struct = selfStationData.getQcStruct();
|
||||
break;
|
||||
case "DETPHD":
|
||||
struct = selfStationData.getDetStruct();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (ROIParam roiParam : roiParams) {
|
||||
Integer ROINum = roiParam.getRoiNum();
|
||||
Map<String, Object> resultMap = selfStationUtil.statisticsROIList(roiParam.getStartChannel(), roiParam.getEndChannel(),
|
||||
|
@ -4853,12 +4881,14 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
result.error500("Please first Reprocessing!");
|
||||
return result;
|
||||
}
|
||||
BetaDataFile betaDataFile = selfStationData.getBetaDataFile();
|
||||
//获取当前操作的台站的id
|
||||
EnergySpectrumStruct sampleStruct = selfStationData.getSampleStruct();
|
||||
EnergySpectrumStruct qcStruct = selfStationData.getQcStruct();
|
||||
EnergySpectrumStruct detStruct = selfStationData.getDetStruct();
|
||||
String siteCode = sampleStruct.site_code;
|
||||
Integer stationId = spectrumAnalysisMapper.getStationId(siteCode);
|
||||
Integer sampleId = null, gasId = null, detId = null, qcId = null;
|
||||
//判断当前分析员当天是否有对应台站的排班任务
|
||||
List<String> userStation = userTaskUtil.findUserStation(userName);
|
||||
boolean bAnalysisResultWriteAuthority = userStation.contains(String.valueOf(stationId));
|
||||
|
@ -4904,6 +4934,30 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
result.error500("Transform PHDFile into structGStoreMiddleProcessData failed.");
|
||||
return result;
|
||||
}
|
||||
|
||||
//处理文件名称
|
||||
String sampleFilePathName = selfStationData.getSampleFilePathName();
|
||||
String detFilePathName = selfStationData.getDetFilePathName();
|
||||
String qcFilePathName = selfStationData.getQcFilePathName();
|
||||
String sampleTmpPath = selfStationData.getSampleTmpPath();
|
||||
String detTmpPath = selfStationData.getDetTmpPath();
|
||||
String qcTmpPath = selfStationData.getQcTmpPath();
|
||||
|
||||
//根据sample文件名称模糊查询sampleId
|
||||
String sampleFilePath = "", qcFilePath = "", detFilePath = "";
|
||||
if (StringUtils.isNotBlank(sampleFilePathName)) {
|
||||
sampleFilePath = StrUtil.subBefore(sampleFilePathName, StringPool.SLASH, true);
|
||||
sampleFilePathName = phdFileUtil.NameStandardBy(sampleFilePath, sampleFilePathName);
|
||||
}
|
||||
if (StringUtils.isNotBlank(detFilePathName)) {
|
||||
detFilePath = StrUtil.subBefore(detFilePathName, StringPool.SLASH, true);
|
||||
detFilePathName = phdFileUtil.NameStandardBy(detFilePath, detFilePathName);
|
||||
}
|
||||
if (StringUtils.isNotBlank(qcFilePathName)) {
|
||||
qcFilePath = StrUtil.subBefore(qcFilePathName, StringPool.SLASH, true);
|
||||
qcFilePathName = phdFileUtil.NameStandardBy(qcFilePath, qcFilePathName);
|
||||
}
|
||||
|
||||
// 读取参数内容
|
||||
Map<String, CalMDCInfo> mdcInfoMap1 = phdFile1.getMdcInfoMap();
|
||||
Map<String, CalMDCInfo> mdcInfoMap2 = phdFile2.getMdcInfoMap();
|
||||
|
@ -4920,14 +4974,25 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
phd.setStatus(sampleData.getStatus());
|
||||
} else {
|
||||
// 如果sampleData为空 存储数据
|
||||
bRet = SaveSampleToDB(phd, sampleInputFileName);
|
||||
if (!bRet) {
|
||||
result.error500("The Database hasn't this Spectrum(" + saveFileName + ") and Insert it to Database failed.");
|
||||
//判断文件是否存储过 如果没有则解析文件并进行存储
|
||||
if (!this.OriginalDataStore(sampleStruct, sampleTmpPath, sampleFilePathName) ){
|
||||
result.error500("sampleFile save failed");
|
||||
return result;
|
||||
}
|
||||
if (!this.OriginalDataStore(detStruct, detTmpPath, detFilePathName) ){
|
||||
result.error500("detFile save failed");
|
||||
return result;
|
||||
}
|
||||
if (StringUtils.isNotBlank(qcFilePathName)) {
|
||||
if (!this.OriginalDataStore(qcStruct, qcTmpPath, qcFilePathName) ){
|
||||
result.error500("qcFile save failed");
|
||||
return result;
|
||||
}
|
||||
qcId = spectrumAnalysisMapper.getSampleId(qcFilePathName);
|
||||
}
|
||||
sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleInputFileName);
|
||||
}
|
||||
Integer sampleId = sampleData.getSampleId();
|
||||
sampleId = sampleData.getSampleId();
|
||||
// 根据sampleId 查询idAnalysis
|
||||
String idAnalysisStr = spectrumAnalysisMapper.getIdAnalysisByIdAnalyst(sampleId.toString(), userName);
|
||||
Integer idAnalysis = StrUtil.isBlank(idAnalysisStr) ? null : Integer.valueOf(idAnalysisStr);
|
||||
|
@ -4979,12 +5044,24 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
analysisManService.saveAnalySettingROI(sampleId, idAnalysis, phdFiles);
|
||||
// 向 RNMAN.GARDS_MDC 表写入 MDC计算结果
|
||||
analysisManService.saveMDCROI(sampleId, mdcInfoMaps, idAnalysis);
|
||||
if (bRet) {
|
||||
try {
|
||||
// 存储PHD文件
|
||||
if (StringUtils.isNotBlank(sampleFilePathName)){
|
||||
savePHDFileToDir(sampleTmpPath, sampleFilePathName);
|
||||
}
|
||||
if (StringUtils.isNotBlank(detFilePathName)){
|
||||
savePHDFileToDir(detTmpPath, detFilePathName);
|
||||
}
|
||||
if (StringUtils.isNotBlank(qcFilePathName)){
|
||||
savePHDFileToDir(qcTmpPath, qcFilePathName);
|
||||
}
|
||||
phd.setStatus("R");
|
||||
//分析成功后存储日志文件和报告文件
|
||||
for (GStoreMiddleProcessData middleData : middleDatas) {
|
||||
String logFileName = middleData.analyses_absolute_LogPath.substring(middleData.analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1);
|
||||
String rptFileName = middleData.analyses_absolute_ReportPath.substring(middleData.analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1)+".txt";
|
||||
String logFileName = selfStationData.getSampleFileName().replace("PHD", "log");
|
||||
// String logFileName = middleData.analyses_absolute_LogPath.substring(middleData.analyses_absolute_LogPath.lastIndexOf(StringPool.SLASH)+1);
|
||||
// String rptFileName = middleData.analyses_absolute_ReportPath.substring(middleData.analyses_absolute_ReportPath.lastIndexOf(StringPool.SLASH)+1)+".txt";
|
||||
String rptFileName = StrUtil.subBefore(middleData.analyses_absolute_ReportPath, StringPool.SLASH, true) + ".txt";
|
||||
File logFile = new File(logFileName);
|
||||
File rptFile = new File(rptFileName);
|
||||
try {
|
||||
|
@ -5002,9 +5079,9 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
rptFile.delete();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.error500("Save analysis results to DB failed.");
|
||||
return result;
|
||||
// 存储报告文件
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//更新detial Information
|
||||
|
@ -5020,7 +5097,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
map.put("sample", detailedInfo);
|
||||
map.put("qc", qcDetailedInfo);
|
||||
map.put("det", detDetailedInfo);
|
||||
//发送数据到redis
|
||||
//todo 发送数据到redis
|
||||
/*middleData.setSample_stationID(String.valueOf(stationId));
|
||||
middleData.setSample_id(String.valueOf(phd.getId_sample()));
|
||||
pushToRedis(middleData, phd);*/
|
||||
|
@ -5029,6 +5106,97 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将PHD文件保存到对应的savefile目录下
|
||||
* @param fileTmpPath 临时文件
|
||||
* @param filePath 存储目录
|
||||
* @throws Exception
|
||||
*/
|
||||
void savePHDFileToDir(String fileTmpPath, String filePath) throws Exception{
|
||||
//sample文件的saveFile存储路径
|
||||
String saveSamplePath = spectrumPathProperties.getRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath;
|
||||
if (StringUtils.isNotBlank(fileTmpPath) && !saveSamplePath.equals(fileTmpPath.replace(StringPool.BACK_SLASH, StringPool.SLASH))) {
|
||||
File sampleTmp = new File(fileTmpPath);
|
||||
ftpUtil.saveFile(saveSamplePath, new FileInputStream(sampleTmp));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean OriginalDataStore(EnergySpectrumStruct sourceData, String tmpPath, String filePathName) {
|
||||
//根据新的文件路径名称查询数据是否存在
|
||||
GardsSampleData isExist = spectrumAnalysisMapper.findSampleByFile(filePathName);
|
||||
//如果数据已经存入过数据库 则 修改状态后返回
|
||||
if (Objects.nonNull(isExist)){
|
||||
//如果文件已经存入过数据库则修改状态
|
||||
spectrumAnalysisMapper.updateAnalysesStatus(filePathName);
|
||||
return true;
|
||||
}
|
||||
//读取文件内容
|
||||
File file = new File(tmpPath);
|
||||
try {
|
||||
//获取文件中块名信息
|
||||
List<String> readLines = getFileBlockList(file);
|
||||
//查询台站id
|
||||
Integer stationId = spectrumAnalysisMapper.getStationId(sourceData.site_code);
|
||||
Integer detectorId = spectrumAnalysisMapper.getDetectorId(sourceData.detector_code);
|
||||
if(Objects.isNull(stationId) || Objects.isNull(detectorId)) {
|
||||
String error = "get station_id or detect_id error";
|
||||
return false;
|
||||
}
|
||||
// betaDataFile.setDetectorId(detectorId.toString());
|
||||
//新增Gards_Sample_Data表数据
|
||||
sampleDataSpectrumService.saveSampleData(sourceData, stationId, detectorId, filePathName, readLines);
|
||||
//获取sampleId
|
||||
Integer sampleId = spectrumAnalysisMapper.getSampleId(filePathName);
|
||||
//存储Gards_Sample_Aux表数据
|
||||
sampleAuxSpectrumService.saveSampleAux(sourceData, sampleId, readLines);
|
||||
//判断文件是否包含Comment块 新增Gards_Description数据
|
||||
if (readLines.contains(SampleFileHeader.COMMENT.getMessage())){
|
||||
sampleDescriptionSpectrumService.saveSampleDescription(sourceData, sampleId);
|
||||
}
|
||||
//判断文件是否包含Certificate块 新增Gards_Sample_Cert数据
|
||||
if (readLines.contains(SampleFileHeader.CERTIFICATE.getMessage())){
|
||||
sampleCertSpectrumService.saveSampleCert(sourceData, sampleId);
|
||||
sampleCertLineSpectrumService.saveSampleCertLine(sourceData, sampleId);
|
||||
}
|
||||
// #g_Energy、#b_Energy、#g_Efficiency #b_Efficiency、#b_Resolution、#g_Resolution 新增Gards_Calibration_Pairs_Orig数据
|
||||
calibrationPairsOrigSpectrumService.saveGardsCalibrationPairsOrig(sourceData, sampleId, readLines);
|
||||
//判断文件是否包含TotalEff块 新增Gards_Sample_Cert数据
|
||||
if (readLines.contains(SampleFileHeader.TOTALEFF.getMessage())){
|
||||
totalEfficiencyPairsSpectrumService.saveTotalEfficiencyPairs(sourceData, sampleId);
|
||||
}
|
||||
//判断是否包含ROI_Limits块 新增Gards_ROI_Limits数据
|
||||
if (readLines.contains(SampleFileHeader.ROILIMITS.getMessage())){
|
||||
roiLimitsSpectrumService.saveRoiLimits(sourceData, sampleId);
|
||||
}
|
||||
//新增Gards_Spectrum数据
|
||||
spectrumService.saveSpectrum(sourceData, sampleId, readLines, filePathName);
|
||||
//判断是否包含Histogram块 新增Gards_Histogram数据
|
||||
if (readLines.contains(SampleFileHeader.HISTOGRAM.getMessage())){
|
||||
histogramService.saveHistogram(sourceData, sampleId, filePathName);
|
||||
}
|
||||
// todo beta 卡出来的gammaROi数据是否要存入表中?
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public List<String> getFileBlockList(File file) {
|
||||
List<String> readLines = new LinkedList<>();
|
||||
try {
|
||||
List<String> allLines = FileUtils.readLines(file, "UTF-8");
|
||||
for (String line:allLines) {
|
||||
if (line.contains("#")){
|
||||
readLines.add(line);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return readLines;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@DS("ora")
|
||||
public Result<?> viewARR(Integer sampleId, HttpServletResponse response) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user