From 78ce76d6c3aa9577d4c306f0fa841dd5e5dde80b Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 15 Sep 2023 10:04:51 +0800 Subject: [PATCH] =?UTF-8?q?zeroTime=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/base/enums/CalibrationType.java | 27 +++++ .../org/jeecg/common/util/PHDFileUtil.java | 108 ++++++++++-------- .../java/org/jeecg/common/util/SSEUtil.java | 40 +++++++ .../modules/controller/GammaController.java | 26 +---- .../jeecg/modules/service/IGammaService.java | 2 + .../service/impl/GammaServiceImpl.java | 28 ++++- 6 files changed, 163 insertions(+), 68 deletions(-) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/CalibrationType.java create mode 100644 jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SSEUtil.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/CalibrationType.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/CalibrationType.java new file mode 100644 index 00000000..a7272376 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/CalibrationType.java @@ -0,0 +1,27 @@ +package org.jeecg.modules.base.enums; + +public enum CalibrationType { + + Cal_Energy(0), + Cal_Resolution(1), + Cal_Efficiency(2), + Cal_Tot_efficiency(3), + Cal_Tail(4), + Cal_Tail_alpha(5), + Cal_Tail_right(6), + Cal_Tail_right_alpha(7), + Cal_Step_ratio(8), + Cal_HalflifeAnalysis(9), + Cal_Default(10); + + public int num; + + CalibrationType(int num){ + this.num = num; + } + + public int getNum(){ + return this.num; + } + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java index cbd3872a..6185b705 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/PHDFileUtil.java @@ -801,63 +801,63 @@ public class PHDFileUtil { BgDataAnlyseResultIn resultIn = new BgDataAnlyseResultIn(); resultIn.setXe131m_con(bgAnalyseResult.Xe131m_con); resultIn.setXe131m_uncer(bgAnalyseResult.Xe131m_uncer); - resultIn.setMDC_Xe131m(bgAnalyseResult.MDC_Xe131m); - resultIn.setLC_Xe131m(bgAnalyseResult.LC_Xe131m); + resultIn.setMdc_Xe131m(bgAnalyseResult.MDC_Xe131m); + resultIn.setLc_Xe131m(bgAnalyseResult.LC_Xe131m); resultIn.setXe131mFlag(bgAnalyseResult.XE_131m_NID_FLAG); resultIn.setXe133_con(bgAnalyseResult.Xe133_con); resultIn.setXe133_uncer(bgAnalyseResult.Xe133_uncer); - resultIn.setMDC_Xe133(bgAnalyseResult.MDC_Xe133); - resultIn.setLC_Xe133(bgAnalyseResult.LC_Xe133); + resultIn.setMdc_Xe133(bgAnalyseResult.MDC_Xe133); + resultIn.setLc_Xe133(bgAnalyseResult.LC_Xe133); resultIn.setXe133Flag(bgAnalyseResult.XE_133_NID_FLAG); resultIn.setXe133m_con(bgAnalyseResult.Xe133m_con); resultIn.setXe133m_uncer(bgAnalyseResult.Xe133m_uncer); - resultIn.setMDC_Xe133m(bgAnalyseResult.MDC_Xe133m); - resultIn.setLC_Xe133m(bgAnalyseResult.LC_Xe133m); + resultIn.setMdc_Xe133m(bgAnalyseResult.MDC_Xe133m); + resultIn.setLc_Xe133m(bgAnalyseResult.LC_Xe133m); resultIn.setXe133mFlag(bgAnalyseResult.XE_133m_NID_FLAG); resultIn.setXe135_con(bgAnalyseResult.Xe135_con); resultIn.setXe135_uncer(bgAnalyseResult.Xe135_uncer); - resultIn.setMDC_Xe135(bgAnalyseResult.MDC_Xe135); - resultIn.setLC_Xe135(bgAnalyseResult.LC_Xe135); + resultIn.setMdc_Xe135(bgAnalyseResult.MDC_Xe135); + resultIn.setLc_Xe135(bgAnalyseResult.LC_Xe135); resultIn.setXe135Flag(bgAnalyseResult.XE_135_NID_FLAG); List gammaCalibrationSpectrumList = new LinkedList<>(); GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum(); gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); - gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_e_c.get(0)); - gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_e_c.get(1)); - gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_e_c.get(2)); + gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_c_e.get(0)); + gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_c_e.get(1)); + gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_c_e.get(2)); gammaCalibrationSpectrumList.add(gammaCalibrationS); GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum(); gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); - gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_e_c.get(0)); - gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_e_c.get(1)); - gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_e_c.get(2)); + gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_c_e.get(0)); + gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_c_e.get(1)); + gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_c_e.get(2)); gammaCalibrationSpectrumList.add(gammaCalibrationG); GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum(); gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); - gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_e_c.get(0)); - gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_e_c.get(1)); - gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_e_c.get(2)); + gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_c_e.get(0)); + gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_c_e.get(1)); + gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_c_e.get(2)); gammaCalibrationSpectrumList.add(gammaCalibrationD); List betaCalibrationSpectrumList = new LinkedList<>(); -// GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); -// betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); -// betaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); -// betaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); -// betaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); -// betaCalibrationSpectrumList.add(betaCalibrationS); -// GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); -// betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); -// betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); -// betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); -// betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); -// betaCalibrationSpectrumList.add(betaCalibrationG); -// GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); -// betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); -// betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); -// betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); -// betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); -// betaCalibrationSpectrumList.add(betaCalibrationD); + GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum(); + betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType()); + gammaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0)); + gammaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1)); + gammaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationS); + GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum(); + betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType()); + betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0)); + betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1)); + betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationG); + GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum(); + betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType()); + betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0)); + betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1)); + betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2)); + betaCalibrationSpectrumList.add(betaCalibrationD); List roiChannelsSpectrumList = new LinkedList<>(); for (int i=0; i roiResultsSpectrumList = new LinkedList<>(); for (int i=0; ibgAnalyseResult.MDC.get(i)) { -// roiResults.setNidFlag(1); -// } else { -// roiResults.setNidFlag(0); -// } + bgAnalyseResult.MDC.add(0, 0.0); + roiResults.setMdc(bgAnalyseResult.MDC.get(i)); + if(bgAnalyseResult.ROI_con_uncer.get(i)>bgAnalyseResult.MDC.get(i)) { + roiResults.setNidFlag(1); + } else { + roiResults.setNidFlag(0); + } roiResultsSpectrumList.add(roiResults); } map.put("gammaCalibrationSpectrumList", gammaCalibrationSpectrumList); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SSEUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SSEUtil.java new file mode 100644 index 00000000..921b8970 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SSEUtil.java @@ -0,0 +1,40 @@ +package org.jeecg.common.util; + +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Component +public class SSEUtil { + private static Map sseCache = new ConcurrentHashMap<>(); + + public SseEmitter subscribe(String id) { + // 超时时间设置为1小时 + SseEmitter sseEmitter = new SseEmitter(3600_000L); + sseCache.put(id, sseEmitter); + sseEmitter.onTimeout(() -> sseCache.remove(id)); + sseEmitter.onCompletion(() -> System.out.println("完成!!!")); + return sseEmitter; + } + + public String push(String id, String content) throws IOException { + SseEmitter sseEmitter = sseCache.get(id); + if (sseEmitter != null) { + sseEmitter.send(content); + } + return "over"; + } + + public String over(String id) { + SseEmitter sseEmitter = sseCache.get(id); + if (sseEmitter != null) { + sseEmitter.complete(); + sseCache.remove(id); + } + return "over"; + } + +} 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 5cfdee78..d4b7c751 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 @@ -1,18 +1,9 @@ package org.jeecg.modules.controller; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.ReUtil; -import cn.hutool.core.util.StrUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.util.ClassUtil; -import org.jeecg.common.util.ExportUtil; import org.jeecg.modules.base.bizVo.GammaRLR; -import org.jeecg.modules.base.enums.ExportTemplate; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.service.IGammaService; import org.springframework.beans.factory.annotation.Autowired; @@ -20,19 +11,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.jeecg.modules.base.enums.ExportTemplate.RLR_B; -import static org.jeecg.modules.base.enums.ExportTemplate.RLR_G; @RestController @RequestMapping("gamma") @@ -201,6 +180,11 @@ public class GammaController { return gammaService.applyDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getCurCalName(), changeData.getSampleId(), changeData.getFileName()); } + @PostMapping("saveDataEnergy") + public void saveDataEnergy(@RequestBody ChangeData changeData, HttpServletResponse response) { + gammaService.saveDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response); + } + @GetMapping("resolutionCalibration") @ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据") public Result resolutionCalibration(@RequestParam Integer sampleId, String fileName, String currentText) { 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 6f29787f..abffbb44 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 @@ -63,6 +63,8 @@ public interface IGammaService{ Result applyDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); + void saveDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response); + Result resolutionCalibration(Integer sampleId, String fileName, String currentText); Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); 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 c2679c9c..ffe06796 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 @@ -73,6 +73,8 @@ public class GammaServiceImpl implements IGammaService { private SpectrumPathProperties spectrumPathProperties; @Autowired private FTPUtil ftpUtil; + @Autowired + private SSEUtil sseUtil; @Value("${ZeroTime}") private String ZeroTimeStr; @Autowired @@ -965,7 +967,7 @@ public class GammaServiceImpl implements IGammaService { } // date of Zero Time - Date datetime = DateUtils.parseDate(date + StringPool.SPACE + time); + Date datetime = DateUtils.parseDate(date + StringPool.SPACE + time, "yyyy-MM-dd HH:mm:ss"); Date oriDate = DateUtils.parseDate("1970-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss"); double second = (datetime.getTime()/1000 - oriDate.getTime()/1000) - t - 8*60*60; @@ -1213,6 +1215,30 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public void saveDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response) { + StringBuffer strBuffer = new StringBuffer(); + strBuffer.append("#g_Energy").append("\n"); + for (int i=0; i