From 8deca3f9648da3ffaa03cfa564c12e8f8c24c8dc Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Thu, 28 Dec 2023 14:20:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E4=BA=A4=E4=BA=92=E5=88=86?= =?UTF-8?q?=E6=9E=90gamma=E9=83=A8=E5=88=86Peak=20Information=EF=BC=8CRadi?= =?UTF-8?q?onuclide=20Activity=E5=8A=9F=E8=83=BDCompairson=E4=B8=8EIDC?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=B9=E6=AF=94=E6=8E=A5=E5=8F=A3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/controller/GammaController.java | 3 +- .../jeecg/modules/service/IDataService.java | 2 + .../service/impl/GammaServiceImpl.java | 16 +++- .../service/impl/IDataServiceImpl.java | 85 +++++++++++++------ 4 files changed, 74 insertions(+), 32 deletions(-) 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 164fb778..0a776fbd 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 @@ -547,8 +547,7 @@ public class GammaController { @GetMapping("nuclComparison") @ApiOperation(value = "Radionuclide Activity页面查看Comparison数据", notes = "Radionuclide Activity页面查看Comparison数据") public Result nuclComparison(String fileName, HttpServletRequest request) { - gammaService.nuclComparison(fileName, request); - return null; + return gammaService.nuclComparison(fileName, request); } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IDataService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IDataService.java index b5861639..85ff90c9 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IDataService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IDataService.java @@ -16,4 +16,6 @@ public interface IDataService { List viewNucl(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn); + void viewStations(); + } 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 49202bd0..7c995165 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 @@ -5901,6 +5901,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("Please select the parse file first!"); return result; } + Map idcStationMap = (Map) redisUtil.get("idcStationMap"); try { String collectStart = ""; if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { @@ -5916,6 +5917,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi Date acquisitionStopDate = new Date(stopTime); //格式化得到采集结束时间的字符串 String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); + //从缓存的idc台站信息中获取当前台站对应的台站id + Integer stationId = null; + if (CollectionUtils.isNotEmpty(idcStationMap)) { + stationId = idcStationMap.get(phd.getHeader().getSite_code()); + } //连接本地同步的idc数据库 conn = dataService.connectInland(); //连接对象为空 则连接idc国际库 @@ -5925,7 +5931,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi //判断是否连接成功 if (Objects.nonNull(conn)) { //查询获取Peaks表的对比数据内容 - peakInfoList = dataService.viewPeaks(phd.getHeader().getSite_code(), phd.getHeader().getSpectrum_quantity(), 0, collectStart, acquisitionStop, conn); + peakInfoList = dataService.viewPeaks(phd.getHeader().getDetector_code(), phd.getHeader().getSpectrum_quantity(), stationId, collectStart, acquisitionStop, conn); } result.setSuccess(true); result.setResult(peakInfoList); @@ -5957,6 +5963,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("Please select the parse file first!"); return result; } + Map idcStationMap = (Map) redisUtil.get("idcStationMap"); try { String collectStart = ""; if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { @@ -5972,6 +5979,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi Date acquisitionStopDate = new Date(stopTime); //格式化得到采集结束时间的字符串 String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); + //从缓存的idc台站信息中获取当前台站对应的台站id + Integer stationId = null; + if (CollectionUtils.isNotEmpty(idcStationMap)) { + stationId = idcStationMap.get(phd.getHeader().getSite_code()); + } //连接本地同步的idc数据库 conn = dataService.connectInland(); //连接对象为空 则连接idc国际库 @@ -5981,7 +5993,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi //判断是否连接成功 if (Objects.nonNull(conn)) { //查询获取Peaks表的对比数据内容 - nuclideActivityList = dataService.viewNucl(phd.getHeader().getSite_code(), phd.getHeader().getSpectrum_quantity(), 0, collectStart, acquisitionStop, conn); + nuclideActivityList = dataService.viewNucl(phd.getHeader().getDetector_code(), phd.getHeader().getSpectrum_quantity(), stationId, collectStart, acquisitionStop, conn); } result.setSuccess(true); result.setResult(nuclideActivityList); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/IDataServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/IDataServiceImpl.java index 96d9e327..a169409e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/IDataServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/IDataServiceImpl.java @@ -3,17 +3,16 @@ package org.jeecg.modules.service.impl; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import org.jeecg.common.util.NumberFormatUtil; +import org.jeecg.common.util.RedisUtil; import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.entity.vo.TableNuclideActivity; import org.jeecg.modules.service.IDataService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.sql.*; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; @Service @@ -37,6 +36,8 @@ public class IDataServiceImpl implements IDataService { @Value("${oversea.password}") private String passwordO; + @Autowired + private RedisUtil redisUtil; @Override public Connection connectInland() { @@ -70,9 +71,11 @@ public class IDataServiceImpl implements IDataService { //拼接sql根据探测器编码,台站id,采样开始时间,采集结束时间 查询 sampleId String sql = ""; sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA "; - sql+="WHERE TRIM( SITE_DET_CODE ) = '"+siteDetCode+"' "; - sql+="AND STATION_ID = "+stationId+" "; - sql+="AND SPECTRAL_QUALIFIER = " + spectralQualifier +" "; + sql+="WHERE TRIM(SITE_DET_CODE) = '"+siteDetCode+"' "; + if (Objects.nonNull(stationId)) { + sql+="AND STATION_ID = "+stationId+" "; + } + sql+="AND SPECTRAL_QUALIFIER = '" + spectralQualifier +"' "; sql+="AND COLLECT_START = TO_DATE( '"+collectStart+"', 'YYYY-MM-DD HH24:MI:SS' ) "; sql+="AND ACQUISITION_STOP = TO_DATE( '"+acquisitionStop+"', 'YYYY-MM-DD HH24:MI:SS' )"; ResultSet query = statement.executeQuery(sql); @@ -150,9 +153,11 @@ public class IDataServiceImpl implements IDataService { //拼接sql根据探测器编码,台站id,采样开始时间,采集结束时间 查询 sampleId String sql = ""; sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA "; - sql+="WHERE TRIM( SITE_DET_CODE ) = '"+siteDetCode+"' "; - sql+="AND STATION_ID = "+stationId+" "; - sql+="AND SPECTRAL_QUALIFIER = " + spectralQualifier + " "; + sql+="WHERE TRIM(SITE_DET_CODE) = '"+siteDetCode+"' "; + if (Objects.nonNull(stationId)) { + sql+="AND STATION_ID = "+stationId+" "; + } + sql+="AND SPECTRAL_QUALIFIER = '"+spectralQualifier+"' "; sql+="AND COLLECT_START = TO_DATE( '"+collectStart+"', 'YYYY-MM-DD HH24:MI:SS' ) "; sql+="AND ACQUISITION_STOP = TO_DATE( '"+acquisitionStop+"', 'YYYY-MM-DD HH24:MI:SS' )"; ResultSet query = statement.executeQuery(sql); @@ -168,30 +173,14 @@ public class IDataServiceImpl implements IDataService { ResultSet executeQuery = statement.executeQuery(nuclSql); while (executeQuery.next()) { String name = executeQuery.getString("NAME"); - double halflife = executeQuery.getDouble("HALFLIFE"); - char units = 'S'; - if(halflife >= 31556736) // 1年 = 365.24 * 24 * 60 * 60 = 31556736s - { - halflife /= 31556736; - units = 'A'; - } - else if(halflife >= 86400) // 1天 = 24 * 60 * 60 = 86400s - { - halflife /= 86400; - units = 'D'; - } - else if(halflife >= 3600) - { - halflife /= 3600; - units = 'H'; - } + String halflife = executeQuery.getString("HALFLIFE"); double mdc = executeQuery.getDouble("MDA"); double conc = executeQuery.getDouble("ACTIV_DECAY"); double activity = executeQuery.getDouble("ACTIV_KEY"); double activityErr = executeQuery.getDouble("ACTIV_KEY_ERR"); TableNuclideActivity nuclideActivity = new TableNuclideActivity(); nuclideActivity.setNuclide(name); - nuclideActivity.setHalfLife(NumberFormatUtil.numberFormat(String.valueOf(halflife))+StringPool.SPACE+units); + nuclideActivity.setHalfLife(halflife); nuclideActivity.setActivity(NumberFormatUtil.numberFormat(String.valueOf(activity))); nuclideActivity.setActErr(NumberFormatUtil.numberFormat(String.valueOf(activityErr))); nuclideActivity.setConc(NumberFormatUtil.numberFormat(String.valueOf(conc))); @@ -234,4 +223,44 @@ public class IDataServiceImpl implements IDataService { return nuclideActivityList; } + @Override + public void viewStations() { + Map stationMap = new HashMap<>(); + //连接本地idc同步库 + Connection conn = connectInland(); + //判断连接对象是否为空 + if (Objects.isNull(conn)) { + //如果连接失败 连接idc国际库 + conn = connectOverSea(); + } + Statement statement = null; + try { + if (Objects.nonNull(conn)) { + statement = conn.createStatement(); + //拼接sql查询GARDS_STATIONS表存储台站数据 + String sql = "SELECT STATION_ID,STATION_CODE FROM RMSMAN.GARDS_STATIONS"; + ResultSet query = statement.executeQuery(sql); + while (query.next()) { + int stationId = query.getInt("STATION_ID"); + String stationCode = query.getString("STATION_CODE"); + stationMap.put(stationCode, stationId); + } + } + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(statement)) { + statement.close(); + } + if (Objects.nonNull(conn)) { + conn.close(); + } + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + redisUtil.set("idcStationMap", stationMap); + } + }