修改核素活度浓度对比分析接口返回的数据结构

This commit is contained in:
duwenyuan 2025-12-16 19:15:38 +08:00
parent ec59d0ce95
commit 814faf3cdc
4 changed files with 209 additions and 10 deletions

View File

@ -25,10 +25,14 @@ public class NuclideActConcIntvl {
*/
private String sampleType;
/** 台站编码
/** 台站ID
*
*/
private Integer stationId;
/** 台站编码
*
*/
private String stationCode;
/**数据源
*

View File

@ -373,12 +373,16 @@
t1.COLLECT_STOP AS collectStop,
t1.SAMPLE_TYPE AS sampleType,
t1.STATION_ID AS stationId,
s.STATION_CODE AS stationCode,
t1.STATUS AS status,
TO_NUMBER(REGEXP_REPLACE(t2.MDC, '[^0-9.Ee-]', '')) AS MDC,
CAST(REGEXP_REPLACE(t2.MDC, '[^0-9.Ee+-]', '') AS BINARY_DOUBLE) AS MDC,
t2.NUCLIDENAME AS NUCLIDE_NAME,
TO_NUMBER(REGEXP_REPLACE(t2.CONCENTRATION, '[^0-9.Ee-]', '')) AS conc
CAST(REGEXP_REPLACE(t2.CONCENTRATION, '[^0-9.Ee+-]', '') AS BINARY_DOUBLE) AS conc,
'0' as concErr
FROM
ORIGINAL.GARDS_SAMPLE_DATA t1
LEFT JOIN CONFIGURATION.GARDS_STATIONS s
ON t1.STATION_ID = s.STATION_ID
LEFT JOIN RNAUTO.GARDS_NUCL_IDED t2 ON
t1.SAMPLE_ID = t2.SAMPLE_ID
<where>
@ -398,12 +402,16 @@
t1.COLLECT_STOP AS collectStop,
t1.SAMPLE_TYPE AS sampleType,
t1.STATION_ID AS stationId,
s.STATION_CODE AS stationCode,
t1.STATUS AS status,
t3.MDC AS MDC,
t3.NUCLIDE_NAME AS NUCLIDE_NAME,
t3.CONC AS conc
t3.CONC AS conc,
t3.CONC_ERR as concErr
FROM
ORIGINAL.GARDS_SAMPLE_DATA t1
LEFT JOIN CONFIGURATION.GARDS_STATIONS s
ON t1.STATION_ID = s.STATION_ID
LEFT JOIN RNAUTO.GARDS_XE_RESULTS t3 ON
t1.SAMPLE_ID = t3.SAMPLE_ID
<where>
@ -430,12 +438,16 @@
t1.COLLECT_STOP AS collectStop,
t1.SAMPLE_TYPE AS sampleType,
t1.STATION_ID AS stationId,
s.STATION_CODE AS stationCode,
t1.STATUS AS status,
TO_NUMBER(REGEXP_REPLACE(t2.MDC, '[^0-9.Ee-]', '')) AS MDC,
CAST(REGEXP_REPLACE(t2.MDC, '[^0-9.Ee+-]', '') AS BINARY_DOUBLE) AS MDC,
t2.NUCLIDENAME AS NUCLIDE_NAME,
TO_NUMBER(REGEXP_REPLACE(t2.CONCENTRATION, '[^0-9.Ee-]', '')) AS conc
CAST(REGEXP_REPLACE(t2.CONCENTRATION, '[^0-9.Ee+-]', '') AS BINARY_DOUBLE) AS conc,
'0' as concErr
FROM
ORIGINAL.GARDS_SAMPLE_DATA t1
LEFT JOIN CONFIGURATION.GARDS_STATIONS s
ON t1.STATION_ID = s.STATION_ID
LEFT JOIN RNMAN.GARDS_NUCL_IDED t2 ON
t1.SAMPLE_ID = t2.SAMPLE_ID
<where>
@ -455,12 +467,16 @@
t1.COLLECT_STOP AS collectStop,
t1.SAMPLE_TYPE AS sampleType,
t1.STATION_ID AS stationId,
s.STATION_CODE AS stationCode,
t1.STATUS AS status,
t3.MDC AS MDC,
t3.NUCLIDE_NAME AS NUCLIDE_NAME,
t3.CONC AS conc
t3.CONC AS conc,
t3.CONC_ERR as concErr
FROM
ORIGINAL.GARDS_SAMPLE_DATA t1
LEFT JOIN CONFIGURATION.GARDS_STATIONS s
ON t1.STATION_ID = s.STATION_ID
LEFT JOIN RNMAN.GARDS_XE_RESULTS t3 ON
t1.SAMPLE_ID = t3.SAMPLE_ID
<where>

View File

@ -4,29 +4,44 @@ import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.entity.*;
import org.jeecg.mapper.SysDefaultNuclideMapper;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.mapper.GardsSampleStatAnalysisMapper;
import org.jeecg.service.ISampleStatAnalysisService;
import org.jeecg.util.DistributionAnalysisToolkit;
import org.jeecg.vo.NuclideActConcIntvlVO;
import org.jeecg.vo.StationInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@DS("ora")
public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalysisMapper, GardsSampleData> implements ISampleStatAnalysisService {
private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
// 动态颜色调色板台站动态时自动循环
private static final String[] DETECTION_COLORS = {
"#0066ff", "#ff0000", "#ff00ff", "#00ffff", "#ffff00", "#ff9900", "#99ff00", "#9900ff"
};
private static final String[] MDC_COLORS = {
"#aaaa00", "#ff6666", "#ff99ff", "#66ffff", "#cccc00", "#ffcc66", "#ccff66", "#cc99ff"
};
@Autowired
private RedisUtil redisUtil;
@Autowired
private SysDefaultNuclideMapper defaultNuclideMapper;
@ -290,6 +305,7 @@ public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalys
* @return 返回样品活度浓度区间信息
*/
@Override
public Result getSampleActConcIntvlAnalysis(String sampleType, String station, String nuclideName, Integer dataSource, Date startDate, Date endDate) {
//声明返回用的结果map
Map<String, Object> resultMap = new HashMap<>();
@ -378,7 +394,8 @@ public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalys
result.setResult(resultMap);
return result;
} catch (Exception e) {
result.error500("样品活度浓度区间频率分析错误:" + e.getMessage());
log.error("样品活度浓度区间频率分析错误:" + e.getMessage(), e);
result.error500("样品活度浓度区间频率分析错误");
return result;
}
@ -475,6 +492,7 @@ public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalys
}
/*** 核素活度浓度对比分析
* 核素活度浓度对比分析
* @param sampleType 样品类型
@ -490,6 +508,7 @@ public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalys
List<NuclideActConcIntvl> nuclideActConcIntvls = new ArrayList<>();
Result result = new Result();
String unit = "P".equals(sampleType) ? "μBq/m³" : "mBq/m³";
try {
result.setCode(CommonConstant.SC_OK_200);
@ -520,7 +539,10 @@ public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalys
break;
}
resultMap.put("nuclideInfoList", nuclideActConcIntvls);
//resultMap.put("nuclideInfoList", nuclideActConcIntvls);
resultMap.put("nuclideInfoList", convertToChartVO(nuclideActConcIntvls, startDate, endDate, unit));
result.setSuccess(true);
result.setResult(resultMap);
return result;
@ -530,6 +552,86 @@ public class SampleStatAnalysisService extends ServiceImpl<GardsSampleStatAnalys
}
}
private NuclideActConcIntvlVO convertToChartVO(List<NuclideActConcIntvl> nuclideActConcIntvls, Date startDate, Date endDate, String unit) {
if (nuclideActConcIntvls == null || nuclideActConcIntvls.isEmpty()) {
return new NuclideActConcIntvlVO();
}
NuclideActConcIntvlVO vo = new NuclideActConcIntvlVO();
//设置核素名称
vo.setNuclideName(nuclideActConcIntvls.get(0).getNuclideName());
vo.setStartTime(startDate);
vo.setEndTime(endDate);
vo.setUnit(unit);
// stationCode 分组
Map<String, List<NuclideActConcIntvl>> groupByStation = nuclideActConcIntvls.stream()
.collect(Collectors.groupingBy(NuclideActConcIntvl::getStationCode));
int colorIndex = 0;
for (Map.Entry<String, List<NuclideActConcIntvl>> entry : groupByStation.entrySet()) {
String displayCode = entry.getKey();
List<NuclideActConcIntvl> records = entry.getValue();
NuclideActConcIntvlVO.StationSeries series = new NuclideActConcIntvlVO.StationSeries();
String stationCode = records.stream()
.findFirst()
.map(record -> record.getStationId() != null ? record.getStationId().toString() : null)
.orElse("UNKNOWN");
series.setStationCode(stationCode);
series.setStationName(displayCode); // 可后续扩展
series.setSampleCount(records.size());
// 动态分配颜色
String detectionColor = DETECTION_COLORS[colorIndex % DETECTION_COLORS.length];
String mdcColor = MDC_COLORS[colorIndex % MDC_COLORS.length];
series.setDetectionColor(detectionColor);
series.setMdcColor(mdcColor);
colorIndex++;
// 构建数据点
for (NuclideActConcIntvl r : records) {
String timeStr = SDF.format(r.getCollectStop());
// MDC 线始终添加
Map<String, Object> mdcPoint = new HashMap<>();
mdcPoint.put("x", timeStr);
mdcPoint.put("y", r.getMdc());
series.getMdcData().add(mdcPoint);
//series.getMdcData().add(new Object[]{timeStr, r.getMdc()});
// 检测值 + 误差条
Double conc = r.getConc();
Double err = r.getConcErr();
if (conc != null && err != null) {
double low = Math.max(conc - err, 0.01);
double high = conc + err;
Map<String, Object> detectionPoint = new HashMap<>();
detectionPoint.put("x", timeStr);
detectionPoint.put("y", conc); // 中心值
detectionPoint.put("low", low); // 下限可选方便前端
detectionPoint.put("high", high); // 上限可选
// 或者用 value + error 结构ECharts 某些系列支持
//detectionPoint.put("value", new double[]{conc, low, high});
series.getDetectionDataWithError().add(detectionPoint);
}
// 无有效检测时不添加点保持图表干净
}
vo.getStations().add(series);
}
return vo;
}
@Override
public List<GardsStations> findStationListByMenuName(String systemType) {
List<GardsStations> gardsStations = new LinkedList<>();

View File

@ -0,0 +1,77 @@
package org.jeecg.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 核素活度浓度对比图表返回 VO
* 支持图形化误差条
*/
@Data
public class NuclideActConcIntvlVO {
/** 图表标题 */
private String title = "核素活度浓度对比分析";
/** 数据开始时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime;
/** 数据结束时间 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime;
/** 当前核素名称 */
private String nuclideName;
/** 单位(固定或动态) */
private String unit = "μBq/m³";
/** 台站系列列表 */
private List<StationSeries> stations=new ArrayList<>();
/**
* 单个台站的图表数据
*/
@Data
public static class StationSeries {
/** 台站编码(如 AUX04 */
private String stationCode;
/** 台站名称(可选) */
private String stationName;
/** 样本数量(图例括号显示) */
private Integer sampleCount;
/** MDC 线颜色 */
private String mdcColor;
/** 检测值主颜色(散点和误差条) */
private String detectionColor;
/**
* MDC 数据[[时间, ], ...]
*/
private List<Map<String, Object>> mdcData=new ArrayList<>();
/**
* 检测值带误差条的数据核心变更
* 每个点格式[时间字符串, 中心值(conc), 下限值(conc - err), 上限值(conc + err)]
* - 如果无检测或低于 MDC整个数组为 null
* - 支持非对称误差下限/上限可不同
* - 前端 ECharts 可直接用此格式绘制误差条推荐方式
*/
private List<Map<String, Object>> detectionDataWithError =new ArrayList<>();
}
}