人工交互分析gamma部分Peak Information,Radionuclide Activity功能Compairson与IDC数据对比接口实现

This commit is contained in:
qiaoqinzheng 2023-12-28 14:20:35 +08:00
parent da660a667b
commit 8deca3f964
4 changed files with 74 additions and 32 deletions

View File

@ -547,8 +547,7 @@ public class GammaController {
@GetMapping("nuclComparison") @GetMapping("nuclComparison")
@ApiOperation(value = "Radionuclide Activity页面查看Comparison数据", notes = "Radionuclide Activity页面查看Comparison数据") @ApiOperation(value = "Radionuclide Activity页面查看Comparison数据", notes = "Radionuclide Activity页面查看Comparison数据")
public Result nuclComparison(String fileName, HttpServletRequest request) { public Result nuclComparison(String fileName, HttpServletRequest request) {
gammaService.nuclComparison(fileName, request); return gammaService.nuclComparison(fileName, request);
return null;
} }
} }

View File

@ -16,4 +16,6 @@ public interface IDataService {
List<TableNuclideActivity> viewNucl(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn); List<TableNuclideActivity> viewNucl(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn);
void viewStations();
} }

View File

@ -5901,6 +5901,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("Please select the parse file first"); result.error500("Please select the parse file first");
return result; return result;
} }
Map<String, Integer> idcStationMap = (Map<String, Integer>) redisUtil.get("idcStationMap");
try { try {
String collectStart = ""; String collectStart = "";
if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { 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); Date acquisitionStopDate = new Date(stopTime);
//格式化得到采集结束时间的字符串 //格式化得到采集结束时间的字符串
String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); 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数据库 //连接本地同步的idc数据库
conn = dataService.connectInland(); conn = dataService.connectInland();
//连接对象为空 则连接idc国际库 //连接对象为空 则连接idc国际库
@ -5925,7 +5931,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
//判断是否连接成功 //判断是否连接成功
if (Objects.nonNull(conn)) { if (Objects.nonNull(conn)) {
//查询获取Peaks表的对比数据内容 //查询获取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.setSuccess(true);
result.setResult(peakInfoList); result.setResult(peakInfoList);
@ -5957,6 +5963,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("Please select the parse file first"); result.error500("Please select the parse file first");
return result; return result;
} }
Map<String, Integer> idcStationMap = (Map<String, Integer>) redisUtil.get("idcStationMap");
try { try {
String collectStart = ""; String collectStart = "";
if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { 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); Date acquisitionStopDate = new Date(stopTime);
//格式化得到采集结束时间的字符串 //格式化得到采集结束时间的字符串
String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); 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数据库 //连接本地同步的idc数据库
conn = dataService.connectInland(); conn = dataService.connectInland();
//连接对象为空 则连接idc国际库 //连接对象为空 则连接idc国际库
@ -5981,7 +5993,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
//判断是否连接成功 //判断是否连接成功
if (Objects.nonNull(conn)) { if (Objects.nonNull(conn)) {
//查询获取Peaks表的对比数据内容 //查询获取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.setSuccess(true);
result.setResult(nuclideActivityList); result.setResult(nuclideActivityList);

View File

@ -3,17 +3,16 @@ package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringPool;
import org.jeecg.common.util.NumberFormatUtil; 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.PeakInfo;
import org.jeecg.modules.entity.vo.TableNuclideActivity; import org.jeecg.modules.entity.vo.TableNuclideActivity;
import org.jeecg.modules.service.IDataService; import org.jeecg.modules.service.IDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.sql.*; import java.sql.*;
import java.util.Comparator; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -37,6 +36,8 @@ public class IDataServiceImpl implements IDataService {
@Value("${oversea.password}") @Value("${oversea.password}")
private String passwordO; private String passwordO;
@Autowired
private RedisUtil redisUtil;
@Override @Override
public Connection connectInland() { public Connection connectInland() {
@ -71,8 +72,10 @@ public class IDataServiceImpl implements IDataService {
String sql = ""; String sql = "";
sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA "; sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA ";
sql+="WHERE TRIM(SITE_DET_CODE) = '"+siteDetCode+"' "; sql+="WHERE TRIM(SITE_DET_CODE) = '"+siteDetCode+"' ";
if (Objects.nonNull(stationId)) {
sql+="AND STATION_ID = "+stationId+" "; sql+="AND STATION_ID = "+stationId+" ";
sql+="AND SPECTRAL_QUALIFIER = " + spectralQualifier +" "; }
sql+="AND SPECTRAL_QUALIFIER = '" + spectralQualifier +"' ";
sql+="AND COLLECT_START = TO_DATE( '"+collectStart+"', 'YYYY-MM-DD HH24:MI:SS' ) "; 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' )"; sql+="AND ACQUISITION_STOP = TO_DATE( '"+acquisitionStop+"', 'YYYY-MM-DD HH24:MI:SS' )";
ResultSet query = statement.executeQuery(sql); ResultSet query = statement.executeQuery(sql);
@ -151,8 +154,10 @@ public class IDataServiceImpl implements IDataService {
String sql = ""; String sql = "";
sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA "; sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA ";
sql+="WHERE TRIM(SITE_DET_CODE) = '"+siteDetCode+"' "; sql+="WHERE TRIM(SITE_DET_CODE) = '"+siteDetCode+"' ";
if (Objects.nonNull(stationId)) {
sql+="AND STATION_ID = "+stationId+" "; sql+="AND STATION_ID = "+stationId+" ";
sql+="AND SPECTRAL_QUALIFIER = " + spectralQualifier + " "; }
sql+="AND SPECTRAL_QUALIFIER = '"+spectralQualifier+"' ";
sql+="AND COLLECT_START = TO_DATE( '"+collectStart+"', 'YYYY-MM-DD HH24:MI:SS' ) "; 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' )"; sql+="AND ACQUISITION_STOP = TO_DATE( '"+acquisitionStop+"', 'YYYY-MM-DD HH24:MI:SS' )";
ResultSet query = statement.executeQuery(sql); ResultSet query = statement.executeQuery(sql);
@ -168,30 +173,14 @@ public class IDataServiceImpl implements IDataService {
ResultSet executeQuery = statement.executeQuery(nuclSql); ResultSet executeQuery = statement.executeQuery(nuclSql);
while (executeQuery.next()) { while (executeQuery.next()) {
String name = executeQuery.getString("NAME"); String name = executeQuery.getString("NAME");
double halflife = executeQuery.getDouble("HALFLIFE"); String halflife = executeQuery.getString("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';
}
double mdc = executeQuery.getDouble("MDA"); double mdc = executeQuery.getDouble("MDA");
double conc = executeQuery.getDouble("ACTIV_DECAY"); double conc = executeQuery.getDouble("ACTIV_DECAY");
double activity = executeQuery.getDouble("ACTIV_KEY"); double activity = executeQuery.getDouble("ACTIV_KEY");
double activityErr = executeQuery.getDouble("ACTIV_KEY_ERR"); double activityErr = executeQuery.getDouble("ACTIV_KEY_ERR");
TableNuclideActivity nuclideActivity = new TableNuclideActivity(); TableNuclideActivity nuclideActivity = new TableNuclideActivity();
nuclideActivity.setNuclide(name); nuclideActivity.setNuclide(name);
nuclideActivity.setHalfLife(NumberFormatUtil.numberFormat(String.valueOf(halflife))+StringPool.SPACE+units); nuclideActivity.setHalfLife(halflife);
nuclideActivity.setActivity(NumberFormatUtil.numberFormat(String.valueOf(activity))); nuclideActivity.setActivity(NumberFormatUtil.numberFormat(String.valueOf(activity)));
nuclideActivity.setActErr(NumberFormatUtil.numberFormat(String.valueOf(activityErr))); nuclideActivity.setActErr(NumberFormatUtil.numberFormat(String.valueOf(activityErr)));
nuclideActivity.setConc(NumberFormatUtil.numberFormat(String.valueOf(conc))); nuclideActivity.setConc(NumberFormatUtil.numberFormat(String.valueOf(conc)));
@ -234,4 +223,44 @@ public class IDataServiceImpl implements IDataService {
return nuclideActivityList; return nuclideActivityList;
} }
@Override
public void viewStations() {
Map<String, Integer> 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);
}
} }