From f41b378856c9c2bfb9f875d731a7395c0ea28410 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 26 Sep 2023 15:23:47 +0800 Subject: [PATCH] =?UTF-8?q?GammaController=E6=96=B0=E5=A2=9EaddComment?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=BF=AE=E6=94=B9=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=90=8E=E7=BB=93=E6=9E=9C=E8=B5=8B=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 88 +++++++++++++++---- .../modules/controller/GammaController.java | 10 ++- .../jeecg/modules/service/IGammaService.java | 4 +- .../service/impl/GammaServiceImpl.java | 73 ++++++++++----- 4 files changed, 134 insertions(+), 41 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 4fb8c475..3696217d 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -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 counts = calFcnEval.counts; + CalValuesOut fwhmcCalFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP()); + List 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 values = new LinkedList<>(); +// List values = new LinkedList<>(); //遍历相除后的矩阵 行数 - for (int i=0; i counts = calFcnEval.counts; double effi = counts.get(0); int index = 0; for(int i=1; i old_ener = phd.getUsedEnerPara().getP(); - List new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP(); + List 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 old_reso = phd.getUsedResoPara().getP(); - List new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP(); + List 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 old_effi = phd.getUsedEffiPara().getP(); - List new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP(); + List 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) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index c7086096..ccddd548 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -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){ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index 89058d3a..dde8a850 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -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); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 2f6cb178..ab7c8b16 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -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 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 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 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> peakInformation(Integer sampleId, String fileName){ Result> result = new Result(); Cache phdCache = localCache.getPHDCache();