修改等级计算参数
This commit is contained in:
parent
43d2aef0bb
commit
d1683ca974
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.base.service;
|
||||
|
||||
import org.jeecg.modules.base.dto.Info;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -8,13 +9,13 @@ import java.util.Map;
|
|||
public interface IThresholdCalculationService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
Map<String, Double> calculateSingleStationThreshold(String stationId);
|
||||
Map<String, Double> calculateSingleStationThreshold(Info info);
|
||||
|
||||
Map<String, Double> getStationThresholds(String stationId);
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
void processBatchCalculation(List<String> stationIds);
|
||||
void processBatchCalculation(List<Info> infos);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,9 @@ package org.jeecg.modules.base.service.impl;
|
|||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.util.NumberFormatUtil;
|
||||
import org.jeecg.common.util.RadionuclideUtil;
|
||||
import org.jeecg.modules.base.dto.Info;
|
||||
import org.jeecg.modules.base.entity.StatisticsResult;
|
||||
import org.jeecg.modules.base.entity.ThresholdMetric;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsThresholdResult;
|
||||
|
|
@ -28,6 +30,7 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
|
|||
|
||||
@Autowired
|
||||
private RnAutoThresholdHisServiceImpl thresholdHisService;
|
||||
|
||||
/**
|
||||
* 获取当前服务处理的数据类型
|
||||
*
|
||||
|
|
@ -41,29 +44,31 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
|
|||
/**
|
||||
* 保存RNAUTO类型阈值计算结果
|
||||
*
|
||||
* @param stationId 台站ID
|
||||
* @param info 台站ID
|
||||
* @param thresholds 阈值映射
|
||||
* @param statistics 统计结果映射
|
||||
*/
|
||||
@Override
|
||||
protected void saveThresholdResults(String stationId, Map<String, Double> thresholds,
|
||||
protected void saveThresholdResults(Info info, Map<String, Double> thresholds,
|
||||
Map<String, StatisticsResult> statistics) {
|
||||
String stationId = info.getStationId();
|
||||
validateSaveParams(stationId, thresholds, statistics);
|
||||
|
||||
log.debug("开始保存RNAUTO阈值结果:台站{},核素{}个", stationId, thresholds.size());
|
||||
List<GardsThresholdResult> results = buildThresholdResultList(stationId, thresholds, statistics);
|
||||
List<GardsThresholdResult> results = buildThresholdResultList(info, thresholds, statistics);
|
||||
|
||||
if (!CollectionUtils.isEmpty(results)) {
|
||||
// 先删除旧数据
|
||||
this.baseMapper.deleteByStationId(stationId);
|
||||
|
||||
// 批量保存新数据
|
||||
boolean saveSuccess = this.saveBatch(results);
|
||||
// saveBatch(results, DEFAULT_BATCH_SIZE);
|
||||
boolean saveSuccess = this.saveBatch(results);
|
||||
// saveBatch(results, DEFAULT_BATCH_SIZE);
|
||||
if (saveSuccess) {
|
||||
List<GardsThresholdResultHistory> resultHisList = results.stream()
|
||||
.map(item -> {
|
||||
GardsThresholdResultHistory his = new GardsThresholdResultHistory();
|
||||
|
||||
BeanUtils.copyProperties(item, his);
|
||||
return his;
|
||||
})
|
||||
|
|
@ -112,8 +117,9 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
|
|||
/**
|
||||
* 构建ThresholdResult列表
|
||||
*/
|
||||
private List<GardsThresholdResult> buildThresholdResultList(String stationId, Map<String, Double> thresholds,
|
||||
private List<GardsThresholdResult> buildThresholdResultList(Info info, Map<String, Double> thresholds,
|
||||
Map<String, StatisticsResult> statistics) {
|
||||
|
||||
List<GardsThresholdResult> results = new ArrayList<>(thresholds.size());
|
||||
|
||||
thresholds.forEach((nuclideName, thresholdValue) -> {
|
||||
|
|
@ -123,14 +129,30 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
|
|||
return;
|
||||
}
|
||||
|
||||
Map<String, String> nulides = info.getNuclides();
|
||||
|
||||
String category = "A"; // 默认无效
|
||||
if (Objects.nonNull(nulides)) {
|
||||
String concStr = info.getNuclides().get(nuclideName);
|
||||
if (StringUtils.hasText(concStr)) {
|
||||
try {
|
||||
double concValue = Double.parseDouble(NumberFormatUtil.numberFormat(concStr));
|
||||
category = concValue < thresholdValue ? "B" : "C";
|
||||
} catch (Exception ignored) {
|
||||
// 解析失败保持 A
|
||||
}
|
||||
}
|
||||
}
|
||||
GardsThresholdResult result = new GardsThresholdResult();
|
||||
result.setId(UUID.randomUUID().toString());
|
||||
result.setStationId(stationId);
|
||||
result.setStationId(info.getStationId());
|
||||
result.setNuclideName(nuclideName);
|
||||
result.setCategory(category);
|
||||
result.setThresholdValue(thresholdValue);
|
||||
result.setMedian(stats.getMedian());
|
||||
result.setPercentile25(stats.getPercentile25());
|
||||
result.setPercentile75(stats.getPercentile75());
|
||||
result.setCollectStop(info.getCollectStop());
|
||||
|
||||
|
||||
results.add(result);
|
||||
|
|
@ -198,7 +220,8 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
|
|||
public List<String> getAllNuclides() {
|
||||
return RadionuclideUtil.getAllNuclides();
|
||||
}
|
||||
public Integer getDayValue(){
|
||||
return RadionuclideUtil.getDayValue();
|
||||
}
|
||||
|
||||
public Integer getDayValue() {
|
||||
return RadionuclideUtil.getDayValue();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.base.service.impl;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.util.RadionuclideUtil;
|
||||
import org.jeecg.modules.base.dto.Info;
|
||||
import org.jeecg.modules.base.entity.StatisticsResult;
|
||||
import org.jeecg.modules.base.entity.ThresholdMetric;
|
||||
import org.jeecg.modules.base.entity.rnman.GardsThresholdResult;
|
||||
|
|
@ -44,12 +45,13 @@ public class RnManThresholdServiceImpl extends ThresholdCalculationBaseService<T
|
|||
* @param statistics 统计结果映射
|
||||
*/
|
||||
|
||||
protected void saveThresholdResults(String stationId, Map<String, Double> thresholds,
|
||||
protected void saveThresholdResults(Info info, Map<String, Double> thresholds,
|
||||
Map<String, StatisticsResult> statistics) {
|
||||
String stationId=info.getStationId();
|
||||
validateSaveParams(stationId, thresholds, statistics);
|
||||
|
||||
log.debug("开始保存RNMAN阈值结果:台站{},核素{}个", stationId, thresholds.size());
|
||||
List<GardsThresholdResult> results = buildThresholdRnManResultList(stationId, thresholds, statistics);
|
||||
List<GardsThresholdResult> results = buildThresholdRnManResultList(info, thresholds, statistics);
|
||||
|
||||
if (!CollectionUtils.isEmpty(results)) {
|
||||
// 先删除旧数据
|
||||
|
|
@ -109,7 +111,7 @@ public class RnManThresholdServiceImpl extends ThresholdCalculationBaseService<T
|
|||
/**
|
||||
* 构建ThresholdRnManResult列表
|
||||
*/
|
||||
private List<GardsThresholdResult> buildThresholdRnManResultList(String stationId, Map<String, Double> thresholds,
|
||||
private List<GardsThresholdResult> buildThresholdRnManResultList(Info info, Map<String, Double> thresholds,
|
||||
Map<String, StatisticsResult> statistics) {
|
||||
List<GardsThresholdResult> results = new ArrayList<>(thresholds.size());
|
||||
|
||||
|
|
@ -122,13 +124,13 @@ public class RnManThresholdServiceImpl extends ThresholdCalculationBaseService<T
|
|||
|
||||
GardsThresholdResult result = new GardsThresholdResult();
|
||||
result.setId(UUID.randomUUID().toString());
|
||||
result.setStationId(stationId);
|
||||
result.setStationId(info.getStationId());
|
||||
result.setNuclideName(nuclideName);
|
||||
result.setThresholdValue(thresholdValue);
|
||||
result.setMedian(stats.getMedian());
|
||||
result.setPercentile25(stats.getPercentile25());
|
||||
result.setPercentile75(stats.getPercentile75());
|
||||
|
||||
result.setCollectStop(info.getCollectStop());
|
||||
results.add(result);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ import org.jeecg.common.properties.ParameterProperties;
|
|||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.NumUtil;
|
||||
import org.jeecg.common.util.RadionuclideUtil;
|
||||
import org.jeecg.modules.base.dto.Info;
|
||||
import org.jeecg.modules.base.entity.StatisticsResult;
|
||||
import org.jeecg.modules.base.entity.ThresholdMetric;
|
||||
import org.jeecg.modules.base.entity.ThresholdMetricResults;
|
||||
import org.jeecg.modules.base.service.IThresholdCalculationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -79,11 +81,11 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
/**
|
||||
* 保存阈值计算结果(子类实现具体保存逻辑)
|
||||
*
|
||||
* @param stationId 台站ID
|
||||
* @param info 台站ID
|
||||
* @param thresholds 阈值映射
|
||||
* @param statistics 统计结果映射
|
||||
*/
|
||||
protected abstract void saveThresholdResults(String stationId, Map<String, Double> thresholds, Map<String, StatisticsResult> statistics);
|
||||
protected abstract void saveThresholdResults(Info info, Map<String, Double> thresholds, Map<String, StatisticsResult> statistics);
|
||||
|
||||
/**
|
||||
* 从数据库查询台站阈值(子类实现具体查询逻辑)
|
||||
|
|
@ -112,12 +114,13 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
/**
|
||||
* 计算单个台站的阈值(公共逻辑)
|
||||
*
|
||||
* @param stationId 台站ID
|
||||
* @param info 台站ID
|
||||
* @return 核素-阈值映射
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Map<String, Double> calculateSingleStationThreshold(String stationId) {
|
||||
public Map<String, Double> calculateSingleStationThreshold(Info info) {
|
||||
String stationId = info.getStationId();
|
||||
// 1. 参数校验
|
||||
validateCalculateParams(stationId);
|
||||
log.info("开始计算单个台站阈值:stationId={}", stationId);
|
||||
|
|
@ -125,7 +128,8 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
List<String> stationIds = Collections.singletonList(stationId);
|
||||
Map<String, Map<String, List<Double>>> metricsMap = getMetricsForStations(stationIds);
|
||||
|
||||
// 3. 检查是否有数据
|
||||
// List<ThresholdMetric> metricsMap = getThresholdMetric(stationIds);
|
||||
// 3. 检查是否有数据getConcentrationsByStation(metricsMap, stationId);//
|
||||
Map<String, List<Double>> metrics = metricsMap.get(stationId);
|
||||
if (CollectionUtils.isEmpty(metrics)) {
|
||||
log.warn("台站{}没有找到有效的度量数据", stationId);
|
||||
|
|
@ -138,12 +142,26 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
calculateThresholdAndStats(metrics, thresholds, statistics);
|
||||
|
||||
// 5. 保存计算结果(子类实现)
|
||||
saveThresholdResults(stationId, thresholds, statistics);
|
||||
saveThresholdResults(info, thresholds, statistics);
|
||||
|
||||
log.info("单个台站阈值计算完成:stationId={}, 核素数量={}", stationId, thresholds.size());
|
||||
return thresholds;
|
||||
}
|
||||
|
||||
//根据台站ID筛选出核素对应的浓度
|
||||
public Map<String, List<ThresholdMetric>> getConcentrationsByStation(List<ThresholdMetric> metrics, String stationId) {
|
||||
return metrics.stream()
|
||||
.filter(m -> Objects.equals(m.getStationId(), Integer.valueOf(stationId)))
|
||||
.filter(m -> StringUtils.hasText(m.getNuclideName()) && StringUtils.hasText(m.getConcentration()))
|
||||
.collect(Collectors.groupingBy(
|
||||
ThresholdMetric::getNuclideName, // 按核素名称分组
|
||||
Collectors.mapping(
|
||||
m -> m, // 转换浓度为 double
|
||||
Collectors.toList()
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个台站的阈值(优先缓存,缓存未命中查库)
|
||||
*
|
||||
|
|
@ -181,7 +199,9 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void processBatchCalculation(List<String> stationIds) {
|
||||
public void processBatchCalculation(List<Info> infos) {
|
||||
List<String> stationIds = infos.stream().map(info -> info.getStationId()).collect(Collectors.toList());
|
||||
|
||||
String currentDataType = getCurrentDataType();
|
||||
log.info("开始批量阈值计算:dataType={}", currentDataType);
|
||||
|
||||
|
|
@ -198,12 +218,12 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
Map<String, Map<String, List<Double>>> metricsMap = getMetricsForStations(stationIds);
|
||||
|
||||
// 3. 处理每个台站
|
||||
stationIds.forEach(stationId -> {
|
||||
Map<String, List<Double>> metrics = metricsMap.get(stationId);
|
||||
infos.forEach(info -> {
|
||||
Map<String, List<Double>> metrics = metricsMap.get(info.getStationId());
|
||||
if (metrics != null && !metrics.isEmpty()) {
|
||||
processSingleStation(stationId, metrics);
|
||||
processSingleStation(info, metrics);
|
||||
} else {
|
||||
log.warn("台站 {} {} 没有度量数据,跳过处理", stationId, currentDataType);
|
||||
log.warn("台站 {} {} 没有度量数据,跳过处理", info.getStationId(), currentDataType);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -269,26 +289,41 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
// 按数据类型查询度量数据
|
||||
List<ThresholdMetric> queryMetrics = queryMetricsByDataType(stationIds, startDate);
|
||||
|
||||
List<ThresholdMetric> metrics = stationIds.stream()
|
||||
.flatMap(stationId -> getAllNuclides().stream()
|
||||
.map(nuclide -> {
|
||||
// 查找匹配的查询结果
|
||||
Optional<ThresholdMetric> matched = queryMetrics.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(qm -> qm.getStationId() == Integer.parseInt(stationId))
|
||||
.filter(qm -> nuclide != null && nuclide.equals(qm.getNuclideName()))
|
||||
.findFirst();
|
||||
List<ThresholdMetric> metrics = new ArrayList<>();
|
||||
|
||||
return matched.orElseGet(()->{
|
||||
ThresholdMetric tm = new ThresholdMetric();
|
||||
tm.setStationId(Integer.valueOf(stationId));
|
||||
tm.setNuclideName(nuclide);
|
||||
tm.setConcentration("0");
|
||||
return tm;
|
||||
});
|
||||
}))
|
||||
.collect(Collectors.toList());
|
||||
// 查询结果的快速索引 (StationId -> (NuclideName -> ThresholdMetric))
|
||||
Map<Integer, Map<String, List<ThresholdMetric>>> metricIndex = queryMetrics.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
ThresholdMetric::getStationId,
|
||||
Collectors.groupingBy(ThresholdMetric::getNuclideName)
|
||||
));
|
||||
|
||||
// 2. 预先处理所有核素名称
|
||||
List<String> allNuclides = RadionuclideUtil.getAllNuclides();
|
||||
|
||||
// 3. 遍历所有组合
|
||||
for (String stationId : stationIds) {
|
||||
Integer station = Integer.parseInt(stationId);
|
||||
// 获取当前站点对应的核素Map,若不存在则返回空Map
|
||||
Map<String, List<ThresholdMetric>> nuclideMap = metricIndex.getOrDefault(station, Collections.emptyMap());
|
||||
|
||||
for (String nuclideName : allNuclides) {
|
||||
// 直接从索引中获取该站点的该核素数据列表
|
||||
List<ThresholdMetric> stationMetrics = nuclideMap.get(nuclideName);
|
||||
|
||||
if (stationMetrics == null || stationMetrics.isEmpty()) {
|
||||
// 没有找到记录,创建默认对象
|
||||
ThresholdMetric tm = new ThresholdMetric();
|
||||
tm.setStationId(station);
|
||||
tm.setNuclideName(nuclideName);
|
||||
tm.setConcentration("0");
|
||||
metrics.add(tm);
|
||||
} else {
|
||||
// 找到了对应的记录,直接添加
|
||||
metrics.addAll(stationMetrics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(metrics)) {
|
||||
log.debug("未查询到核素度量数据:台站{}", stationIds);
|
||||
|
|
@ -303,6 +338,52 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
return result;
|
||||
}
|
||||
|
||||
protected List<ThresholdMetric> getThresholdMetric(List<String> stationIds) {
|
||||
// 参数校验
|
||||
if (CollectionUtils.isEmpty(stationIds)) {
|
||||
log.warn("获取核素度量数据失败:台站ID列表为空");
|
||||
throw new IllegalArgumentException("台站ID列表不可为空");
|
||||
}
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_YEAR, -getDayValue());
|
||||
String startDate = DateUtils.formatDate(calendar.getTime(), "yyyy-MM-dd HH:mm:ss");
|
||||
log.debug("查询核素度量数据:台站{}个,时间范围{}至今",
|
||||
stationIds.size(), startDate);
|
||||
|
||||
// 按数据类型查询度量数据
|
||||
List<ThresholdMetric> queryMetrics = queryMetricsByDataType(stationIds, startDate);
|
||||
|
||||
List<ThresholdMetric> metrics = stationIds.stream()
|
||||
.flatMap(stationId -> getAllNuclides().stream()
|
||||
.map(nuclide -> {
|
||||
// 查找匹配的查询结果
|
||||
Optional<ThresholdMetric> matched = queryMetrics.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(qm -> qm.getStationId() == Integer.parseInt(stationId))
|
||||
.filter(qm -> nuclide != null && nuclide.equals(qm.getNuclideName()))
|
||||
.findFirst();
|
||||
|
||||
return matched.orElseGet(() -> {
|
||||
ThresholdMetric tm = new ThresholdMetric();
|
||||
tm.setStationId(Integer.valueOf(stationId));
|
||||
tm.setNuclideName(nuclide);
|
||||
tm.setConcentration("0");
|
||||
return tm;
|
||||
});
|
||||
}))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
if (CollectionUtils.isEmpty(metrics)) {
|
||||
log.debug("未查询到核素度量数据:台站{}", stationIds);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按数据类型查询度量数据(差异化查询逻辑)
|
||||
*
|
||||
|
|
@ -385,13 +466,45 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
// protected void calculateThresholdAndStats(Map<String, List<ThresholdMetric>> metrics,
|
||||
// Map<String, Double> thresholds,
|
||||
// Map<String, StatisticsResult> statistics) {
|
||||
// if (metrics == null || metrics.isEmpty()) {
|
||||
// log.warn("核素度量数据为空,跳过计算");
|
||||
// return;
|
||||
// }
|
||||
// metrics.forEach((nuclideName, values) -> {
|
||||
// if (values==null||values.isEmpty()) {
|
||||
// log.trace("核素{}数据为空,跳过计算", nuclideName);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // 计算统计值(中位数、四分位数)
|
||||
// StatisticsResult stats = calculateStatistics( nuclideName);
|
||||
// statistics.put(nuclideName, stats);
|
||||
//
|
||||
// // 计算阈值:中位数 + 3 * IQR(四分位距)
|
||||
// double median = stats.getMedian();
|
||||
// double q1 = stats.getPercentile25();
|
||||
// double q3 = stats.getPercentile75();
|
||||
// double iqr = q3 - q1;
|
||||
// double threshold = NumUtil.keep(median + (iqr * 3), 6);
|
||||
//
|
||||
// thresholds.put(nuclideName, threshold);
|
||||
// });
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 处理单个台站(批量计算时用)
|
||||
*
|
||||
* @param stationId 台站ID
|
||||
* @param metrics 核素-浓度列表映射
|
||||
* @param info 台站ID
|
||||
* @param metrics 核素-浓度列表映射
|
||||
*/
|
||||
protected void processSingleStation(String stationId, Map<String, List<Double>> metrics) {
|
||||
protected void processSingleStation(Info info, Map<String, List<Double>> metrics) {
|
||||
Map<String, Double> thresholds = new HashMap<>();
|
||||
Map<String, StatisticsResult> statistics = new HashMap<>();
|
||||
|
||||
|
|
@ -399,10 +512,10 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
calculateThresholdAndStats(metrics, thresholds, statistics);
|
||||
|
||||
// 保存结果(子类实现)
|
||||
saveThresholdResults(stationId, thresholds, statistics);
|
||||
saveThresholdResults(info, thresholds, statistics);
|
||||
|
||||
log.info("台站 {} 处理完成:dataType={},生成 {} 个阈值结果",
|
||||
stationId, getCurrentDataType(), thresholds.size());
|
||||
info.getStationId(), getCurrentDataType(), thresholds.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -433,6 +546,7 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算分位数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class GradingConsumer implements StreamListener<String, ObjectRecord<Stri
|
|||
//如果是全谱,更新台站阈值
|
||||
if ("FULL".equals(info.getFullOrPrel())) {
|
||||
//更新台站阈值
|
||||
rnAutoService.calculateSingleStationThreshold(info.getStationId());
|
||||
rnAutoService.calculateSingleStationThreshold(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ import org.jeecg.modules.base.dto.Info;
|
|||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsThresholdResult;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsTransportStatus;
|
||||
import org.jeecg.modules.base.enums.*;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.enums.ErrorType;
|
||||
import org.jeecg.modules.base.enums.TransportTaskStatusEnum;
|
||||
import org.jeecg.modules.exception.BAnalyseException;
|
||||
import org.jeecg.modules.exception.FileNotExistException;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
|
@ -310,7 +312,19 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
|
||||
//样品分级
|
||||
category = spectrumServiceQuotes.getSampleGradingService().processAutoTypeB(getSampleInfo(), thresholds);
|
||||
|
||||
if (category >= 3) {
|
||||
GardsTransportStatus transportStatus = new GardsTransportStatus();
|
||||
transportStatus.setSampleId(this.sampleData.getSampleId());
|
||||
transportStatus.setDescription("");
|
||||
transportStatus.setTransportStatus(0);
|
||||
transportStatus.setCloseStatus(0);
|
||||
transportStatus.setModdate(new Date());
|
||||
boolean result = spectrumServiceQuotes.getGardsTransportStatusService().save(transportStatus);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取样品分级数据错误");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -370,6 +384,7 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
final Instant instant = this.sampleData.getCollectStart().toInstant();
|
||||
final LocalDateTime collectTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
info.setCollectionDate(collectTime);
|
||||
info.setCollectStop(this.sampleData.getCollectStop());
|
||||
info.setDatasource(DSType.ARMDARR.getType());
|
||||
info.setFullOrPrel(this.sampleData.getSpectralQualifie());
|
||||
info.setBetaOrGamma(SpectrumType.BETA.getType());
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ import org.jeecg.modules.base.bizVo.AttributeItemVo;
|
|||
import org.jeecg.modules.base.dto.*;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.rnauto.*;
|
||||
import org.jeecg.modules.base.enums.DSType;
|
||||
import org.jeecg.modules.base.enums.MiddleDataType;
|
||||
import org.jeecg.modules.base.enums.SpectrumType;
|
||||
import org.jeecg.modules.base.enums.*;
|
||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
|
|
@ -185,6 +183,16 @@ public class Sample_G_Analysis {
|
|||
//样品分级
|
||||
Integer category = serviceQuotes.getSampleGradingService().processAutoTypeP(info, thresholds);
|
||||
middleData.setAnalyses_category(category);
|
||||
if (category >= 3) {
|
||||
GardsTransportStatus transportStatus = new GardsTransportStatus();
|
||||
transportStatus.setSampleId(this.sampleData.getSampleId());
|
||||
transportStatus.setDescription("");
|
||||
transportStatus.setTransportStatus(0);
|
||||
transportStatus.setCloseStatus(0);
|
||||
transportStatus.setModdate(new Date());
|
||||
boolean result = serviceQuotes.getGardsTransportStatusService().save(transportStatus);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
|
@ -233,6 +241,7 @@ public class Sample_G_Analysis {
|
|||
final Instant instant = DateUtils.parseDate(middleData.sample_collection_start).toInstant();
|
||||
final LocalDateTime collectTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
info.setCollectionDate(collectTime);
|
||||
info.setCollectStop(this.sampleData.getCollectStop());
|
||||
info.setDatasource(DSType.ARMDARR.getType());
|
||||
info.setFullOrPrel(this.sampleData.getSpectralQualifie());
|
||||
info.setBetaOrGamma(SpectrumType.GAMMA.getType());
|
||||
|
|
@ -1117,7 +1126,7 @@ public class Sample_G_Analysis {
|
|||
gardsAnalyses.setScacPath(middleData.getAnalyses_scac_filePath());
|
||||
gardsAnalyses.setLogPath(middleData.getAnalyses_LogPath());
|
||||
gardsAnalyses.setReportPath(middleData.getAnalyses_ReportPath());
|
||||
gardsAnalyses.setCategory((int)middleData.analyses_category);
|
||||
gardsAnalyses.setCategory((int) middleData.analyses_category);
|
||||
return gardsAnalyses;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class RnManGradingConsumer implements StreamListener<String, ObjectRecord
|
|||
private void consume(Info info) {
|
||||
if ("FULL".equals(info.getFullOrPrel())) {
|
||||
//更新台站阈值
|
||||
rnManService.calculateSingleStationThreshold(info.getStationId());
|
||||
rnManService.calculateSingleStationThreshold(info);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IGenerateHtmlReport {
|
||||
/**
|
||||
* 生成基础HTML报告
|
||||
* @param data 报告数据
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generateBasicHtmlReport(Map<String, Object> data);
|
||||
|
||||
/**
|
||||
* 生成带样式的HTML报告
|
||||
* @param data 报告数据
|
||||
* @param style 自定义CSS样式
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generateStyledHtmlReport(Map<String, Object> data, String style);
|
||||
|
||||
/**
|
||||
* 生成HTML报告并保存到文件
|
||||
* @param data 报告数据
|
||||
* @param filePath 文件保存路径
|
||||
* @return 是否保存成功
|
||||
*/
|
||||
boolean generateHtmlReportToFile(Map<String, Object> data, String filePath);
|
||||
|
||||
/**
|
||||
* 生成带模板的HTML报告
|
||||
* @param data 报告数据
|
||||
* @param templatePath HTML模板路径
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generateHtmlReportWithTemplate(Map<String, Object> data, String templatePath);
|
||||
|
||||
/**
|
||||
* 生成带图表和交互功能的HTML报告
|
||||
* @param data 报告数据
|
||||
* @param includeCharts 是否包含图表
|
||||
* @param interactive 是否包含交互功能
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generateAdvancedHtmlReport(Map<String, Object> data, boolean includeCharts, boolean interactive);
|
||||
|
||||
/**
|
||||
* 生成多页HTML报告
|
||||
* @param pagesData 多页数据,key为页面名称,value为页面数据
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generateMultiPageHtmlReport(Map<String, Map<String, Object>> pagesData);
|
||||
|
||||
/**
|
||||
* 生成HTML报告并返回字节数组(便于网络传输)
|
||||
* @param data 报告数据
|
||||
* @return HTML字节数组
|
||||
*/
|
||||
byte[] generateHtmlReportAsBytes(Map<String, Object> data);
|
||||
|
||||
/**
|
||||
* 生成带分页功能的HTML报告
|
||||
* @param data 报告数据
|
||||
* @param itemsPerPage 每页项目数
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generatePaginatedHtmlReport(List<Map<String, Object>> data, int itemsPerPage);
|
||||
|
||||
/**
|
||||
* 生成响应式HTML报告(适配不同设备)
|
||||
* @param data 报告数据
|
||||
* @return 生成的HTML字符串
|
||||
*/
|
||||
String generateResponsiveHtmlReport(Map<String, Object> data);
|
||||
|
||||
/**
|
||||
* 生成HTML报告并返回Base64编码(便于嵌入)
|
||||
* @param data 报告数据
|
||||
* @return Base64编码的HTML字符串
|
||||
*/
|
||||
String generateHtmlReportAsBase64(Map<String, Object> data);
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class RnManGardsThresholdServiceImpl extends ServiceImpl<RnManGardsThresh
|
|||
* @return List<GardsThresholdResult> GardsThresholdResult
|
||||
*/
|
||||
@Override
|
||||
public List<GardsThresholdResult> findThresholdResults(String stationId) {
|
||||
public List<GardsThresholdResult> findThresholdResults(String stationId) {
|
||||
// 获取未分级样品
|
||||
LambdaQueryWrapper<GardsThresholdResult> queryWrapper = new LambdaQueryWrapper<GardsThresholdResult>();
|
||||
queryWrapper.eq(GardsThresholdResult::getStationId, stationId);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import org.jeecg.common.properties.SpectrumPathProperties;
|
|||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.*;
|
||||
import org.jeecg.modules.service.IGardsNuclLibService;
|
||||
import org.jeecg.modules.email.EmailReceivePolicy;
|
||||
import org.jeecg.modules.service.IGardsNuclLibService;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
|
@ -76,12 +76,12 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
} else {
|
||||
//Linux版本加载dll工具库
|
||||
System.load("/usr/local/jdk/lib/libReadPHDFile.so");
|
||||
System.load("/usr/local/jdk/lib/libGammaAnaly.so");
|
||||
System.load("/usr/local/jdk/lib/libGammaAnalyALG.so");
|
||||
}
|
||||
nuclLibService.getNuclideMap();
|
||||
//根据配置文件配置邮件获取策略定义时间条件,默认EmailReceivePolicy.HISTORY_ORDER_RECEIVE.getPolicy()
|
||||
Date systemStartupTime = null;
|
||||
if(EmailReceivePolicy.CURR_DATE_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){
|
||||
if (EmailReceivePolicy.CURR_DATE_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())) {
|
||||
systemStartupTime = new Date();
|
||||
}
|
||||
//校验临时存储目录是否存在,不存在则创建
|
||||
|
|
@ -106,13 +106,13 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
*/
|
||||
private void checkTempStorageDirectory() throws IOException {
|
||||
ApplicationHome home = new ApplicationHome(getClass());
|
||||
File tempStorageDirectory = new File(home.getSource().getParentFile().getAbsolutePath()+File.separator+taskProperties.getTemporaryStoragePath());
|
||||
if(!tempStorageDirectory.exists() || !tempStorageDirectory.isDirectory()){
|
||||
File tempStorageDirectory = new File(home.getSource().getParentFile().getAbsolutePath() + File.separator + taskProperties.getTemporaryStoragePath());
|
||||
if (!tempStorageDirectory.exists() || !tempStorageDirectory.isDirectory()) {
|
||||
tempStorageDirectory.setReadable(true);
|
||||
tempStorageDirectory.setWritable(true);
|
||||
tempStorageDirectory.mkdir();
|
||||
taskProperties.setTemporaryStoragePath(tempStorageDirectory.getAbsolutePath());
|
||||
}else{
|
||||
} else {
|
||||
FileUtils.deleteDirectory(tempStorageDirectory);
|
||||
checkTempStorageDirectory();
|
||||
}
|
||||
|
|
@ -122,12 +122,12 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
* 校验存储目录是否存在,不存在则创建,存在无操作
|
||||
*/
|
||||
private void checkStorageDirectory() {
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getSaveFilePath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getLogPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getUndealPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getFilesourcePath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getEmlPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getEmlErrorPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath()+File.separator+spectrumPathProperties.getErrorFilePath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getSaveFilePath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getLogPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getUndealPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getFilesourcePath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getEmlPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getEmlErrorPath());
|
||||
FileUtil.mkdir(spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getErrorFilePath());
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +78,6 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ
|
|||
gammaService.readMDCParameter();
|
||||
nuclLibService.getNuclideMap();
|
||||
nuclCoincidenceSumSpectrumService.getNuclCoincidenceMap();
|
||||
// dataService.viewStations();
|
||||
dataService.viewStations();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user