GammaController新增addComment方法

修改分析后结果赋值问题
This commit is contained in:
qiaoqinzheng 2023-09-26 15:23:47 +08:00
parent a0c1a335ee
commit f41b378856
4 changed files with 134 additions and 41 deletions

View File

@ -37,6 +37,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@ -1088,26 +1089,28 @@ public class GammaFileUtil {
double[] array = dE.stream().mapToDouble(Double::doubleValue).toArray();
SimpleMatrix dEMatrix = new SimpleMatrix(calDerivEval.rowNum, calDerivEval.colNum, true, array);
//calFcnEval计算得到矩阵数据
CalValuesOut calFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedEnerPara().getP());
List<Double> counts = calFcnEval.counts;
CalValuesOut fwhmcCalFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP());
List<Double> fwhmcCounts = fwhmcCalFcnEval.counts;
//计算后的矩阵的集合转换成数组
double[] array2 = counts.stream().mapToDouble(Double::doubleValue).toArray();
double[] array2 = fwhmcCounts.stream().mapToDouble(Double::doubleValue).toArray();
//按照行数 列数 实际数据 生成矩阵
SimpleMatrix calMatrix = new SimpleMatrix(calFcnEval.rowNum, calFcnEval.colNum, true, array2);
SimpleMatrix calMatrix = new SimpleMatrix(fwhmcCalFcnEval.rowNum, fwhmcCalFcnEval.colNum, true, array2);
//计算后的矩阵 / dE矩阵 得到除后的矩阵
SimpleMatrix matrixC = calMatrix.elementDiv(dEMatrix);
//声明一个集合接收除后的矩阵数据
List<Double> values = new LinkedList<>();
// List<Double> values = new LinkedList<>();
//遍历相除后的矩阵 行数
for (int i=0; i<matrixC.numRows(); i++) {
//遍历相除后的矩阵 列数
for (int j=0; j<matrixC.numCols(); i++){
values.add(matrixC.get(i, j));
}
}
// for (int i=0; i<matrixC.numRows(); i++) {
// //遍历相除后的矩阵 列数
// for (int j=0; j<matrixC.numCols(); i++){
// values.add(matrixC.get(i, j));
// }
// }
//取除后矩阵的第一个数据
double fwhmc = values.get(0);
double fwhmc = matrixC.get(0, 0);
//取计算后的矩阵第一个数据
CalValuesOut calFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedEffiPara().getP());
List<Double> counts = calFcnEval.counts;
double effi = counts.get(0);
int index = 0;
for(int i=1; i<phd.getVEnergy().size(); ++i) {
@ -1811,6 +1814,58 @@ public class GammaFileUtil {
}
}
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
if(CollectionUtils.isNotEmpty(phd.getMapEnerKD())) {
String key = "";
key = phd.getNewEner();
phd.setUsedEner(key);
GEnergyBlock source = new GEnergyBlock();
GEnergyBlock gEnergyBlock = phd.getMapEnerKD().get(phd.getNewEner());
BeanUtils.copyProperties(gEnergyBlock, source);
phd.setUsedEnerKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = phd.getMapEnerPara().get(phd.getNewEner());
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedEnerPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapResoKD())) {
String key = "";
key = phd.getNewReso();
phd.setUsedReso(key);
GResolutionBlock source = new GResolutionBlock();
GResolutionBlock gResolutionBlock = phd.getMapResoKD().get(phd.getNewReso());
BeanUtils.copyProperties(gResolutionBlock, source);
phd.setUsedResoKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = phd.getMapResoPara().get(phd.getNewReso());
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedResoPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapEffiKD())) {
String key = "";
key = phd.getNewEffi();
phd.setUsedEffi(key);
GEfficiencyBlock source = new GEfficiencyBlock();
GEfficiencyBlock gEfficiencyBlock = phd.getMapEffiKD().get(phd.getNewEffi());
BeanUtils.copyProperties(gEfficiencyBlock, source);
phd.setUsedEffiKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = Objects.nonNull(phd.getMapEffiPara().get(phd.getNewEffi()))?phd.getMapEffiPara().get(phd.getNewEffi()):new ParameterInfo();
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedEffiPara(info);
}
if(CollectionUtils.isNotEmpty(phd.getMapTotEKD())) {
String key = "";
key = phd.getNewTotE();
phd.setUsedTotE(key);
TotaleffBlock source = new TotaleffBlock();
TotaleffBlock totaleffBlock = phd.getMapTotEKD().get(phd.getNewTotE());
BeanUtils.copyProperties(totaleffBlock, source);
phd.setUsedTotEKD(source);
ParameterInfo info = new ParameterInfo();
ParameterInfo parameterInfo = Objects.nonNull(phd.getMapTotEPara().get(phd.getNewTotE()))?phd.getMapTotEPara().get(phd.getNewTotE()):new ParameterInfo();
BeanUtils.copyProperties(parameterInfo, info);
phd.setUsedTotEPara(info);
}
for (PeakInfo peak:phd.getVPeak()) {
if (StringUtils.isBlank(peak.recoilBetaChan)) {
@ -1848,7 +1903,7 @@ public class GammaFileUtil {
}
List<Double> old_ener = phd.getUsedEnerPara().getP();
List<Double> new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP();
List<Double> new_ener = CollectionUtils.isNotEmpty(phd.getMapEnerPara())?phd.getMapEnerPara().get(phd.getNewEner()).getP():new LinkedList<>();
if(old_ener.size() != new_ener.size()) {
return 1;
}
@ -1859,7 +1914,7 @@ public class GammaFileUtil {
}
List<Double> old_reso = phd.getUsedResoPara().getP();
List<Double> new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP();
List<Double> new_reso = CollectionUtils.isNotEmpty(phd.getMapResoPara())?phd.getMapResoPara().get(phd.getNewReso()).getP():new LinkedList<>();
if(old_reso.size() != new_reso.size()) {
return 1;
}
@ -1870,7 +1925,7 @@ public class GammaFileUtil {
}
List<Double> old_effi = phd.getUsedEffiPara().getP();
List<Double> new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP();
List<Double> new_effi = CollectionUtils.isNotEmpty(phd.getMapEffiPara())?phd.getMapEffiPara().get(phd.getNewEffi()).getP():new LinkedList<>();
if(old_effi.size() != new_effi.size()) {
return -1;
}
@ -1879,7 +1934,8 @@ public class GammaFileUtil {
return -1;
}
}
return 0;
//return 0;
return 1;
}
public void UpdateEfficiency(PHDFile phd) {

View File

@ -36,8 +36,8 @@ public class GammaController {
@GetMapping("initValue")
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
return gammaService.initValue(sampleId, dbName, request);
public Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request) {
return gammaService.initValue(sampleId, dbName, fileName, request);
}
@GetMapping("analysisProcess")
@ -350,6 +350,12 @@ public class GammaController {
return gammaService.viewComment(sampleId, fileName);
}
@PutMapping("addComment")
@ApiOperation(value = "修改Comment数据", notes = "修改Comment数据")
public Result addComment(String fileName, String comment) {
return gammaService.addComment(fileName, comment);
}
@GetMapping("peakInformation")
@ApiOperation(value = "查看Peak Information页面数据", notes = "查看Peak Information页面数据")
public Result<?> peakInformation(Integer sampleId, String fileName){

View File

@ -12,7 +12,7 @@ import java.util.List;
public interface IGammaService{
Result initValue(Integer sampleId, String dbName, HttpServletRequest request);
Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request);
Result testFun(String fileName, HttpServletRequest request);
@ -116,6 +116,8 @@ public interface IGammaService{
Result viewComment(Integer sampleId, String fileName);
Result addComment(String fileName, String comment);
Result<?> peakInformation(Integer sampleId, String fileName);
void exportPeakInformation(Integer sampleId, String fileName, HttpServletResponse response);

View File

@ -120,33 +120,45 @@ public class GammaServiceImpl implements IGammaService {
private IGardsAnalySettingSpectrumService analySettingSpectrumService;
@Override
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
public Result initValue(Integer sampleId, String dbName, String samfileName, HttpServletRequest request) {
Result result = new Result();
//
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = new PHDFile();
//读取文件内容
//根据sampleId获取sample文件路径
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
if (StringUtils.isBlank(sampleFilePath)){
result.error500("样品文件不存在!");
return result;
String lastName = "";
if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) {
//根据sampleId获取sample文件路径
String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
if (StringUtils.isBlank(sampleFilePath)){
result.error500("样品文件不存在!");
return result;
}
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!flag){
return result;
}
//声明基础数组信息
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
if (!bRet){
return result;
}
lastName = fileName;
} else {
String pathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
String fileName = samfileName;
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!flag){
return result;
}
lastName = fileName;
}
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
if (!flag){
return result;
}
//声明基础数组信息
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
if (!bRet){
return result;
}
phdCache.put(fileName, phd);
phdCache.put(lastName, phd);
localCache.setPHDCache(phdCache);
result.setSuccess(true);
result.setResult(phd);
@ -174,7 +186,6 @@ public class GammaServiceImpl implements IGammaService {
}
Map<String, NuclideLines> nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides);
//解析获取临时文件信息
File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName);
ObjectMapper mapper = new ObjectMapper();
try {
@ -1057,7 +1068,9 @@ public class GammaServiceImpl implements IGammaService {
result.error500("请先选择解析文件!");
return result;
}
phd.setTotalCmt(comments);
if (StringUtils.isNotBlank(comments)) {
phd.setTotalCmt(comments);
}
return Result.ok();
}
@ -2342,6 +2355,22 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public Result addComment(String fileName, String comment) {
Result result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
if(StringUtils.isNotBlank(comment)) {
phd.setTotalCmt(comment);
}
result.success("修改成功");
return result;
}
public Result<List<TablePeak>> peakInformation(Integer sampleId, String fileName){
Result<List<TablePeak>> result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();