人工交互分析查询gamma对比数据接口峰对比数据返回类修改

新增人工交互分析beta部分查询对比数据接口
This commit is contained in:
qiaoqinzheng 2024-01-18 16:57:25 +08:00
parent 92f7180f31
commit 469f15f48f
6 changed files with 173 additions and 20 deletions

View File

@ -260,4 +260,9 @@ public class SpectrumAnalysesController {
spectrumAnalysisService.saveToTxt(rrrLogInfo, request, response);
}
@GetMapping("xeComparison")
public Result xeComparison(String sampleFileName, HttpServletRequest request) {
return spectrumAnalysisService.xeComparison(sampleFileName, request);
}
}

View File

@ -1,7 +1,8 @@
package org.jeecg.modules.service;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.entity.GardsXeResultsView;
import org.jeecg.modules.entity.vo.TableNuclideActivity;
import org.jeecg.modules.entity.vo.TablePeak;
import java.sql.Connection;
import java.util.List;
@ -12,10 +13,12 @@ public interface IDataService {
Connection connectOverSea();
List<PeakInfo> viewPeaks(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn);
List<TablePeak> viewPeaks(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);
List<GardsXeResultsView> viewBetaXeResult(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn);
void viewStations();
}

View File

@ -91,4 +91,7 @@ public interface ISpectrumAnalysisService {
void saveToExcel(RRRLogInfo rrrLogInfo, HttpServletRequest request, HttpServletResponse response);
void saveToTxt(RRRLogInfo rrrLogInfo, HttpServletRequest request, HttpServletResponse response);
Result xeComparison(String sampleFileName, HttpServletRequest request);
}

View File

