自建台站新增initValue方法

自建台站新增暂时数据库加载数据方法
This commit is contained in:
qiaoqinzheng 2024-01-26 15:21:34 +08:00
parent a730178204
commit 071e9690c6
4 changed files with 129 additions and 2 deletions

View File

@ -20,6 +20,18 @@ public class SelfStationController {
@Autowired
private ISelfStationService selfStationService;
@GetMapping("initValue")
@ApiOperation(value = "预加载谱文件数据", notes = "预加载谱文件数据")
public Result initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName, HttpServletRequest request) {
return selfStationService.initValue(dbName, sampleId, analyst, sampleFileName, detFileName, request);
}
@GetMapping("loadFromDB")
@ApiOperation(value = "从数据库加载自建台站数据", notes = "从数据库加载自建台站数据")
public Result loadFromDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
return selfStationService.loadFromDB(dbName, sampleId, analyst, request);
}
@GetMapping("loadFromFile")
@ApiOperation(value = "从文件加载自建台站谱数据", notes = "从文件加载自建台站谱数据")
public Result loadFromFile(String sampleFileName, String detFileName, HttpServletRequest request) {

View File

@ -10,6 +10,10 @@ import java.util.List;
public interface ISelfStationService {
Result initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName, HttpServletRequest request);
Result loadFromDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
Result loadSelfStationByFile(String sampleFileName, String detFileName, HttpServletRequest request);
void deleteSelfStationCache(String sampleFileName, HttpServletRequest request);

View File

@ -13,7 +13,9 @@ import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.FTPUtil;
import org.jeecg.common.util.PHDFileUtil;
import org.jeecg.common.util.SelfStationUtil;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
@ -40,6 +42,115 @@ public class SelfStationServiceImpl implements ISelfStationService {
private SelfStationUtil selfStationUtil;
@Autowired
private SelfCache selfStationCache;
@Autowired
private SpectrumAnalysisMapper spectrumAnalysisMapper;
@Override
public Result initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName, HttpServletRequest request) {
if (StringUtils.isNotBlank(dbName) && Objects.nonNull(sampleId)) {
return loadFromDB(dbName, sampleId, analyst, request);
} else {
return loadSelfStationByFile(sampleFileName, detFileName, request);
}
}
@Override
public Result loadFromDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
Result result = new Result();
Map<String, Map<String, Object>> resultMap = new HashMap<>();
//获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//获取自建台站缓存信息
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
//判断sampleId是否为空
if (Objects.isNull(sampleId)){
result.error500("Please select a piece of data");
return result;
}
//查询分析id相关的分析结果
Integer analysisID = null;
if (dbName.equalsIgnoreCase("auto")){
dbName = "RNAUTO";
analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO");
} else if (dbName.equalsIgnoreCase("man")){
dbName = "RNMAN";
analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, analyst);
}
try {
//查询数据库文件信息
SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId, analysisID);
//判断数据库分析结果基础信息是否为空
if (Objects.nonNull(dbSpectrumFilePath)) {
//获取sample相关信息
GardsSampleData sample = null;
String sampleFileName = "";
if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())) {
sample = spectrumAnalysisMapper.findSampleByFilePath(dbSpectrumFilePath.getSampleFilePath());
sampleFileName = dbSpectrumFilePath.getSampleFilePath().substring(dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH) + 1);
}
//获取det相关信息
GardsSampleData detBg = null;
String detFileName = "";
if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) {
detBg = spectrumAnalysisMapper.findSampleByFilePath(dbSpectrumFilePath.getDetBgFilePath());
detFileName = dbSpectrumFilePath.getDetBgFilePath().substring(dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)+1);
}
//从缓存中获取公用变量的数据
SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + "-" + userName);
if (Objects.isNull(selfStationData)) {
//初始化自建台站数据对象
selfStationData = new SelfStationData();
//判断sample文件名是否为空
if (Objects.nonNull(sample)) {
//拼接sample文件路径
String sampleFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath();
//返回结果map
Map<String, Object> map = new HashMap<>();
//获取sample分析后的对象
EnergySpectrumStruct struct = selfStationUtil.getSourceData(sampleFilePath, "sample", selfStationData);
if (Objects.nonNull(struct)) {
selfStationData.setSampleStruct(struct);
selfStationData.setSampleTmpPath(sampleFilePath);
selfStationUtil.loadFile(selfStationData, sample.getSampleId(), sample.getStatus(), "sample", map);
resultMap.put("sample", map);
}
}
//判断det文件名是否为空
if (Objects.nonNull(detBg)) {
//拼接det文件路径
String detFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath();
//返回结果map
Map<String, Object> map = new HashMap<>();
//获取sample分析后的对象
EnergySpectrumStruct struct = selfStationUtil.getSourceData(detFilePath, "det", selfStationData);
if (Objects.nonNull(struct)) {
selfStationData.setDetStruct(struct);
selfStationData.setDetTmpPath(detFilePath);
selfStationUtil.loadFile(selfStationData, detBg.getSampleId(), detBg.getStatus(), "det", map);
resultMap.put("det", map);
}
}
} else {
if (Objects.nonNull(sample)) {
//返回结果map
Map<String, Object> map = new HashMap<>();
selfStationUtil.loadFile(selfStationData, sample.getSampleId(), sample.getStatus(), "sample", map);
resultMap.put("sample", map);
}
if (Objects.nonNull(detBg)) {
//返回结果map
Map<String, Object> map = new HashMap<>();
selfStationUtil.loadFile(selfStationData, detBg.getSampleId(), detBg.getStatus(), "det", map);
resultMap.put("det", map);
}
}
}
} catch (Exception e) {
}
return result;
}
@Override
public Result loadSelfStationByFile(String sampleFileName, String detFileName, HttpServletRequest request) {

View File

@ -489,7 +489,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
List<String> filePaths = new LinkedList<>();
//判断sample信息是否存在
if (Objects.nonNull(sample)) {
betaDataFile.setSampleFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath());
betaDataFile.setSampleFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getSampleFilePath());
betaDataFile.setSampleFileName(sampleFileName);
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
if (Objects.nonNull(sampleTmp)) {
@ -503,7 +503,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
}
//判断gas信息是否存在
if (Objects.nonNull(gasBg)) {
betaDataFile.setGasFilePathName(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath());
betaDataFile.setGasFilePathName(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH +dbSpectrumFilePath.getGasBgFilePath());
betaDataFile.setGasFileName(gasFileName);
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
if (Objects.nonNull(gasTmp)) {