feat:补充beta 分析部分接口
This commit is contained in:
parent
40e94299a7
commit
19c9bae348
|
@ -325,6 +325,23 @@ public class SelfStationController {
|
||||||
|
|
||||||
/***************************************** beta ******************************************/
|
/***************************************** beta ******************************************/
|
||||||
|
|
||||||
|
@PostMapping("ReAnalyse")
|
||||||
|
public Result ReAnalyse(@RequestBody AnalyseData analyseData, HttpServletRequest request) {
|
||||||
|
return selfStationService.ReAnalyse(analyseData, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("analyseCurrentSpectrum")
|
||||||
|
@ApiOperation(value = "解析当前加载文件数据", notes = "解析当前加载文件数据")
|
||||||
|
public Result analyseCurrentSpectrum(@RequestBody AnalyseBetaInfo analyseBetaInfo, HttpServletRequest request) {
|
||||||
|
String dbName = analyseBetaInfo.getDbNames().get(0);
|
||||||
|
Integer sampleId = analyseBetaInfo.getSampleIds().get(0);
|
||||||
|
String sampleFileName = analyseBetaInfo.getSampleFileNames().get(0);
|
||||||
|
String gasFileName = analyseBetaInfo.getGasFileNames().get(0);
|
||||||
|
String detFileName = analyseBetaInfo.getDetFileNames().get(0);
|
||||||
|
String qcFileName = analyseBetaInfo.getQcFileNames().get(0);
|
||||||
|
return selfStationService.analyseCurrentSpectrum(dbName, sampleId, sampleFileName, gasFileName, detFileName, qcFileName, request);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("fitting")
|
@PostMapping("fitting")
|
||||||
@ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线")
|
@ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线")
|
||||||
public Result fitting(@RequestBody FittingBody fittingBody, HttpServletRequest request) {
|
public Result fitting(@RequestBody FittingBody fittingBody, HttpServletRequest request) {
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class SelfStationData implements Serializable {
|
||||||
*/
|
*/
|
||||||
private SelfStationVueData detVueData;
|
private SelfStationVueData detVueData;
|
||||||
|
|
||||||
|
private BetaDataFile betaDataFile;
|
||||||
|
|
||||||
private List<List<Double>> gammaNewEnergyListNow;
|
private List<List<Double>> gammaNewEnergyListNow;
|
||||||
|
|
||||||
private List<List<Double>> betaNewEnergyListNow;
|
private List<List<Double>> betaNewEnergyListNow;
|
||||||
|
|
|
@ -106,6 +106,12 @@ public interface ISelfStationService {
|
||||||
|
|
||||||
Result acceptBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request);
|
Result acceptBaseLine(BaseLineCtrls baseLineCtrls, HttpServletRequest request);
|
||||||
|
|
||||||
|
Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request);
|
||||||
|
|
||||||
|
Result analyseCurrentSpectrum(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
|
||||||
|
|
||||||
|
Result analyseAllSpectrum(List<String> dbNames, List<Integer> sampleIds, List<String> sampleFileNames, List<String> gasFileNames, List<String> detFileNames, List<String> qcFileNames, String currentFileName, HttpServletRequest request);
|
||||||
|
|
||||||
Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPointsArray, Integer count,
|
Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPointsArray, Integer count,
|
||||||
String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request);
|
String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package org.jeecg.modules.service.impl;
|
package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
@ -17,10 +13,8 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.math3.fitting.GaussianCurveFitter;
|
|
||||||
import org.apache.commons.math3.fitting.WeightedObservedPoints;
|
import org.apache.commons.math3.fitting.WeightedObservedPoints;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.cache.LocalCache;
|
|
||||||
import org.jeecg.common.cache.SelfCache;
|
import org.jeecg.common.cache.SelfCache;
|
||||||
import org.jeecg.common.constant.StringConstant;
|
import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.ParameterProperties;
|
import org.jeecg.common.properties.ParameterProperties;
|
||||||
|
@ -32,12 +26,11 @@ import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.entity.rnman.GardsAnalySetting;
|
import org.jeecg.modules.base.entity.rnman.GardsAnalySetting;
|
||||||
import org.jeecg.modules.entity.GardsSampleDataSpectrum;
|
import org.jeecg.modules.entity.GardsSampleDataSpectrum;
|
||||||
|
import org.jeecg.modules.entity.GardsXeResultsSpectrum;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
|
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
|
||||||
import org.jeecg.modules.native_jni.CalValuesHandler;
|
import org.jeecg.modules.native_jni.CalValuesHandler;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.BgBoundary;
|
|
||||||
import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam;
|
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
import org.jeecg.modules.service.*;
|
import org.jeecg.modules.service.*;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
@ -46,22 +39,15 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.w3c.dom.*;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -71,6 +57,8 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GammaFileUtil gammaFileUtil;
|
private GammaFileUtil gammaFileUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private PHDFileUtil phdFileUtil;
|
||||||
|
@Autowired
|
||||||
private ParameterProperties parameterProperties;
|
private ParameterProperties parameterProperties;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FTPUtil ftpUtil;
|
private FTPUtil ftpUtil;
|
||||||
|
@ -3335,6 +3323,778 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request) {
|
||||||
|
Result result = new Result();
|
||||||
|
//声明接收当前分析后的返回结果的map
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
//获取当前登陆的用户名
|
||||||
|
String userName = JwtUtil.getUserNameByToken(request);
|
||||||
|
//获取当前操作的文件名称
|
||||||
|
String currentFileName = analyseData.getCurrentFileName();
|
||||||
|
//获取自建台站缓存信息
|
||||||
|
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||||
|
SelfStationData selfStationData = selfCache.getIfPresent(currentFileName + "-" + userName);
|
||||||
|
//获取缓存信息
|
||||||
|
// Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||||
|
if ("CurrentSpectrum".equals(analyseData.getApplyType())) {
|
||||||
|
BetaDataFile betaDataFile = selfStationData.getBetaDataFile();
|
||||||
|
// BetaDataFile betaDataFile = cache.getIfPresent(currentFileName + "-" + userName);
|
||||||
|
if (Objects.isNull(betaDataFile)) {
|
||||||
|
result.error500("Load basic file information first!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
map = BetaGammaAnalyzeCurrentProcess(analyseData, betaDataFile);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(map);
|
||||||
|
} else if ("AllSpectrum".equals(analyseData.getApplyType())) {
|
||||||
|
//获取当前选中的文件名称
|
||||||
|
map = BetaGammaAnalyzeAllProcess(analyseData, userName, currentFileName);
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(map);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, BetaDataFile betaDataFile) {
|
||||||
|
//声明一个map 缓存xeData计算后的结果
|
||||||
|
Map<String, Object> xeMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
//存储重新分析字段的实体类
|
||||||
|
SpectrumGroup spectrum_group = new SpectrumGroup();
|
||||||
|
//获取计算参数
|
||||||
|
List<SeriseData> betaList = new LinkedList<>();
|
||||||
|
List<String> betaFittingPara = new LinkedList<>();
|
||||||
|
List<String> betaFittingParaToUi = new LinkedList<>();
|
||||||
|
List<SeriseData> gammaList = new LinkedList<>();
|
||||||
|
List<String> gammaFittingPara = new LinkedList<>();
|
||||||
|
List<String> gammaFittingParaToUi = new LinkedList<>();
|
||||||
|
//判断是否对beta页面进行过分析
|
||||||
|
if (analyseData.isBetaEnergyValid()) {
|
||||||
|
//如果进行过分析 则将当前beta用于分析的新的数据 赋值到最终使用的数组
|
||||||
|
if (Objects.nonNull(betaDataFile)) {
|
||||||
|
//重新分析时将当前的数组封装给到最终记录结果的数组中
|
||||||
|
betaDataFile.setBetaList(betaDataFile.getBetaListNow());
|
||||||
|
betaDataFile.setBetaFittingPara(betaDataFile.getBetaFittingParaNow());
|
||||||
|
betaDataFile.setBetaFittingParaToUi(betaDataFile.getBetaFittingParaToUiNow());
|
||||||
|
betaDataFile.setBetaNewEnergyList(betaDataFile.getBetaNewEnergyListNow());
|
||||||
|
//将新的数组封装到各自的数组中
|
||||||
|
betaList = betaDataFile.getBetaList();
|
||||||
|
betaFittingPara = betaDataFile.getBetaFittingPara();
|
||||||
|
betaFittingParaToUi = betaDataFile.getBetaFittingParaToUi();
|
||||||
|
}
|
||||||
|
//封装重新计算的数据
|
||||||
|
List<Double> beCal = new LinkedList<>();
|
||||||
|
beCal.add(Double.valueOf(betaFittingParaToUi.get(0)));
|
||||||
|
beCal.add(Double.valueOf(betaFittingParaToUi.get(1)));
|
||||||
|
beCal.add(Double.valueOf(betaFittingParaToUi.get(2)));
|
||||||
|
spectrum_group.BgCalPara.b_e_cal = beCal;
|
||||||
|
List<Double> bc2e = new LinkedList<>();
|
||||||
|
bc2e.add(Double.valueOf(betaFittingPara.get(0)));
|
||||||
|
bc2e.add(Double.valueOf(betaFittingPara.get(1)));
|
||||||
|
bc2e.add(Double.valueOf(betaFittingPara.get(2)));
|
||||||
|
spectrum_group.b_c2e = bc2e;
|
||||||
|
if (analyseData.isSampleData()) {
|
||||||
|
betaDataFile.setBBetaEnergyValidSample(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
betaDataFile.setSampleBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("sampleBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isGasBgData()) {
|
||||||
|
betaDataFile.setBBetaEnergyValidGas(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
betaDataFile.setGasBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("gasBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isDetBgData()) {
|
||||||
|
betaDataFile.setBBetaEnergyValidDet(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
betaDataFile.setDetBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("detBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isQcData()) {
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
betaDataFile.setQcBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("qcBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断是否对gamma页面进行过分析
|
||||||
|
if (analyseData.isGammaEnergyValid()) {
|
||||||
|
//如果缓存数据不为空 且对gamma进行了计算 将当前gamma的计算结果赋值到最终的结果数组 进行新的分析使用
|
||||||
|
if (Objects.nonNull(betaDataFile)) {
|
||||||
|
betaDataFile.setGammaList(betaDataFile.getGammaListNow());
|
||||||
|
betaDataFile.setGammaFittingPara(betaDataFile.getGammaFittingParaNow());
|
||||||
|
betaDataFile.setGammaFittingParaToUi(betaDataFile.getGammaFittingParaToUiNow());
|
||||||
|
betaDataFile.setGammaNewEnergyList(betaDataFile.getGammaNewEnergyListNow());
|
||||||
|
gammaList = betaDataFile.getGammaList();
|
||||||
|
gammaFittingPara = betaDataFile.getGammaFittingPara();
|
||||||
|
gammaFittingParaToUi = betaDataFile.getGammaFittingParaToUi();
|
||||||
|
}
|
||||||
|
List<Double> geCal = new LinkedList<>();
|
||||||
|
geCal.add(Double.valueOf(gammaFittingParaToUi.get(0)));
|
||||||
|
geCal.add(Double.valueOf(gammaFittingParaToUi.get(1)));
|
||||||
|
geCal.add(Double.valueOf(gammaFittingParaToUi.get(2)));
|
||||||
|
spectrum_group.BgCalPara.g_e_cal = geCal;
|
||||||
|
List<Double> gc2e = new LinkedList<>();
|
||||||
|
gc2e.add(Double.valueOf(gammaFittingPara.get(0)));
|
||||||
|
gc2e.add(Double.valueOf(gammaFittingPara.get(1)));
|
||||||
|
gc2e.add(Double.valueOf(gammaFittingPara.get(2)));
|
||||||
|
spectrum_group.g_c2e = gc2e;
|
||||||
|
if (analyseData.isSampleData()) {
|
||||||
|
betaDataFile.setBGammaEnergyValidSample(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
betaDataFile.setSampleGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("sampleGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isGasBgData()) {
|
||||||
|
betaDataFile.setBGammaEnergyValidGas(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
betaDataFile.setGasGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("gasGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isDetBgData()) {
|
||||||
|
betaDataFile.setBGammaEnergyValidDet(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
betaDataFile.setDetGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("detGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isQcData()) {
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
betaDataFile.setQcGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("qcGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断是否勾选了sample
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData();
|
||||||
|
//判断是否勾选了gas
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData();
|
||||||
|
//判断是否勾选了det
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData();
|
||||||
|
//判断是否勾选了qc
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData();
|
||||||
|
File sampleTmp = null;
|
||||||
|
File gasTmp = null;
|
||||||
|
File detTmp = null;
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||||
|
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||||
|
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||||
|
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
|
||||||
|
//调用分析方法进行分析操作
|
||||||
|
boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, betaDataFile);
|
||||||
|
if (analyseData.isQcData()) {
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getQcFilePathName())) {
|
||||||
|
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
|
||||||
|
if (Objects.nonNull(struct)) {
|
||||||
|
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap, betaDataFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bRet) {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) xeMap.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
betaDataFile.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) xeMap.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
betaDataFile.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) xeMap.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
betaDataFile.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) xeMap.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
betaDataFile.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
List<GardsXeResultsSpectrum> xeResultsSpectrumList = (List<GardsXeResultsSpectrum>) xeMap.get("XeData");
|
||||||
|
if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){
|
||||||
|
for (GardsXeResultsSpectrum xeData: xeResultsSpectrumList) {
|
||||||
|
Double conc = xeData.getConc();
|
||||||
|
Double mdc = xeData.getMdc();
|
||||||
|
if (conc < 0){
|
||||||
|
xeData.setColor("red");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (0<conc && conc < mdc) {
|
||||||
|
xeData.setColor("#ffcc30");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (conc > mdc) {
|
||||||
|
xeData.setColor("green");
|
||||||
|
xeData.setNidFlag(1);
|
||||||
|
}
|
||||||
|
xeData.setMdc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc()))));
|
||||||
|
xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc()))));
|
||||||
|
xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr()))));
|
||||||
|
}
|
||||||
|
betaDataFile.setXeResultsSpectrumList(xeResultsSpectrumList);
|
||||||
|
betaDataFile.setBProcessed(true);
|
||||||
|
betaDataFile.setSaveAnalysisResult(true);
|
||||||
|
betaDataFile.setBgPara(spectrum_group.BgCalPara);
|
||||||
|
}
|
||||||
|
xeMap.put("bProcessed", true);
|
||||||
|
xeMap.put("savedAnalysisResult", true);
|
||||||
|
} else {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) xeMap.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
betaDataFile.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) xeMap.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
betaDataFile.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) xeMap.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
betaDataFile.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) xeMap.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
betaDataFile.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
betaDataFile.setBProcessed(false);
|
||||||
|
betaDataFile.setSaveAnalysisResult(false);
|
||||||
|
betaDataFile.setXeResultsSpectrumList(Collections.EMPTY_LIST);
|
||||||
|
xeMap.put("XeData", Collections.EMPTY_LIST);
|
||||||
|
xeMap.put("bProcessed", false);
|
||||||
|
xeMap.put("savedAnalysisResult", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return xeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> BetaGammaAnalyzeAllProcess(AnalyseData analyseData, String userName, String currentFileName){
|
||||||
|
//获取自建台站缓存信息
|
||||||
|
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||||
|
SelfStationData selfStationData = selfCache.getIfPresent(currentFileName + "-" + userName);
|
||||||
|
//从本地缓存获取beta gamma的数组
|
||||||
|
// Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||||
|
//返回最终结果用的map
|
||||||
|
Map<String, Map<String, Object>> analyseResultMap = new HashMap<>();
|
||||||
|
try {
|
||||||
|
//需要操作的数据集合
|
||||||
|
for (String sampleFileName: analyseData.getSampleFileNames()){
|
||||||
|
//使用当前文件名称获取用于获取计算的参数内容
|
||||||
|
// BetaDataFile betaDataFile = cache.getIfPresent(currentFileName + "-" + userName);
|
||||||
|
BetaDataFile betaDataFile = selfStationData.getBetaDataFile();
|
||||||
|
//获取缓存的计算结果
|
||||||
|
List<SeriseData> betaList = new LinkedList<>();
|
||||||
|
List<String> betaFittingPara = new LinkedList<>();
|
||||||
|
List<String> betaFittingParaToUi = new LinkedList<>();
|
||||||
|
List<List<Double>> betaNewEnergyListNow = new LinkedList<>();
|
||||||
|
List<SeriseData> gammaList = new LinkedList<>();
|
||||||
|
List<String> gammaFittingPara = new LinkedList<>();
|
||||||
|
List<String> gammaFittingParaToUi = new LinkedList<>();
|
||||||
|
List<List<Double>> gammaNewEnergyListNow = new LinkedList<>();
|
||||||
|
//根据sample文件名称获取当前文件的缓存信息
|
||||||
|
// BetaDataFile sampleBetaData = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
SelfStationData selfStationData1 = selfCache.getIfPresent(currentFileName + "-" + userName);
|
||||||
|
BetaDataFile sampleBetaData = selfStationData1.getBetaDataFile();
|
||||||
|
//存储重新分析字段的实体类
|
||||||
|
SpectrumGroup spectrum_group = new SpectrumGroup();
|
||||||
|
//声明一个map 缓存xeData计算后的结果
|
||||||
|
Map<String, Object> xeMap = new HashMap<>();
|
||||||
|
//判断beta是否进行过分析
|
||||||
|
if (analyseData.isBetaEnergyValid()) {
|
||||||
|
//判断缓存数据是否为空
|
||||||
|
if (Objects.nonNull(betaDataFile) && Objects.nonNull(sampleBetaData)) {
|
||||||
|
//重新分析时将当前的数组封装给到最终记录结果的数组中
|
||||||
|
betaDataFile.setBetaList(betaDataFile.getBetaListNow());
|
||||||
|
betaDataFile.setBetaFittingPara(betaDataFile.getBetaFittingParaNow());
|
||||||
|
betaDataFile.setBetaFittingParaToUi(betaDataFile.getBetaFittingParaToUiNow());
|
||||||
|
betaDataFile.setBetaNewEnergyList(betaDataFile.getBetaNewEnergyListNow());
|
||||||
|
//将新的数组封装到各自的数组中
|
||||||
|
betaList = betaDataFile.getBetaList();
|
||||||
|
betaFittingPara = betaDataFile.getBetaFittingPara();
|
||||||
|
betaFittingParaToUi = betaDataFile.getBetaFittingParaToUi();
|
||||||
|
betaNewEnergyListNow = betaDataFile.getBetaNewEnergyListNow();
|
||||||
|
//将当前文件用到的计算数据同步到需要计算的文件缓存
|
||||||
|
sampleBetaData.setBetaList(betaList);
|
||||||
|
sampleBetaData.setBetaFittingPara(betaFittingPara);
|
||||||
|
sampleBetaData.setBetaFittingParaToUi(betaFittingParaToUi);
|
||||||
|
sampleBetaData.setBetaNewEnergyList(betaNewEnergyListNow);
|
||||||
|
}
|
||||||
|
List<Double> beCal = new LinkedList<>();
|
||||||
|
beCal.add(Double.valueOf(betaFittingParaToUi.get(0)));
|
||||||
|
beCal.add(Double.valueOf(betaFittingParaToUi.get(1)));
|
||||||
|
beCal.add(Double.valueOf(betaFittingParaToUi.get(2)));
|
||||||
|
spectrum_group.BgCalPara.b_e_cal = beCal;
|
||||||
|
List<Double> bc2e = new LinkedList<>();
|
||||||
|
bc2e.add(Double.valueOf(betaFittingPara.get(0)));
|
||||||
|
bc2e.add(Double.valueOf(betaFittingPara.get(1)));
|
||||||
|
bc2e.add(Double.valueOf(betaFittingPara.get(2)));
|
||||||
|
spectrum_group.b_c2e = bc2e;
|
||||||
|
if (analyseData.isSampleData()) {
|
||||||
|
sampleBetaData.setBBetaEnergyValidSample(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
sampleBetaData.setSampleBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("sampleBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isGasBgData()) {
|
||||||
|
sampleBetaData.setBBetaEnergyValidGas(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
sampleBetaData.setGasBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("gasBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isDetBgData()) {
|
||||||
|
sampleBetaData.setBBetaEnergyValidDet(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
sampleBetaData.setDetBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("detBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isQcData()) {
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getBetaNewEnergyList())) {
|
||||||
|
sampleBetaData.setQcBetaEnergyList(betaDataFile.getBetaNewEnergyList());
|
||||||
|
xeMap.put("qcBetaEnergyData", betaDataFile.getBetaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//判断gamma是否进行了计算
|
||||||
|
if (analyseData.isGammaEnergyValid()) {
|
||||||
|
//判断缓存数据是否为空
|
||||||
|
if (Objects.nonNull(betaDataFile) && Objects.nonNull(sampleBetaData)) {
|
||||||
|
//重新分析时将当前的数组封装给到最终记录结果的数组中
|
||||||
|
betaDataFile.setGammaList(betaDataFile.getGammaListNow());
|
||||||
|
betaDataFile.setGammaFittingPara(betaDataFile.getGammaFittingParaNow());
|
||||||
|
betaDataFile.setGammaFittingParaToUi(betaDataFile.getGammaFittingParaToUiNow());
|
||||||
|
betaDataFile.setGammaNewEnergyList(betaDataFile.getGammaNewEnergyListNow());
|
||||||
|
//将新的数组封装到各自的数组中
|
||||||
|
gammaList = betaDataFile.getGammaList();
|
||||||
|
gammaFittingPara = betaDataFile.getGammaFittingPara();
|
||||||
|
gammaFittingParaToUi = betaDataFile.getGammaFittingParaToUi();
|
||||||
|
gammaNewEnergyListNow = betaDataFile.getGammaNewEnergyListNow();
|
||||||
|
//将当前文件用到的计算数据同步到需要计算的文件缓存
|
||||||
|
sampleBetaData.setGammaList(gammaList);
|
||||||
|
sampleBetaData.setGammaFittingPara(gammaFittingPara);
|
||||||
|
sampleBetaData.setGammaFittingParaToUi(gammaFittingParaToUi);
|
||||||
|
sampleBetaData.setGammaNewEnergyList(gammaNewEnergyListNow);
|
||||||
|
}
|
||||||
|
List<Double> geCal = new LinkedList<>();
|
||||||
|
geCal.add(Double.valueOf(gammaFittingParaToUi.get(0)));
|
||||||
|
geCal.add(Double.valueOf(gammaFittingParaToUi.get(1)));
|
||||||
|
geCal.add(Double.valueOf(gammaFittingParaToUi.get(2)));
|
||||||
|
spectrum_group.BgCalPara.g_e_cal = geCal;
|
||||||
|
List<Double> gc2e = new LinkedList<>();
|
||||||
|
gc2e.add(Double.valueOf(gammaFittingPara.get(0)));
|
||||||
|
gc2e.add(Double.valueOf(gammaFittingPara.get(1)));
|
||||||
|
gc2e.add(Double.valueOf(gammaFittingPara.get(2)));
|
||||||
|
spectrum_group.g_c2e = gc2e;
|
||||||
|
if (analyseData.isSampleData()) {
|
||||||
|
sampleBetaData.setBGammaEnergyValidSample(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
sampleBetaData.setSampleGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("sampleGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isGasBgData()) {
|
||||||
|
sampleBetaData.setBGammaEnergyValidGas(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
sampleBetaData.setGasGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("gasGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isDetBgData()) {
|
||||||
|
sampleBetaData.setBGammaEnergyValidDet(true);
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
sampleBetaData.setDetGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("detGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (analyseData.isQcData()) {
|
||||||
|
if (CollectionUtils.isNotEmpty(betaDataFile.getGammaNewEnergyList())) {
|
||||||
|
sampleBetaData.setQcGammaEnergyList(betaDataFile.getGammaNewEnergyList());
|
||||||
|
xeMap.put("qcGammaEnergyData", betaDataFile.getGammaNewEnergyList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData();
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData();
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData();
|
||||||
|
spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData();
|
||||||
|
File sampleTmp = null;
|
||||||
|
File gasTmp = null;
|
||||||
|
File detTmp = null;
|
||||||
|
if (StringUtils.isNotBlank(sampleBetaData.getSampleTmpPath())) {
|
||||||
|
sampleTmp = new File(sampleBetaData.getSampleTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(sampleBetaData.getGasTmpPath())) {
|
||||||
|
gasTmp = new File(sampleBetaData.getGasTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(sampleBetaData.getDetTmpPath())) {
|
||||||
|
detTmp = new File(sampleBetaData.getDetTmpPath());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
|
||||||
|
//调用分析方法进行分析操作
|
||||||
|
boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, sampleBetaData);
|
||||||
|
if (analyseData.isQcData()) {
|
||||||
|
if (StringUtils.isNotBlank(sampleBetaData.getQcFilePathName())) {
|
||||||
|
EnergySpectrumStruct struct = sampleBetaData.getQcStruct();
|
||||||
|
if (Objects.nonNull(struct)) {
|
||||||
|
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, xeMap, sampleBetaData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bRet) {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) xeMap.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
sampleBetaData.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) xeMap.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
sampleBetaData.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) xeMap.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
sampleBetaData.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) xeMap.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
sampleBetaData.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
List<GardsXeResultsSpectrum> xeResultsSpectrumList = (List<GardsXeResultsSpectrum>) xeMap.get("XeData");
|
||||||
|
if (CollectionUtils.isNotEmpty(xeResultsSpectrumList)){
|
||||||
|
for (GardsXeResultsSpectrum xeData:xeResultsSpectrumList) {
|
||||||
|
Double conc = xeData.getConc();
|
||||||
|
Double mdc = xeData.getMdc();
|
||||||
|
if (conc < 0){
|
||||||
|
xeData.setColor("red");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (0<conc && conc < mdc) {
|
||||||
|
xeData.setColor("#ffcc30");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (conc > mdc) {
|
||||||
|
xeData.setColor("green");
|
||||||
|
xeData.setNidFlag(1);
|
||||||
|
}
|
||||||
|
xeData.setMdc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc()))));
|
||||||
|
xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc()))));
|
||||||
|
xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr()))));
|
||||||
|
}
|
||||||
|
sampleBetaData.setXeResultsSpectrumList(xeResultsSpectrumList);
|
||||||
|
sampleBetaData.setBProcessed(true);
|
||||||
|
sampleBetaData.setSaveAnalysisResult(true);
|
||||||
|
sampleBetaData.setBgPara(spectrum_group.BgCalPara);
|
||||||
|
}
|
||||||
|
xeMap.put("bProcessed", true);
|
||||||
|
xeMap.put("savedAnalysisResult", true);
|
||||||
|
analyseResultMap.put(sampleFileName, xeMap);
|
||||||
|
} else {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) xeMap.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
sampleBetaData.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) xeMap.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
sampleBetaData.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) xeMap.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
sampleBetaData.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) xeMap.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
sampleBetaData.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
sampleBetaData.setBProcessed(false);
|
||||||
|
sampleBetaData.setSaveAnalysisResult(false);
|
||||||
|
sampleBetaData.setXeResultsSpectrumList(Collections.EMPTY_LIST);
|
||||||
|
xeMap.put("XeData", Collections.EMPTY_LIST);
|
||||||
|
xeMap.put("bProcessed", false);
|
||||||
|
xeMap.put("savedAnalysisResult", false);
|
||||||
|
analyseResultMap.put(sampleFileName, xeMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return analyseResultMap.get(currentFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result analyseCurrentSpectrum(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) {
|
||||||
|
Result result = new Result();
|
||||||
|
//获取用户名
|
||||||
|
String userName = JwtUtil.getUserNameByToken(request);
|
||||||
|
//获取自建台站缓存信息
|
||||||
|
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||||
|
SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
BetaDataFile betaDataFile = selfStationData.getBetaDataFile();
|
||||||
|
//根据sample文件名称-用户名获取缓存信息
|
||||||
|
// Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||||
|
// BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
if (Objects.isNull(betaDataFile)) {
|
||||||
|
result.error500("Load basic file information first!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
BgCalibratePara BgCalPara = null;
|
||||||
|
try {
|
||||||
|
//根据文件路径 文件名称获取对应的临时文件
|
||||||
|
File sampleTmp = null;
|
||||||
|
File gasTmp = null;
|
||||||
|
File detTmp = null;
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||||
|
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||||
|
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||||
|
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||||
|
}
|
||||||
|
if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) {
|
||||||
|
result.error500("Failed to obtain the ftp file. Procedure!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//获取计算后的数据
|
||||||
|
List<SeriseData> betaList = new LinkedList<>();
|
||||||
|
List<String> betaFittingParaToUi = new LinkedList<>();
|
||||||
|
List<SeriseData> gammaList = new LinkedList<>();
|
||||||
|
List<String> gammaFittingParaToUi = new LinkedList<>();
|
||||||
|
if (Objects.nonNull(betaDataFile)) {
|
||||||
|
betaList = betaDataFile.getBetaList();
|
||||||
|
betaFittingParaToUi = betaDataFile.getBetaFittingParaToUi();
|
||||||
|
gammaList = betaDataFile.getGammaList();
|
||||||
|
gammaFittingParaToUi = betaDataFile.getGammaFittingParaToUi();
|
||||||
|
BgCalPara = betaDataFile.getBgPara();
|
||||||
|
}
|
||||||
|
//调用分析方法
|
||||||
|
boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map, betaDataFile);
|
||||||
|
if (bRet) {
|
||||||
|
//分析qc文件信息并重新计算qc边界值
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getQcFilePathName())) {
|
||||||
|
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
|
||||||
|
if (Objects.nonNull(struct)) {
|
||||||
|
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map, betaDataFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) map.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
betaDataFile.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) map.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
betaDataFile.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) map.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
betaDataFile.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) map.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
betaDataFile.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(map)) {
|
||||||
|
List<GardsXeResultsSpectrum> xeDataList = (List<GardsXeResultsSpectrum>) map.get("XeData");
|
||||||
|
if (CollectionUtils.isNotEmpty(xeDataList)){
|
||||||
|
for (GardsXeResultsSpectrum xeData:xeDataList) {
|
||||||
|
Double conc = xeData.getConc();
|
||||||
|
Double mdc = xeData.getMdc();
|
||||||
|
if (conc < 0){
|
||||||
|
xeData.setColor("red");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (0<conc && conc < mdc) {
|
||||||
|
xeData.setColor("#ffcc30");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (conc > mdc) {
|
||||||
|
xeData.setColor("green");
|
||||||
|
xeData.setNidFlag(1);
|
||||||
|
}
|
||||||
|
xeData.setMdc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc()))));
|
||||||
|
xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc()))));
|
||||||
|
xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr()))));
|
||||||
|
}
|
||||||
|
betaDataFile.setXeResultsSpectrumList(xeDataList);
|
||||||
|
}
|
||||||
|
betaDataFile.setBProcessed(true);
|
||||||
|
betaDataFile.setSaveAnalysisResult(true);
|
||||||
|
map.put("bProcessed", true);
|
||||||
|
map.put("savedAnalysisResult", true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) map.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
betaDataFile.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) map.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
betaDataFile.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) map.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
betaDataFile.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) map.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
betaDataFile.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
map.put("XeData", Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setBProcessed(false);
|
||||||
|
betaDataFile.setSaveAnalysisResult(false);
|
||||||
|
betaDataFile.setXeResultsSpectrumList(Collections.EMPTY_LIST);
|
||||||
|
map.put("bProcessed", false);
|
||||||
|
map.put("savedAnalysisResult", false);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(map);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result analyseAllSpectrum(List<String> dbNames, List<Integer> sampleIds, List<String> sampleFileNames, List<String> gasFileNames, List<String> detFileNames, List<String> qcFileNames, String currentFileName, HttpServletRequest request) {
|
||||||
|
Result result = new Result();
|
||||||
|
//获取用户名
|
||||||
|
String userName = JwtUtil.getUserNameByToken(request);
|
||||||
|
//获取自建台站缓存信息
|
||||||
|
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||||
|
//获取本地缓存
|
||||||
|
// Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||||
|
Map<String, Map<String, Object>> mapList = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if (CollectionUtils.isNotEmpty(sampleFileNames)) {
|
||||||
|
for (int i=0; i<sampleFileNames.size(); i++) {
|
||||||
|
String sampleFileName = sampleFileNames.get(i);
|
||||||
|
BgCalibratePara BgCalPara = null;
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
//获取缓存数据
|
||||||
|
SelfStationData selfStationData = selfCache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
BetaDataFile betaDataFile = selfStationData.getBetaDataFile();
|
||||||
|
// BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||||
|
//根据文件路径 文件名称获取对应的临时文件
|
||||||
|
File sampleTmp = null;
|
||||||
|
File gasTmp = null;
|
||||||
|
File detTmp = null;
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||||
|
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||||
|
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||||
|
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||||
|
}
|
||||||
|
//获取缓存内容
|
||||||
|
List<SeriseData> betaList = new LinkedList<>();
|
||||||
|
List<String> betaFittingParaToUi = new LinkedList<>();
|
||||||
|
List<SeriseData> gammaList = new LinkedList<>();
|
||||||
|
List<String> gammaFittingParaToUi = new LinkedList<>();
|
||||||
|
if (Objects.nonNull(betaDataFile)) {
|
||||||
|
betaList = betaDataFile.getBetaList();
|
||||||
|
betaFittingParaToUi = betaDataFile.getBetaFittingParaToUi();
|
||||||
|
gammaList = betaDataFile.getGammaList();
|
||||||
|
gammaFittingParaToUi = betaDataFile.getGammaFittingParaToUi();
|
||||||
|
BgCalPara = betaDataFile.getBgPara();
|
||||||
|
}
|
||||||
|
if(Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
|
||||||
|
//调用分析方法
|
||||||
|
boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, BgCalPara, map, betaDataFile);
|
||||||
|
//分析qc文件信息并重新计算qc边界值
|
||||||
|
if (StringUtils.isNotBlank(betaDataFile.getQcFilePathName())) {
|
||||||
|
EnergySpectrumStruct struct = betaDataFile.getQcStruct();
|
||||||
|
if (Objects.nonNull(struct)) {
|
||||||
|
phdFileUtil.CalQCBoundary(betaList, gammaList, betaFittingParaToUi, gammaFittingParaToUi, struct, map, betaDataFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bRet) {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) map.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
betaDataFile.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) map.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
betaDataFile.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) map.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
betaDataFile.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) map.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
betaDataFile.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
List<GardsXeResultsSpectrum> xeDataList = (List<GardsXeResultsSpectrum>) map.get("XeData");
|
||||||
|
if (CollectionUtils.isNotEmpty(xeDataList)){
|
||||||
|
for (GardsXeResultsSpectrum xeData:xeDataList) {
|
||||||
|
Double conc = xeData.getConc();
|
||||||
|
Double mdc = xeData.getMdc();
|
||||||
|
if (conc < 0){
|
||||||
|
xeData.setColor("red");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (0<conc && conc < mdc) {
|
||||||
|
xeData.setColor("#ffcc30");
|
||||||
|
xeData.setNidFlag(0);
|
||||||
|
} else if (conc > mdc) {
|
||||||
|
xeData.setColor("green");
|
||||||
|
xeData.setNidFlag(1);
|
||||||
|
}
|
||||||
|
xeData.setMdc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getMdc()))));
|
||||||
|
xeData.setConc(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConc()))));
|
||||||
|
xeData.setConcErr(Double.valueOf(NumberFormatUtil.numberSixLen(String.valueOf(xeData.getConcErr()))));
|
||||||
|
}
|
||||||
|
betaDataFile.setXeResultsSpectrumList(xeDataList);
|
||||||
|
}
|
||||||
|
betaDataFile.setBProcessed(true);
|
||||||
|
betaDataFile.setSaveAnalysisResult(true);
|
||||||
|
map.put("bProcessed", true);
|
||||||
|
map.put("savedAnalysisResult", true);
|
||||||
|
mapList.put(sampleFileName, map);
|
||||||
|
} else {
|
||||||
|
List<Boundary> sampleBoundary = (List<Boundary>) map.get("SampleBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(sampleBoundary)) {
|
||||||
|
betaDataFile.setSampleBoundary(sampleBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> gasBoundary = (List<Boundary>) map.get("GasBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(gasBoundary)) {
|
||||||
|
betaDataFile.setGasBoundary(gasBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> detBoundary = (List<Boundary>) map.get("DetBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(detBoundary)) {
|
||||||
|
betaDataFile.setDetBoundary(detBoundary);
|
||||||
|
}
|
||||||
|
List<Boundary> qcBoundary = (List<Boundary>) map.get("QCBoundary");
|
||||||
|
if(CollectionUtils.isNotEmpty(qcBoundary)) {
|
||||||
|
betaDataFile.setQcBoundary(qcBoundary);
|
||||||
|
}
|
||||||
|
map.put("XeData", Collections.EMPTY_LIST);
|
||||||
|
betaDataFile.setBProcessed(false);
|
||||||
|
betaDataFile.setSaveAnalysisResult(false);
|
||||||
|
betaDataFile.setXeResultsSpectrumList(Collections.EMPTY_LIST);
|
||||||
|
map.put("bProcessed", false);
|
||||||
|
map.put("savedAnalysisResult", false);
|
||||||
|
mapList.put(sampleFileName, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
result.setSuccess(true);
|
||||||
|
result.setResult(mapList);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPoints, Integer count,
|
public Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPoints, Integer count,
|
||||||
String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request) {
|
String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user