Merge remote-tracking branch 'origin/mdc' into mdc
This commit is contained in:
commit
cf855d9f28
|
@ -4,6 +4,11 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
|
@ -22,6 +27,7 @@ import java.nio.file.Paths;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.jeecg.common.util.ClassUtil.classPathStream;
|
||||
|
||||
|
@ -183,4 +189,50 @@ public class ExportUtil {
|
|||
Map<String,Object> dataMap){
|
||||
exportXls(response,template,target,dataSet,dataMap,"file.xls");
|
||||
}
|
||||
|
||||
public static Workbook createWorkBook(List<String> stationNameList, List<String> columnNameList, Map<String, List<Map<String, Object>>> dataMap) {
|
||||
//创建工作簿
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
//遍历台站数量
|
||||
for (int i=0; i<stationNameList.size(); i++) {
|
||||
String stationName = stationNameList.get(i);
|
||||
//创建工作页
|
||||
Sheet sheet = workbook.createSheet(stationName);
|
||||
//声明行下标
|
||||
int rowIndex = 0;
|
||||
//创建第一行
|
||||
Row row = sheet.createRow(rowIndex);
|
||||
for (int j=0; j<columnNameList.size(); j++) {
|
||||
String columnName = columnNameList.get(j);
|
||||
//创建当前行的单元格
|
||||
Cell cell = row.createCell(j);
|
||||
cell.setCellValue(columnName);
|
||||
}
|
||||
rowIndex+=1;
|
||||
//根据台站名称获取数据
|
||||
List<Map<String, Object>> dataList = dataMap.get(stationName);
|
||||
//遍历数据根据字段名称取值赋值
|
||||
for (int j=0; j<dataList.size(); j++,rowIndex++) {
|
||||
//创建存储数据的行
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
//数据数组中读取下标对应的数据
|
||||
Map<String, Object> data = dataList.get(j);
|
||||
for (int k=0; k<columnNameList.size(); k++) {
|
||||
Cell cell = dataRow.createCell(k);
|
||||
//从列名数组中读取列名
|
||||
String columnName = columnNameList.get(k);
|
||||
//根据列名读取对应数据的信息
|
||||
Object value = data.get(StringUtils.upperCase(columnName));
|
||||
if (Objects.nonNull(value)) {
|
||||
cell.setCellValue(value.toString());
|
||||
} else {
|
||||
cell.setCellValue("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -208,4 +208,28 @@ public class WebStatisticsController {
|
|||
HttpServletResponse response){
|
||||
reviewedService.rrrExport(stationIds, startTime, endTime,response);
|
||||
}
|
||||
|
||||
@GetMapping("findNuclideList")
|
||||
@ApiOperation(value = "查询核素列表数据", notes = "查询核素列表数据")
|
||||
public Result findNuclideList(String systemType) {
|
||||
return gardsSampleDataWebService.findNuclideList(systemType);
|
||||
}
|
||||
|
||||
@GetMapping("findNuclideStatistics")
|
||||
@ApiOperation(value = "查询核素统计结果", notes = "查询核素统计结果")
|
||||
public Result findNuclideStatistics(String stationId, String systemType, String dbName, String[] nuclideNames,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
|
||||
return gardsSampleDataWebService.findNuclideStatistics(stationId, systemType, dbName, nuclideNames, startDate, endDate);
|
||||
}
|
||||
|
||||
@GetMapping("exportNuclideStatistics")
|
||||
@ApiOperation(value = "导出核素统计结果", notes = "导出核素统计结果")
|
||||
public void exportNuclideStatistics(String[] stationIds, String systemType, String dbName, String[] nuclideNames,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
|
||||
HttpServletResponse response) {
|
||||
gardsSampleDataWebService.exportNuclideStatistics(stationIds, systemType, dbName, nuclideNames, startDate, endDate, response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,4 +27,6 @@ public interface GardsSampleDataWebMapper extends BaseMapper<GardsSampleDataWeb>
|
|||
|
||||
Integer getSampleId(@Param(value = "filePathName") String filePathName);
|
||||
|
||||
List<Map<String, Object>> findNuclideStatistics(@Param(value = "stationId") String stationId, @Param(value = "startTime") String startTime, @Param(value = "endTime") String endTime, @Param(value = "nuclideSql") String nuclideSql);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide;
|
||||
|
||||
@Mapper
|
||||
public interface SysDefaultNuclideMapper extends BaseMapper<SysDefaultNuclide> {
|
||||
}
|
|
@ -178,4 +178,48 @@
|
|||
SELECT SAMPLE_ID FROM ORIGINAL.GARDS_SAMPLE_DATA WHERE INPUT_FILE_NAME = #{filePathName}
|
||||
</select>
|
||||
|
||||
<select id="findNuclideStatistics" resultType="java.util.Map">
|
||||
SELECT
|
||||
AA.STATION_ID,
|
||||
AA.SAMPLE_ID,
|
||||
AA.SAMPLE_REF_ID,
|
||||
AA.SPECTRAL_QUALIFIE,
|
||||
AA.COLLECT_START,
|
||||
AA.COLLECT_STOP,
|
||||
AA.QUANTITY,
|
||||
AA.XE_VOLUME,
|
||||
AA.ACQUISITION_START,
|
||||
AA.ACQUISITION_STOP,
|
||||
AA.ACQUISITION_LIVE_SEC,
|
||||
AA.SITE_DET_CODE,
|
||||
${nuclideSql}
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
A.STATION_ID,
|
||||
A.SAMPLE_ID,
|
||||
B.SAMPLE_REF_ID,
|
||||
A.SPECTRAL_QUALIFIE,
|
||||
A.COLLECT_START,
|
||||
A.COLLECT_STOP,
|
||||
A.QUANTITY,
|
||||
B.XE_VOLUME,
|
||||
A.ACQUISITION_START,
|
||||
A.ACQUISITION_STOP,
|
||||
A.ACQUISITION_LIVE_SEC,
|
||||
A.SITE_DET_CODE
|
||||
FROM
|
||||
ORIGINAL.GARDS_SAMPLE_DATA A,
|
||||
ORIGINAL.GARDS_SAMPLE_AUX B
|
||||
WHERE
|
||||
A.STATION_ID = #{stationId}
|
||||
AND A.SAMPLE_ID = B.SAMPLE_ID
|
||||
AND A.DATA_TYPE = 'S'
|
||||
AND A.SPECTRAL_QUALIFIE = 'FULL'
|
||||
AND A.COLLECT_START BETWEEN TO_DATE(#{startTime}, 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(#{endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||||
) AA
|
||||
ORDER BY
|
||||
AA.COLLECT_START
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -51,4 +51,11 @@ public interface IGardsSampleDataWebService extends IService<GardsSampleDataWeb>
|
|||
List<Integer> sampleIds);
|
||||
|
||||
List<GardsSampleDataWeb> queryByModDate(Date startTime, Date endTime);
|
||||
|
||||
Result findNuclideList(String systemType);
|
||||
|
||||
Result findNuclideStatistics(String stationId, String systemType, String dbName, String[] nuclideNames, Date startDate, Date endDate);
|
||||
|
||||
void exportNuclideStatistics(String[] stationIds, String systemType, String dbName, String[] nuclideNames, Date startDate, Date endDate, HttpServletResponse response);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,8 +23,12 @@ import org.jeecg.common.util.*;
|
|||
import org.jeecg.modules.base.entity.original.GardsSampleAux;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleDescription;
|
||||
import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide;
|
||||
import org.jeecg.modules.base.enums.SystemType;
|
||||
import org.jeecg.modules.base.enums.XeNuclideName;
|
||||
import org.jeecg.modules.entity.GardsSampleDataWeb;
|
||||
import org.jeecg.modules.entity.data.*;
|
||||
import org.jeecg.modules.entity.dto.SampleDataDto;
|
||||
import org.jeecg.modules.entity.vo.SpectrumFileRecord;
|
||||
import org.jeecg.modules.mapper.*;
|
||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||
|
@ -52,26 +56,10 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
|||
@Autowired
|
||||
private GardsSampleAuxMapper gardsSampleAuxMapper;
|
||||
@Autowired
|
||||
private GardsCalibrationPairsOrigMapper gardsCalibrationPairsOrigMapper;
|
||||
private SysDefaultNuclideMapper defaultNuclideMapper;
|
||||
@Autowired
|
||||
private GardsSampleDescriptionMapper gardsSampleDescriptionMapper;
|
||||
@Autowired
|
||||
private GardsBgEfficiencyPairsMapper gardsBgEfficiencyPairsMapper;
|
||||
@Autowired
|
||||
private GardsRoiLimitsMapper gardsRoiLimitsMapper;
|
||||
@Autowired
|
||||
private GardsSampleRatiosMapper gardsSampleRatiosMapper;
|
||||
@Autowired
|
||||
private GardsSpectrumMapper gardsSpectrumMapper;
|
||||
@Autowired
|
||||
private GardsHistogramMapper gardsHistogramMapper;
|
||||
@Autowired
|
||||
private GardsSampleCertMapper gardsSampleCertMapper;
|
||||
@Autowired
|
||||
private GardsSampleCertLineMapper gardsSampleCertLineMapper;
|
||||
@Autowired
|
||||
private ReadLineUtil readLineUtil;
|
||||
@Autowired
|
||||
private FTPUtil ftpUtil;
|
||||
@Autowired
|
||||
private SpectrumPathProperties spectrumPathProperties;
|
||||
|
@ -864,4 +852,450 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
|
|||
queryWrapper.orderByAsc(GardsSampleDataWeb::getSiteDetCode);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("master")
|
||||
public Result findNuclideList(String systemType) {
|
||||
Result result = new Result();
|
||||
LambdaQueryWrapper<SysDefaultNuclide> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDefaultNuclide::getUseType, 4);
|
||||
if (systemType.equals("beta")) {
|
||||
queryWrapper.eq(SysDefaultNuclide::getNuclideType, SystemType.BETA.getType());
|
||||
} else if (systemType.equals("gamma")) {
|
||||
queryWrapper.eq(SysDefaultNuclide::getNuclideType, SystemType.GAMMA.getType());
|
||||
} else if (systemType.equals("Particulate")) {
|
||||
queryWrapper.eq(SysDefaultNuclide::getNuclideType, SystemType.PARTICULATE.getType());
|
||||
}
|
||||
List<SysDefaultNuclide> defaultNuclides = defaultNuclideMapper.selectList(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(defaultNuclides);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findNuclideStatistics(String stationId, String systemType, String dbName, String[] nuclideNames, Date startDate, Date endDate) {
|
||||
Result result = new Result();
|
||||
//存储结果
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
//从redis中获取台站信息
|
||||
Map<String, String> stationMap = (Map<String, String>)redisUtil.get("stationMap");
|
||||
//判断开始时间是否为空
|
||||
if (Objects.isNull(startDate)){
|
||||
result.error500("The start time cannot be empty");
|
||||
return result;
|
||||
}
|
||||
String startTime = DateUtils.formatDate(startDate, "yyyy-MM-dd") + " 00:00:00";
|
||||
//判断结束时间是否为空
|
||||
if (Objects.isNull(endDate)) {
|
||||
result.error500("The end time cannot be empty");
|
||||
return result;
|
||||
}
|
||||
String endTime = DateUtils.formatDate(endDate, "yyyy-MM-dd") + " 23:59:59";
|
||||
List<String> allDayTime = DateUtils.getAllDay(DateUtils.formatDate(startDate, "yyyy-MM-dd"), DateUtils.formatDate(endDate, "yyyy-MM-dd"));
|
||||
//判断查询的核素内容是否为空
|
||||
List<String> nuclideNameList = new LinkedList<>();
|
||||
if (nuclideNames != null && nuclideNames.length > 0) {
|
||||
nuclideNameList = Arrays.asList(nuclideNames);
|
||||
}
|
||||
//判断要查询的数据库类型
|
||||
if (dbName.equals("auto")) {
|
||||
dbName = "RNAUTO";
|
||||
} else if (dbName.equals("man")) {
|
||||
dbName = "RNMAN";
|
||||
}
|
||||
//判断系统类型查询对应匹配的核素信息
|
||||
String nuclideSql = "";
|
||||
if (systemType.equals("beta")) {
|
||||
nuclideSql = betaNuclideSql(dbName, nuclideNameList);
|
||||
for (int i=0; i< nuclideNameList.size(); i++) {
|
||||
String nuclideName = nuclideNameList.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
List<Double> concList = new LinkedList<>();
|
||||
List<Double> mdcList = new LinkedList<>();
|
||||
resultMap.put(nuclideName+"Conc", concList);
|
||||
resultMap.put(nuclideName+"MDC", mdcList);
|
||||
}
|
||||
}
|
||||
} else if (systemType.equals("gamma")) {
|
||||
nuclideSql = gammaNuclideSql(dbName, nuclideNameList);
|
||||
for (int i=0; i< nuclideNameList.size(); i++) {
|
||||
String nuclideName = nuclideNameList.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
List<Double> concList = new LinkedList<>();
|
||||
List<Double> mdcList = new LinkedList<>();
|
||||
resultMap.put(nuclideName+"Conc", concList);
|
||||
resultMap.put(nuclideName+"MDC", mdcList);
|
||||
}
|
||||
}
|
||||
} else if (systemType.equals("Particulate")) {
|
||||
nuclideSql = particulateSql(dbName, nuclideNameList);
|
||||
for (int i=0; i< nuclideNameList.size(); i++) {
|
||||
String nuclideName = nuclideNameList.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
List<Double> concList = new LinkedList<>();
|
||||
resultMap.put(nuclideName+"Conc", concList);
|
||||
}
|
||||
}
|
||||
}
|
||||
//拼接sql查询结果
|
||||
List<Map<String, Object>> nuclideStatisticsMap = this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql);
|
||||
//处理查询结果
|
||||
handleNuclideData(nuclideStatisticsMap, systemType, nuclideNameList, allDayTime, resultMap);
|
||||
//返回台站名称
|
||||
String stationName = stationMap.get(stationId);
|
||||
resultMap.put("STATION_NAME", stationName);
|
||||
result.setSuccess(true);
|
||||
result.setResult(resultMap);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportNuclideStatistics(String[] stationIds, String systemType, String dbName, String[] nuclideNames, Date startDate, Date endDate, HttpServletResponse response) {
|
||||
Map<String, List<Map<String, Object>>> resultMap = new HashMap<>();
|
||||
//从redis中获取台站信息
|
||||
Map<String, String> stationMap = (Map<String, String>)redisUtil.get("stationMap");
|
||||
//判断开始时间是否为空
|
||||
if (Objects.isNull(startDate)){
|
||||
return;
|
||||
}
|
||||
String startTime = DateUtils.formatDate(startDate, "yyyy-MM-dd") + " 00:00:00";
|
||||
//判断结束时间是否为空
|
||||
if (Objects.isNull(endDate)) {
|
||||
return;
|
||||
}
|
||||
String endTime = DateUtils.formatDate(endDate, "yyyy-MM-dd") + " 23:59:59";
|
||||
//判断查询的核素内容是否为空
|
||||
List<String> nuclideNameList = new LinkedList<>();
|
||||
if (nuclideNames != null && nuclideNames.length > 0) {
|
||||
nuclideNameList = Arrays.asList(nuclideNames);
|
||||
}
|
||||
//判断要查询的数据库类型
|
||||
if (dbName.equals("auto")) {
|
||||
dbName = "RNAUTO";
|
||||
} else if (dbName.equals("man")) {
|
||||
dbName = "RNMAN";
|
||||
}
|
||||
//列名数组
|
||||
List<String> columnNameList = new LinkedList<>();
|
||||
//判断系统类型查询对应匹配的核素信息
|
||||
String nuclideSql = "";
|
||||
if (systemType.equals("beta")) {
|
||||
//存储基础列名
|
||||
columnNameList.add("STATION_ID");
|
||||
columnNameList.add("SAMPLE_ID");
|
||||
columnNameList.add("SPECTRAL_QUALIFIE");
|
||||
columnNameList.add("COLLECT_START");
|
||||
columnNameList.add("QUANTITY");
|
||||
columnNameList.add("XE_VOLUME");
|
||||
columnNameList.add("ACQUISITION_START");
|
||||
columnNameList.add("ACQUISITION_LIVE_SEC");
|
||||
columnNameList.add("SITE_DET_CODE");
|
||||
nuclideSql = betaNuclideSql(dbName, nuclideNameList);
|
||||
for (int i=0; i< nuclideNameList.size(); i++) {
|
||||
String nuclideName = nuclideNameList.get(i);
|
||||
String upperNuclideName = nuclideName.toUpperCase();
|
||||
if (upperNuclideName.equals(XeNuclideName.XE_131m.getType().toUpperCase())) {
|
||||
nuclideName = XeNuclideName.XE_131m.getType();
|
||||
} else if (upperNuclideName.equals(XeNuclideName.XE_133m.getType().toUpperCase())) {
|
||||
nuclideName = XeNuclideName.XE_133m.getType();
|
||||
}
|
||||
nuclideNameList.set(i, nuclideName);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
columnNameList.add(StringUtils.upperCase(nuclideName));
|
||||
columnNameList.add(StringUtils.upperCase(nuclideName+"MDC"));
|
||||
}
|
||||
}
|
||||
} else if (systemType.equals("gamma")) {
|
||||
//存储基础列名
|
||||
columnNameList.add("STATION_ID");
|
||||
columnNameList.add("SAMPLE_ID");
|
||||
columnNameList.add("SAMPLE_REF_ID");
|
||||
columnNameList.add("COLLECT_START");
|
||||
columnNameList.add("COLLECT_STOP");
|
||||
columnNameList.add("QUANTITY");
|
||||
columnNameList.add("ACQUISITION_START");
|
||||
columnNameList.add("ACQUISITION_STOP");
|
||||
columnNameList.add("ACQUISITION_LIVE_SEC");
|
||||
columnNameList.add("SITE_DET_CODE");
|
||||
nuclideSql = gammaNuclideSql(dbName, nuclideNameList);
|
||||
for (int i=0; i< nuclideNameList.size(); i++) {
|
||||
String nuclideName = nuclideNameList.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
columnNameList.add(StringUtils.upperCase(nuclideName));
|
||||
columnNameList.add(StringUtils.upperCase(nuclideName+"MDC"));
|
||||
}
|
||||
}
|
||||
} else if (systemType.equals("Particulate")) {
|
||||
//存储基础列名
|
||||
columnNameList.add("STATION_ID");
|
||||
columnNameList.add("SAMPLE_ID");
|
||||
columnNameList.add("SAMPLE_REF_ID");
|
||||
columnNameList.add("COLLECT_START");
|
||||
columnNameList.add("COLLECT_STOP");
|
||||
columnNameList.add("QUANTITY");
|
||||
columnNameList.add("ACQUISITION_START");
|
||||
columnNameList.add("ACQUISITION_STOP");
|
||||
columnNameList.add("ACQUISITION_LIVE_SEC");
|
||||
columnNameList.add("SITE_DET_CODE");
|
||||
nuclideSql = particulateSql(dbName, nuclideNameList);
|
||||
for (int i=0; i< nuclideNameList.size(); i++) {
|
||||
String nuclideName = nuclideNameList.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
columnNameList.add(StringUtils.upperCase(nuclideName));
|
||||
}
|
||||
}
|
||||
}
|
||||
//台站名称数组
|
||||
List<String> stationNameList = new LinkedList<>();
|
||||
for (String stationId:stationIds) {
|
||||
//返回台站名称
|
||||
String stationName = stationMap.get(stationId);
|
||||
//拼接sql查询结果
|
||||
List<Map<String, Object>> nuclideStatisticsMap = this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql);
|
||||
resultMap.put(stationName, nuclideStatisticsMap);
|
||||
//添加台站名称到集合
|
||||
stationNameList.add(stationName);
|
||||
}
|
||||
Workbook workbook = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
// 设置文件名、Excel类型(xls|xlsx)
|
||||
outputStream = ExportUtil.xls(response,"nuclide.xls");
|
||||
workbook = ExportUtil.createWorkBook(stationNameList, columnNameList, resultMap);
|
||||
workbook.write(outputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(outputStream))
|
||||
outputStream.close();
|
||||
if (ObjectUtil.isNotNull(workbook))
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String betaNuclideSql(String dbName, List<String> nuclideNames) {
|
||||
String sql = "";
|
||||
//存储每个核素对应的sql
|
||||
List<String> nuclideSqls = new LinkedList<>();
|
||||
//遍历核素名称拼接sql语句
|
||||
for (int i=0; i<nuclideNames.size(); i++) {
|
||||
//读取核素名称
|
||||
String nuclideName = nuclideNames.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
String nuclideSql = "(SELECT DISTINCT\n" +
|
||||
"D.CONC\n" +
|
||||
"FROM\n" +
|
||||
""+dbName+".GARDS_XE_RESULTS D\n" +
|
||||
"WHERE\n" +
|
||||
"D.NUCLIDE_NAME = '"+nuclideName+"'\n" +
|
||||
"AND D.SAMPLE_ID = AA.SAMPLE_ID\n" +
|
||||
"AND D.NID_FLAG = 1\n" +
|
||||
") AS "+nuclideName+",\n" +
|
||||
"(SELECT DISTINCT\n" +
|
||||
"D.MDC\n" +
|
||||
"FROM\n" +
|
||||
""+dbName+".GARDS_XE_RESULTS D\n" +
|
||||
"WHERE\n" +
|
||||
"D.NUCLIDE_NAME = '"+nuclideName+"'\n" +
|
||||
"AND D.SAMPLE_ID = AA.SAMPLE_ID\n" +
|
||||
") AS "+nuclideName+"MDC";
|
||||
nuclideSqls.add(nuclideSql);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(nuclideSqls)) {
|
||||
//向数组的各sql后填充,合成一个sql
|
||||
sql = StringUtils.join(nuclideSqls, StringPool.COMMA);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String gammaNuclideSql(String dbName, List<String> nuclideNames) {
|
||||
String sql = "";
|
||||
//存储每个核素对应的sql
|
||||
List<String> nuclideSqls = new LinkedList<>();
|
||||
//遍历核素名称
|
||||
for (int i=0; i<nuclideNames.size(); i++) {
|
||||
String nuclideName = nuclideNames.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
String nuclideSql = "(SELECT DISTINCT\n" +
|
||||
"D.CONCENTRATION\n" +
|
||||
"FROM\n" +
|
||||
""+dbName+".GARDS_NUCL_IDED D\n" +
|
||||
"WHERE\n" +
|
||||
"D.NUCLIDENAME = '"+nuclideName+"'\n" +
|
||||
"AND D.SAMPLE_ID = AA.SAMPLE_ID\n" +
|
||||
") AS "+nuclideName+",\n" +
|
||||
"(\n" +
|
||||
"SELECT DISTINCT\n" +
|
||||
"D.MDC\n" +
|
||||
"FROM\n" +
|
||||
""+dbName+".GARDS_NUCL_IDED D\n" +
|
||||
"WHERE\n" +
|
||||
"D.NUCLIDENAME = '"+nuclideName+"'\n" +
|
||||
"AND D.SAMPLE_ID = AA.SAMPLE_ID\n" +
|
||||
") AS "+nuclideName+"MDC";
|
||||
nuclideSqls.add(nuclideSql);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(nuclideSqls)) {
|
||||
//向数组的各sql后填充,合成一个sql
|
||||
sql = StringUtils.join(nuclideSqls, StringPool.COMMA);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private String particulateSql(String dbName, List<String> nuclideNames) {
|
||||
String sql = "";
|
||||
//存储核素sql
|
||||
List<String> nuclideSqls = new LinkedList<>();
|
||||
//遍历核素信息
|
||||
for (int i=0; i<nuclideNames.size(); i++) {
|
||||
String nuclideName = nuclideNames.get(i);
|
||||
if (StringUtils.isNotBlank(nuclideName)) {
|
||||
String nuclideSql = "(SELECT DISTINCT\n" +
|
||||
"D.CONCENTRATION\n" +
|
||||
"FROM\n" +
|
||||
""+dbName+".GARDS_NUCL_IDED D\n" +
|
||||
"WHERE\n" +
|
||||
"D.NUCLIDENAME = '"+nuclideName+"'\n" +
|
||||
"AND D.SAMPLE_ID = AA.SAMPLE_ID\n" +
|
||||
") AS "+nuclideName;
|
||||
nuclideSqls.add(nuclideSql);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(nuclideSqls)) {
|
||||
sql = StringUtils.join(nuclideSqls, StringPool.COMMA);
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
private void handleNuclideData(List<Map<String, Object>> nuclideStatisticsMap, String systemType, List<String> nuclideNameList, List<String> allDateTime, Map<String, Object> resultMap) {
|
||||
//存储横坐标采集开始时间
|
||||
List<String> collectStartList = new LinkedList<>();
|
||||
//存储横坐标对应体积
|
||||
List<Double> quantityList = new LinkedList<>();
|
||||
//存储横坐标对应acq活时间
|
||||
List<Double> acqLiveSecList = new LinkedList<>();
|
||||
//遍历日期时间
|
||||
for (int i=0; i< allDateTime.size(); i++) {
|
||||
//根据下标获取日期时间
|
||||
String dayTime = allDateTime.get(i);
|
||||
//新增标识判断是否包含 可能存在一天有多条数据的情况
|
||||
boolean isHave = false;
|
||||
//遍历查询结果数组
|
||||
for (int j=0; j< nuclideStatisticsMap.size(); j++) {
|
||||
//根据下标获取核素查询结果
|
||||
Map<String, Object> nuclideStatistics = nuclideStatisticsMap.get(j);
|
||||
//获取采集开始时间
|
||||
Object collectStart = nuclideStatistics.get("COLLECT_START");
|
||||
//采集开始时间转为字符串
|
||||
String collectStartStr = collectStart.toString();
|
||||
//截取采集开始时间的年月日
|
||||
collectStartStr = collectStartStr.substring(0, 10);
|
||||
//如果采集时间包含当前日期 则正常的读取数据并存入数组
|
||||
if (dayTime.equals(collectStartStr)) {
|
||||
collectStartList.add(collectStart.toString());
|
||||
//获取体积
|
||||
Object quantity = nuclideStatistics.get("QUANTITY");
|
||||
//判断体积数值是否有 如果有 正常存储
|
||||
if (Objects.nonNull(quantity)) {
|
||||
quantityList.add(Double.valueOf(quantity.toString()));
|
||||
} else {
|
||||
quantityList.add(null);
|
||||
}
|
||||
//获取acq活时间
|
||||
Object acquisitionLiveSec = nuclideStatistics.get("ACQUISITION_LIVE_SEC");
|
||||
//判断活时间是否为空 如果不为空 正常存储
|
||||
if (Objects.nonNull(acquisitionLiveSec)) {
|
||||
acqLiveSecList.add(Double.valueOf(acquisitionLiveSec.toString()));
|
||||
} else {
|
||||
acqLiveSecList.add(null);
|
||||
}
|
||||
//判断系统类型决定读取核素的信息
|
||||
if (systemType.equals("beta") || systemType.equals("gamma")) {
|
||||
for (String nuclideName: nuclideNameList) {
|
||||
List<Double> concList = (List<Double>) resultMap.get(nuclideName + "Conc");
|
||||
List<Double> mdcList = (List<Double>) resultMap.get(nuclideName + "MDC");
|
||||
//将核素名称转为全部大写
|
||||
String columnName = StringUtils.upperCase(nuclideName);
|
||||
//读取查询出的浓度
|
||||
Object conc = nuclideStatistics.get(columnName);
|
||||
//判断如果浓度不为空 正常存储
|
||||
if (Objects.nonNull(conc)) {
|
||||
if (conc.toString().toLowerCase().contains("inf") || conc.toString().toLowerCase().contains("nan")) {
|
||||
concList.add(null);
|
||||
} else {
|
||||
concList.add(Double.valueOf(conc.toString()));
|
||||
}
|
||||
} else {
|
||||
concList.add(null);
|
||||
}
|
||||
//读取查询出的mdc结果
|
||||
Object mdc = nuclideStatistics.get(columnName + "MDC");
|
||||
//判断如果mdc结果不为空 正常存储
|
||||
if (Objects.nonNull(mdc)) {
|
||||
if (mdc.toString().toLowerCase().contains("inf") || mdc.toString().toLowerCase().contains("nan")) {
|
||||
mdcList.add(null);
|
||||
} else {
|
||||
mdcList.add(Double.valueOf(mdc.toString()));
|
||||
}
|
||||
} else {
|
||||
mdcList.add(null);
|
||||
}
|
||||
}
|
||||
} else if (systemType.equals("Particulate")) {
|
||||
for (String nuclideName: nuclideNameList) {
|
||||
List<Double> concList = (List<Double>) resultMap.get(nuclideName + "Conc");
|
||||
//将核素名称转为全部大写
|
||||
String columnName = StringUtils.upperCase(nuclideName);
|
||||
//读取查询出的浓度
|
||||
Object conc = nuclideStatistics.get(columnName);
|
||||
//判断如果浓度不为空 正常存储
|
||||
if (Objects.nonNull(conc)) {
|
||||
if (conc.toString().toLowerCase().contains("inf") || conc.toString().toLowerCase().contains("nan")) {
|
||||
concList.add(null);
|
||||
} else {
|
||||
concList.add(Double.valueOf(conc.toString()));
|
||||
}
|
||||
} else {
|
||||
concList.add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
isHave = true;
|
||||
} else { //如果采集时间不包含当前日期 各数组填补null
|
||||
//如果全数组遍历后都没有 就填充空数据
|
||||
if (j == nuclideStatisticsMap.size()-1 && !isHave) {
|
||||
collectStartList.add(dayTime+" 00:00:00");
|
||||
quantityList.add(null);
|
||||
acqLiveSecList.add(null);
|
||||
//判断系统类型决定读取核素的信息
|
||||
if (systemType.equals("beta") || systemType.equals("gamma")) {
|
||||
for (String nuclideName: nuclideNameList) {
|
||||
List<Double> concList = (List<Double>) resultMap.get(nuclideName + "Conc");
|
||||
List<Double> mdcList = (List<Double>) resultMap.get(nuclideName + "MDC");
|
||||
concList.add(null);
|
||||
mdcList.add(null);
|
||||
}
|
||||
} else if (systemType.equals("Particulate")) {
|
||||
for (String nuclideName: nuclideNameList) {
|
||||
List<Double> concList = (List<Double>) resultMap.get(nuclideName + "Conc");
|
||||
concList.add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resultMap.put("CollectStart", collectStartList);
|
||||
resultMap.put("Quantity", quantityList);
|
||||
resultMap.put("AcqLiveSec", acqLiveSecList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user