fix:自建台站saveToDB
This commit is contained in:
parent
b19f5087ed
commit
40e94299a7
|
@ -1017,7 +1017,8 @@ public class Sample_C_Analysis {
|
|||
GStoreMiddleProcessData middleData = entry.getValue();
|
||||
calibrationRois.addAll(saveCalibrationROI(sampleId, IdAnalysis, roiId, middleData));
|
||||
}
|
||||
this.serviceQuotes.getCalibrationRoiAutoService().createBatch(calibrationRois);
|
||||
if (CollUtil.isNotEmpty(calibrationRois))
|
||||
this.serviceQuotes.getCalibrationRoiAutoService().createBatch(calibrationRois);
|
||||
}
|
||||
|
||||
public List<GardsPeaksRoi> savePeaksROI(Integer sampleId, Integer IdAnalysis,
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.*;
|
|||
import static org.jeecgframework.codegenerate.a.a.i;
|
||||
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public class AnalysisManServiceImpl implements AnalysisManService {
|
||||
|
||||
@Autowired
|
||||
|
@ -258,7 +257,8 @@ public class AnalysisManServiceImpl implements AnalysisManService {
|
|||
GStoreMiddleProcessData middleData = entry.getValue();
|
||||
calibrationRois.addAll(saveCalibrationROI(sampleId, idAnalysis, roiId, middleData));
|
||||
}
|
||||
calibrationRoiManService.createBatch(calibrationRois);
|
||||
if (CollUtil.isNotEmpty(calibrationRois))
|
||||
calibrationRoiManService.createBatch(calibrationRois);
|
||||
}
|
||||
|
||||
public List<GardsCalibrationRoi> saveCalibrationROI(Integer sampleId, Integer IdAnalysis, Integer roiId,
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
RNMAN.GARDS_ANALYSES
|
||||
SET ANALYSISBEGIN = to_date(#{analyses.analysisBeginStr},'yyyy/MM/dd HH24:mi:ss'),
|
||||
ANALYSISEND = to_date(#{analyses.analysisEndStr},'yyyy/MM/dd HH24:mi:ss'),
|
||||
ANALYST = #{analyses.analyst},
|
||||
COMMENTS = #{analyses.comments}
|
||||
ANALYST = #{analyses.analyst}
|
||||
WHERE
|
||||
IDANALYSIS = #{analyses.idAnalysis}
|
||||
</update>
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.service.impl;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
|
@ -56,6 +57,25 @@ public class GardsAnalysesSpectrumServiceImpl extends ServiceImpl<GardsAnalysesM
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer saveAnalyses(Integer sampleId, String startTime, String userName) {
|
||||
GardsAnalyses analyses = new GardsAnalyses();
|
||||
try {
|
||||
analyses.setSampleId(sampleId);
|
||||
analyses.setAnalysisBegin(DateUtils.parseDate(startTime));
|
||||
analyses.setAnalysisEnd(new Date());
|
||||
analyses.setType("Interactive");
|
||||
analyses.setSoftware("");
|
||||
analyses.setSwVersion("1.0.1");
|
||||
analyses.setAnalyst(userName);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.save(analyses);
|
||||
String idAnalysis = spectrumAnalysisMapper.getIdAnalysisByIdAnalyst(sampleId.toString(), userName);
|
||||
return StrUtil.isBlank(idAnalysis) ? null : Integer.valueOf(idAnalysis);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateEntity(GStoreMiddleProcessData middleData, PHDFile phd, String userName, String comments, String idAnalysis) {
|
||||
|
@ -79,25 +99,6 @@ public class GardsAnalysesSpectrumServiceImpl extends ServiceImpl<GardsAnalysesM
|
|||
this.baseMapper.updateEntity(analyses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer saveAnalyses(Integer sampleId, String startTime, String userName) {
|
||||
GardsAnalyses analyses = new GardsAnalyses();
|
||||
try {
|
||||
analyses.setSampleId(sampleId);
|
||||
analyses.setAnalysisBegin(DateUtils.parseDate(startTime));
|
||||
analyses.setAnalysisEnd(new Date());
|
||||
analyses.setType("Interactive");
|
||||
analyses.setSoftware("");
|
||||
analyses.setSwVersion("1.0.1");
|
||||
analyses.setAnalyst(userName);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.save(analyses);
|
||||
String idAnalysis = spectrumAnalysisMapper.getIdAnalysisByIdAnalyst(sampleId.toString(), userName);
|
||||
return StrUtil.isBlank(idAnalysis) ? null : Integer.valueOf(idAnalysis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAnalyses(String startTime, String userName, Integer idAnalysis) {
|
||||
GardsAnalysesSpectrum analyses = new GardsAnalysesSpectrum();
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.jeecg.modules.service.*;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.w3c.dom.*;
|
||||
|
@ -118,8 +119,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
@Autowired
|
||||
private IGardsAnalysesSpectrumService analysesSpectrumService;
|
||||
|
||||
private List<String> phdFilePaths;
|
||||
|
||||
|
||||
@Override
|
||||
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName,
|
||||
|
@ -4027,6 +4026,8 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@DS("ora")
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public Result saveToDB(String fileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
|
@ -4068,9 +4069,25 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
GStoreMiddleProcessData middleData4 = new GStoreMiddleProcessData();
|
||||
List<GStoreMiddleProcessData> middleDatas =
|
||||
ListUtil.toList(middleData1, middleData2, middleData3, middleData4);
|
||||
List<PHDFile> phdFiles = create4PHD(sampleStruct);
|
||||
|
||||
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
|
||||
PHDFile phdFile1 = sampleVueData.getROIOnePHDFile();
|
||||
PHDFile phdFile2 = sampleVueData.getROITwoPHDFile();
|
||||
PHDFile phdFile3 = sampleVueData.getROIThreePHDFile();
|
||||
PHDFile phdFile4 = sampleVueData.getROIFourPHDFile();
|
||||
phdFile1.setRoiSuffix("_ROI_1");
|
||||
phdFile2.setRoiSuffix("_ROI_2");
|
||||
phdFile3.setRoiSuffix("_ROI_3");
|
||||
phdFile4.setRoiSuffix("_ROI_4");
|
||||
List<PHDFile> phdFiles = ListUtil.toList(phdFile1, phdFile2, phdFile3, phdFile4);
|
||||
|
||||
String path1 = savePathName + StrUtil.SLASH + phdFile1.getFilename();
|
||||
String path2 = savePathName + StrUtil.SLASH + phdFile2.getFilename();
|
||||
String path3 = savePathName + StrUtil.SLASH + phdFile3.getFilename();
|
||||
String path4 = savePathName + StrUtil.SLASH + phdFile4.getFilename();
|
||||
List<String> phdFilePaths = ListUtil.toList(path1, path2, path3, path4);
|
||||
//读取参数内容
|
||||
Map<String, CalMDCInfo> mdcInfoMap = readMDCParameter(phdFiles);
|
||||
Map<String, CalMDCInfo> mdcInfoMap = phdFile1.getMdcInfoMap();
|
||||
|
||||
bRet = gammaFileUtil.GetInterMiddlData(phdFiles, userName, middleDatas, "save");
|
||||
if (!bRet) {
|
||||
|
@ -4102,10 +4119,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
if (ObjectUtil.isNull(idAnalysis)) {
|
||||
// 向 RNMAN.GARDS_ANALYSES 表插入数据
|
||||
idAnalysis = analysesSpectrumService.saveAnalyses(sampleId, phd.getAnaly_start_time(), userName);
|
||||
// 向 RNMAN.GARDS_ANALYSES_ROI 表插入数据
|
||||
analysisManService.saveAnalysisROI(sampleId, idAnalysis, sampleStruct, middleDatas, this.phdFilePaths);
|
||||
// 获取Table IdAnalysis:RoiId:GStoreMiddleProcessData
|
||||
analysisManService.middleDataTable(idAnalysis, middleDatas);
|
||||
// 修改sample_data状态
|
||||
spectrumAnalysisMapper.updateAnalysesStatus(sampleInputFileName);
|
||||
} else {
|
||||
|
@ -4131,7 +4144,9 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
analysisManService.deleteAnalySetting(idAnalysis);
|
||||
}
|
||||
// 向 RNMAN.GARDS_ANALYSES_ROI 表插入数据
|
||||
analysisManService.saveAnalysisROI(sampleId, idAnalysis, sampleStruct, middleDatas, this.phdFilePaths);
|
||||
analysisManService.saveAnalysisROI(sampleId, idAnalysis, sampleStruct, middleDatas, phdFilePaths);
|
||||
// 获取Map IdAnalysis:RoiId:GStoreMiddleProcessData
|
||||
analysisManService.middleDataTable(idAnalysis, middleDatas);
|
||||
// 向 RNMAN.GARDS_CALIBRATION_PAIRS 表写入 Energy 刻度数据对
|
||||
analysisManService.saveCalibrationPairsROI(sampleId, idAnalysis);
|
||||
analysisManService.saveCalibrationROI(sampleId, idAnalysis);
|
||||
|
@ -4187,77 +4202,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Map<String, CalMDCInfo> readMDCParameter(List<PHDFile> phdFiles) {
|
||||
//存储文件结果用的map
|
||||
Map<String, CalMDCInfo> mdcInfoMap = new TreeMap<>();
|
||||
if (CollUtil.isEmpty(phdFiles)) return mdcInfoMap;
|
||||
String systemType = phdFiles.get(0).getHeader().getSystem_type();
|
||||
//配置文件路径
|
||||
String filePath = parameterProperties.getFilePath()+ File.separator + "MDCParameter.xml";
|
||||
try {
|
||||
//创建一个文档解析器工厂
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
//创建文档解析器
|
||||
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
|
||||
//读取xml文件生成一个文档
|
||||
Document document = documentBuilder.parse(filePath);
|
||||
if (Objects.nonNull(document)){
|
||||
//获取文档的根元素
|
||||
Element element = document.getDocumentElement();
|
||||
//获取根元素的子节点
|
||||
NodeList docChildNodes = element.getChildNodes();
|
||||
//判断文件内的节点是否大于0
|
||||
if (Objects.nonNull(docChildNodes) && docChildNodes.getLength() > 0) {
|
||||
//遍历文件节点读取内容
|
||||
for (int i=0; i<docChildNodes.getLength(); i++) {
|
||||
//获取节点信息
|
||||
Node node = docChildNodes.item(i);
|
||||
if (node.getNodeName().equalsIgnoreCase(systemType)) {
|
||||
NodeList childNodes = node.getChildNodes();
|
||||
if (Objects.nonNull(childNodes) && childNodes.getLength() > 0) {
|
||||
//遍历子节点信息
|
||||
for (int j=0; j< childNodes.getLength(); j++) {
|
||||
//获取子节点信息
|
||||
Node childNode = childNodes.item(j);
|
||||
//判断节点名称是否是item
|
||||
if (childNode.getNodeName().equalsIgnoreCase("item")) {
|
||||
//获取节点属性信息
|
||||
NamedNodeMap attributes = childNode.getAttributes();
|
||||
//判断节点属性信息是否为空
|
||||
if (Objects.nonNull(attributes)) {
|
||||
CalMDCInfo info = new CalMDCInfo();
|
||||
//遍历属性信息
|
||||
for (int k=0; k<attributes.getLength(); k++) {
|
||||
//根据顺序读取属性
|
||||
Node attribute = attributes.item(k);
|
||||
if (attribute.getNodeName().equalsIgnoreCase("nuclide_name")) {
|
||||
info.setNuclideName(attribute.getNodeValue());
|
||||
} else if (attribute.getNodeName().equalsIgnoreCase("halflife")) {
|
||||
info.setHalflife(Double.valueOf(attribute.getNodeValue()));
|
||||
}
|
||||
}
|
||||
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(info.getNuclideName()) && Objects.nonNull(info.getHalflife())) {
|
||||
mdcInfoMap.put(info.getNuclideName(), info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (MapUtil.isNotEmpty(mdcInfoMap)) {
|
||||
for (PHDFile phdFile : phdFiles) {
|
||||
phdFile.setMdcInfoMap(mdcInfoMap);
|
||||
}
|
||||
}
|
||||
} catch (ParserConfigurationException | IOException | SAXException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return mdcInfoMap;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean SaveSampleToDB(PHDFile phd, String input_file_name) {
|
||||
boolean bRet = false;
|
||||
|
@ -4326,11 +4270,11 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
final String[] yearMonth = arr[1].split(StringConstant.SLASH);
|
||||
StringBuilder relativePath = new StringBuilder();
|
||||
relativePath.append(spectrumPathProperties.getFilePathMap().get(systemType));
|
||||
relativePath.append(File.separator);
|
||||
relativePath.append(StrUtil.SLASH);
|
||||
relativePath.append(spectrumPathProperties.getFilePathMap().get(dataType));
|
||||
relativePath.append(File.separator);
|
||||
relativePath.append(StrUtil.SLASH);
|
||||
relativePath.append(yearMonth[0]);
|
||||
relativePath.append(File.separator);
|
||||
relativePath.append(StrUtil.SLASH);
|
||||
relativePath.append(yearMonth[1]);
|
||||
return relativePath.toString();
|
||||
}
|
||||
|
@ -4342,78 +4286,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
return rootPath + saveFilePath + StrUtil.SLASH + saveRelativePath;
|
||||
}
|
||||
|
||||
private List<PHDFile> create4PHD(EnergySpectrumStruct sampleStruct){
|
||||
// 计算边界值
|
||||
List<Double> gEnergy = sampleStruct.g_energy;
|
||||
List<Double> gCentroidChannel = sampleStruct.g_centroid_channel;
|
||||
List<Double> bElectronEnergy = sampleStruct.b_electron_energy;
|
||||
List<Double> bChannel = sampleStruct.b_channel;
|
||||
long bChannels = sampleStruct.b_channels;
|
||||
long gChannels = sampleStruct.g_channels;
|
||||
List<Long> hCounts = sampleStruct.h_counts;
|
||||
CalcBgBoundaryParam calcBgBoundaryParam = new CalcBgBoundaryParam();
|
||||
calcBgBoundaryParam.g_e_cal = EnergySpectrumHandler.GetFileFittingPara(gEnergy, gCentroidChannel);
|
||||
calcBgBoundaryParam.b_e_cal = EnergySpectrumHandler.GetFileFittingPara(bElectronEnergy, bChannel);
|
||||
calcBgBoundaryParam.b_energy = sampleStruct.b_electron_energy;
|
||||
calcBgBoundaryParam.b_channel = sampleStruct.b_channel;
|
||||
calcBgBoundaryParam.g_channel = sampleStruct.g_centroid_channel;
|
||||
calcBgBoundaryParam.g_energy = sampleStruct.g_energy;
|
||||
calcBgBoundaryParam.ROI_B_start_x1 = sampleStruct.POI_B_x1;
|
||||
calcBgBoundaryParam.ROI_B_stop_x2 = sampleStruct.POI_B_x2;
|
||||
calcBgBoundaryParam.ROI_G_start_y1 = sampleStruct.POI_G_y1;
|
||||
calcBgBoundaryParam.ROI_G_stop_y2 = sampleStruct.POI_G_y2;
|
||||
BgBoundary bgBoundary = EnergySpectrumHandler.CalcBgBoundary(calcBgBoundaryParam);
|
||||
// 新Beta谱:只取X轴数据从Y轴0的位置开始连成一条线,一直到顶画出矩形框 这个矩形框内的数据就是Gamma谱数据
|
||||
List<Integer> roiBBoundaryStart = bgBoundary.ROI_B_Boundary_start;
|
||||
List<Integer> roiBBoundaryStop = bgBoundary.ROI_B_Boundary_stop;
|
||||
|
||||
// 根据范围1划分 范围1对应的折线图
|
||||
List<Long> roiOneCounts = selfStationUtil.roiList(roiBBoundaryStart.get(0), roiBBoundaryStop.get(0),
|
||||
bChannels, gChannels, hCounts);
|
||||
// 根据范围2划分 范围2对应的折线图
|
||||
List<Long> roiTwoCounts = selfStationUtil.roiList(roiBBoundaryStart.get(1), roiBBoundaryStop.get(1),
|
||||
bChannels, gChannels, hCounts);
|
||||
// 根据范围3划分 范围3对应的折线图
|
||||
List<Long> roiThreeCounts = selfStationUtil.roiList(roiBBoundaryStart.get(2), roiBBoundaryStop.get(2),
|
||||
bChannels, gChannels, hCounts);
|
||||
// 根据范围4划分 范围4对应的折线图
|
||||
List<Long> roiFourCounts = selfStationUtil.roiList(roiBBoundaryStart.get(3), roiBBoundaryStop.get(3),
|
||||
bChannels, gChannels, hCounts);
|
||||
|
||||
// 根据ROI生成四个Gamma谱文件 文件命名格式为: 样品谱原名_ROI_x.PHD
|
||||
String sampleFilename = saveFileName(sampleStruct);
|
||||
String saveFullPathName = saveFullPathName(sampleStruct);
|
||||
|
||||
String gammaOneName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_1.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPathName, gammaOneName, sampleStruct, roiOneCounts);
|
||||
|
||||
String gammaTwoName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_2.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPathName, gammaTwoName, sampleStruct, roiTwoCounts);
|
||||
|
||||
String gammaThreeName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_3.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPathName, gammaThreeName, sampleStruct, roiThreeCounts);
|
||||
|
||||
String gammaFourName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_4.PHD";
|
||||
selfStationUtil.createGammaFile(saveFullPathName, gammaFourName, sampleStruct, roiFourCounts);
|
||||
// 将生成的GammaPHD文件转换为PHDFile对象
|
||||
PHDFile phdFile1 = selfStationUtil.getGammaPHD(gammaOneName, saveFullPathName);
|
||||
phdFile1.setRoiSuffix("_ROI_1");
|
||||
PHDFile phdFile2 = selfStationUtil.getGammaPHD(gammaTwoName, saveFullPathName);
|
||||
phdFile2.setRoiSuffix("_ROI_2");
|
||||
PHDFile phdFile3 = selfStationUtil.getGammaPHD(gammaThreeName, saveFullPathName);
|
||||
phdFile3.setRoiSuffix("_ROI_3");
|
||||
PHDFile phdFile4 = selfStationUtil.getGammaPHD(gammaFourName, saveFullPathName);
|
||||
phdFile4.setRoiSuffix("_ROI_4");
|
||||
String saveRelativePath = savePathName(sampleStruct);
|
||||
String path1 = saveRelativePath + StrUtil.SLASH + gammaOneName;
|
||||
String path2 = saveRelativePath + StrUtil.SLASH + gammaTwoName;
|
||||
String path3 = saveRelativePath + StrUtil.SLASH + gammaThreeName;
|
||||
String path4 = saveRelativePath + StrUtil.SLASH + gammaFourName;
|
||||
|
||||
phdFilePaths = ListUtil.toList(path1, path2, path3, path4);
|
||||
return ListUtil.toList(phdFile1, phdFile2, phdFile3, phdFile4);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行gamma分析
|
||||
* @param phd gamma 数据
|
||||
|
|
Loading…
Reference in New Issue
Block a user