fix:增加interactive弹窗内的接口
This commit is contained in:
parent
b5d4b23f3c
commit
3d97ffb539
|
@ -11,4 +11,6 @@ public class SeriseData implements Serializable {
|
|||
|
||||
private double y;
|
||||
|
||||
private double e;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ import cn.hutool.core.util.StrUtil;
|
|||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.cache.SelfCache;
|
||||
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
|
||||
import org.jeecg.modules.base.enums.CalName;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
|
@ -970,4 +972,37 @@ public class SelfStationUtil extends AbstractLogOrReport {
|
|||
out.printf("%" + ( c.length() + (17 - b.length())) + "s", c+"\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ROI从selfStationData 获取对应的gamma数据
|
||||
* @param gammaROINum
|
||||
* @param selfStationCache
|
||||
* @return
|
||||
*/
|
||||
public PHDFile getGammaPHD(String fileName, String userName, int gammaROINum, SelfCache selfStationCache) {
|
||||
PHDFile phd = null;
|
||||
//获取自建台站缓存信息
|
||||
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||
SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||
if (Objects.isNull(selfStationData)) {
|
||||
return phd;
|
||||
}
|
||||
switch (gammaROINum) {
|
||||
case 1:
|
||||
phd = selfStationData.getSampleVueData().getROIOnePHDFile();
|
||||
break;
|
||||
case 2:
|
||||
phd = selfStationData.getSampleVueData().getROITwoPHDFile();
|
||||
break;
|
||||
case 3:
|
||||
phd = selfStationData.getSampleVueData().getROIThreePHDFile();
|
||||
break;
|
||||
case 4:
|
||||
phd = selfStationData.getSampleVueData().getROIFourPHDFile();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return phd;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jeecg.modules.controller;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
import org.jeecg.modules.entity.vo.ChangeData;
|
||||
import org.jeecg.modules.entity.vo.ConfigureData;
|
||||
import org.jeecg.modules.entity.vo.FittingBody;
|
||||
|
@ -179,6 +180,99 @@ public class SelfStationController {
|
|||
return selfStationService.Reprocessing(fileName, processKey, request);
|
||||
}
|
||||
|
||||
@GetMapping("InteractiveTool")
|
||||
@ApiOperation(value = "analyze菜单下InteractiveTool页面数据", notes = "analyze菜单下InteractiveTool页面数据")
|
||||
public Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request) {
|
||||
return selfStationService.InteractiveTool(sampleId, fileName, gammaROINum, request);
|
||||
}
|
||||
|
||||
@GetMapping("insertPeak")
|
||||
@ApiOperation(value = "InteractiveTool页面Insert按钮页面", notes = "InteractiveTool页面Insert按钮页面")
|
||||
public Result insertPeak(Integer sampleId, String fileName, int gammaROINum, Integer curChan, HttpServletRequest request) {
|
||||
return selfStationService.insertPeak(sampleId, fileName, gammaROINum, curChan, request);
|
||||
}
|
||||
|
||||
@PostMapping("acceptResults")
|
||||
@ApiOperation(value = "InteractiveTool页面Insert页面save", notes = "InteractiveTool页面Insert页面save")
|
||||
public Result acceptResults(@RequestBody AcceptInfo acceptInfo, HttpServletRequest request) {
|
||||
return selfStationService.acceptResults(acceptInfo.getFileName(), acceptInfo.getGammaROINum(),
|
||||
acceptInfo.isAccept(), acceptInfo.getOldPeak(), acceptInfo.getTablePeaksList(), acceptInfo.getNewPeak(),
|
||||
acceptInfo.getFlag(), request);
|
||||
}
|
||||
|
||||
@GetMapping("deletePeak")
|
||||
@ApiOperation(value = "InteractiveTool页面delete按钮", notes = "InteractiveTool页面delete按钮")
|
||||
public Result deletePeak(String fileName, int gammaROINum, int curRow, HttpServletRequest request) {
|
||||
return selfStationService.deletePeak(fileName, curRow, gammaROINum, request);
|
||||
}
|
||||
|
||||
@GetMapping("fitPeak")
|
||||
public Result fitPeak(int left, int right, String fileName, int gammaROINum, HttpServletRequest request) {
|
||||
return selfStationService.fitPeak(left, right, fileName, gammaROINum, request);
|
||||
}
|
||||
|
||||
@GetMapping("getGammaSelPosNuclide")
|
||||
@ApiOperation(value = "gamma主页面选择channel加载对应核素信息接口", notes = "gamma主页面选择channel加载对应核素信息接口")
|
||||
public Result getGammaSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, double energy, HttpServletRequest request) {
|
||||
return selfStationService.getGammaSelPosNuclide(sampleId, fileName, gammaROINum, channel, energy, request);
|
||||
}
|
||||
|
||||
@GetMapping("getGammaSelPosNuclideApp")
|
||||
@ApiOperation(value = "gamma主页面选择channel加载对应核素信息接口", notes = "gamma主页面选择channel加载对应核素信息接口")
|
||||
public Result getGammaSelPosNuclideApp(@RequestParam("sampleId") Integer sampleId,@RequestParam("fileName") String fileName,
|
||||
int gammaROINum,
|
||||
@RequestParam("channel") int channel,@RequestParam("energy") double energy,
|
||||
HttpServletRequest request) {
|
||||
return selfStationService.getGammaSelPosNuclide(sampleId, fileName, gammaROINum, channel, energy, request);
|
||||
}
|
||||
|
||||
@GetMapping("getSelPosNuclide")
|
||||
@ApiOperation(value = "InteractiveTool页面选择channel加载对应核素信息接口", notes = "InteractiveTool页面选择channel加载对应核素信息接口")
|
||||
public Result getSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, HttpServletRequest request) {
|
||||
return selfStationService.getSelPosNuclide(sampleId, fileName, gammaROINum, channel, request);
|
||||
}
|
||||
|
||||
@PostMapping("addNuclide")
|
||||
@ApiOperation(value = "InteractiveTool页面增加核素信息接口", notes = "InteractiveTool页面增加核素信息接口")
|
||||
public Result addNuclide(@RequestBody NuclideInfo nuclideInfo, HttpServletRequest request) {
|
||||
return selfStationService.addNuclide(nuclideInfo.getCurRow(), nuclideInfo.getNuclideName(),
|
||||
nuclideInfo.getFileName(), nuclideInfo.getGammaRoiNum(), nuclideInfo.getList_identify(), request);
|
||||
}
|
||||
|
||||
@PostMapping("deleteNuclide")
|
||||
@ApiOperation(value = "InteractiveTool页面删除核素信息接口", notes = "InteractiveTool页面删除核素信息接口")
|
||||
public Result deleteNuclide(@RequestBody NuclideInfo nuclideInfo, HttpServletRequest request) {
|
||||
return selfStationService.deleteNuclide(nuclideInfo.getCurRow(), nuclideInfo.getNuclideName(),
|
||||
nuclideInfo.getFileName(), nuclideInfo.getGammaRoiNum(), nuclideInfo.getList_identify(), request);
|
||||
}
|
||||
|
||||
@GetMapping("viewPeakComment")
|
||||
@ApiOperation(value = "InteractiveTool页面查看峰对应备注信息接口", notes = "InteractiveTool页面查看峰对应备注信息接口")
|
||||
public Result viewPeakComment(String fileName, int gammaROINum, int curRow, HttpServletRequest request) {
|
||||
return selfStationService.viewPeakComment(fileName, gammaROINum, curRow, request);
|
||||
}
|
||||
|
||||
@PostMapping("addPeakComment")
|
||||
@ApiOperation(value = "InteractiveTool页面add峰对应备注信息接口", notes = "InteractiveTool页面add峰对应备注信息接口")
|
||||
public Result addPeakComment(@RequestBody CommentsInfo commentsInfo, HttpServletRequest request) {
|
||||
return selfStationService.addPeakComment(commentsInfo.getFileName(), commentsInfo.getCurRow(),
|
||||
commentsInfo.getGammaROINum(),commentsInfo.getComments(), request);
|
||||
}
|
||||
|
||||
@GetMapping("viewGeneralComment")
|
||||
@ApiOperation(value = "InteractiveTool页面查看备注信息接口", notes = "InteractiveTool页面查看备注信息接口")
|
||||
public Result viewGeneralComment(String fileName, int gammaROINum, HttpServletRequest request) {
|
||||
return selfStationService.viewGeneralComment(fileName, gammaROINum, request);
|
||||
}
|
||||
|
||||
@PostMapping("addGeneralComment")
|
||||
@ApiOperation(value = "InteractiveTool页面add备注信息接口", notes = "InteractiveTool页面add备注信息接口")
|
||||
public Result addGeneralComment(@RequestBody CommentsInfo commentsInfo, HttpServletRequest request) {
|
||||
return selfStationService.addGeneralComment(commentsInfo.getFileName(), commentsInfo.getGammaROINum(),
|
||||
commentsInfo.getComments(), request);
|
||||
}
|
||||
|
||||
/***************************************** beta ******************************************/
|
||||
|
||||
@PostMapping("fitting")
|
||||
@ApiOperation(value = "公式计算新的曲线", notes = "公式计算新的曲线")
|
||||
|
|
|
@ -20,4 +20,6 @@ public class AcceptInfo implements Serializable {
|
|||
|
||||
private String flag;
|
||||
|
||||
private Integer gammaROINum;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ public class CommentsInfo implements Serializable {
|
|||
|
||||
private String comments;
|
||||
|
||||
private int gammaROINum;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ public class NuclideInfo implements Serializable {
|
|||
|
||||
private Integer curRow;
|
||||
|
||||
private Integer gammaRoiNum;
|
||||
|
||||
private String nuclideName;
|
||||
|
||||
private String fileName;
|
||||
|
|
|
@ -13,6 +13,10 @@ public class SelfStationVueData implements Serializable {
|
|||
/**
|
||||
* ROI-1结果数据
|
||||
*/
|
||||
/**
|
||||
* ROI-1 Gamma文件名称
|
||||
*/
|
||||
private String ROIOneFileName;
|
||||
/**
|
||||
* 折线图横纵坐标数组
|
||||
*/
|
||||
|
@ -34,6 +38,10 @@ public class SelfStationVueData implements Serializable {
|
|||
/**
|
||||
* ROI-2结果数据
|
||||
*/
|
||||
/**
|
||||
* ROI-2 Gamma文件名称
|
||||
*/
|
||||
private String ROITwoFileName;
|
||||
/**
|
||||
* 折线图横纵坐标数组
|
||||
*/
|
||||
|
@ -55,6 +63,10 @@ public class SelfStationVueData implements Serializable {
|
|||
/**
|
||||
* ROI-3结果数据
|
||||
*/
|
||||
/**
|
||||
* ROI-3 Gamma文件名称
|
||||
*/
|
||||
private String ROIThreeFileName;
|
||||
//折线图横纵坐标数组
|
||||
private List<SeriseData> ROIThreeList;
|
||||
private List<Long> ROIThreeCounts;
|
||||
|
@ -70,6 +82,10 @@ public class SelfStationVueData implements Serializable {
|
|||
/**
|
||||
* ROI-4结果数据
|
||||
*/
|
||||
/**
|
||||
* ROI-4 Gamma文件名称
|
||||
*/
|
||||
private String ROIFourFileName;
|
||||
//折线图横纵坐标数组
|
||||
private List<SeriseData> ROIFourList;
|
||||
private List<Long> ROIFourCounts;
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.jeecg.modules.service;
|
|||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.entity.vo.ConfigureData;
|
||||
import org.jeecg.modules.entity.vo.ParameterInfo;
|
||||
import org.jeecg.modules.entity.vo.PeakInfo;
|
||||
import org.jeecg.modules.entity.vo.SeriseData;
|
||||
import org.jeecg.modules.entity.vo.TablePeaks;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -65,6 +67,33 @@ public interface ISelfStationService {
|
|||
|
||||
Result Reprocessing(String fileName, String processKey, HttpServletRequest request);
|
||||
|
||||
Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request);
|
||||
|
||||
Result insertPeak(Integer sampleId, String fileName, int gammaROINum, Integer curChan, HttpServletRequest request);
|
||||
|
||||
Result acceptResults(String fileName, int gammaROINum, boolean accept, List<PeakInfo> oldPeak, List<TablePeaks> tablePeaksList,
|
||||
List<PeakInfo> newPeak, String flag, HttpServletRequest request);
|
||||
|
||||
Result deletePeak(String fileName, int curRow, int gammaROINum, HttpServletRequest request);
|
||||
|
||||
Result fitPeak(int left, int right, String fileName, int gammaROINum, HttpServletRequest request);
|
||||
|
||||
Result getGammaSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, double energy, HttpServletRequest request);
|
||||
|
||||
Result getSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, HttpServletRequest request);
|
||||
|
||||
Result addNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum, List<String> list_identify, HttpServletRequest request);
|
||||
|
||||
Result deleteNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum, List<String> list_identify, HttpServletRequest request);
|
||||
|
||||
Result viewPeakComment(String fileName, int gammaROINum, int curRow, HttpServletRequest request);
|
||||
|
||||
Result addPeakComment(String fileName, int gammaROINum, int curRow, String comments, HttpServletRequest request);
|
||||
|
||||
Result viewGeneralComment(String fileName, int gammaROINum, HttpServletRequest request);
|
||||
|
||||
Result addGeneralComment(String fileName, int gammaROINum, String comments, HttpServletRequest request);
|
||||
|
||||
Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPointsArray, Integer count,
|
||||
String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request);
|
||||
|
||||
|
|
|
@ -4,10 +4,13 @@ import cn.hutool.core.collection.ListUtil;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -240,6 +243,33 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
selfStationData.setSampleStruct(struct);
|
||||
selfStationData.setSampleTmpPath(sampleFilePath);
|
||||
selfStationUtil.loadFile(selfStationData, null, null, "sample", map);
|
||||
|
||||
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(gammaTwoName, path));
|
||||
sampleVueData.setROITwoFileName(gammaTwoName);
|
||||
sampleVueData.setROITwoPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
|
||||
sampleVueData.setROIThreeFileName(gammaThreeName);
|
||||
sampleVueData.setROIThreePHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
|
||||
sampleVueData.setROIFourFileName(gammaFourName);
|
||||
sampleVueData.setROIFourPHDFile(selfStationUtil.getGammaPHD(gammaTwoName, path));
|
||||
|
||||
resultMap.put("sample", map);
|
||||
// 初始化Configure
|
||||
initConfigure(struct, selfStationData);
|
||||
|
@ -1799,43 +1829,19 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
//获取自建台站缓存信息
|
||||
Cache<String, SelfStationData> selfCache = selfStationCache.getSelfCache();
|
||||
SelfStationData selfStationData = selfCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
// 根据ROI生成四个Gamma谱文件
|
||||
// 文件命名为Beta名称后面_ROI_x.PHD
|
||||
|
||||
// 生成Gamma文件名
|
||||
String gammaOneName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_1.PHD";
|
||||
// 创建Gamma文件
|
||||
selfStationUtil.createGammaFile(pathName, gammaOneName, selfStationData.getSampleStruct(),
|
||||
selfStationData.getSampleVueData().getROIOneCounts());
|
||||
|
||||
String gammaTwoName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_2.PHD";
|
||||
selfStationUtil.createGammaFile(pathName, gammaTwoName, selfStationData.getSampleStruct(),
|
||||
selfStationData.getSampleVueData().getROITwoCounts());
|
||||
|
||||
String gammaThreeName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_3.PHD";
|
||||
selfStationUtil.createGammaFile(pathName, gammaThreeName, selfStationData.getSampleStruct(),
|
||||
selfStationData.getSampleVueData().getROIThreeCounts());
|
||||
|
||||
String gammaFourName = StrUtil.subBefore(fileName, ".PHD", true) + "_ROI_4.PHD";
|
||||
selfStationUtil.createGammaFile(pathName, gammaFourName, selfStationData.getSampleStruct(),
|
||||
selfStationData.getSampleVueData().getROIFourCounts());
|
||||
|
||||
|
||||
|
||||
// Gamma文件内容转换为PHD实体
|
||||
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(phdOne)) {
|
||||
if (Objects.isNull(selfStationData)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
|
||||
SelfStationVueData sampleVueData = selfStationData.getSampleVueData();
|
||||
|
||||
// Gamma文件内容转换为PHD实体
|
||||
PHDFile phdOne = sampleVueData.getROIOnePHDFile();
|
||||
PHDFile phdTwo = sampleVueData.getROITwoPHDFile();
|
||||
PHDFile phdThree = sampleVueData.getROIThreePHDFile();
|
||||
PHDFile phdFour = sampleVueData.getROIFourPHDFile();
|
||||
|
||||
phdOne.setUserId(processKey);
|
||||
// 赋值xml文件存放路径
|
||||
phdOne.setXmlFilePath(parameterProperties.getFilePath());
|
||||
|
@ -1848,8 +1854,9 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
"1. It has already Analyed.\n" +
|
||||
"2. You didn't change any setting or calibration.";
|
||||
result.error500(warning);
|
||||
} else if (flag == -1) {
|
||||
} else {
|
||||
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self");
|
||||
if (flag == -1) {
|
||||
//分析时将phd的核素map重置
|
||||
phdOne.setPhdNuclideMap(nuclideLinesMap);
|
||||
//重新计算核素的活度浓度
|
||||
|
@ -1866,7 +1873,6 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
"\t3.Test QC again.";
|
||||
result.error500(warning);
|
||||
} else {
|
||||
Map<String, NuclideLines> nuclideLinesMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phdOne.getHeader().getSystem_type()+"-self");
|
||||
|
||||
try {
|
||||
Map<String, Object> gammaResult = Maps.newHashMap();
|
||||
|
@ -1878,7 +1884,7 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
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());
|
||||
|
@ -1898,9 +1904,826 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
result.error500(StrUtil.replace(e.getMessage(), "%s", "ROI"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result InteractiveTool(Integer sampleId, String fileName, int gammaROINum, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||
// 表单
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("table", vPeak);
|
||||
// Chart 折线图
|
||||
List<Long> m_vCount = new LinkedList<>();
|
||||
long m_nCount = phd.getSpec().getNum_g_channel();
|
||||
long m_nSChan = phd.getSpec().getBegin_channel();
|
||||
// 确保绘制曲线时所有谱都是从1道开始
|
||||
int i = 0;
|
||||
if (m_nSChan == 0) {
|
||||
i = 1;
|
||||
}
|
||||
for (; i < m_nCount; ++i) {
|
||||
m_vCount.add(phd.getSpec().getCounts().get(i));
|
||||
}
|
||||
if (m_nSChan == 0) {
|
||||
m_vCount.add(0L);
|
||||
}
|
||||
ChartData channelCountChart = gammaFileUtil.Channel_Count(phd, colorMap.get("Color_Spec"));
|
||||
ChartData channelBaseLineChart = gammaFileUtil.Channel_BaseLine(phd, colorMap.get("Color_Base"));
|
||||
List<ChartData> channelPeakChart = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak"));
|
||||
List<ShapeData> channelBaseCPChart = gammaFileUtil.Channel_BaseCP(phd);
|
||||
map.put("channelCountChart", channelCountChart);
|
||||
map.put("channelBaseLineChart", channelBaseLineChart);
|
||||
map.put("channelPeakChart", channelPeakChart);
|
||||
map.put("channelBaseCPChart", channelBaseCPChart);
|
||||
// Bar Chart 柱状图
|
||||
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
|
||||
map.put("barChart", differance);
|
||||
// 赋值energy
|
||||
map.put("energy", phd.getVEnergy());
|
||||
// 赋值BaseCtrls
|
||||
map.put("BaseCtrls", phd.getBaseCtrls());
|
||||
// FitBaseLine颜色
|
||||
map.put("FitBaseLine", colorMap.get("Color_Fitbase"));
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result insertPeak(Integer sampleId, String fileName, int gammaROINum, Integer curChan, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
// 判断当前选中的channel是否在正常允许范围内
|
||||
if (curChan <= phd.getBaseCtrls().getRg_low() + 1 || curChan >= phd.getBaseCtrls().getRg_high() - 1) {
|
||||
result.error500("Couldn't insert peak, maybe out of range");
|
||||
return result;
|
||||
}
|
||||
// 备份原来的峰列表
|
||||
List<PeakInfo> vOriPeaks = new LinkedList<>();
|
||||
vOriPeaks.addAll(phd.getVPeak());
|
||||
List<Double> peakCentroid = new LinkedList<>();
|
||||
List<Double> fwhmc = new LinkedList<>();
|
||||
List<Double> tail = new LinkedList<>();
|
||||
List<Double> tailAlpha = new LinkedList<>();
|
||||
List<Double> upperTail = new LinkedList<>();
|
||||
List<Double> upperTailAlpha = new LinkedList<>();
|
||||
List<Double> area = new LinkedList<>();
|
||||
List<Double> stepRatio = new LinkedList<>();
|
||||
for (PeakInfo peakInfo : vOriPeaks) {
|
||||
peakCentroid.add(peakInfo.peakCentroid);
|
||||
fwhmc.add(peakInfo.fwhmc);
|
||||
tail.add(peakInfo.tail);
|
||||
tailAlpha.add(peakInfo.tailAlpha);
|
||||
upperTail.add(peakInfo.upperTail);
|
||||
upperTailAlpha.add(peakInfo.upperTailAlpha);
|
||||
area.add(peakInfo.area);
|
||||
stepRatio.add(peakInfo.area * peakInfo.stepRatio);
|
||||
}
|
||||
// 声明基础数据
|
||||
List<Double> m_vCount = new LinkedList<>();
|
||||
long m_nCount = phd.getSpec().getNum_g_channel();
|
||||
long m_nSChan = phd.getSpec().getBegin_channel();
|
||||
|
||||
// 确保绘制曲线时所有谱都是从1道开始
|
||||
int i = 0;
|
||||
if (m_nSChan == 0) i = 1;
|
||||
for (; i < m_nCount; ++i) {
|
||||
m_vCount.add(phd.getSpec().getCounts().get(i).doubleValue());
|
||||
}
|
||||
if (m_nSChan == 0) {
|
||||
m_vCount.add(0.0);
|
||||
}
|
||||
// 添加到vPeak中
|
||||
gammaFileUtil.InitPara(phd);
|
||||
// 插入峰
|
||||
StructInsertInput insertInput = new StructInsertInput();
|
||||
insertInput.peakCentroid = peakCentroid;
|
||||
insertInput.fwhmc = fwhmc;
|
||||
insertInput.tail = tail;
|
||||
insertInput.tailAlpha = tailAlpha;
|
||||
insertInput.upperTail = upperTail;
|
||||
insertInput.upperTailAlpha = upperTailAlpha;
|
||||
insertInput.area = area;
|
||||
insertInput.stepRatio = stepRatio;
|
||||
insertInput.usedEnerPara = phd.getUsedEnerPara().getP();
|
||||
insertInput.usedResoPara = phd.getUsedResoPara().getP();
|
||||
insertInput.usedEffiPara = phd.getUsedEffiPara().getP();
|
||||
insertInput.num_g_channel = phd.getSpec().getNum_g_channel();
|
||||
insertInput.begin_channel = phd.getSpec().getBegin_channel();
|
||||
insertInput.XCtrl = phd.getBaseCtrls().getXCtrl();
|
||||
insertInput.YCtrl = phd.getBaseCtrls().getYCtrl();
|
||||
insertInput.YSlope = phd.getBaseCtrls().getYSlope();
|
||||
insertInput.para_tail = phd.getPara_tail().getP();
|
||||
insertInput.para_tailAlpha = phd.getPara_tailAlpha().getP();
|
||||
insertInput.para_tailRight = phd.getPara_tailRight().getP();
|
||||
insertInput.para_tailRightAlpha = phd.getPara_tailRightAlpha().getP();
|
||||
insertInput.para_stepRatio = phd.getPara_stepRatio().getP();
|
||||
insertInput.rg_low = phd.getBaseCtrls().getRg_low();
|
||||
insertInput.rg_high = phd.getBaseCtrls().getRg_high();
|
||||
insertInput.curChan = curChan;
|
||||
insertInput.vCount = m_vCount;
|
||||
StructInsertOutput structInsertOutput = CalValuesHandler.insertPeaks(insertInput);
|
||||
List<PeakInfo> newPeaks = new LinkedList<>();
|
||||
newPeaks.addAll(phd.getVPeak());
|
||||
if (structInsertOutput.vIdx.size() > 0) {
|
||||
for (int j = 0; j < structInsertOutput.vIdx.size(); j++) {
|
||||
int a = 0;
|
||||
while (a < phd.getVPeak().size() && structInsertOutput.peakCentroid.get(j) > phd.getVPeak().get(a).peakCentroid) {
|
||||
++a;
|
||||
}
|
||||
PeakInfo peak = new PeakInfo();
|
||||
peak.index = a + 1;
|
||||
peak.left = structInsertOutput.vLeft.get(j).intValue();
|
||||
peak.right = structInsertOutput.vRight.get(j).intValue();
|
||||
peak.peakCentroid = structInsertOutput.peakCentroid.get(j);
|
||||
peak.energy = structInsertOutput.energy.get(j);
|
||||
peak.area = structInsertOutput.area.get(j);
|
||||
Double sensitivity = String.valueOf(structInsertOutput.sensitivity.get(j)).equalsIgnoreCase("nan") ? Double.NaN : structInsertOutput.sensitivity.get(j);
|
||||
peak.sensitivity = sensitivity;
|
||||
peak.fwhm = structInsertOutput.fwhm.get(j);
|
||||
peak.fwhmc = structInsertOutput.fwhmc.get(j);
|
||||
peak.stepRatio = structInsertOutput.stepRatio.get(j);
|
||||
peak.tail = structInsertOutput.tail.get(j);
|
||||
peak.tailAlpha = structInsertOutput.tailAlpha.get(j);
|
||||
peak.upperTail = structInsertOutput.upperTail.get(j);
|
||||
peak.upperTailAlpha = structInsertOutput.upperTailAlpha.get(j);
|
||||
peak.efficiency = structInsertOutput.efficiency.get(j);
|
||||
peak.BWWidthChan = 0;
|
||||
peak.recoilBetaChan = Objects.isNull(structInsertOutput.recoilBetaChan.get(j))?"nan":String.valueOf(structInsertOutput.recoilBetaChan.get(j));
|
||||
peak.recoilDeltaChan = Objects.isNull(structInsertOutput.recoilDeltaChan.get(j))?"nan":String.valueOf(structInsertOutput.recoilDeltaChan.get(j));
|
||||
newPeaks.add(a, peak);
|
||||
}
|
||||
}
|
||||
int left = structInsertOutput.vLeft.get(0).intValue();
|
||||
int right = structInsertOutput.vRight.get(0).intValue();
|
||||
|
||||
List<Integer> vIdx = new LinkedList<>();
|
||||
int ii = 0;
|
||||
for (PeakInfo peak : newPeaks) {
|
||||
if (peak.peakCentroid >= right) {
|
||||
break;
|
||||
} else if (peak.peakCentroid > left) {
|
||||
vIdx.add(ii);
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
|
||||
FitPeakBaseLine(newPeaks, phd.getUsedEnerPara().getP(), vIdx, map);
|
||||
map.put("oldPeaks", vOriPeaks);
|
||||
map.put("newPeaks", newPeaks);
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void FitPeakBaseLine(List<PeakInfo> vPeaks, List<Double> p, List<Integer> vIdx, Map<String, Object> map) {
|
||||
List<TablePeaks> tablePeaksList = new LinkedList<>();
|
||||
int peakNum = vIdx.size();
|
||||
for (int i = 0; i < peakNum; i++) {
|
||||
int peakIdx = vIdx.get(i);
|
||||
PeakInfo peak = vPeaks.get(peakIdx);
|
||||
TablePeaks tablePeaks = new TablePeaks();
|
||||
tablePeaks.setLab(String.valueOf(peakIdx + 1));
|
||||
String nuclide = "";
|
||||
for (String peakNuclide : peak.nuclides) {
|
||||
nuclide += peakNuclide + ";";
|
||||
}
|
||||
tablePeaks.setNuclide(org.apache.commons.lang3.StringUtils.isBlank(nuclide) ? nuclide : nuclide.substring(0, nuclide.length() - 1));
|
||||
|
||||
tablePeaks.setEnergy(NumberFormatUtil.numberFormat(String.valueOf(peak.energy)));
|
||||
tablePeaks.setNetArea(NumberFormatUtil.numberFormat(String.valueOf(peak.area)));
|
||||
tablePeaks.setFwhm(NumberFormatUtil.numberFormat(String.valueOf(peak.fwhm)));
|
||||
tablePeaks.setStep(NumberFormatUtil.numberFormat(String.valueOf(peak.area * peak.stepRatio)));
|
||||
double deriva = CalValuesHandler.calDerivaOut(peak.peakCentroid, p);
|
||||
tablePeaks.setBwGamma(NumberFormatUtil.numberFormat(String.valueOf(peak.BWWidthChan * deriva)));
|
||||
tablePeaks.setNetAreaB(false);
|
||||
tablePeaks.setCentroid(true);
|
||||
tablePeaks.setFwhmB(true);
|
||||
tablePeaksList.add(tablePeaks);
|
||||
}
|
||||
map.put("tablePeaksList", tablePeaksList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result acceptResults(String fileName, int gammaROINum, boolean accept, List<PeakInfo> oldPeak,
|
||||
List<TablePeaks> tablePeaksList, List<PeakInfo> newPeak, String flag, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
List<Long> m_vCount = new LinkedList<>();
|
||||
long m_nCount = phd.getSpec().getNum_g_channel();
|
||||
long m_nSChan = phd.getSpec().getBegin_channel();
|
||||
// 获取当前角色的颜色配置
|
||||
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||
// 确保绘制曲线时所有谱都是从1道开始
|
||||
int i = 0;
|
||||
if (m_nSChan == 0) {
|
||||
i = 1;
|
||||
}
|
||||
for (; i < m_nCount; ++i) {
|
||||
m_vCount.add(phd.getSpec().getCounts().get(i));
|
||||
}
|
||||
if (m_nSChan == 0) {
|
||||
m_vCount.add(0L);
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// 根据boolean 决定是否保留本次数据 如果保留则不需要操作vPeak 并重新拟合线
|
||||
if (accept) {
|
||||
Map<String, NuclideLines> nuclideLinesMap = phd.getPhdNuclideMap();//(Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
if (flag.equalsIgnoreCase("insert")) {// 如果传递的flag标识 是 Insert则进行峰值的插入
|
||||
//重新赋值index
|
||||
for (int k=0; k<newPeak.size(); k++) {
|
||||
newPeak.get(k).index = k;
|
||||
}
|
||||
phd.setVPeak(newPeak);
|
||||
}
|
||||
|
||||
List<Double> vC_Rg = new LinkedList<>();
|
||||
vC_Rg.add(Double.valueOf(phd.getBaseCtrls().getRg_low()));
|
||||
vC_Rg.add(Double.valueOf(phd.getBaseCtrls().getRg_high()));
|
||||
|
||||
List<Double> vE_Rg = CalValuesHandler.calFcnEval(vC_Rg, phd.getUsedEnerPara().getP()).counts;
|
||||
if (vE_Rg.size() != 2 || vE_Rg.get(0).isNaN() || vE_Rg.get(1).isNaN()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
List<Integer> Af = new LinkedList<>();
|
||||
List<Integer> Cf = new LinkedList<>();
|
||||
List<Integer> Ff = new LinkedList<>();
|
||||
// 遍历列表中的数据
|
||||
for (int j = 0; j < tablePeaksList.size(); j++) {
|
||||
TablePeaks nPeak = tablePeaksList.get(j);
|
||||
PeakInfo peak = phd.getVPeak().get(Integer.valueOf(nPeak.getLab()) - 1);
|
||||
double dE = CalValuesHandler.calDerivaOut(peak.peakCentroid, phd.getUsedEnerPara().getP());
|
||||
peak.energy = Double.parseDouble(nPeak.getEnergy());
|
||||
|
||||
if (peak.energy < vE_Rg.get(0) || peak.energy > vE_Rg.get(1)) {
|
||||
result.error500("The energy isn't in the analysis range.");
|
||||
return result;
|
||||
}
|
||||
List<Double> energys = new LinkedList<>();
|
||||
energys.add(peak.energy);
|
||||
peak.peakCentroid = CalValuesHandler.energyToChannel(energys, phd.getUsedEnerPara().getP()).counts.get(0);
|
||||
peak.area = Double.parseDouble(nPeak.getNetArea());
|
||||
peak.fwhm = Double.parseDouble(nPeak.getFwhm());
|
||||
peak.stepRatio = Double.valueOf(nPeak.getStep()) / peak.area;
|
||||
peak.BWWidthChan = Double.valueOf(nPeak.getBwGamma()) / dE;
|
||||
if (dE > 0) {
|
||||
peak.fwhmc = peak.fwhm / dE;
|
||||
}
|
||||
|
||||
if (!tablePeaksList.get(j).isNetAreaB()) {
|
||||
Af.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1);
|
||||
}
|
||||
if (!tablePeaksList.get(j).isCentroid()) {
|
||||
Cf.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1);
|
||||
}
|
||||
if (!tablePeaksList.get(j).isFwhmB()) {
|
||||
Ff.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1);
|
||||
}
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String phdStr = mapper.writeValueAsString(phd);
|
||||
String strValue = CalValuesHandler.fitPeakFull(phdStr, Af, Cf, Ff);
|
||||
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
|
||||
for (Map.Entry<String, Object> entry : parseMap.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("vPeak")) {
|
||||
List<PeakInfo> value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class);
|
||||
for (PeakInfo info:value) {
|
||||
if (info.significance == -9999) {
|
||||
info.significance = Double.POSITIVE_INFINITY;
|
||||
}
|
||||
}
|
||||
phd.setVPeak(value);
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("vBase")) {
|
||||
List<Double> vBase = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class);
|
||||
phd.setVBase(vBase);
|
||||
phd.getBaseCtrls().setBaseline(vBase);
|
||||
}
|
||||
}
|
||||
// 重新计算peak的改变
|
||||
gammaFileUtil.PeaksChanged(phd);
|
||||
//重新计算核素活度浓度
|
||||
gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap);
|
||||
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("table", vPeak);
|
||||
List<ChartData> channelPeak = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak"));
|
||||
map.put("channelPeakChart", channelPeak);
|
||||
ChartData channelBaseLine = gammaFileUtil.Channel_BaseLine(phd, colorMap.get("Color_Base"));
|
||||
map.put("channelBaseLineChart", channelBaseLine);
|
||||
List<SeriseData> differance = gammaFileUtil.Differance(phd, phd.getVPeak());
|
||||
map.put("barChart", differance);
|
||||
gammaFileUtil.UpdateChart(phd, map, colorMap);
|
||||
} else {// 如果不保留 根据下标移除对应的vPeak数据
|
||||
if (CollectionUtils.isNotEmpty(oldPeak)) {
|
||||
phd.getVPeak().clear();
|
||||
phd.setVPeak(oldPeak);
|
||||
map.put("table", phd.getVPeak());
|
||||
List<ChartData> channelPeak = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak"));
|
||||
map.put("channelPeakChart", channelPeak);
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deletePeak(String fileName, int gammaROINum, int curRow, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
//获取用户名称
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
//获取缓存的核素信息
|
||||
Map<String, NuclideLines> nuclideMap = phd.getPhdNuclideMap();
|
||||
//获取颜色信息
|
||||
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||
//声明一个结果的map
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
//获取峰的大小
|
||||
int peakNum = phd.getVPeak().size();
|
||||
if (peakNum < 1) {
|
||||
result.error500("No peak to delete.");
|
||||
return result;
|
||||
}
|
||||
//判断当前要操作的下标是否在范围内
|
||||
if (curRow >= 0 && curRow < peakNum) {
|
||||
//获取当前下标位置的峰值信息
|
||||
PeakInfo info = phd.getVPeak().get(curRow);
|
||||
//获取当前选中的峰值信息的能量值
|
||||
double energy = info.energy;
|
||||
if (CollectionUtils.isNotEmpty(info.nuclides)) {
|
||||
//遍历核素信息
|
||||
for (int i=0; i<info.nuclides.size(); i++) {
|
||||
String nuclideName = info.nuclides.get(i);
|
||||
//从缓存信息中获取核素名称
|
||||
NuclideLines nuclideLines = nuclideMap.get(nuclideName);
|
||||
//获取最大活度的核素位置
|
||||
int maxYeildIdx = nuclideLines.maxYeildIdx;
|
||||
//获取最大活度对应的核素能量值
|
||||
Double maxEnergy = nuclideLines.getVenergy().get(maxYeildIdx);
|
||||
//判断当前选中的峰值信息的能量值 是否在 最大活度对应的核素能量值公差范围内
|
||||
if (energy >= maxEnergy-0.5 && energy <= maxEnergy+0.5) {
|
||||
//则需要删除所有关联的核素信息并 从MapNucAct中移除相关核素内容
|
||||
for (PeakInfo peakInfo: phd.getVPeak()) {
|
||||
//如果峰的核素名称中包含当前删除的核素
|
||||
if (peakInfo.nuclides.contains(nuclideName)) {
|
||||
peakInfo.nuclides.remove(nuclideName);
|
||||
}
|
||||
}
|
||||
//从核素相关map中移除核素信息
|
||||
phd.getMapNucActMda().remove(nuclideName);
|
||||
//移除核素信息
|
||||
nuclideMap.remove(nuclideName);
|
||||
}
|
||||
}
|
||||
}
|
||||
//将当前行从峰数组中移除
|
||||
phd.getVPeak().remove(curRow);
|
||||
//重新计算核素活度浓度
|
||||
gammaFileUtil.NuclidesIdent(phd, nuclideMap);
|
||||
//重新分析数据
|
||||
gammaFileUtil.PeaksChanged(phd);
|
||||
for (int i = 0; i < phd.getVPeak().size(); i++) {
|
||||
PeakInfo peakInfo = phd.getVPeak().get(i);
|
||||
peakInfo.index = i;
|
||||
}
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("table", vPeak);
|
||||
List<ChartData> channelPeak = gammaFileUtil.Channel_Peak(phd, colorMap.get("Color_Peak"));
|
||||
map.put("channelPeakChart", channelPeak);
|
||||
gammaFileUtil.UpdateChart(phd, map, colorMap);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result fitPeak(int left, int right, String fileName, int gammaROINum, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
// 获取用户名
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
// 判断当前phd文件对应的peak的数据是否小于1
|
||||
if (phd.getVPeak().size() < 1) {
|
||||
result.error500("No peak to fit.");
|
||||
return result;
|
||||
}
|
||||
// 判断当前选择的左侧道值是否大于右侧道值
|
||||
if (left > right) {
|
||||
int temp = left;
|
||||
left = right;
|
||||
right = temp;
|
||||
}
|
||||
|
||||
// 找出与插入峰相关联的峰的索引
|
||||
List<Integer> vIdx = new LinkedList<>();
|
||||
int ii = 0;
|
||||
for (PeakInfo peak : phd.getVPeak()) {
|
||||
if (peak.peakCentroid >= right) {
|
||||
break;
|
||||
} else if (peak.peakCentroid > left) {
|
||||
vIdx.add(ii);
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(vIdx)) {
|
||||
result.error500("There are 0 peak between channel " + left + " and " + right);
|
||||
return result;
|
||||
}
|
||||
// 备份原来的峰列表
|
||||
List<PeakInfo> vOriPeaks = phd.getVPeak();
|
||||
|
||||
FitPeakBaseLine(phd.getVPeak(), phd.getUsedEnerPara().getP(), vIdx, map);
|
||||
map.put("oldPeaks", vOriPeaks);
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getGammaSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, double energy,
|
||||
HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
if (phd.getVPeak().size() < 1) {
|
||||
return result;
|
||||
}
|
||||
// if (energy > 0) {
|
||||
// channel = (int) gammaFileUtil.GetEnergyByFloatChan(phd, (int) energy);
|
||||
// } else if (channel > 0){
|
||||
// energy = gammaFileUtil.GetEnergyByFloatChan(phd, channel);
|
||||
// }
|
||||
int index = gammaFileUtil.FindNearPeak(phd.getVPeak(), channel, false);
|
||||
|
||||
//获取缓存的核素信息
|
||||
Map<String, NuclideLines> nuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
Map<String, NuclideLines> nuclCoincidenceSumMap = (Map<String, NuclideLines>) redisUtil.get("nuclCoincidenceSumMap");
|
||||
//计算核素范围的最小能量值
|
||||
double min = energy - phd.getSetting().getEnergyTolerance();
|
||||
//计算核素范围的最大能量值
|
||||
double max = energy + phd.getSetting().getEnergyTolerance();
|
||||
//声明返回的数组内容
|
||||
List<String> list_possible = new LinkedList<>();
|
||||
//判断缓存的核素信息是否为空
|
||||
if (CollectionUtils.isNotEmpty(nuclideMap)) {
|
||||
//遍历核素信息
|
||||
for (Map.Entry<String, NuclideLines> entry:nuclideMap.entrySet()) {
|
||||
//获取核素的关联信息
|
||||
NuclideLines nuclideLines = entry.getValue();
|
||||
//获取核素关联的全部能量信息
|
||||
List<Double> venergy = nuclideLines.getVenergy();
|
||||
List<String> fullNames = nuclideLines.getFullNames();
|
||||
//遍历能量
|
||||
for (int i=0; i<venergy.size(); i++) {
|
||||
//如果有一个能量在范围内 则将核素名称存入返回结果数组并结束当前核素名称的循环
|
||||
if (Objects.nonNull(venergy.get(i)) && venergy.get(i) > min && venergy.get(i) < max) {
|
||||
list_possible.add(fullNames.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (phd.getHeader().getSystem_type().equals("P")) {
|
||||
if (CollectionUtils.isNotEmpty(nuclCoincidenceSumMap)) {
|
||||
for (Map.Entry<String, NuclideLines> entry:nuclCoincidenceSumMap.entrySet()) {
|
||||
//获取核素的关联信息
|
||||
NuclideLines nuclideLines = entry.getValue();
|
||||
//获取核素关联的全部能量信息
|
||||
List<Double> venergy = nuclideLines.getVenergy();
|
||||
List<String> fullNames = nuclideLines.getFullNames();
|
||||
//遍历能量
|
||||
for (int i=0; i<venergy.size(); i++) {
|
||||
//如果有一个能量在范围内 则将核素名称存入返回结果数组并结束当前核素名称的循环
|
||||
if (Objects.nonNull(venergy.get(i)) && venergy.get(i) > min && venergy.get(i) < max) {
|
||||
list_possible.add(fullNames.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 用户当前已选中的核素名称
|
||||
List<String> list_identify = phd.getVPeak().get(index).nuclides;
|
||||
|
||||
map.put("index", index);
|
||||
map.put("possible", list_possible);
|
||||
map.put("identify", list_identify);
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getSelPosNuclide(Integer sampleId, String fileName, int gammaROINum, int channel, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
if (phd.getVPeak().size() < 1) {
|
||||
return result;
|
||||
}
|
||||
int index = gammaFileUtil.FindNearPeak(phd.getVPeak(), channel, false);
|
||||
|
||||
//获取缓存的核素信息
|
||||
Map<String, NuclideLines> nuclideMap = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
//计算核素范围的最小能量值
|
||||
double min = phd.getVPeak().get(index).energy - phd.getSetting().getEnergyTolerance();
|
||||
//计算核素范围的最大能量值
|
||||
double max = phd.getVPeak().get(index).energy + phd.getSetting().getEnergyTolerance();
|
||||
//声明返回的数组内容
|
||||
List<String> list_possible = new LinkedList<>();
|
||||
//判断缓存的核素信息是否为空
|
||||
if (CollectionUtils.isNotEmpty(nuclideMap)) {
|
||||
//遍历核素信息
|
||||
for (Map.Entry<String, NuclideLines> entry:nuclideMap.entrySet()) {
|
||||
//获取核素的关联信息
|
||||
NuclideLines nuclideLines = entry.getValue();
|
||||
//获取核素关联的全部能量信息
|
||||
List<Double> venergy = nuclideLines.getVenergy();
|
||||
//遍历能量
|
||||
for (int i=0; i<venergy.size(); i++) {
|
||||
//如果有一个能量在范围内 则将核素名称存入返回结果数组并结束当前核素名称的循环
|
||||
if (Objects.nonNull(venergy.get(i)) && venergy.get(i) > min && venergy.get(i) < max) {
|
||||
list_possible.add(entry.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 用户当前已选中的核素名称
|
||||
List<String> list_identify = phd.getVPeak().get(index).nuclides;
|
||||
|
||||
map.put("index", index);
|
||||
map.put("possible", list_possible);
|
||||
map.put("identify", list_identify);
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum,
|
||||
List<String> list_identify, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
// 获取需要新增的核素名称
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(nuclideName)) {
|
||||
result.error500("The nuclide name cannot be empty!");
|
||||
return result;
|
||||
}
|
||||
// 判断当前用户的核素列表是否有核素信息 如果不为空就返回 不进行改变
|
||||
if (list_identify.indexOf(nuclideName) > 0) {
|
||||
return result;
|
||||
}
|
||||
// 用户当前的核素信息新增核素名称
|
||||
list_identify.add(nuclideName);
|
||||
// 根据要进行修改的列的数据下标 操作Vpeak数据
|
||||
List<String> peakNuclides = phd.getVPeak().get(curRow).nuclides;
|
||||
if (peakNuclides.indexOf(nuclideName) < 0 ) {
|
||||
peakNuclides.add(nuclideName);
|
||||
}
|
||||
// 查询当前用户所关心的核素名称
|
||||
Map<String, NuclideLines> mapNucLines = (Map<String, NuclideLines>) redisUtil.get(userName+StringPool.DASH+phd.getHeader().getSystem_type());
|
||||
//用户当前缓存的核素信息
|
||||
Map<String, NuclideLines> phdNuclideMap = phd.getPhdNuclideMap();
|
||||
// 查询出核素信息
|
||||
NuclideLines it_line = mapNucLines.get(nuclideName);
|
||||
// 如果核素信息不存在返回
|
||||
if (Objects.isNull(it_line)) {
|
||||
return result;
|
||||
}
|
||||
List<Integer> vPeakIdx = new LinkedList<>(); // 从 0 开始
|
||||
int t_idx = 0;
|
||||
for (PeakInfo peak : phd.getVPeak()) {
|
||||
if (peak.nuclides.contains(nuclideName)) {
|
||||
vPeakIdx.add(t_idx);
|
||||
}
|
||||
t_idx++;
|
||||
}
|
||||
//重新计算核素的MDA值
|
||||
gammaFileUtil.CalcNuclideMDA(phd, it_line, nuclideName, vPeakIdx);
|
||||
map.put("identify", list_identify);
|
||||
//格式化核素表单内容
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("table", vPeak);
|
||||
//如果当前缓存的谱核素信息不包含当前核素
|
||||
if (Objects.isNull(phdNuclideMap.get(nuclideName))) {
|
||||
//将redis缓存的谱核素信息 存入到缓存map中
|
||||
phdNuclideMap.put(nuclideName, it_line);
|
||||
phd.setPhdNuclideMap(phdNuclideMap);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteNuclide(Integer curRow, String nuclideName, String fileName, int gammaROINum,
|
||||
List<String> list_identify, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
//获取用户名
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, NuclideLines> nuclideMap = phd.getPhdNuclideMap();
|
||||
//判断当前选择的核素名称是否包含在当前Peak的核素列表中
|
||||
int index = list_identify.indexOf(nuclideName);
|
||||
if (index >= 0) {
|
||||
// 如果所选的行下标小于0 或者 超出界限 则不进行处理
|
||||
if (curRow < 0 || curRow >= phd.getVPeak().size()) {
|
||||
return result;
|
||||
}
|
||||
//从缓存信息中获取核素名称
|
||||
NuclideLines nuclideLines = nuclideMap.get(nuclideName);
|
||||
//获取最大活度的核素位置
|
||||
int maxYeildIdx = nuclideLines.maxYeildIdx;
|
||||
//获取最大活度对应的核素能量值
|
||||
Double maxEnergy = nuclideLines.getVenergy().get(maxYeildIdx);
|
||||
//获取当前选中的峰值信息的能量值
|
||||
double energy = phd.getVPeak().get(curRow).energy;
|
||||
//判断当前选中的峰值信息的能量值 是否在 最大活度对应的核素能量值公差范围内
|
||||
if (energy >= maxEnergy-0.5 && energy <= maxEnergy+0.5) {
|
||||
//则需要删除所有关联的核素信息并 从MapNucAct中移除相关核素内容
|
||||
for (PeakInfo peakInfo: phd.getVPeak()) {
|
||||
//如果峰的核素名称中包含当前删除的核素
|
||||
if (peakInfo.nuclides.contains(nuclideName)) {
|
||||
peakInfo.nuclides.remove(nuclideName);
|
||||
}
|
||||
}
|
||||
//从核素相关map中移除核素信息
|
||||
phd.getMapNucActMda().remove(nuclideName);
|
||||
//移除核素信息
|
||||
nuclideMap.remove(nuclideName);
|
||||
//重新计算核素活度浓度
|
||||
gammaFileUtil.NuclidesIdent(phd, nuclideMap);
|
||||
//从核素的选中列表中移除对应下标的核素信息
|
||||
list_identify.remove(index);
|
||||
//重新初始化峰列表信息
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("identify", list_identify);
|
||||
map.put("table", vPeak);
|
||||
} else {
|
||||
// 更新峰信息列表和表格
|
||||
// 根据核素名称获取对应的下标并从list_identify,phd.getVPeak()移除
|
||||
list_identify.remove(index);
|
||||
int peakNuclIndex = phd.getVPeak().get(curRow).nuclides.indexOf(nuclideName);
|
||||
phd.getVPeak().get(curRow).nuclides.remove(peakNuclIndex);
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
// 处理核素MDA、MDC
|
||||
gammaFileUtil.ReCalcMdaMdc(phd, nuclideName, curRow + 1);
|
||||
// 谱的峰信息通过stream流过滤出包含当前核素名称的峰信息
|
||||
List<PeakInfo> peakInfoList = phd.getVPeak().stream().filter(item -> item.nuclides.indexOf(nuclideName) >= 0).collect(Collectors.toList());
|
||||
//过滤结果小于等于0 则说明当前核素在峰值中不存在了 需要从缓存的核素信息map中移除核素
|
||||
if (peakInfoList.size() <= 0) {
|
||||
//移除核素信息
|
||||
nuclideMap.remove(nuclideName);
|
||||
}
|
||||
map.put("identify", list_identify);
|
||||
map.put("table", vPeak);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result viewPeakComment(String fileName, int gammaROINum, int curRow, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
if (curRow >= 0 && curRow < phd.getVPeak().size()) {
|
||||
result.setSuccess(true);
|
||||
result.setResult(phd.getVPeak().get(curRow).comments);
|
||||
} else {
|
||||
result.error500("Please first select the peak to which you want to add comments!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addPeakComment(String fileName, int gammaROINum, int curRow, String comments, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
if (curRow >= 0 && curRow < phd.getVPeak().size()) {
|
||||
phd.getVPeak().get(curRow).comments = comments;
|
||||
List<PeakInfo> vPeak = gammaFileUtil.InitPeakTable(phd.getVPeak());
|
||||
map.put("table", vPeak);
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
} else {
|
||||
result.error500("Please first select the peak to which you want to add comments!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result viewGeneralComment(String fileName, int gammaROINum, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(phd.getTotalCmt());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addGeneralComment(String fileName, int gammaROINum, String comments, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 从缓存中获取Gamma数据
|
||||
PHDFile phd = selfStationUtil.getGammaPHD(fileName, userName, gammaROINum, selfStationCache);
|
||||
if (Objects.isNull(phd)) {
|
||||
result.error500("Please select the parse file first!");
|
||||
return result;
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(comments)) {
|
||||
phd.setTotalCmt(comments);
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result fitting(Double paramA, Double paramB, Double paramC, List<SeriseData> tempPoints, Integer count,
|
||||
String sampleFileName, String tabName, boolean fittingBtn, HttpServletRequest request) {
|
||||
|
@ -2448,6 +3271,14 @@ public class SelfStationServiceImpl implements ISelfStationService {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行gamma分析
|
||||
* @param phd gamma 数据
|
||||
* @param nuclideLinesMap 核素
|
||||
* @param colorMap 拟合数据的颜色
|
||||
* @return
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private Map<String, Object> gammaAnalyse(PHDFile phd, Map<String, NuclideLines> nuclideLinesMap,
|
||||
Map<String, String> colorMap) throws RuntimeException{
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user