@ -2,10 +2,13 @@ package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.jeecg.common.util.NumberFormatUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.entity.GardsXeResultsView;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.entity.vo.TableNuclideActivity;
import org.jeecg.modules.entity.vo.TablePeak;
import org.jeecg.modules.service.IDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -62,10 +65,10 @@ public class DataServiceImpl implements IDataService {
}
@Override
public List<PeakInfo> viewPeaks(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn) {
public List<TablePeak> viewPeaks(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn) {
Statement statement = null;
Integer sampleId = null;
List<PeakInfo> peakInfoList = new LinkedList<>();
List<TablePeak> peakInfoList = new LinkedList<>();
try {
statement = conn.createStatement();
//拼接sql根据探测器编码台站id采样开始时间采集结束时间 查询 sampleId
@ -99,21 +102,22 @@ public class DataServiceImpl implements IDataService {
double significance = executeQuery.getDouble("DETECTABILITY");
int peakId = executeQuery.getInt("PEAK_ID");
//声明一个PeakInfo实体类存储查询出的数据
PeakInfo peak = new PeakInfo();
peak.index = peakId;
peak.area = area;
peak.areaErr = areaErr;
peak.peakCentroid = centroChannel;
peak.energy = energy;
peak.fwhm = fwhm;
peak.multiIndex = multiplet;
peak.significance = significance;
TablePeak peak = new TablePeak();
peak.setNo(peakId);
peak.setNetArea(String.format("%.3f", area));
peak.setAreaErr(String.format("%.3f", areaErr));
peak.setCentroid(String.format("%.3f", centroChannel));
peak.setEnergy(String.format("%.3f", energy));
peak.setFwhm(String.format("%.3f", fwhm));
peak.setMultiplet(String.valueOf(multiplet));
peak.setSignificant(String.format("%.3f", significance));
peak.setIndentify("");
peakInfoList.add(peak);
}
//判断峰信息是否为空
if (CollectionUtils.isNotEmpty(peakInfoList)) {
//根据峰下标进行排序
peakInfoList = peakInfoList.stream().sorted(Comparator.comparing(item-> item.index)).collect(Collectors.toList());
peakInfoList = peakInfoList.stream().sorted(Comparator.comparing(item-> item.getNo())).collect(Collectors.toList());
//峰信息不为空 查询峰核素信息表 读取峰关联核素名称
String nuclIdedSql = "SELECT NAME,PEAK FROM RMSMAN.GARDS_NUCL_LINES_IDED " +
"WHERE SAMPLE_ID = "+sampleId;
@ -121,11 +125,13 @@ public class DataServiceImpl implements IDataService {
while (resultSet.next()) {
String name = resultSet.getString("NAME");
int peak = resultSet.getInt("PEAK");
peakInfoList.stream().forEach(item->{
if (item.index == peak) {
item.nuclides.add(name+ StringPool.SEMICOLON);
for (TablePeak item : peakInfoList) {
if (item.getNo() == peak) {
String indentify = item.getIndentify();
indentify+=name + StringPool.SEMICOLON;
item.setIndentify(indentify);
}
});
}
}
}
}
@ -168,7 +174,7 @@ public class DataServiceImpl implements IDataService {
if(Objects.nonNull(sampleId)) {
//拼接sql查询核素信息表
String nuclSql = "SELECT NAME,HALFLIFE,MDA,ACTIV_DECAY,ACTIV_KEY,ACTIV_KEY_ERR FROM RMSMAN.GARDS_NUCL_IDED " +
"WHERE SAMPLE_ID = "+sampleId;
"WHERE SAMPLE_ID = "+sampleId + " AND NID_FLAG = 1";
//执行sql查询结果
ResultSet executeQuery = statement.executeQuery(nuclSql);
while (executeQuery.next()) {
@ -223,6 +229,75 @@ public class DataServiceImpl implements IDataService {
return nuclideActivityList;
}
@Override
public List<GardsXeResultsView> viewBetaXeResult(String siteDetCode, String spectralQualifier, Integer stationId, String collectStart, String acquisitionStop, Connection conn) {
Statement statement = null;
Integer sampleId = null;
List<GardsXeResultsView> xeResultsViewList = new LinkedList<>();
try {
statement = conn.createStatement();
//拼接sql根据探测器编码台站id采样开始时间采集结束时间 查询 sampleId
String sql = "";
sql+="SELECT SAMPLE_ID FROM RMSMAN.GARDS_SAMPLE_DATA ";
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);
while (query.next()) {
sampleId = query.getInt("SAMPLE_ID");
}
//判断条件查询到的sampleId是否为空 如果不为空 则继续查询
if(Objects.nonNull(sampleId)) {
//拼接sql根据sampleId查询beta分析结果表内容数据
String xeResultSql = "SELECT NUCLIDE_ID,CONC,CONC_ERR,MDC,NID_FLAG FROM RMSMAN.GARDS_BG_ISOTOPE_CONCS " +
"WHERE SAMPLE_ID = "+sampleId;
//执行sql得到查询结果
ResultSet executeQuery = statement.executeQuery(xeResultSql);
while (executeQuery.next()) {
int nuclideId = executeQuery.getInt("NUCLIDE_ID");
double conc = executeQuery.getDouble("CONC");
double concErr = executeQuery.getDouble("CONC_ERR");
double mdc = executeQuery.getDouble("MDC");
int nidFlag = executeQuery.getInt("NID_FLAG");
//声明一个XeResult实体类存储查询出的数据
GardsXeResultsView xeResultsView = new GardsXeResultsView();
if (8 == nuclideId) {
xeResultsView.setNuclideName("XE131M");
} else if (9 == nuclideId) {
xeResultsView.setNuclideName("XE133M");
} else if (10 == nuclideId) {
xeResultsView.setNuclideName("XE133");
} else if (11 == nuclideId) {
xeResultsView.setNuclideName("XE135");
}
xeResultsView.setConc(NumberFormatUtil.numberFormat(String.valueOf(conc)));
xeResultsView.setConcErr(NumberFormatUtil.numberFormat(String.valueOf(concErr)));
xeResultsView.setMdc(NumberFormatUtil.numberFormat(String.valueOf(mdc)));
xeResultsView.setNidFlag(nidFlag);
xeResultsViewList.add(xeResultsView);
}
if (CollectionUtils.isNotEmpty(xeResultsViewList)) {
xeResultsViewList = xeResultsViewList.stream().sorted(Comparator.comparing(GardsXeResultsView::getNuclideName)).collect(Collectors.toList());
}
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(statement)) {
statement.close();
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return xeResultsViewList;
}
@Override
public void viewStations() {
Map<String, Integer> stationMap = new HashMap<>();

View File

@ -5948,7 +5948,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
public Result peakComparison(String fileName, HttpServletRequest request) {
Result result = new Result();
Connection conn = null;
List<PeakInfo> peakInfoList = new LinkedList<>();
List<TablePeak> peakInfoList = new LinkedList<>();
//获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//读取缓存内容

View File

@ -57,6 +57,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.ParseException;
import java.time.Instant;
import java.time.LocalDateTime;
@ -118,6 +120,8 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
private RedisStreamUtil redisStreamUtil;
@Autowired
private NameStandUtil nameStandUtil;
@Autowired
private IDataService dataService;
@Override
@ -6019,4 +6023,67 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
return spectrumData;
}
@Override
public Result xeComparison(String sampleFileName, HttpServletRequest request) {
Result result = new Result();
Connection conn = null;
List<GardsXeResultsView> xeResultsViewList = new LinkedList<>();
//获取用户名称
String userName = JwtUtil.getUserNameByToken(request);
//获取本地缓存
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
if (Objects.isNull(betaDataFile)) {
result.error500("Load basic file information first!");
return result;
}
Map<String, Integer> idcStationMap = (Map<String, Integer>) redisUtil.get("idcStationMap");
try {
EnergySpectrumStruct struct = betaDataFile.getSampleStruct();
String collectStart = "";
if (struct.collection_start_time.indexOf(StringPool.DOT) > 0) {
collectStart = struct.collection_start_date + " " + struct.collection_start_time.substring(0, struct.collection_start_time.indexOf(StringPool.DOT));
} else {
collectStart = struct.collection_start_date + " " + struct.collection_start_time;
}
//获取采集开始时间
Date acqStart = DateUtils.parseDate(struct.acquisition_start_date + " " + struct.acquisition_start_time);
//计算得到采集结束时间对应的毫秒数
long stopTime = (long) (acqStart.getTime() + (struct.acquisition_real_time * 1000));
//根据毫秒数得到采集结束时间
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(struct.site_code);
}
//连接本地同步的idc数据库
conn = dataService.connectInland();
//连接对象为空 则连接idc国际库
if (Objects.isNull(conn)) {
conn = dataService.connectOverSea();
}
//判断是否连接成功
if (Objects.nonNull(conn)) {
//查询获取beta分析后的xe结果表的对比数据内容
xeResultsViewList = dataService.viewBetaXeResult(struct.detector_code, struct.spectrum_quantity, stationId, collectStart, acquisitionStop, conn);
}
result.setSuccess(true);
result.setResult(xeResultsViewList);
} catch (ParseException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(conn)) {
conn.close();
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return result;
}
}