From 5b1cf4567d1fa672c824b7308cce60e3a2e7d9a0 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 20 Oct 2023 09:41:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Beta=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BC=93=E5=AD=98=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20BetaCache=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/cache/BetaCache.java | 4 ++++ .../controller/SpectrumAnalysesController.java | 8 ++++---- .../service/ISpectrumAnalysisService.java | 2 +- .../impl/SpectrumAnalysisServiceImpl.java | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java index be2ac261..842eca57 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/BetaCache.java @@ -33,4 +33,8 @@ public class BetaCache { this.betaCache = betaCache; } + public void deleteBetaCache(String key){ + this.betaCache.invalidate(key); + } + } 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 d6b8bee7..c19ba1bb 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 @@ -64,10 +64,10 @@ public class SpectrumAnalysesController { return spectrumAnalysisService.getFileSpectrumChart(sampleFileName, gasFileName, detFileName, qcFileName, request); } - @DeleteMapping("deleteDBSpectrumChartData") - @ApiOperation(value = "删除折线图缓存数据",notes = "删除折线图缓存数据") - public Result deleteDBSpectrumChartData(Integer[] sampleIds) { - return spectrumAnalysisService.deleteDBSpectrumChartData(sampleIds); + @DeleteMapping("deleteSpectrumCacheData") + @ApiOperation(value = "删除缓存数据",notes = "删除缓存数据") + public void deleteSpectrumCacheData(String sampleFileName, String qcFileName, HttpServletRequest request) { + spectrumAnalysisService.deleteSpectrumCacheData(sampleFileName, qcFileName, request); } @GetMapping("viewComment") 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 76deb763..fe7b45ec 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 @@ -24,7 +24,7 @@ public interface ISpectrumAnalysisService { Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request); - Result deleteDBSpectrumChartData(Integer[] sampleIds); + void deleteSpectrumCacheData(String sampleFileName, String qcFileName, HttpServletRequest request); Result viewComment(Integer sampleId, String sampleFileName, HttpServletRequest request); 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 7eab662d..109c1d72 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 @@ -575,14 +575,16 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { } @Override - public Result deleteDBSpectrumChartData(Integer[] sampleIds) { - Result result = new Result(); - if (Objects.isNull(sampleIds)){ - result.error500("删除失败!"); - return result; - } - result.success("删除成功"); - return result; + public void deleteSpectrumCacheData(String sampleFileName, String qcFileName, HttpServletRequest request) { + String userName = JwtUtil.getUserNameByToken(request); + String betaKey = qcFileName + "-" + userName + "-beta"; + betaCache.deleteBetaCache(betaKey); + String gammaKey = qcFileName + "-" + userName + "-gamma"; + betaCache.deleteBetaCache(gammaKey); + String analyseKey = sampleFileName + "-" + userName + "-reAnalyseParam"; + betaCache.deleteBetaCache(analyseKey); + String xeKey = sampleFileName + "-" + userName + "-xeData"; + betaCache.deleteBetaCache(xeKey); } @Override From b9f5e68f9e49e900179c6e9d2a233b315d173f70 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 20 Oct 2023 10:29:02 +0800 Subject: [PATCH 2/3] =?UTF-8?q?FileFtransitUtil=E8=AE=A1=E7=AE=97vvReso?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=E7=B2=BE=E5=BA=A6=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 --- .../main/java/org/jeecg/common/util/FileFtransitUtil.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 a837f85c..5e0cc5dd 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 @@ -1020,13 +1020,12 @@ public class FileFtransitUtil { i1 = 0; i2 = EngNum - 1; } - datas.setEner_slope(Float.valueOf(Eng[i2]-Eng[i1])/(Cer[i2]-Cer[i1])); + datas.setEner_slope((Eng[i2]-Eng[i1])/(Cer[i2]-Cer[i1])); datas.setEner_intercept(Float.valueOf(String.valueOf(((datas.getVvEner().get(0).get(i1) * datas.getVvEner().get(1).get(i2) - datas.getVvEner().get(0).get(i2) * datas.getVvEner().get(1).get(i1)) / (datas.getVvEner().get(1).get(i2) - datas.getVvEner().get(1).get(i1)))))); } - for(int i=0; i Date: Fri, 20 Oct 2023 10:30:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4Demo=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/modules/controller/Demo.java | 579 ------------------ 1 file changed, 579 deletions(-) delete mode 100644 jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/Demo.java diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/Demo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/Demo.java deleted file mode 100644 index 4f129a3b..00000000 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/Demo.java +++ /dev/null @@ -1,579 +0,0 @@ -package org.jeecg.modules.controller; - -import com.baomidou.mybatisplus.core.toolkit.StringPool; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.jeecg.common.constant.DateConstant; -import org.jeecg.common.util.FileFtransitUtil; -import org.jeecg.modules.entity.vo.*; -import org.jeecg.modules.native_jni.CalValuesHandler; - -import java.io.*; -import java.lang.reflect.Array; -import java.math.BigInteger; -import java.nio.*; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.util.*; - - -public class Demo { - - public static void main(String[] args) throws IOException { - System.loadLibrary("ReadPHDFile"); - System.loadLibrary("GammaAnaly"); - FileData datas = new FileData(); - File imsFile = new File("D:\\ARMD\\材料\\spc-ims\\201809160001P.Ims"); - FileFtransitUtil.ReadIMS(imsFile, datas); - File spcFile = new File("D:\\ARMD\\材料\\spc-ims\\test.SPC"); - // r:只读 rw:读写 - RandomAccessFile SpcFile = new RandomAccessFile(spcFile.getAbsolutePath(), "rw"); - //分析SPC文件并创建所需要的spc文件的基础内容 - SpcHead1 m_head1 = new SpcHead1(); - SpcHead2 m_head2 = new SpcHead2(); - GermaniumCalib m_calibParam = new GermaniumCalib(); - byte[] m_totalContents = AnalyseSPC(m_head1, m_head2, m_calibParam); - if(m_totalContents.length<=0) { - String Warning = "The file standard.spc isn't exist or it's format is invalid."; - } - //SpcFile写入内容 - SpcFile.write(m_totalContents); - - // 写第1个128字节————头部指针信息 - { - MakeSpcHead(datas, m_head1, m_head2); - SpcFile.seek(0); - byte[] head1 = new byte[80]; - //使用系统的赋值数组 来源数组 开始下标 目标数组 开始下标 长度 - System.arraycopy(writeShort(m_head1.Inftyp), 0, head1, 0, 2); - System.arraycopy(writeShort(m_head1.Filtyp), 0, head1, 2, 2); - System.arraycopy(writeShort(m_head1.Reserved1), 0, head1, 4, 2); - System.arraycopy(writeShort(m_head1.Reserved2), 0, head1, 6, 2); - System.arraycopy(writeShort(m_head1.AcqInfRP), 0, head1, 8, 2); - System.arraycopy(writeShort(m_head1.SamDesRP), 0, head1, 10, 2); - System.arraycopy(writeShort(m_head1.DetDesRP), 0, head1, 12, 2); - System.arraycopy(writeShort(m_head1.EbrDesRP), 0, head1, 14, 2); - System.arraycopy(writeShort(m_head1.AnaRP1), 0, head1, 16, 2); - System.arraycopy(writeShort(m_head1.AnaRP2), 0, head1, 18, 2); - System.arraycopy(writeShort(m_head1.AnaRP3), 0, head1, 20, 2); - System.arraycopy(writeShort(m_head1.AnaRP4), 0, head1, 22, 2); - System.arraycopy(writeShort(m_head1.SrpDesRP), 0, head1, 24, 2); - System.arraycopy(writeShort(m_head1.IeqDesRP), 0, head1, 26, 2); - System.arraycopy(writeShort(m_head1.GeoDesRP), 0, head1, 28, 2); - System.arraycopy(writeShort(m_head1.MpcDesRP), 0, head1, 30, 2); - System.arraycopy(writeShort(m_head1.CalDesRP), 0, head1, 32, 2); - System.arraycopy(writeShort(m_head1.CalRP1), 0, head1, 34, 2); - System.arraycopy(writeShort(m_head1.CalRP2), 0, head1, 36, 2); - System.arraycopy(writeShort(m_head1.EffRP), 0, head1, 38, 2); - System.arraycopy(writeShort(m_head1.ROI1), 0, head1, 40, 2); - System.arraycopy(writeShort(m_head1.EngPrRP), 0, head1, 42, 2); - System.arraycopy(writeShort(m_head1.EngPrNum), 0, head1, 44, 2); - System.arraycopy(writeShort(m_head1.Reserved3), 0, head1, 46, 2); - System.arraycopy(writeShort(m_head1.DDP), 0, head1, 48, 2); - System.arraycopy(writeShort(m_head1.ActUnit), 0, head1, 50, 2); - System.arraycopy(writeShort(m_head1.LabPerRP), 0, head1, 52, 2); - System.arraycopy(writeShort(m_head1.MaxNumE), 0, head1, 54, 2); - System.arraycopy(writeShort(m_head1.MaxNumU), 0, head1, 56, 2); - System.arraycopy(writeShort(m_head1.EffNum), 0, head1, 58, 2); - System.arraycopy(writeShort(m_head1.SpcFirstRP), 0, head1, 60, 2); - System.arraycopy(writeShort(m_head1.SpcRecNum), 0, head1, 62, 2); - System.arraycopy(writeShort(m_head1.SpcChnNum), 0, head1, 64, 2); - System.arraycopy(writeShort(m_head1.Abstch), 0, head1, 66, 2); - System.arraycopy(writeFloat(m_head1.AcqTime), 0, head1, 68, 4); - System.arraycopy(writeDouble(m_head1.AcqTime8), 0, head1, 72, 8); - SpcFile.write(head1); - SpcFile.seek(78); - byte[] head2 = new byte[20]; - System.arraycopy(writeShort(m_head2.AddRAM), 0, head2, 0, 2); - System.arraycopy(writeShort(m_head2.Seqnum), 0, head2, 2, 2); - System.arraycopy(writeShort(m_head2.Mcanu), 0, head2, 4, 2); - System.arraycopy(writeShort(m_head2.Segnum), 0, head2, 6, 2); - System.arraycopy(writeShort(m_head2.Mcadvt), 0, head2, 8, 2); - System.arraycopy(writeShort(m_head2.Chnsrt), 0, head2, 10, 2); - System.arraycopy(writeFloat(m_head2.RealTime), 0, head2, 12, 4); - System.arraycopy(writeFloat(m_head2.LiveTime), 0, head2, 16, 4); - SpcFile.write(head2); - } - - // 写第2个128字节————Acquisition信息 - { - char[] acq_info = new char[128]; - acq_info[0] = ' '; - int offset = 16; // 16 Bytes Spectrum file name - String temp = GetDate(datas.getAcq_date()); - for(int i=0; i 10 ? 10 : temp.length(); - for(int i=0; i 10 ? 10 : temp.length(); - for(int i=0; i 0 && datas.getVvReso().size() > 0) { - int size = Math.min(datas.getVvEner().get(0).size(), datas.getVvReso().get(0).size()); - if(size > 32*1) { - size = 32*1; - } - m_head1.EngPrNum = (short) size; - } - if(datas.getVvEffi().size() > 0) { - m_head1.EffNum = (short) datas.getVvEffi().get(0).size(); - } - m_head1.SpcRecNum = (short) (datas.getNum_count()/32); - m_head1.SpcChnNum = (short) datas.getNum_count(); - m_head1.AcqTime = 12631.7f; - m_head1.AcqTime8 = 12631.7; - - m_head2.Chnsrt = (short) datas.getStart_chan(); - m_head2.RealTime = datas.getAcq_real(); - m_head2.LiveTime = datas.getAcq_live(); - } - - public static void MakeCalibParam(FileData datas, GermaniumCalib m_calibParam) { - if(datas.getVvEffi().size() < 3 || datas.getVvEner().size() < 3 || datas.getVvReso().size() < 3) { - return; - } - - m_calibParam.NumOfChan = (short) datas.getNum_count(); - if(datas.getVvEner().size() > 0 && datas.getVvReso().size() > 0) { - int size = Math.min(datas.getVvEner().get(0).size(), datas.getVvReso().get(0).size()); - if(size > 32*1) { - size = 32*1; - } - m_calibParam.EngPairs = (short) size; - } - if(datas.getVvEffi().size() > 0) { - m_calibParam.EffPairs = (short) datas.getVvEffi().get(0).size(); - } - ParameterInfo ener_para = new ParameterInfo(); - ener_para.setP(CalValuesHandler.calFitPara("Cal_Energy", 2, datas.getVvEner().get(1), datas.getVvEner().get(0), datas.getVvEner().get(2))); - ParameterInfo reso_para = new ParameterInfo(); - reso_para.setP(CalValuesHandler.calFitPara("Cal_Resolution", 2, datas.getVvReso().get(0), datas.getVvReso().get(1), datas.getVvReso().get(2))); - if(ener_para.getP().size() < 3) { - return; - } else if(ener_para.getP().size() == 3) { - ener_para.getP().add(0.0); - } - if(reso_para.getP().size() < 3) { - return; - } else if(reso_para.getP().size() == 3) { - reso_para.getP().add(0.0); - } - m_calibParam.EnerCoefA = Float.valueOf(String.valueOf(ener_para.getP().get(1))); - m_calibParam.EnerCoefB = Float.valueOf(String.valueOf(ener_para.getP().get(2))); - m_calibParam.EnerCoefC = Float.valueOf(String.valueOf(ener_para.getP().get(3))); - m_calibParam.FwhmCoefA = Float.valueOf(String.valueOf(reso_para.getP().get(1))); - m_calibParam.FwhmCoefB = Float.valueOf(String.valueOf(reso_para.getP().get(2))); - m_calibParam.FwhmCoefC = Float.valueOf(String.valueOf(reso_para.getP().get(3))); - } - - public static String GetDate(String str) { - str = str.substring(0, 10); // YYYY/MM/DD - String temp = str.substring(str.length()-2)+ StringPool.DASH; // DD- - int month = Integer.valueOf(str.substring(5, 7)); - switch(month) { // DD-MMM - case 1: temp+="Jan"; break; - case 2: temp+="Feb"; break; - case 3: temp+="Mar"; break; - case 4: temp+="Apr"; break; - case 5: temp+="May"; break; - case 6: temp+="Jun"; break; - case 7: temp+="Jul"; break; - case 8: temp+="Aug"; break; - case 9: temp+="Sep"; break; - case 10: temp+="Oct"; break; - case 11: temp+="Nov"; break; - case 12: temp+="Dec"; break; - default: temp+="Jan"; break; - } - temp+=String.format("-%s", str.substring(2, 4)); // DD-MMM-YY - if(str.substring(0, 2) == "20") { // DD-MMM-YY* - temp+="1"; - } else { - temp+="0"; - } - return temp; - } - - public static String convert(byte[] bytes, String type) { - List values = new LinkedList<>(); - for (int i=0; i=0; i--) { - if (values.get(i).length() == 1) { - index+="0"+values.get(i); - } else { - index+=values.get(i); - } - } - if (type.equalsIgnoreCase("short")) { - short shortValue = new BigInteger(index, 16).shortValue(); - return String.valueOf(shortValue); - } else if (type.equalsIgnoreCase("int")) { - int intValue = new BigInteger(index, 16).intValue(); - return String.valueOf(intValue); - } else if (type.equalsIgnoreCase("char")) { - int decimal = Integer.parseInt(index, 16); - char charValue = (char) decimal; - return String.valueOf(charValue); - } else if (type.equalsIgnoreCase("float")){ - float floatValue = Float.intBitsToFloat(new BigInteger(index, 16).intValue()); - return String.valueOf(floatValue); - } else if (type.equalsIgnoreCase("double")) { - double doubleValue = Double.longBitsToDouble(Long.parseLong(index, 16)); - return String.valueOf(doubleValue); - } - return ""; - } - - public static byte[] writeShort(int v) { - byte[] byteArr = new byte[2]; - byteArr[0] = (byte) ((v >>> 0) & 0xFF); - byteArr[1] = (byte) ((v >>> 8) & 0xFF); - return byteArr; - } - - public static byte[] writeChar(int v) { - byte[] byteArr = new byte[2]; - byteArr[0] = (byte) ((v >>> 0) & 0xFF); - byteArr[1] = (byte) ((v >>> 8) & 0xFF); - return byteArr; - } - - public static byte[] writeInt(int v) { - byte[] byteArr = new byte[4]; - byteArr[0] = (byte) ((v >>> 0) & 0xFF); - byteArr[1] = (byte) ((v >>> 8) & 0xFF); - byteArr[2] = (byte) ((v >>> 16) & 0xFF); - byteArr[3] = (byte) ((v >>> 24) & 0xFF); - return byteArr; - } - - public static byte[] writeLong(long v) { - byte[] byteArr = new byte[8]; - byteArr[0] = (byte) ((v >>> 0) & 0xFF); - byteArr[1] = (byte) ((v >>> 8) & 0xFF); - byteArr[2] = (byte) ((v >>> 16) & 0xFF); - byteArr[3] = (byte) ((v >>> 24) & 0xFF); - byteArr[4] = (byte) ((v >>> 32) & 0xFF); - byteArr[5] = (byte) ((v >>> 40) & 0xFF); - byteArr[6] = (byte) ((v >>> 48) & 0xFF); - byteArr[7] = (byte) ((v >>> 56) & 0xFF); - return byteArr; - } - - public static byte[] writeFloat(float v) { - byte[] byteArr = writeInt(Float.floatToIntBits(v)); - return byteArr; - } - - public static byte[] writeDouble(double v) { - byte[] byteArr = writeLong(Double.doubleToLongBits(v)); - return byteArr; - } - - - -}