fix:修复新beta的保存接口执行非常慢的问题

This commit is contained in:
xiaoguangbin 2024-08-09 15:54:47 +08:00
parent e266148da1
commit a2e48e5b84
3 changed files with 88 additions and 42 deletions

View File

@ -889,6 +889,45 @@ public class PHDFileUtil extends AbstractLogOrReport {
return path.toString();
}
}
public String NameStandardBy(String fileName, String systemType,String dataType) {
StringBuffer path = new StringBuffer();
try {
if(systemType.contains("B")) {
path.append("Spectrum");
path.append(StringPool.SLASH+"Xenon");
path.append(StringPool.SLASH+"Sauna");
} else if(systemType.contains("G")) {
path.append("Spectrum");
path.append(StringPool.SLASH+"Xenon");
path.append(StringPool.SLASH+"Spalax");
} else if (systemType.contains("C")) {
path.append("Spectrum");
path.append(StringPool.SLASH+"Xenon");
path.append(StringPool.SLASH+"Self");
}
if(dataType.contains("SAMPLEPHD")) {
path.append(StringPool.SLASH+"Samplephd");
} else if(dataType.contains("DETBKPHD")) {
path.append(StringPool.SLASH+"Detbkphd");
} else if(dataType.contains("GASBKPHD")) {
path.append(StringPool.SLASH+"Gasbkphd");
} else if(dataType.contains("QCPHD")) {
path.append(StringPool.SLASH+"Qcphd");
}
int pos = fileName.indexOf('-');
if(-1 == pos) {
} else if(fileName.length() >= pos+7) {
path.append(StringPool.SLASH+fileName.substring(pos+1,pos+5));
path.append(StringPool.SLASH+fileName.substring(pos+5,pos+7));
}
path.append(StringPool.SLASH+fileName);
return path.toString();
}catch (Exception e){
e.printStackTrace();
return path.toString();
}
}
public List<String> FileNameByStandardForm(String filePath, String sampleFileName) {
//用于最后的结果

View File

@ -939,6 +939,38 @@ public class SelfStationUtil extends AbstractLogOrReport {
return phd;
}
/**
* 创建Gamma PHD文件并转换为数据存入SelfStationVueData
* @param path PHD保存地址
* @param sampleFileName beta样品谱名称
* @param struct beta谱数据
* @param sampleVueData 存储数据实体
*/
public void createGamma(String path, String sampleFileName, EnergySpectrumStruct struct, SelfStationVueData sampleVueData){
// 根据ROI生成四个Gamma谱文件, 文件命名为Beta名称后面_ROI_x.PHD
String gammaOneName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_1.PHD";
// 创建Gamma文件
this.createGammaFile(path, gammaOneName, struct, sampleVueData.getROIOneCounts());
String gammaTwoName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_2.PHD";
this.createGammaFile(path, gammaTwoName, struct, sampleVueData.getROITwoCounts());
String gammaThreeName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_3.PHD";
this.createGammaFile(path, gammaThreeName, struct, sampleVueData.getROIThreeCounts());
String gammaFourName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_4.PHD";
this.createGammaFile(path, gammaFourName, struct, sampleVueData.getROIFourCounts());
// Gamma文件内容转换为PHD实体
sampleVueData.setROIOneFileName(gammaOneName);
sampleVueData.setROIOnePHDFile(this.getGammaPHD(gammaOneName, path));
sampleVueData.setROITwoFileName(gammaTwoName);
sampleVueData.setROITwoPHDFile(this.getGammaPHD(gammaTwoName, path));
sampleVueData.setROIThreeFileName(gammaThreeName);
sampleVueData.setROIThreePHDFile(this.getGammaPHD(gammaThreeName, path));
sampleVueData.setROIFourFileName(gammaFourName);
sampleVueData.setROIFourPHDFile(this.getGammaPHD(gammaFourName, path));
}
/**
* 根据ROI卡出来的Gamma数据生成新的GammaPHD文件
* @param pathName 文件存储路径

View File

@ -27,6 +27,7 @@ import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
import org.jeecg.modules.base.dto.RoiDto;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
@ -61,9 +62,9 @@ import java.util.*;
import java.util.stream.Collectors;
@Service
@Service("SelfStationService")
@DS("ora")
public class SelfStationServiceImpl implements ISelfStationService {
public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelfStationService {
@Autowired
private GammaFileUtil gammaFileUtil;
@ -417,29 +418,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
// 根据ROI生成四个Gamma谱文件, 文件命名为Beta名称后面_ROI_x.PHD
String gammaOneName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_1.PHD";
// 创建Gamma文件
selfStationUtil.createGammaFile(path, gammaOneName, selfStationData.getSampleStruct(), sampleVueData.getROIOneCounts());
String gammaTwoName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_2.PHD";
selfStationUtil.createGammaFile(path, gammaTwoName, selfStationData.getSampleStruct(), sampleVueData.getROITwoCounts());
String gammaThreeName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_3.PHD";
selfStationUtil.createGammaFile(path, gammaThreeName, selfStationData.getSampleStruct(), sampleVueData.getROIThreeCounts());
String gammaFourName = StrUtil.subBefore(sampleFileName, ".PHD", true) + "_ROI_4.PHD";
selfStationUtil.createGammaFile(path, gammaFourName, selfStationData.getSampleStruct(), sampleVueData.getROIFourCounts());
// Gamma文件内容转换为PHD实体
sampleVueData.setROIOneFileName(gammaOneName);
sampleVueData.setROIOnePHDFile(selfStationUtil.getGammaPHD(gammaOneName, path));
sampleVueData.setROITwoFileName(gammaTwoName);
sampleVueData.setROITwoPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
sampleVueData.setROIThreeFileName(gammaThreeName);
sampleVueData.setROIThreePHDFile(selfStationUtil.getGammaPHD(gammaThreeName, path));
sampleVueData.setROIFourFileName(gammaFourName);
sampleVueData.setROIFourPHDFile(selfStationUtil.getGammaPHD(gammaFourName, path));
selfStationUtil.createGamma(path, sampleFileName, struct, sampleVueData);
resultMap.put("sample", map);
// 初始化Configure
@ -581,7 +560,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
BeanUtils.copyProperties(roiFourPHDFile.getSetting(), roiFourPHDFile.getUsedSetting());
}
@DS("ora")
public void initConfigure(Integer idAnalysis, SelfStationData selfStationData){
GardsAnalySetting analySetting = spectrumAnalysisMapper.getAnalySetting(idAnalysis);
if (Objects.nonNull(analySetting)) {
@ -677,7 +655,13 @@ public class SelfStationServiceImpl implements ISelfStationService {
roiBBoundaryStart.add(roiParam.getRoiNum() - 1, roiParam.getStartChannel());
roiBBoundaryStop.add(roiParam.getRoiNum() - 1, roiParam.getEndChannel());
}
// 根据ROI卡Gamma能谱数据
selfStationUtil.getGammaByROI("sample", roiBBoundaryStart, roiBBoundaryStop, selfStationData);
SelfStationVueData sampleData = selfStationData.getSampleVueData();
String path = StrUtil.subBefore(selfStationData.getSampleFilePathName(), StringPool.SLASH, true);
// 生成gamma数据
selfStationUtil.createGamma(path, selfStationData.getSampleFileName(), struct, sampleData);
}
@Override
@ -4570,7 +4554,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
@Override
@DS("ora")
public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) {
Result result = new Result();
Map<String, Object> map = new HashMap<>();
@ -4745,7 +4728,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
}
@Override
@DS("ora")
public Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request) {
Result result = new Result();
Map<String, List<String>> map = new HashMap<>();
@ -4956,8 +4938,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
}
@Override
@DS("ora")
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Transactional
public Result saveToDB(String fileName, HttpServletRequest request) {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
@ -5041,18 +5022,14 @@ public class SelfStationServiceImpl implements ISelfStationService {
String qcTmpPath = selfStationData.getQcTmpPath();
//根据sample文件名称模糊查询sampleId
String sampleFilePath = "", qcFilePath = "", detFilePath = "";
if (StringUtils.isNotBlank(sampleFilePathName) && StringUtils.isNotBlank(sampleFileName)) {
sampleFilePath = StrUtil.subBefore(sampleFilePathName, StringPool.SLASH, true);
sampleFilePathName = phdFileUtil.NameStandardBy(sampleFilePath, sampleFileName);
sampleFilePathName = phdFileUtil.NameStandardBy(sampleFileName, sampleStruct.system_type, sampleStruct.data_type);
}
if (StringUtils.isNotBlank(detFilePathName) && StringUtils.isNotBlank(detFileName)) {
detFilePath = StrUtil.subBefore(detFilePathName, StringPool.SLASH, true);
detFilePathName = phdFileUtil.NameStandardBy(detFilePath, detFileName);
detFilePathName = phdFileUtil.NameStandardBy(detFileName, detStruct.system_type, detStruct.data_type);
}
if (StringUtils.isNotBlank(qcFilePathName) && StringUtils.isNotBlank(qcFileName)) {
qcFilePath = StrUtil.subBefore(qcFilePathName, StringPool.SLASH, true);
qcFilePathName = phdFileUtil.NameStandardBy(qcFilePath, qcFileName);
qcFilePathName = phdFileUtil.NameStandardBy(qcFileName, qcStruct.system_type, qcStruct.data_type);
}
// 读取参数内容
@ -5063,7 +5040,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
List<Map<String, CalMDCInfo>> mdcInfoMaps = ListUtil.toList(mdcInfoMap1, mdcInfoMap2,
mdcInfoMap3, mdcInfoMap4);
// 根据文件名称查询对应的sampleId 如果存在则赋值sampleId, Status 如果不存在则先存储数据信息到sampleData
PHDFile phd = new PHDFile();
PHDFile phd = sampleVueData.getROIOnePHDFile();
BeanUtils.copyProperties(phdFiles.get(0), phd);
GardsSampleDataSpectrum sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleInputFileName);
if (ObjectUtil.isNotNull(sampleData)) {
@ -5089,7 +5066,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
}
qcId = spectrumAnalysisMapper.getSampleId(qcFilePathName);
}
sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleInputFileName);
sampleData = spectrumAnalysisMapper.findSampleByFilePath(sampleFilePathName);
}
sampleId = sampleData.getSampleId();
// 根据sampleId 查询idAnalysis
@ -5297,7 +5274,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
@Override
@DS("ora")
public Result<?> viewARR(Integer sampleId, HttpServletResponse response) {
GardsAnalyses analyses = spectrumAnalysisMapper.viewARRSelf(sampleId);
Map<String, String> result = new HashMap<>();
@ -5355,7 +5331,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
}
@Override
@DS("ora")
public Result<?> viewAutomaticAnalysisLog(Integer sampleId) {
GardsAnalyses analyses = spectrumAnalysisMapper.viewLogSelf(sampleId);
Map<String, String> result = new HashMap<>();