From 8063149ba52f0a9cb84a78fce97070d93b4f296e Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 20 Oct 2023 16:55:36 +0800 Subject: [PATCH] =?UTF-8?q?beta=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96Extrapola?= =?UTF-8?q?tion=E9=A1=B5=E9=9D=A2=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=20ga?= =?UTF-8?q?mma=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9EKorSumAnalyse=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E6=96=B0=E5=A2=9E=E5=AE=9E=E4=BD=93=E7=B1=BBAnalys?= =?UTF-8?q?eExtInfo=EF=BC=8CChangeExtInfo=20FileFtransitUtil=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=86=99=E5=85=A5SPC=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=EF=BC=8CCalibrationTime=E5=AD=97=E6=AE=B5=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E9=97=AE=E9=A2=98=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/util/FileFtransitUtil.java | 63 +++++---- .../modules/entity/vo/AnalyseExtInfo.java | 15 +-- .../modules/entity/vo/ChangeExtInfo.java | 28 ++++ .../modules/controller/GammaController.java | 8 +- .../SpectrumAnalysesController.java | 14 +- .../jeecg/modules/service/IGammaService.java | 8 +- .../service/ISpectrumAnalysisService.java | 2 + .../service/impl/GammaServiceImpl.java | 85 +++++++++++- .../impl/SpectrumAnalysisServiceImpl.java | 126 ++++++++++-------- 9 files changed, 244 insertions(+), 105 deletions(-) create mode 100644 jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/entity/vo/ChangeExtInfo.java diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/FileFtransitUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/FileFtransitUtil.java index 5e0cc5dd..c74540c9 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/FileFtransitUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/FileFtransitUtil.java @@ -1276,13 +1276,21 @@ public class FileFtransitUtil { char[] cal_info = new char[128]; cal_info[0] = '0'; int offset = 32; // 32 Bytes Calibration file name - String temp = GetDate(datas.getCalibra_time().substring(0, 10)); + String temp = ""; + if (StringUtils.isNotBlank(datas.getCalibra_time())) { + temp = GetDate(datas.getCalibra_time().substring(0, 10)); + } else { + temp = GetDate(""); + } for(int i=0; i eb; - private String dbName; + private List nx; - private String sampleFileName; + private List ny; - private String detFileName; - - private Integer gammaBegin; - - private Integer gammaEnd; + private Double acqRealTime; private Double minEnergy; private Double halfLife; + private String acqStartTime; + private String fitType; } diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/entity/vo/ChangeExtInfo.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/entity/vo/ChangeExtInfo.java new file mode 100644 index 00000000..c87291f4 --- /dev/null +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/modules/entity/vo/ChangeExtInfo.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ChangeExtInfo implements Serializable { + + private Integer sampleId; + + private String dbName; + + private String sampleFileName; + + private String detFileName; + + private Integer gammaBegin; + + private Integer gammaEnd; + + private Double minEnergy; + + private Double halfLife; + + private String fitType; + +} 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 652256bb..5bae8433 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,10 +1,8 @@ package org.jeecg.modules.controller; -import com.google.common.cache.Cache; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.cache.LocalCache; import org.jeecg.modules.base.bizVo.GammaRLR; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.feignclient.SystemClient; @@ -17,7 +15,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.List; -import java.util.concurrent.ConcurrentMap; @RestController @RequestMapping("gamma") @@ -223,6 +220,11 @@ public class GammaController { return result; } + @PostMapping("KorSumAnalyse") + public Result KorSumAnalyse(@RequestBody List inputDataList) { + return gammaService.KorSumAnalyse(inputDataList); + } + @GetMapping("energyCalibration") @ApiOperation(value = "查看Energy Calibration数据", notes = "查看Energy Calibration数据") public Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width, HttpServletRequest request) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index c19ba1bb..f8b8ae86 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -1,14 +1,9 @@ package org.jeecg.modules.controller; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.constant.SymbolConstant; import org.jeecg.modules.base.bizVo.BetaRLR; import org.jeecg.modules.entity.GardsSampleDataSpectrum; import org.jeecg.modules.entity.vo.*; @@ -20,10 +15,6 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; @RestController @RequestMapping("spectrumAnalysis") @@ -148,6 +139,11 @@ public class SpectrumAnalysesController { return spectrumAnalysisService.viewExtrapolation(sampleId, sampleFileName, request); } + @PostMapping("changeDataExtrapolation") + public Result changeDataExtrapolation(@RequestBody ChangeExtInfo extInfo, HttpServletRequest request) { + return spectrumAnalysisService.changeDataExtrapolation(extInfo, request); + } + @PostMapping("analyseExtrapolation") public Result analyseExtrapolation(@RequestBody AnalyseExtInfo extInfo, HttpServletRequest request) { return spectrumAnalysisService.analyseExtrapolation(extInfo, request); 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 edd078db..02306622 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 @@ -70,16 +70,14 @@ public interface IGammaService{ Result ZeroTimeAnalyse(String nuclide1, String nuclide2, Double product1, Double product2, String target, String energyTFH, String date, String time); - void exportZeroTimeAnalyse(String nuclide1, String nuclide2, - Double product1, Double product2, - String target, String energyTFH, - String date, String time, - HttpServletResponse response); + void exportZeroTimeAnalyse(String nuclide1, String nuclide2, Double product1, Double product2, String target, String energyTFH, String date, String time, HttpServletResponse response); Result Korsum(); List KorSumInput(CoeffData coeffData); + Result KorSumAnalyse(List inputDataList); + Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width, HttpServletRequest request); Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index fe7b45ec..43e9832a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -52,6 +52,8 @@ public interface ISpectrumAnalysisService { Result viewExtrapolation(Integer sampleId, String sampleFileName, HttpServletRequest request); + Result changeDataExtrapolation(ChangeExtInfo extInfo, HttpServletRequest request); + Result analyseExtrapolation(AnalyseExtInfo extInfo, HttpServletRequest request); Result viewMDC(Integer sampleId, String sampleFileName, HttpServletRequest request); 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 e8df062c..3079408d 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 @@ -2177,16 +2177,97 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi }else { effi = Math.exp( coeffData.Effciency1*ener + coeffData.Effciency2 + coeffData.Effciency3/ener + coeffData.Effciency4/Math.pow(ener,2) + coeffData.Effciency5/Math.pow(ener, 3) + coeffData.Effciency6/Math.pow(ener, 4) ); totE = Math.exp( coeffData.totalEf1*ener + coeffData.totalEf2 + coeffData.totalEf3/ener + coeffData.totalEf4/Math.pow(ener,2) + coeffData.totalEf5/Math.pow(ener, 3) + coeffData.totalEf6/Math.pow(ener, 4) ); - data.setTotalEffi(totE); - data.setPeakEffi(effi); + data.setTotalEffi(Double.parseDouble(NumberFormatUtil.numberFormat(String.valueOf(totE)))); + data.setPeakEffi(Double.parseDouble(NumberFormatUtil.numberFormat(String.valueOf(effi)))); } data.setEnergy(energys.get(i)); data.setUncertain(10.0); inputDataList.add(data); } + inputDataList = inputDataList.stream().sorted((data1, data2) -> { + return data1.getEnergy().compareTo(data2.getEnergy()); + }).collect(Collectors.toList()); return inputDataList; } + @Override + public Result KorSumAnalyse(List inputDataList) { + Result result = new Result(); + DecimalFormat df = new DecimalFormat("#.##########"); + //读取Remaining文件 + String readRemaining = ReadRemaining(); + //KORDAT文件的标准头部信息 + String m_kordatHeader = "0. 0. 0. 10 17.03.1988"; + //分析所需生成的文件 + String kordatPath = parameterProperties.getFilePath() + StringPool.SLASH + "KORDAT"; + //生成文件 + File kordat = new File(kordatPath); + //向文件内写入内容 + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(kordat)); + StringBuffer out = new StringBuffer(); + // 写头部信息 + out.append(m_kordatHeader); + out.append(System.lineSeparator()); + //遍历数组写入表单数据 + for (int i=0; i m_mapNuclideInfo = new HashMap<>(); + + result.setSuccess(true); + result.setResult(m_mapNuclideInfo); + return result; + } + + private String ReadRemaining() { + String txtPath = parameterProperties.getFilePath() + StringPool.SLASH + "Kordat_Remaining.txt"; + File file = new File(txtPath); + StringBuilder m_remainingData = new StringBuilder(); + + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + String line; + while ((line = reader.readLine()) != null) { + m_remainingData.append(line).append(System.lineSeparator()); + } + } catch (IOException e) { + e.printStackTrace(); + } + return m_remainingData.toString(); + } + @Override public Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width, HttpServletRequest request) { Result result = new Result(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 109c1d72..23dbe273 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -16,7 +16,6 @@ import com.google.common.cache.Cache; import org.apache.commons.io.FileUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; -import org.apache.commons.net.ftp.FTPFile; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; @@ -39,17 +38,13 @@ import org.jeecg.modules.base.enums.*; import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; -import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.struct.BgAnalyseResult; -import org.jeecg.modules.native_jni.struct.BgBoundary; -import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestBody; import org.thymeleaf.TemplateEngine; import org.thymeleaf.context.Context; import org.thymeleaf.spring5.SpringTemplateEngine; @@ -2117,7 +2112,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result analyseExtrapolation(AnalyseExtInfo extInfo, HttpServletRequest request) { + public Result changeDataExtrapolation(ChangeExtInfo extInfo, HttpServletRequest request) { Result result = new Result(); Map map = new HashMap<>(); String userName = JwtUtil.getUserNameByToken(request); @@ -2183,7 +2178,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { if (CollectionUtils.isNotEmpty(detTmp.h_counts)) { detbgr_historgram = detTmp.h_counts; } - //计算 //Ng double s_Ng = 0.0; @@ -2230,25 +2224,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { Nx.add((1-EbT)/EbT); index++; } - int pos=0; String fittype = extInfo.getFitType(); - if(fittype.equals("liner")) { - pos=1; - } else if(fittype.equals("poly2")) { - pos=0; - } else if(fittype.equals("poly3")) { - } - double lamadaXe = Math.log(2)/(extInfo.getHalfLife()*24*60*60); - List fittingPara = new LinkedList<>(); - fittingPara = EnergySpectrumHandler.GetFittingPara(Nx,Ny,fittype); - if(CollectionUtils.isEmpty(fittingPara) && pos>fittingPara.size()-1) { - return result; - } - double acqRealTime = sampleRealTime; - double Xe_activity = fittingPara.get(pos)*(lamadaXe*acqRealTime)/(1-Math.exp(-lamadaXe*acqRealTime)); - List line_serise_data = new LinkedList<>(); List scatter_serise_data = new LinkedList<>(); - double maxLeft=0.0; double maxBottom=0.0; double minLeft=0.0; @@ -2273,7 +2250,73 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { scatter_serise_data.add(temp); } String functionFit = ""; - String tempStr = ""; + if(fittype.equals("liner")) { + functionFit = "y = a*x + b "; + } else if(fittype.equals("poly2")) { + functionFit = "y = a+ b*x + c*x^2 "; + } else if(fittype.equals("poly3")) { + functionFit = "y = a+ b*x + c*x^2 +d*x^3 "; + } + List extDataList = new LinkedList<>(); + for(int i=0;i map = new HashMap<>(); + //计算 + List Eb = extInfo.getEb(); + List Ny = extInfo.getNy(); + List Nx = extInfo.getNx(); + int pos=0; + String fittype = extInfo.getFitType(); + if(fittype.equals("liner")) { + pos=1; + } else if(fittype.equals("poly2")) { + pos=0; + } else if(fittype.equals("poly3")) { + } + double lamadaXe = Math.log(2)/(extInfo.getHalfLife()*24*60*60); + List fittingPara = new LinkedList<>(); + fittingPara = EnergySpectrumHandler.GetFittingPara(Nx,Ny,fittype); + if(CollectionUtils.isEmpty(fittingPara) && pos>fittingPara.size()-1) { + return result; + } + double acqRealTime = extInfo.getAcqRealTime(); + double Xe_activity = fittingPara.get(pos)*(lamadaXe*acqRealTime)/(1-Math.exp(-lamadaXe*acqRealTime)); + List line_serise_data = new LinkedList<>(); + double maxLeft=0.0; + double maxBottom=0.0; + double minLeft=0.0; + for(int i=0;iNx.get(i)) { + minLeft = Nx.get(i); + } + if(maxLeftNy.get(i)) { + minLeft = Ny.get(i); + } + } + String functionFit = ""; if(fittype.equals("liner")) { SeriseData left = new SeriseData(); List data = new LinkedList<>(); @@ -2293,7 +2336,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { line_serise_data.add(left); line_serise_data.add(right); functionFit = "y = a*x + b "; - if (scatter_serise_data.size()>1) { + if (Nx.size()>1) { functionFit = String.format("y = %f*x + %f ", fittingPara.get(0), fittingPara.get(1)); } } else if(fittype.equals("poly2")) { @@ -2308,47 +2351,22 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { line_serise_data.add(temp); } functionFit = "y = a+ b*x + c*x^2 "; - if (scatter_serise_data.size()>1) { + if (Nx.size()>1) { functionFit = String.format("y = %f+ %f*x + %f*x^2 ",fittingPara.get(0),fittingPara.get(1),fittingPara.get(2)); } } else if(fittype.equals("poly3")) { functionFit = "y = a+ b*x + c*x^2 +d*x^3 "; } - List extDataList = new LinkedList<>(); - for(int i=0;i1) { - refTime = sampleTmp.acquisition_start_date+" "+sampleTmp.acquisition_start_time; + if (Nx.size()>1) { + refTime = extInfo.getAcqStartTime(); xeAct = String.valueOf(Xe_activity); } - map.put("tableData", extDataList); map.put("functionFit", functionFit); map.put("refTime", refTime); map.put("xeAct", xeAct); - map.put("resultViewScatterDataValue", scatter_serise_data); map.put("resultViewLineDataValue", line_serise_data); - if(maxLeft<=0||maxBottom<=0||scatter_serise_data.size()<=1) { - result.setSuccess(true); - result.setResult(map); - return result; - } - if(maxLeft<4) { - map.put("leftFormat", "%f"); - } else { - map.put("leftFormat", "%i"); - } - - maxBottom+=1; - maxLeft*=1.5; - minLeft-=1.5; result.setSuccess(true); result.setResult(map); return result;