fix:1。增加qc文件;2.增加交互分析(gamma)

This commit is contained in:
xiaoguangbin 2024-07-17 09:53:43 +08:00
parent 9bbdd5eb5d
commit 03d92b7889
7 changed files with 191 additions and 65 deletions

View File

@ -40,6 +40,10 @@ public class SelfStationUtil extends AbstractLogOrReport {
struct = selfStationData.getSampleStruct();
} else if (systemType.equals("det")) {
struct = selfStationData.getDetStruct();
} else if (systemType.equals("qc")) {
struct = selfStationData.getQcStruct();
} else {
return;
}
//存储页面操作数据
SelfStationVueData selfStationVueData = new SelfStationVueData();
@ -143,6 +147,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getDetVueData().setROIOneBetaStart(startChannel);
selfStationData.getDetVueData().setROIOneBetaStop(endChannel);
selfStationData.getDetVueData().setROIOneList(seriseDataList);
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)oneMap.get("counts"));
}
map.put("ROIOneStart", roiBBoundaryStart.get(0));
map.put("ROIOneStop", roiBBoundaryStop.get(0));
@ -158,10 +163,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getSampleVueData().setROITwoBetaStart(startChannel);
selfStationData.getSampleVueData().setROITwoBetaStop(endChannel);
selfStationData.getSampleVueData().setROITwoList(seriseDataList);
selfStationData.getSampleVueData().setROITwoCounts((List<Long>)twoMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROITwoBetaStart(startChannel);
selfStationData.getDetVueData().setROITwoBetaStop(endChannel);
selfStationData.getDetVueData().setROITwoList(seriseDataList);
selfStationData.getSampleVueData().setROITwoCounts((List<Long>)twoMap.get("counts"));
}
map.put("ROITwoStart", roiBBoundaryStart.get(1));
map.put("ROITwoStop", roiBBoundaryStop.get(1));
@ -177,11 +184,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getSampleVueData().setROIThreeBetaStart(startChannel);
selfStationData.getSampleVueData().setROIThreeBetaStop(endChannel);
selfStationData.getSampleVueData().setROIThreeList(seriseDataList);
selfStationData.getSampleVueData().setROIThreeCounts((List<Long>)threeMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROIThreeBetaStart(startChannel);
selfStationData.getDetVueData().setROIThreeBetaStop(endChannel);
selfStationData.getDetVueData().setROIThreeList(seriseDataList);
selfStationData.getSampleVueData().setROIOneCounts((List<Long>)threeMap.get("counts"));
selfStationData.getSampleVueData().setROIThreeCounts((List<Long>)threeMap.get("counts"));
}
map.put("ROIThreeStart", roiBBoundaryStart.get(2));
map.put("ROIThreeStop", roiBBoundaryStop.get(2));
@ -197,10 +205,12 @@ public class SelfStationUtil extends AbstractLogOrReport {
selfStationData.getSampleVueData().setROIFourBetaStart(startChannel);
selfStationData.getSampleVueData().setROIFourBetaStop(endChannel);
selfStationData.getSampleVueData().setROIFourList(seriseDataList);
selfStationData.getSampleVueData().setROIFourCounts((List<Long>)fourMap.get("counts"));
} else if (systemType.equals("det")) {
selfStationData.getDetVueData().setROIFourBetaStart(startChannel);
selfStationData.getDetVueData().setROIFourBetaStop(endChannel);
selfStationData.getDetVueData().setROIFourList(seriseDataList);
selfStationData.getSampleVueData().setROIFourCounts((List<Long>)fourMap.get("counts"));
}
map.put("ROIFourStart", roiBBoundaryStart.get(3));
map.put("ROIFourStop", roiBBoundaryStop.get(3));
@ -472,7 +482,8 @@ public class SelfStationUtil extends AbstractLogOrReport {
return equation;
}
public void UpdateChartResolution(List<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurReso, SelfStationData selfStationData, Double width, Map<String, Object> map) {
public void UpdateChartResolution(List<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurReso,
SelfStationData selfStationData, Double width, Map<String, Object> map) {
int num = m_vCurEnergy.size();
if(num < 1) return;

View File

@ -22,8 +22,9 @@ public class SelfStationController {
@GetMapping("initValue")
@ApiOperation(value = "预加载谱文件数据", notes = "预加载谱文件数据")
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName, HttpServletRequest request) {
selfStationService.initValue(dbName, sampleId, analyst, sampleFileName, detFileName, request);
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName,
String qcFileName, HttpServletRequest request) {
selfStationService.initValue(dbName, sampleId, analyst, sampleFileName, detFileName,qcFileName, request);
}
@GetMapping("loadFromDB")
@ -34,8 +35,8 @@ public class SelfStationController {
@GetMapping("loadFromFile")
@ApiOperation(value = "从文件加载自建台站谱数据", notes = "从文件加载自建台站谱数据")
public Result loadFromFile(String sampleFileName, String detFileName, HttpServletRequest request) {
return selfStationService.loadSelfStationByFile(sampleFileName, detFileName, request);
public Result loadFromFile(String sampleFileName, String detFileName, String qcFileName, HttpServletRequest request) {
return selfStationService.loadSelfStationByFile(sampleFileName, detFileName, qcFileName, request);
}
@DeleteMapping("deleteSelfStationCache")

View File

@ -4,9 +4,8 @@ import lombok.Data;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@Data
public class SelfStationData implements Serializable {
@ -21,6 +20,11 @@ public class SelfStationData implements Serializable {
*/
private String detTmpPath;
/**
* qc临时文件路径
*/
private String qcTmpPath;
/**
* sample文件分析内容
*/
@ -112,6 +116,31 @@ public class SelfStationData implements Serializable {
public SelfStationData() {
sampleVueData = new SelfStationVueData();
detVueData = new SelfStationVueData();
betaList = new LinkedList<>();
betaFittingPara = new LinkedList<>();
betaFittingParaToUi = new LinkedList<>();
gammaList = new LinkedList<>();
gammaFittingPara = new LinkedList<>();
gammaFittingParaToUi = new LinkedList<>();
betaListNow = new LinkedList<>();
betaFittingParaNow = new LinkedList<>();
betaFittingParaToUiNow = new LinkedList<>();
gammaListNow = new LinkedList<>();
gammaFittingParaNow = new LinkedList<>();
gammaFittingParaToUiNow = new LinkedList<>();
bGammaEnergyValidSample = false;
bBetaEnergyValidSample = false;
bGammaEnergyValidGas = false;
bBetaEnergyValidGas = false;
bGammaEnergyValidDet = false;
bBetaEnergyValidDet = false;
gammaNewEnergyListNow = new LinkedList<>();
betaNewEnergyListNow = new LinkedList<>();
}
}

View File

@ -13,24 +13,44 @@ public class SelfStationVueData implements Serializable {
/**
* ROI-1结果数据
*/
//折线图横纵坐标数组
/**
* 折线图横纵坐标数组
*/
private List<SeriseData> ROIOneList;
private List<Long> ROIOneCounts;
//ROI-1范围矩形框起始道值
/**
* ROI-1范围矩形框起始道值
*/
private Integer ROIOneBetaStart;
//ROI-1范围矩形框终止道值
/**
* ROI-1范围矩形框终止道值
*/
private Integer ROIOneBetaStop;
/**
* ROI-1 GammaPHD数据
*/
private PHDFile ROIOnePHDFile;
/**
* ROI-2结果数据
*/
//折线图横纵坐标数组
/**
* 折线图横纵坐标数组
*/
private List<SeriseData> ROITwoList;
private List<Long> ROITwoCounts;
//ROI-2范围矩形框起始道值
/**
* ROI-2范围矩形框起始道值
*/
private Integer ROITwoBetaStart;
//ROI-2范围矩形框终止道值
/**
* ROI-2范围矩形框终止道值
*/
private Integer ROITwoBetaStop;
/**
* ROI-2 GammaPHD数据
*/
private PHDFile ROITwoPHDFile;
/**
* ROI-3结果数据
@ -42,6 +62,10 @@ public class SelfStationVueData implements Serializable {
private Integer ROIThreeBetaStart;
//ROI-3范围矩形框终止道值
private Integer ROIThreeBetaStop;
/**
* ROI-3 GammaPHD数据
*/
private PHDFile ROIThreePHDFile;
/**
* ROI-4结果数据
@ -53,6 +77,10 @@ public class SelfStationVueData implements Serializable {
private Integer ROIFourBetaStart;
//ROI-4范围矩形框终止道值
private Integer ROIFourBetaStop;
/**
* ROI-4 GammaPHD数据
*/
private PHDFile ROIFourPHDFile;
// 当前修改的刻度名称
private String newEner;

View File

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

View File

@ -5,9 +5,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.google.common.cache.Cache;
import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.cache.SelfCache;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
@ -55,11 +55,12 @@ public class SelfStationServiceImpl implements ISelfStationService {
private SpectrumAnalysisMapper spectrumAnalysisMapper;
@Override
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName, HttpServletRequest request) {
public void initValue(String dbName, Integer sampleId, String analyst, String sampleFileName, String detFileName,
String qcFileName, HttpServletRequest request) {
if (StringUtils.isNotBlank(dbName) && Objects.nonNull(sampleId)) {
loadFromDB(dbName, sampleId, analyst, request);
} else {
loadSelfStationByFile(sampleFileName, detFileName, request);
loadSelfStationByFile(sampleFileName, detFileName,qcFileName, request);
}
}
@ -164,7 +165,8 @@ public class SelfStationServiceImpl implements ISelfStationService {
}
@Override
public Result loadSelfStationByFile(String sampleFileName, String detFileName, HttpServletRequest request) {
public Result loadSelfStationByFile(String sampleFileName, String detFileName, String qcFileName,
HttpServletRequest request) {
Result result = new Result();
Map<String, Map<String, Object>> resultMap = new HashMap<>();
//获取用户名
@ -209,6 +211,21 @@ public class SelfStationServiceImpl implements ISelfStationService {
resultMap.put("det", map);
}
}
//判断qc文件名是否为空
if (StringUtils.isNotBlank(qcFileName)) {
//拼接det文件路径
String qcFilePath = path + StringPool.SLASH + qcFileName;
//返回结果map
Map<String, Object> map = new HashMap<>();
//获取sample分析后的对象
EnergySpectrumStruct struct = selfStationUtil.getSourceData(qcFilePath, "qc", selfStationData);
if (Objects.nonNull(struct)) {
selfStationData.setQcStruct(struct);
selfStationData.setQcTmpPath(qcFilePath);
selfStationUtil.loadFile(selfStationData, null, null, "qc", map);
resultMap.put("qc", map);
}
}
} else {
if (StringUtils.isNotBlank(sampleFileName)) {
//返回结果map
@ -1641,79 +1658,110 @@ public class SelfStationServiceImpl implements ISelfStationService {
// Gamma文件内容转换为PHD实体
PHDFile phd = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
PHDFile phdOne = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
PHDFile phdTwo = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
PHDFile phdThree = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
PHDFile phdFour = selfStationUtil.getGammaPHD(gammaTwoName, pathName);
// Cache<String, PHDFile> phdCache = localCache.getPHDCache();
// PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
if (Objects.isNull(phd)) {
if (Objects.isNull(phdOne)) {
result.error500("Please select the parse file first");
return result;
}
phd.setUserId(processKey);
phdOne.setUserId(processKey);
// 赋值xml文件存放路径
phd.setXmlFilePath(parameterProperties.getFilePath());
phdOne.setXmlFilePath(parameterProperties.getFilePath());
// 获取当前角色的颜色配置
Map<String, String> colorMap = sysUserColorService.initColor(userName);
// 分析文件数据
int flag = gammaFileUtil.AnalyseData(phd);
int flag = gammaFileUtil.AnalyseData(phdOne);
if (flag == 0) {
String warning = "The spectrum needn't Analyed. Maybe:\n" +
"1. It has already Analyed.\n" +
"2. You didn't change any setting or calibration.";
result.error500(warning);
} else if (flag == -1) {
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type());
//分析时将phd的核素map重置
phd.setPhdNuclideMap(nuclideLinesMap);
phdOne.setPhdNuclideMap(nuclideLinesMap);
//重新计算核素的活度浓度
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
// todo 不要qcflags
// gammaFileUtil.RunQC(phd);
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
phd.setEfficiencyCurRow(0);
gammaFileUtil.NuclidesIdent(phdOne, nuclideLinesMap);
phdOne.setEfficiencyParam(phdOne.getUsedEffiPara().getP());
phdOne.setEfficiencyEnergy(phdOne.getUsedEffiKD().getG_energy());
phdOne.setEfficiencyCurRow(0);
// 重新计算峰值
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
gammaFileUtil.getNuclideMDCValue(phd, phd.getMdcInfoMap(), nuclideLinesMDCMap);
gammaFileUtil.getNuclideMDCValue(phdOne, phdOne.getMdcInfoMap(), nuclideLinesMDCMap);
String warning = "Finish three tasks:\n" +
"\t1.Update efficiencies of all peaks;\n" +
"\t2.Identify nuclides again;\n" +
"\t3.Test QC again.";
result.error500(warning);
} else {
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type());
try {
Map<String, Object> gammaResult = Maps.newHashMap();
Map<String, Object> map1 = this.gammaAnalyse(phdOne, nuclideLinesMap, colorMap);
Map<String, Object> map2 = this.gammaAnalyse(phdTwo, nuclideLinesMap, colorMap);
Map<String, Object> map3 = this.gammaAnalyse(phdThree, nuclideLinesMap, colorMap);
Map<String, Object> map4 = this.gammaAnalyse(phdFour, nuclideLinesMap, colorMap);
gammaResult.put("ROI1", map1);
gammaResult.put("ROI2", map2);
gammaResult.put("ROI3", map3);
gammaResult.put("ROI4", map4);
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
sampleVueData.setUsedEnerKD(phdOne.getUsedEnerKD());
sampleVueData.setUsedEffiKD(phdOne.getUsedEffiKD());
sampleVueData.setUsedResoKD(phdOne.getUsedResoKD());
sampleVueData.setMapEnerKD(phdOne.getMapEnerKD());
sampleVueData.setMapResoKD(phdOne.getMapResoKD());
sampleVueData.setMapEffiKD(phdOne.getMapEffiKD());
sampleVueData.setUsedEnerPara(phdOne.getUsedEnerPara());
sampleVueData.setUsedEffiPara(phdOne.getUsedEffiPara());
sampleVueData.setUsedResoPara(phdOne.getUsedResoPara());
sampleVueData.setMapEnerPara(phdOne.getMapEnerPara());
sampleVueData.setMapResoPara(phdOne.getMapResoPara());
sampleVueData.setMapEffiPara(phdOne.getMapEffiPara());
result.setSuccess(true);
result.setResult(gammaResult);
} catch (RuntimeException e) {
result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI"));
}
}
return result;
}
private Map<String, Object> gammaAnalyse(PHDFile phd, Map<String, NuclideLines> nuclideLinesMap,
Map<String, String> colorMap) throws RuntimeException{
Map<String, Object> map = new HashMap<>();
//分析时将phd的核素map重置
phd.setPhdNuclideMap(nuclideLinesMap);
//调用分析算法
boolean analyseSpectrum = gammaFileUtil.AnalyseSpectrum(phd, nuclideLinesMap);
if (analyseSpectrum) {
// 重新分析各峰值对应的核素信息
// gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
phd.setEfficiencyParam(phd.getUsedEffiPara().getP());
phd.setEfficiencyEnergy(phd.getUsedEffiKD().getG_energy());
phd.setEfficiencyCurRow(0);
// 重新计算峰值
Map<String, NuclideLines> nuclideLinesMDCMap = (Map<String, NuclideLines>) redisUtil.get("AllNuclideMap");
gammaFileUtil.getNuclideMDCValue(phd, phd.getMdcInfoMap(), nuclideLinesMDCMap);
Map<String, Object> map = new HashMap<>();
gammaFileUtil.UpdateChart(phd, map, colorMap);
// 更新 QC Flags 状态
phd.getQcItems().clear();
// List<String> qcstate = gammaFileUtil.Qcstate(phd);
// todo 不要qcflags
// map.put("QCFlag", qcstate);
map.put("bAnalyed", phd.isBAnalyed());
map.put("peak", phd.getVPeak());
map.put("BaseCtrls", phd.getBaseCtrls());
// Bar Chart 柱状图
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
map.put("barChart", differance);
result.setSuccess(true);
result.setResult(map);
} else {
result.error500("There is a problem with the current phd file, Analysis failure!");
throw new RuntimeException("There is a problem with the current %s phd file, Analysis failure!");
}
}
return result;
return map;
}
}

View File

@ -380,11 +380,19 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
detaFileName = detphd;
detStatus = true;
}
//匹配获取QCFile
boolean qcStatus = true;
String qcphd = phdFileUtil.GetQCPHD(sampleFileName, fileNames);
if (StringUtils.isBlank(qcphd)) {
qcphd = sampleFileName.substring(0, 23)+"_Q.PHD";
qcStatus = false;
}
map.put("sampleFileName", sampleFileName);
map.put("gasFileName", "");
map.put("detFileName", detaFileName);
map.put("detFileStatus", detStatus);
map.put("qcFileName", "");
map.put("qcFileName", qcphd);
map.put("qcFileStatus", qcStatus);
map.put("sampleSystemType", sampleSystemType);
}
}