修改LocalDateTime改为使用Date类型

This commit is contained in:
duwenyuan 2026-05-23 11:06:52 +08:00
parent 5b920b4935
commit f72f4d7a7a
19 changed files with 655 additions and 467 deletions

View File

@ -4,10 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.jeecg.modules.base.enums.SourceType;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -29,7 +27,7 @@ public class Info implements Serializable {
private String sampleName; private String sampleName;
// 采样时间 // 采样时间
private LocalDateTime collectionDate; private Date collectionDate;
//采集停止时间 //采集停止时间
private Date collectStop; private Date collectStop;
// 数据源类型(ARMDARR=1|ARMDRRR=2|IDCARR=3|IDCRRR=4) // 数据源类型(ARMDARR=1|ARMDRRR=2|IDCARR=3|IDCRRR=4)

View File

@ -3,7 +3,7 @@ package org.jeecg.modules.base.entity;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.util.Date;
@Data @Data
public class GardsNuclThresholds implements Serializable { public class GardsNuclThresholds implements Serializable {
@ -12,6 +12,6 @@ public class GardsNuclThresholds implements Serializable {
private String stationId; private String stationId;
private Double thresholdValue; private Double thresholdValue;
private String nuclideName; private String nuclideName;
private LocalDateTime calculationTime; private Date calculationTime;
} }

View File

@ -7,6 +7,7 @@ import org.jeecg.modules.base.entity.ThresholdMetric;
import org.jeecg.modules.base.entity.rnauto.GardsThresholdResult; import org.jeecg.modules.base.entity.rnauto.GardsThresholdResult;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Date;
import java.util.List; import java.util.List;
@Mapper @Mapper
@ -20,5 +21,5 @@ public interface ThresholdRnAutoResultMapper extends BaseMapper<GardsThresholdRe
List<ThresholdMetric> selectByRnAutoStationIds(@Param("stationIds") List<String> stationIds, List<ThresholdMetric> selectByRnAutoStationIds(@Param("stationIds") List<String> stationIds,
@Param("oneYearAgo") @Param("oneYearAgo")
Timestamp oneYearAgo); Date oneYearAgo);
} }

View File

@ -7,6 +7,7 @@ import org.jeecg.modules.base.entity.ThresholdMetric;
import org.jeecg.modules.base.entity.rnman.GardsThresholdResult; import org.jeecg.modules.base.entity.rnman.GardsThresholdResult;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Date;
import java.util.List; import java.util.List;
@Mapper @Mapper
@ -19,5 +20,5 @@ public interface ThresholdRnManResultMapper extends BaseMapper<GardsThresholdRes
List<GardsThresholdResult> selectByStationId(String stationId); List<GardsThresholdResult> selectByStationId(String stationId);
List<ThresholdMetric> selectByRnManStationIds(@Param("stationIds") List<String> stationIds, List<ThresholdMetric> selectByRnManStationIds(@Param("stationIds") List<String> stationIds,
@Param("oneYearAgo") Timestamp oneYearAgo); @Param("oneYearAgo") Date oneYearAgo);
} }

View File

@ -26,7 +26,8 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@DS("ora") @DS("ora")
public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<ThresholdRnAutoResultMapper, GardsThresholdResult> { public class RnAutoThresholdServiceImpl
extends ThresholdCalculationBaseService<ThresholdRnAutoResultMapper, GardsThresholdResult> {
@Autowired @Autowired
@ -118,7 +119,8 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
/** /**
* 构建ThresholdResult列表 * 构建ThresholdResult列表
*/ */
private List<GardsThresholdResult> buildThresholdResultList(Info info, Map<String, Double> thresholds, private List<GardsThresholdResult> buildThresholdResultList(Info info,
Map<String, Double> thresholds,
Map<String, StatisticsResult> statistics) { Map<String, StatisticsResult> statistics) {
List<GardsThresholdResult> results = new ArrayList<>(thresholds.size()); List<GardsThresholdResult> results = new ArrayList<>(thresholds.size());
@ -137,7 +139,8 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
String concStr = info.getNuclides().get(nuclideName); String concStr = info.getNuclides().get(nuclideName);
if (StringUtils.hasText(concStr)) { if (StringUtils.hasText(concStr)) {
try { try {
double concValue = Double.parseDouble(NumberFormatUtil.numberFormat(concStr)); double concValue =
Double.parseDouble(NumberFormatUtil.numberFormat(concStr));
category = concValue < thresholdValue ? "B" : "C"; category = concValue < thresholdValue ? "B" : "C";
} catch (Exception ignored) { } catch (Exception ignored) {
// 解析失败保持 A // 解析失败保持 A
@ -146,7 +149,7 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
} }
GardsThresholdResult result = new GardsThresholdResult(); GardsThresholdResult result = new GardsThresholdResult();
result.setId(UUID.randomUUID().toString()); result.setId(UUID.randomUUID().toString());
result.setStationId(Integer.parseInt(info.getStationId()) ); result.setStationId(Integer.parseInt(info.getStationId()));
result.setNuclideName(nuclideName); result.setNuclideName(nuclideName);
result.setCategory(category); result.setCategory(category);
result.setThresholdValue(thresholdValue); result.setThresholdValue(thresholdValue);
@ -208,11 +211,9 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService<
* @param startDate 开始时间 * @param startDate 开始时间
* @return List<ThresholdMetric> ThresholdMetric * @return List<ThresholdMetric> ThresholdMetric
*/ */
public List<ThresholdMetric> queryMetricsByDataType(List<String> stationIds, String startDate) { public List<ThresholdMetric> queryMetricsByDataType(List<String> stationIds, Date startDate) {
try { try {
Timestamp timestamp = Timestamp.valueOf(startDate); return this.baseMapper.selectByRnAutoStationIds(stationIds, startDate);
return this.baseMapper.selectByRnAutoStationIds(stationIds, timestamp);
} catch (Exception e) { } catch (Exception e) {
log.error("查询核素度量数据失败:,台站{}", stationIds, e); log.error("查询核素度量数据失败:,台站{}", stationIds, e);
return Collections.emptyList(); return Collections.emptyList();

View File

@ -177,10 +177,9 @@ public class RnManThresholdServiceImpl extends ThresholdCalculationBaseService<T
* @param startDate 开始时间 * @param startDate 开始时间
* @return List<ThresholdMetric> ThresholdMetric * @return List<ThresholdMetric> ThresholdMetric
*/ */
public List<ThresholdMetric> queryMetricsByDataType(List<String> stationIds, String startDate) { public List<ThresholdMetric> queryMetricsByDataType(List<String> stationIds, Date startDate) {
try { try {
Timestamp timestamp = Timestamp.valueOf(startDate); return this.baseMapper.selectByRnManStationIds(stationIds, startDate);
return this.baseMapper.selectByRnManStationIds(stationIds, timestamp);
} catch (Exception e) { } catch (Exception e) {
log.error("查询核素度量数据失败:,台站{}", stationIds, e); log.error("查询核素度量数据失败:,台站{}", stationIds, e);

View File

@ -25,6 +25,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -280,9 +282,8 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
} }
//查询核素浓度 //查询核素浓度
// 计算查询时间范围近1年 // 计算查询时间范围近1年
Calendar calendar = Calendar.getInstance(); Date startDate = Date.from(LocalDateTime.now().minusDays(getDayValue())
calendar.add(Calendar.DAY_OF_YEAR, -getDayValue()); .atZone(ZoneId.systemDefault()).toInstant());
String startDate = DateUtils.formatDate(calendar.getTime(), "yyyy-MM-dd HH:mm:ss");
log.debug("查询核素度量数据:台站{}个,时间范围{}至今", log.debug("查询核素度量数据:台站{}个,时间范围{}至今",
stationIds.size(), startDate); stationIds.size(), startDate);
@ -345,9 +346,8 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
throw new IllegalArgumentException("台站ID列表不可为空"); throw new IllegalArgumentException("台站ID列表不可为空");
} }
Calendar calendar = Calendar.getInstance(); Date startDate = Date.from(LocalDateTime.now().minusDays(getDayValue())
calendar.add(Calendar.DAY_OF_YEAR, -getDayValue()); .atZone(ZoneId.systemDefault()).toInstant());
String startDate = DateUtils.formatDate(calendar.getTime(), "yyyy-MM-dd HH:mm:ss");
log.debug("查询核素度量数据:台站{}个,时间范围{}至今", log.debug("查询核素度量数据:台站{}个,时间范围{}至今",
stationIds.size(), startDate); stationIds.size(), startDate);
@ -391,7 +391,7 @@ public abstract class ThresholdCalculationBaseService<M extends BaseMapper<T>, T
* @param startDate 开始时间 * @param startDate 开始时间
* @return 度量数据列表 * @return 度量数据列表
*/ */
protected abstract List<ThresholdMetric> queryMetricsByDataType(List<String> stationIds, String startDate); protected abstract List<ThresholdMetric> queryMetricsByDataType(List<String> stationIds, Date startDate);
/** /**
* 解析度量数据到分层映射 * 解析度量数据到分层映射

View File

@ -38,10 +38,11 @@ import org.springframework.stereotype.Component;
import static org.jeecg.common.constant.enums.MessageTypeEnum.*; import static org.jeecg.common.constant.enums.MessageTypeEnum.*;
import static org.jeecg.common.util.TokenUtils.getTempToken; import static org.jeecg.common.util.TokenUtils.getTempToken;
import static org.jeecg.modules.base.enums.Template.ANALYSIS_NUCLIDE; import static org.jeecg.modules.base.enums.Template.ANALYSIS_NUCLIDE;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -94,56 +95,70 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
// 手动删除已消费消息 // 手动删除已消费消息
redisStreamUtil.del(streamKey, recordId.getValue()); redisStreamUtil.del(streamKey, recordId.getValue());
} }
}catch (Exception e){ } catch (Exception e) {
log.error("AnalysisConsumer消费异常: ", e); log.error("AnalysisConsumer消费异常: ", e);
}finally { } finally {
destroy(); destroy();
} }
} }
private void consume(Info info){ private void consume(Info info) {
String stationId = info.getStationId(); String stationId = info.getStationId();
String sampleId = info.getSampleId(); String sampleId = info.getSampleId();
String fullOrPrel = info.getFullOrPrel(); String fullOrPrel = info.getFullOrPrel();
String datasource = info.getDatasource(); String datasource = info.getDatasource();
Map<String, String> infoNuclideMap = info.getNuclides(); Map<String, String> infoNuclideMap = info.getNuclides();
if (StrUtil.isBlank(stationId)) return; if (StrUtil.isBlank(stationId)) {
if (StrUtil.isBlank(sampleId)) return; return;
if (MapUtil.isEmpty(infoNuclideMap)) return; }
if (StrUtil.isBlank(sampleId)) {
return;
}
if (MapUtil.isEmpty(infoNuclideMap)) {
return;
}
List<AlarmAnalysisRule> rules = ruleService.allAnalysisRule(); List<AlarmAnalysisRule> rules = ruleService.allAnalysisRule();
for (AlarmAnalysisRule rule : rules) { for (AlarmAnalysisRule rule : rules) {
// 当前规则是否有报警条件 // 当前规则是否有报警条件
String conditionStr = rule.getConditions(); String conditionStr = rule.getConditions();
if (StrUtil.isBlank(conditionStr)) if (StrUtil.isBlank(conditionStr)) {
continue; continue;
}
// 是否在当前规则关注的台站列表内 // 是否在当前规则关注的台站列表内
String stations = rule.getStations(); String stations = rule.getStations();
if (!StrUtil.contains(stations, stationId)) if (!StrUtil.contains(stations, stationId)) {
continue; continue;
}
// 是否在当前规则关注的数据源内 // 是否在当前规则关注的数据源内
String source = rule.getSource(); String source = rule.getSource();
if (!StrUtil.contains(source,datasource)) if (!StrUtil.contains(source, datasource)) {
continue; continue;
}
// 是否在当前规则关注的谱类型内 // 是否在当前规则关注的谱类型内
String spectralQualifier = rule.getSpectralQualifier(); String spectralQualifier = rule.getSpectralQualifier();
if (!StrUtil.contains(spectralQualifier,fullOrPrel)) if (!StrUtil.contains(spectralQualifier, fullOrPrel)) {
continue; continue;
}
// 是否有当前规则关注的核素 // 是否有当前规则关注的核素
String nuclidesStr = rule.getNuclides(); String nuclidesStr = rule.getNuclides();
if (StrUtil.isBlank(nuclidesStr)) continue; if (StrUtil.isBlank(nuclidesStr)) {
continue;
}
Set<String> names = infoNuclideMap.keySet(); Set<String> names = infoNuclideMap.keySet();
List<String> follow = ListUtil.toList(nuclidesStr.split(COMMA)); List<String> follow = ListUtil.toList(nuclidesStr.split(COMMA));
// 因数据库 Xe核素名称 M大小写不统一先统一大小写再进行比较 // 因数据库 Xe核素名称 M大小写不统一先统一大小写再进行比较
Collection<String> follows = follow.stream().map(f -> { Collection<String> follows = follow.stream().map(f -> {
if(f.toLowerCase().contains("xe")){ if (f.toLowerCase().contains("xe")) {
return f.replace("M", "m"); return f.replace("M", "m");
} }
return f; return f;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 推送过来的核素集合与所关注核素集合取交集 // 推送过来的核素集合与所关注核素集合取交集
Collection<String> cross = CollectionUtil.intersection(names, follows); Collection<String> cross = CollectionUtil.intersection(names, follows);
if (CollUtil.isEmpty(cross)) continue; if (CollUtil.isEmpty(cross)) {
continue;
}
Map<String, String> nuclidesCross = infoNuclideMap.entrySet().stream() Map<String, String> nuclidesCross = infoNuclideMap.entrySet().stream()
.filter(entry -> cross.contains(entry.getKey())) .filter(entry -> cross.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
@ -155,7 +170,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
String[] inSplit = rule.getIdentifyNuclides().split(","); String[] inSplit = rule.getIdentifyNuclides().split(",");
if (inSplit.length >= 1) { if (inSplit.length >= 1) {
info.setIdentifyNuclideSet(Arrays.stream(inSplit).map(f -> { info.setIdentifyNuclideSet(Arrays.stream(inSplit).map(f -> {
if(f.toLowerCase().contains("xe")){ if (f.toLowerCase().contains("xe")) {
return f.replace("M", "m"); return f.replace("M", "m");
} }
return f; return f;
@ -166,20 +181,24 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
} }
} }
private void judge(Info info, Map<String,String> nuclidesCross){ private void judge(Info info, Map<String, String> nuclidesCross) {
Set<String> nuclideNames = nuclidesCross.keySet(); Set<String> nuclideNames = nuclidesCross.keySet();
String conditionStr = info.getConditions(); String conditionStr = info.getConditions();
String betaOrGamma = info.getBetaOrGamma(); String betaOrGamma = info.getBetaOrGamma();
String datasource = info.getDatasource(); String datasource = info.getDatasource();
String stationId = info.getStationId(); String stationId = info.getStationId();
String stationCode=""; String stationCode = "";
HashMap<String, Object> stationMap = (HashMap<String, Object>)redisUtil.get(RedisConstant.STATION_CODE_MAP); HashMap<String, Object> stationMap =
(HashMap<String, Object>) redisUtil.get(RedisConstant.STATION_CODE_MAP);
String sampleId = info.getSampleId(); String sampleId = info.getSampleId();
String sampleName = info.getSampleName(); String sampleName = info.getSampleName();
Set<String> identifyNuclideSet = info.getIdentifyNuclideSet(); Set<String> identifyNuclideSet = info.getIdentifyNuclideSet();
// 获取谱文件采样日期 如果为null 则默认为LocalDate.now() // 获取谱文件采样日期 如果为null 则默认为LocalDate.now()
LocalDate collDate = ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() : LocalDate localDate = info.getCollectionDate().toInstant()
info.getCollectionDate().toLocalDate(); .atZone(ZoneId.systemDefault())
.toLocalDate();
LocalDate collDate =
ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() : localDate;
List<String> conditions = ListUtil.toList(conditionStr.split(COMMA)); List<String> conditions = ListUtil.toList(conditionStr.split(COMMA));
List<NuclideInfo> firstDetected = new ArrayList<>(); // 首次发现 List<NuclideInfo> firstDetected = new ArrayList<>(); // 首次发现
@ -189,20 +208,26 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
List<NuclideInfo> identifyNuclideResult = new ArrayList<>(); List<NuclideInfo> identifyNuclideResult = new ArrayList<>();
for (String con : conditions) { for (String con : conditions) {
Condition condition = Condition.valueOf1(con); Condition condition = Condition.valueOf1(con);
if (ObjectUtil.isNull(condition)) continue; if (ObjectUtil.isNull(condition)) {
switch (condition){ continue;
}
switch (condition) {
case FIRST_FOUND: // 首次发现该元素 case FIRST_FOUND: // 首次发现该元素
firstDetected = this.firstDetected(betaOrGamma, datasource, stationId, sampleId, nuclidesCross); firstDetected = this.firstDetected(betaOrGamma, datasource, stationId, sampleId,
nuclidesCross);
break; break;
case ABOVE_AVERAGE: // 元素浓度高于均值 case ABOVE_AVERAGE: // 元素浓度高于均值
moreThanAvg = this.moreThanAvg(datasource, stationId, collDate, nuclidesCross); moreThanAvg = this.moreThanAvg(datasource, stationId, collDate, nuclidesCross);
break; break;
case MEANWHILE: // 同时出现两种及以上核素 case MEANWHILE: // 同时出现两种及以上核素
meanWhile = this.meanWhile(betaOrGamma, datasource, sampleId, nuclidesCross); meanWhile = this.meanWhile(betaOrGamma, datasource, sampleId, nuclidesCross);
if (meanWhile.size() < 2) meanWhile = ListUtil.empty(); if (meanWhile.size() < 2) {
meanWhile = ListUtil.empty();
}
break; break;
case IDENTIFY_NUCLIDES: // 识别到某个核素 case IDENTIFY_NUCLIDES: // 识别到某个核素
identifyNuclideResult = this.meanWhile(info.getNuclides(), datasource, identifyNuclideSet); identifyNuclideResult =
this.meanWhile(info.getNuclides(), datasource, identifyNuclideSet);
break; break;
default: default:
break; break;
@ -219,7 +244,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo); nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
} }
} }
if (CollUtil.isNotEmpty(meanWhile)){ if (CollUtil.isNotEmpty(meanWhile)) {
String above = meanWhile.stream() String above = meanWhile.stream()
.map(NuclideInfo::getNuclide) .map(NuclideInfo::getNuclide)
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE)); .collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
@ -228,7 +253,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo); nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
} }
} }
if (CollUtil.isNotEmpty(identifyNuclideResult)){ if (CollUtil.isNotEmpty(identifyNuclideResult)) {
String above = identifyNuclideResult.stream() String above = identifyNuclideResult.stream()
.map(NuclideInfo::getNuclide) .map(NuclideInfo::getNuclide)
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE)); .collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
@ -237,9 +262,10 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo); nuclideInfoMap.put(nuclideInfo.getNuclide(), nuclideInfo);
} }
} }
if (CollUtil.isNotEmpty(moreThanAvg)){ if (CollUtil.isNotEmpty(moreThanAvg)) {
String above = moreThanAvg.stream() String above = moreThanAvg.stream()
.map(item -> item.getNuclide() + "(" + item.getValue() + ")" + " > " + item.getThreshold()) .map(item -> item.getNuclide() + "(" + item.getValue() + ")" + " > " +
item.getThreshold())
.collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE)); .collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE));
dataTool.put("moreThanAvg", above); dataTool.put("moreThanAvg", above);
for (NuclideInfo nuclideInfo : moreThanAvg) { for (NuclideInfo nuclideInfo : moreThanAvg) {
@ -247,23 +273,26 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
} }
} }
// 如果报警数据为空 则不需要发送报警信息和生成报警日志 // 如果报警数据为空 则不需要发送报警信息和生成报警日志
if (MapUtil.isEmpty(dataTool.get())) return; if (MapUtil.isEmpty(dataTool.get())) {
return;
}
// 产生报警信息的Sample信息 // 产生报警信息的Sample信息
if (CollUtil.isNotEmpty(stationMap)) if (CollUtil.isNotEmpty(stationMap)) {
{ stationCode = stationMap.get(stationId).toString();
stationCode=stationMap.get(stationId).toString();
} }
dataTool.put("sampleId", sampleId).put("sampleName", sampleName); dataTool.put("sampleId", sampleId).put("sampleName", sampleName);
DataTool titleData = DataTool.getInstance(); DataTool titleData = DataTool.getInstance();
titleData.put("stationCode",stationCode); titleData.put("stationCode", stationCode);
// 构建预警信息实例 准备发送预警信息,20250327--修改模版 // 构建预警信息实例 准备发送预警信息,20250327--修改模版
MessageDTO messageDTO = TemplateUtil.parse1(ANALYSIS_NUCLIDE.getCode(), dataTool.get(),titleData.get()); MessageDTO messageDTO =
TemplateUtil.parse1(ANALYSIS_NUCLIDE.getCode(), dataTool.get(), titleData.get());
// 保存报警日志 // 保存报警日志
AlarmAnalysisLog logInfo = new AlarmAnalysisLog(); AlarmAnalysisLog logInfo = new AlarmAnalysisLog();
BeanUtil.copyProperties(info, logInfo); BeanUtil.copyProperties(info, logInfo);
SampleType sampleType = SampleType.typeOf(betaOrGamma); SampleType sampleType = SampleType.typeOf(betaOrGamma);
if (ObjectUtil.isNotNull(sampleType)) if (ObjectUtil.isNotNull(sampleType)) {
logInfo.setSampleType(sampleType.getValue()); logInfo.setSampleType(sampleType.getValue());
}
logInfo.setAlarmInfo(messageDTO.getContent()); logInfo.setAlarmInfo(messageDTO.getContent());
// 报警信息中核素列表 // 报警信息中核素列表
@ -283,7 +312,8 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
* 首次发现该核素 * 首次发现该核素
*/ */
private List<NuclideInfo> firstDetected(String betaOrGamma, String dataSourceType, private List<NuclideInfo> firstDetected(String betaOrGamma, String dataSourceType,
String stationId, String sampleId, Map<String,String> nuclidesCross){ String stationId, String sampleId,
Map<String, String> nuclidesCross) {
List<NuclideInfo> result = Lists.newArrayList(); List<NuclideInfo> result = Lists.newArrayList();
/* 查询用户关注的核素是否存在 如果不存在则为首次发现该核素 /* 查询用户关注的核素是否存在 如果不存在则为首次发现该核素
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
@ -293,11 +323,12 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
throw new RuntimeException("detectorId is null or empty"); throw new RuntimeException("detectorId is null or empty");
} }
Set<String> nuclideNames = nuclidesCross.keySet(); Set<String> nuclideNames = nuclidesCross.keySet();
List<String> list = analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId, List<String> list =
detectorId, sampleId, nuclideNames); analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId,
if(CollUtil.isNotEmpty(list)){ detectorId, sampleId, nuclideNames);
if (CollUtil.isNotEmpty(list)) {
for (Map.Entry<String, String> f : nuclidesCross.entrySet()) { for (Map.Entry<String, String> f : nuclidesCross.entrySet()) {
if(list.contains(f.getKey())){ if (list.contains(f.getKey())) {
NuclideInfo nuclideInfo = new NuclideInfo(); NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(f.getKey()); nuclideInfo.setNuclide(f.getKey());
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType)); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
@ -325,13 +356,15 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
String nuclideName = nuclide.getKey(); String nuclideName = nuclide.getKey();
String concValue = nuclide.getValue();// 浓度值 String concValue = nuclide.getValue();// 浓度值
String avgValue = nuclideAvgs.get(nuclideName);// 浓度均值 String avgValue = nuclideAvgs.get(nuclideName);// 浓度均值
if (!NumberUtil.isNumber(concValue) || !NumberUtil.isNumber(avgValue)) if (!NumberUtil.isNumber(concValue) || !NumberUtil.isNumber(avgValue)) {
continue; continue;
}
BigDecimal conc = new BigDecimal(concValue); BigDecimal conc = new BigDecimal(concValue);
BigDecimal avg = new BigDecimal(avgValue); BigDecimal avg = new BigDecimal(avgValue);
// 如果核素浓度值小于均值,继续判断下一个核素 // 如果核素浓度值小于均值,继续判断下一个核素
if (NumberUtil.isLessOrEqual(conc, avg)) if (NumberUtil.isLessOrEqual(conc, avg)) {
continue; continue;
}
NuclideInfo nuclideInfo = new NuclideInfo(); NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(nuclideName); nuclideInfo.setNuclide(nuclideName);
nuclideInfo.setThreshold(avg.toString()); nuclideInfo.setThreshold(avg.toString());
@ -344,19 +377,21 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
} }
/* /*
* 是否同时存在两种及以上核素 * 是否同时存在两种及以上核素
* */ * */
private List<NuclideInfo> meanWhile(String betaOrGamma, String dataSourceType, private List<NuclideInfo> meanWhile(String betaOrGamma, String dataSourceType,
String sampleId, Map<String,String> nuclidesCross){ String sampleId, Map<String, String> nuclidesCross) {
List<NuclideInfo> result = Lists.newArrayList(); List<NuclideInfo> result = Lists.newArrayList();
/* 查询用户关注的核素中 该谱中是否存在两种及以上核素 /* 查询用户关注的核素中 该谱中是否存在两种及以上核素
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
*/ */
Set<String> nuclideNames = nuclidesCross.keySet(); Set<String> nuclideNames = nuclidesCross.keySet();
List<String> list = analysisResultService.nuclideExist(betaOrGamma, dataSourceType, sampleId, nuclideNames); List<String> list =
if(CollUtil.isNotEmpty(list)){ analysisResultService.nuclideExist(betaOrGamma, dataSourceType, sampleId,
nuclideNames);
if (CollUtil.isNotEmpty(list)) {
for (Map.Entry<String, String> f : nuclidesCross.entrySet()) { for (Map.Entry<String, String> f : nuclidesCross.entrySet()) {
if(list.contains(f.getKey())){ if (list.contains(f.getKey())) {
NuclideInfo nuclideInfo = new NuclideInfo(); NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(f.getKey()); nuclideInfo.setNuclide(f.getKey());
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType)); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
@ -368,16 +403,18 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
} }
return result; return result;
} }
/* /*
* 是否同时存在两种及以上核素 * 是否同时存在两种及以上核素
* */ * */
private List<NuclideInfo> meanWhile(Map<String,String> nuclideMap, String dataSourceType, Set<String> nuclideNames){ private List<NuclideInfo> meanWhile(Map<String, String> nuclideMap, String dataSourceType,
Set<String> nuclideNames) {
List<NuclideInfo> result = Lists.newArrayList(); List<NuclideInfo> result = Lists.newArrayList();
/* 查询用户关注的核素中 该谱中是否存在两种及以上核素 /* 查询用户关注的核素中 该谱中是否存在两种及以上核素
判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值
*/ */
for (String name : nuclideNames) { for (String name : nuclideNames) {
if(nuclideMap.containsKey(name)){ if (nuclideMap.containsKey(name)) {
NuclideInfo nuclideInfo = new NuclideInfo(); NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(name); nuclideInfo.setNuclide(name);
nuclideInfo.setDatasource(DSType.typeOf(dataSourceType)); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
@ -401,7 +438,7 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
redisUtil = SpringContextUtils.getBean(RedisUtil.class); redisUtil = SpringContextUtils.getBean(RedisUtil.class);
} }
private void destroy(){ private void destroy() {
// end 删除临时Token // end 删除临时Token
UserTokenContext.remove(); UserTokenContext.remove();
} }

View File

@ -446,9 +446,7 @@ public class Sample_B_Analysis implements BlockConstant {
info.setIdAnalysis(this.analyses.getIdAnalysis().toString()); info.setIdAnalysis(this.analyses.getIdAnalysis().toString());
info.setSampleType(this.sampleData.getSampleType()); info.setSampleType(this.sampleData.getSampleType());
info.setSampleName(this.phdFileName); info.setSampleName(this.phdFileName);
final Instant instant = this.sampleData.getCollectStart().toInstant(); info.setCollectionDate(this.sampleData.getCollectStart());
final LocalDateTime collectTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
info.setCollectionDate(collectTime);
info.setCollectStop(this.sampleData.getCollectStop()); info.setCollectStop(this.sampleData.getCollectStop());
info.setDatasource(DSType.ARMDARR.getType()); info.setDatasource(DSType.ARMDARR.getType());
info.setFullOrPrel(this.sampleData.getSpectralQualifie()); info.setFullOrPrel(this.sampleData.getSpectralQualifie());

View File

@ -45,9 +45,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.ParseException; import java.text.ParseException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
@ -238,8 +235,7 @@ public class Sample_G_Analysis {
info.setSampleType(middleData.getSample_Type()); info.setSampleType(middleData.getSample_Type());
info.setIdAnalysis(middleData.getIdAnalysis()); info.setIdAnalysis(middleData.getIdAnalysis());
info.setSampleName(middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH) + 1)); info.setSampleName(middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH) + 1));
final Instant instant = DateUtils.parseDate(middleData.sample_collection_start).toInstant(); Date collectTime = DateUtils.parseDate(middleData.sample_collection_start);
final LocalDateTime collectTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
info.setCollectionDate(collectTime); info.setCollectionDate(collectTime);
info.setCollectStop(this.sampleData.getCollectStop()); info.setCollectStop(this.sampleData.getCollectStop());
info.setDatasource(DSType.ARMDARR.getType()); info.setDatasource(DSType.ARMDARR.getType());

View File

@ -6,7 +6,7 @@ import org.jeecg.modules.entity.*;
import org.jeecg.modules.entity.vo.TableNuclideActivity; import org.jeecg.modules.entity.vo.TableNuclideActivity;
import org.jeecg.modules.entity.vo.TablePeak; import org.jeecg.modules.entity.vo.TablePeak;
import java.time.LocalDateTime; import java.util.Date;
import java.util.List; import java.util.List;
@Mapper @Mapper
@ -16,8 +16,8 @@ public interface IDCDataMapper {
List<Integer> getGardsSampleData(@Param("siteDetCode") String siteDetCode, List<Integer> getGardsSampleData(@Param("siteDetCode") String siteDetCode,
@Param("stationId") Integer stationId, @Param("stationId") Integer stationId,
@Param("spectralQualifier") String spectralQualifier, @Param("spectralQualifier") String spectralQualifier,
@Param("collectStart") LocalDateTime collectStart, @Param("collectStart") Date collectStart,
@Param("acquisitionStop") LocalDateTime acquisitionStop); @Param("acquisitionStop") Date acquisitionStop);
List<TablePeak> getGardsPeaksSpectrum(@Param("sampleId") Integer sampleId); List<TablePeak> getGardsPeaksSpectrum(@Param("sampleId") Integer sampleId);

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.service.impl; package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
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 com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@ -20,13 +21,16 @@ import org.springframework.stereotype.Service;
import java.sql.*; import java.sql.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import java.util.*; import java.util.*;
import java.util.Date;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@DS("ora")
public class DataServiceImpl implements IDataService { public class DataServiceImpl implements IDataService {
// 日期格式常量 // 日期格式常量
private static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; private static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
@ -47,9 +51,9 @@ public class DataServiceImpl implements IDataService {
Integer sampleId = null; Integer sampleId = null;
List<TablePeak> peakInfoList = new LinkedList<>(); List<TablePeak> peakInfoList = new LinkedList<>();
try { try {
// 字符串转 LocalDateTime // 字符串转 Date
LocalDateTime collectStartDate = parseToLocalDateTime(collectStart); Date collectStartDate = parseToDateTime(collectStart);
LocalDateTime acquisitionStopDate = parseToLocalDateTime(acquisitionStop); Date acquisitionStopDate = parseToDateTime(acquisitionStop);
//根据探测器编码台站id采样开始时间采集结束时间 查询 sampleId //根据探测器编码台站id采样开始时间采集结束时间 查询 sampleId
List<Integer> sampleIds = List<Integer> sampleIds =
@ -101,9 +105,9 @@ public class DataServiceImpl implements IDataService {
Integer sampleId = null; Integer sampleId = null;
List<TableNuclideActivity> nuclideActivityList = new LinkedList<>(); List<TableNuclideActivity> nuclideActivityList = new LinkedList<>();
try { try {
// 字符串转 LocalDateTime // 字符串转 Date
LocalDateTime collectStartDate = parseToLocalDateTime(collectStart); Date collectStartDate = parseToDateTime(collectStart);
LocalDateTime acquisitionStopDate = parseToLocalDateTime(acquisitionStop); Date acquisitionStopDate = parseToDateTime(acquisitionStop);
List<Integer> sampleIds = List<Integer> sampleIds =
idcDataMapper.getGardsSampleData(siteDetCode, stationId, spectralQualifier, idcDataMapper.getGardsSampleData(siteDetCode, stationId, spectralQualifier,
@ -159,9 +163,9 @@ public class DataServiceImpl implements IDataService {
List<GardsXeResultsView> xeResultsViewList = new LinkedList<>(); List<GardsXeResultsView> xeResultsViewList = new LinkedList<>();
try { try {
//根据探测器编码台站id采样开始时间采集结束时间 查询 sampleId //根据探测器编码台站id采样开始时间采集结束时间 查询 sampleId
// 字符串转 LocalDateTime // 字符串转 DateTime
LocalDateTime collectStartDate = parseToLocalDateTime(collectStart); Date collectStartDate = parseToDateTime(collectStart);
LocalDateTime acquisitionStopDate = parseToLocalDateTime(acquisitionStop); Date acquisitionStopDate = parseToDateTime(acquisitionStop);
List<Integer> sampleIds = List<Integer> sampleIds =
idcDataMapper.getGardsSampleData(siteDetCode, stationId, spectralQualifier, idcDataMapper.getGardsSampleData(siteDetCode, stationId, spectralQualifier,
collectStartDate, acquisitionStopDate); collectStartDate, acquisitionStopDate);
@ -225,12 +229,14 @@ public class DataServiceImpl implements IDataService {
} }
/** /**
* 字符串转 LocalDateTime * 字符串转 Date
*/ */
private LocalDateTime parseToLocalDateTime(String dateTimeStr) { private Date parseToDateTime(String dateTimeStr) {
String normalizedStr = dateTimeStr.replace('/', '-'); String normalizedStr = dateTimeStr.replace('/', '-');
try { try {
return LocalDateTime.parse(normalizedStr, DATE_TIME_FORMATTER); LocalDateTime localDateTime= LocalDateTime.parse(normalizedStr, DATE_TIME_FORMATTER);
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
throw new IllegalArgumentException("日期时间格式解析错误: " + dateTimeStr, e); throw new IllegalArgumentException("日期时间格式解析错误: " + dateTimeStr, e);
} }

View File

@ -803,17 +803,20 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
result.error500("The end time cannot be empty"); result.error500("The end time cannot be empty");
return result; return result;
} }
LocalDateTime startTime = startDate // 开始时间当天零点
.toInstant() LocalDateTime startLdt = startDate.toInstant()
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.of("Asia/Shanghai")) // 北京时间
.toLocalDate() .toLocalDate()
.atStartOfDay(); .atStartOfDay();
Date startTime = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
LocalDateTime endTime = endDate // 结束时间23:59:59.999
.toInstant() LocalDateTime endLdt = endDate.toInstant()
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.of("Asia/Shanghai"))
.toLocalDate() .toLocalDate()
.atTime(LocalTime.MAX); .atTime(LocalTime.of(23, 59, 59, 999_000_000));
Date endTime = Date.from(endLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
List<String> menuTypeList = Arrays.asList(menuTypes); List<String> menuTypeList = Arrays.asList(menuTypes);
if (CollectionUtils.isEmpty(menuTypeList)) { if (CollectionUtils.isEmpty(menuTypeList)) {
result.error500("The spectrum type cannot be empty"); result.error500("The spectrum type cannot be empty");
@ -5395,14 +5398,10 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
info.setSampleType(middleData.sample_Type); info.setSampleType(middleData.sample_Type);
info.setSampleName(middleData.analyses_save_filePath.substring( info.setSampleName(middleData.analyses_save_filePath.substring(
middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH) + 1)); middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH) + 1));
final Instant instant = Date collectTime = DateUtils.parseDate(middleData.sample_collection_start);
DateUtils.parseDate(middleData.sample_collection_start).toInstant();
final LocalDateTime collectTime =
instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
info.setCollectionDate(collectTime); info.setCollectionDate(collectTime);
final Instant instantStop = Date collectStopTime = DateUtils.parseDate(middleData.sample_collection_stop);
DateUtils.parseDate(middleData.sample_collection_stop).toInstant(); info.setCollectStop(collectStopTime);
info.setCollectStop(Date.from(instantStop));
info.setDatasource(DSType.ARMDRRR.getType()); info.setDatasource(DSType.ARMDRRR.getType());
info.setFullOrPrel(phd.getHeader().getSpectrum_quantity()); info.setFullOrPrel(phd.getHeader().getSpectrum_quantity());
info.setBetaOrGamma(SpectrumType.GAMMA.getType()); info.setBetaOrGamma(SpectrumType.GAMMA.getType());

View File

@ -7,9 +7,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.DbType;
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 com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@ -57,11 +55,9 @@ import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine; import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
import javax.annotation.PostConstruct;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
@ -285,17 +281,19 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
result.error500("The end time cannot be empty"); result.error500("The end time cannot be empty");
return result; return result;
} }
LocalDateTime startTime = startDate // 开始时间当天零点
.toInstant() LocalDateTime startLdt = startDate.toInstant()
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.of("Asia/Shanghai")) // 北京时间
.toLocalDate() .toLocalDate()
.atStartOfDay(); .atStartOfDay();
Date startTime = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
LocalDateTime endTime = endDate // 结束时间23:59:59.999
.toInstant() LocalDateTime endLdt = endDate.toInstant()
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.of("Asia/Shanghai"))
.toLocalDate() .toLocalDate()
.atTime(LocalTime.MAX); .atTime(LocalTime.of(23, 59, 59, 999_000_000));
Date endTime = Date.from(endLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
List<String> menuTypeList = Arrays.asList(menuTypes); List<String> menuTypeList = Arrays.asList(menuTypes);
if (CollectionUtils.isEmpty(menuTypeList)) { if (CollectionUtils.isEmpty(menuTypeList)) {
@ -524,13 +522,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
String qcFileName = ""; String qcFileName = "";
if (Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && if (Objects.nonNull(dbSpectrumFilePath.getCollectStart()) &&
StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode())) { StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode())) {
LocalDateTime collectStart = dbSpectrumFilePath String collectStartStr =
.getCollectStart() DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(),
.toInstant() "yyyy/MM/dd HH:mm:ss");
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
dbQcFilePath = spectrumAnalysisMapper.getQCFilePath( dbQcFilePath = spectrumAnalysisMapper.getQCFilePath(
dbSpectrumFilePath.getSiteDetCode(), collectStart); dbSpectrumFilePath.getSiteDetCode(),
collectStartStr);
if (StringUtils.isNotBlank(dbQcFilePath)) { if (StringUtils.isNotBlank(dbQcFilePath)) {
qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath); qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath);
qcFileName = dbQcFilePath.substring( qcFileName = dbQcFilePath.substring(
@ -964,16 +961,13 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
detBgMap.put("fileName", betaDataFile.getDetFileName()); detBgMap.put("fileName", betaDataFile.getDetFileName());
resultMap.put("detBg", detBgMap); resultMap.put("detBg", detBgMap);
} }
LocalDateTime collectStart = sampleData
.getCollectStart()
.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
// 查询Qc谱 // 查询Qc谱
String collectStartStr =
DateUtils.formatDate(sampleData.getCollectStart(),
"yyyy/MM/dd HH:mm:ss");
String qcFilePath = String qcFilePath =
spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(),
collectStart); collectStartStr);
if (StringUtils.isNotBlank(qcFilePath)) { if (StringUtils.isNotBlank(qcFilePath)) {
GardsSampleData qcSampleData = GardsSampleData qcSampleData =
spectrumAnalysisMapper.findSampleByFilePath(qcFilePath); spectrumAnalysisMapper.findSampleByFilePath(qcFilePath);
@ -2878,8 +2872,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
spectrumAnalysisMapper.selectThresholdDataBySampleId(schemaName, spectrumAnalysisMapper.selectThresholdDataBySampleId(schemaName,
rrrLogInfo.getSampleId().toString()); rrrLogInfo.getSampleId().toString());
//获取阈值历史信息 //获取阈值历史信息
LocalDateTime startTime = LocalDateTime.now().minusYears(1); Date startTime = Date.from(
LocalDateTime endTime = LocalDateTime.now(); LocalDateTime.now().minusYears(1).atZone(ZoneId.systemDefault())
.toInstant());
Date endTime =
Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant());
List<ThresholdResultHistory> thresholdHistoryValues = List<ThresholdResultHistory> thresholdHistoryValues =
spectrumAnalysisMapper.selectThresholdHistoryBySampleId(schemaName, spectrumAnalysisMapper.selectThresholdHistoryBySampleId(schemaName,
rrrLogInfo.getSampleId().toString(), startTime); rrrLogInfo.getSampleId().toString(), startTime);
@ -4791,10 +4789,14 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
.toLocalDate() .toLocalDate()
.atStartOfDay(); .atStartOfDay();
Date startDate = Date.from(start.atZone(ZoneId.systemDefault()).toInstant());
LocalDateTime end = endTime.toInstant() LocalDateTime end = endTime.toInstant()
.atZone(ZoneId.systemDefault()) .atZone(ZoneId.systemDefault())
.toLocalDate() .toLocalDate()
.atTime(23, 59, 59); .atTime(23, 59, 59);
Date endDate = Date.from(end.atZone(ZoneId.systemDefault()).toInstant());
DateTimeFormatter formatter = DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@ -4811,7 +4813,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
} }
if (statisticsType.equals("Colloc_Time")) { if (statisticsType.equals("Colloc_Time")) {
List<StatisticsData> statisticsData = List<StatisticsData> statisticsData =
spectrumAnalysisMapper.statisticsQueryCollection(start, end, spectrumAnalysisMapper.statisticsQueryCollection(startDate, endDate,
detectorIdList); detectorIdList);
StcGraph stcGraph = new StcGraph(); StcGraph stcGraph = new StcGraph();
stcGraph.setM_strGraphName("Colloction Time"); stcGraph.setM_strGraphName("Colloction Time");
@ -4840,7 +4842,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
result.setResult(stcGraph); result.setResult(stcGraph);
} else if (statisticsType.equals("Acq_Time")) { } else if (statisticsType.equals("Acq_Time")) {
List<StatisticsData> statisticsData = List<StatisticsData> statisticsData =
spectrumAnalysisMapper.statisticsQueryAcquisition(start, end, spectrumAnalysisMapper.statisticsQueryAcquisition(startDate, endDate,
detectorIdList); detectorIdList);
StcGraph stcGraph = new StcGraph(); StcGraph stcGraph = new StcGraph();
@ -4872,7 +4874,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
result.setResult(stcGraph); result.setResult(stcGraph);
} else if (statisticsType.equals("Xe_volumn")) { } else if (statisticsType.equals("Xe_volumn")) {
List<StatisticsData> statisticsData = List<StatisticsData> statisticsData =
spectrumAnalysisMapper.statisticsQueryXeVolumn(start, end, spectrumAnalysisMapper.statisticsQueryXeVolumn(startDate, endDate,
detectorIdList); detectorIdList);
StcGraph stcGraph = new StcGraph(); StcGraph stcGraph = new StcGraph();
stcGraph.setM_strGraphName("Xe Volumn"); stcGraph.setM_strGraphName("Xe Volumn");
@ -4890,7 +4892,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
result.setResult(stcGraph); result.setResult(stcGraph);
} else if (statisticsType.equals("Sample_Volumn")) { } else if (statisticsType.equals("Sample_Volumn")) {
List<StatisticsData> statisticsData = List<StatisticsData> statisticsData =
spectrumAnalysisMapper.statisticsQuerySampleVolumn(start, end, spectrumAnalysisMapper.statisticsQuerySampleVolumn(startDate, endDate,
detectorIdList); detectorIdList);
StcGraph stcGraph = new StcGraph(); StcGraph stcGraph = new StcGraph();
stcGraph.setM_strGraphName("Sample Volumn"); stcGraph.setM_strGraphName("Sample Volumn");
@ -6665,17 +6667,14 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
info.setSampleId(betaDataFile.getSampleId()); info.setSampleId(betaDataFile.getSampleId());
info.setSampleType(betaDataFile.getSampleStruct().system_type); info.setSampleType(betaDataFile.getSampleStruct().system_type);
info.setSampleName(betaDataFile.getSampleFileName()); info.setSampleName(betaDataFile.getSampleFileName());
final Instant instant = DateUtils.parseDate( Date collectTime = DateUtils.parseDate(
betaDataFile.getSampleStruct().collection_start_date + StringPool.SPACE + betaDataFile.getSampleStruct().collection_start_date + StringPool.SPACE +
betaDataFile.getSampleStruct().collection_start_time).toInstant(); betaDataFile.getSampleStruct().collection_start_time);
final LocalDateTime collectTime =
instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
info.setCollectionDate(collectTime); info.setCollectionDate(collectTime);
Date collectStopTime = DateUtils.parseDate(
final Instant instantStop = DateUtils.parseDate(
betaDataFile.getSampleStruct().collection_stop_date + StringPool.SPACE + betaDataFile.getSampleStruct().collection_stop_date + StringPool.SPACE +
betaDataFile.getSampleStruct().collection_stop_time).toInstant(); betaDataFile.getSampleStruct().collection_stop_time);
info.setCollectStop(Date.from(instantStop)); info.setCollectStop(collectStopTime);
info.setDatasource(DSType.ARMDRRR.getType()); info.setDatasource(DSType.ARMDRRR.getType());
info.setFullOrPrel(betaDataFile.getSampleStruct().spectrum_quantity); info.setFullOrPrel(betaDataFile.getSampleStruct().spectrum_quantity);
info.setBetaOrGamma(SpectrumType.BETA.getType()); info.setBetaOrGamma(SpectrumType.BETA.getType());
@ -8976,8 +8975,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport
List<Map<String, Object>> thresholdValues = List<Map<String, Object>> thresholdValues =
spectrumAnalysisMapper.selectThresholdDataBySampleId(schemaName, sampleId); spectrumAnalysisMapper.selectThresholdDataBySampleId(schemaName, sampleId);
//获取阈值历史信息 //获取阈值历史信息
LocalDateTime startTime = LocalDateTime.now().minusYears(1); Date startTime = Date.from(
LocalDateTime endTime = LocalDateTime.now(); LocalDateTime.now().minusYears(1).atZone(ZoneId.systemDefault())
.toInstant());
Date endTime =
Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant());
List<ThresholdResultHistory> thresholdHistoryValues = List<ThresholdResultHistory> thresholdHistoryValues =
spectrumAnalysisMapper.selectThresholdHistoryBySampleId(schemaName, spectrumAnalysisMapper.selectThresholdHistoryBySampleId(schemaName,
sampleId, startTime); sampleId, startTime);

View File

@ -7,26 +7,33 @@ import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.entity.GardsSampleDataWeb; import org.jeecg.modules.entity.GardsSampleDataWeb;
import org.jeecg.modules.entity.vo.SpectrumFileRecord; import org.jeecg.modules.entity.vo.SpectrumFileRecord;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Mapper @Mapper
public interface GardsSampleDataWebMapper extends BaseMapper<GardsSampleDataWeb> { public interface GardsSampleDataWebMapper extends BaseMapper<GardsSampleDataWeb> {
Page<GardsSampleDataWeb> findAutoPage(String startDate, String endDate, List<Integer> stationIdList, String qualifie, String sampleType, Page<GardsSampleDataWeb> page); Page<GardsSampleDataWeb> findAutoPage(@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
List<Integer> stationIdList, String qualifie,
String sampleType, Page<GardsSampleDataWeb> page);
Page<GardsSampleDataWeb> findReviewedPage(String startDate, String endDate, List<Integer> stationIdList, String qualifie, Page<GardsSampleDataWeb> page); Page<GardsSampleDataWeb> findReviewedPage(@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
Page<GardsSampleDataWeb> findParticulatePage(String dataType, String spectralQualifie, String startDate, String endDate, List<Integer> stationIdList, Page<GardsSampleDataWeb> page); List<Integer> stationIdList, String qualifie,
Page<GardsSampleDataWeb> page);
Integer getAnalysisID(@Param(value = "sampleId") Integer sampleId); Integer getAnalysisID(@Param(value = "sampleId") Integer sampleId);
SpectrumFileRecord getDBSpectrumFilePath(Integer sampleId, Integer analysisID); SpectrumFileRecord getDBSpectrumFilePath(Integer sampleId, Integer analysisID);
String getQCFilePath(String siteDetCode, String collectStartStr); String getQCFilePath(@Param("siteDetCode") String siteDetCode,
@Param("startTime") Date startTime);
Integer getSampleId(@Param(value = "filePathName") String filePathName); List<Map<String, Object>> findNuclideStatistics(@Param(value = "stationId") String stationId,
@Param(value = "startTime") Date startTime,
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); @Param(value = "endTime") Date endTime,
@Param(value = "nuclideSql") String nuclideSql);
} }

View File

@ -28,12 +28,12 @@
ORIGINAL.GARDS_SAMPLE_DATA sam ORIGINAL.GARDS_SAMPLE_DATA sam
INNER JOIN RNAUTO.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID INNER JOIN RNAUTO.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID
<where> <where>
sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') sam.COLLECT_START >= #{startDate}
and sam.COLLECT_STOP &lt;= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') AND sam.COLLECT_STOP &lt;= #{endDate}
<if test="stationIdList.size==0 and stationIdList != null"> <if test="stationIdList != null and stationIdList.size == 0">
and sam.STATION_ID in ('') AND 1 = 0
</if> </if>
<if test="stationIdList.size>0 and stationIdList != null"> <if test="stationIdList != null and stationIdList.size > 0">
and sam.STATION_ID in and sam.STATION_ID in
<foreach collection="stationIdList" item="stationId" open="(" close=")" separator=","> <foreach collection="stationIdList" item="stationId" open="(" close=")" separator=",">
#{stationId} #{stationId}
@ -75,13 +75,13 @@
ORIGINAL.GARDS_SAMPLE_DATA sam ORIGINAL.GARDS_SAMPLE_DATA sam
INNER JOIN RNMAN.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID INNER JOIN RNMAN.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID
<where> <where>
sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') sam.COLLECT_START >= #{startDate}
AND sam.COLLECT_STOP &lt;= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') AND sam.COLLECT_STOP &lt;= #{endDate}
AND ana.REPORT_PAHT IS NOT NULL AND ana.REPORT_PAHT IS NOT NULL
<if test="stationIdList.size ==0 and stationIdList != null"> <if test="stationIdList != null and stationIdList.size == 0">
and sam.STATION_ID in ('') AND 1 = 0
</if> </if>
<if test="stationIdList.size>0 and stationIdList != null"> <if test="stationIdList != null and stationIdList.size > 0">
and sam.STATION_ID in and sam.STATION_ID in
<foreach collection="stationIdList" item="stationId" open="(" close=")" separator=","> <foreach collection="stationIdList" item="stationId" open="(" close=")" separator=",">
#{stationId} #{stationId}
@ -166,11 +166,11 @@
FROM ORIGINAL.GARDS_SAMPLE_DATA org_sample_data FROM ORIGINAL.GARDS_SAMPLE_DATA org_sample_data
<where> <where>
org_sample_data.ACQUISITION_START= org_sample_data.ACQUISITION_START=
(SELECT MAX(qc_samples.ACQUISITION_START) FROM ORIGINAL.GARDS_SAMPLE_DATA qc_samples WHERE qc_samples.SITE_DET_CODE= '${siteDetCode}' (SELECT MAX(qc_samples.ACQUISITION_START) FROM ORIGINAL.GARDS_SAMPLE_DATA qc_samples WHERE qc_samples.SITE_DET_CODE= #{siteDetCode}
AND qc_samples.DATA_TYPE='Q' AND qc_samples.DATA_TYPE='Q'
AND qc_samples.SPECTRAL_QUALIFIE='FULL' AND qc_samples.SPECTRAL_QUALIFIE='FULL'
AND qc_samples.ACQUISITION_START &lt;= TO_DATE('${collectStartStr}', 'YYYY-MM-DD hh24:mi:ss')) AND qc_samples.ACQUISITION_START &lt;= #{startTime})
AND org_sample_data.SITE_DET_CODE= '${siteDetCode}' AND org_sample_data.SITE_DET_CODE= #{siteDetCode}
</where> </where>
</select> </select>

View File

@ -2,10 +2,7 @@ package org.jeecg.modules.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -14,7 +11,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.ExportUtil; import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses; import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
@ -22,7 +18,6 @@ import org.jeecg.modules.entity.GardsSampleDataWeb;
import org.jeecg.modules.entity.dto.SampleDataDto; import org.jeecg.modules.entity.dto.SampleDataDto;
import org.jeecg.modules.mapper.GardsAnalysesAutoMapper; import org.jeecg.modules.mapper.GardsAnalysesAutoMapper;
import org.jeecg.modules.mapper.GardsSampleDataWebMapper; import org.jeecg.modules.mapper.GardsSampleDataWebMapper;
import org.jeecg.modules.mapper.GardsSampleDataWebPostgresMapper;
import org.jeecg.modules.service.IAutoService; import org.jeecg.modules.service.IAutoService;
import org.jeecg.modules.service.IGardsSampleDataWebService; import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.ExcelExportUtil;
@ -30,12 +25,12 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.sql.SQLException; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -49,23 +44,8 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
@Autowired @Autowired
private GardsSampleDataWebMapper gardsSampleDataWebMapper; private GardsSampleDataWebMapper gardsSampleDataWebMapper;
@Autowired @Autowired
private GardsSampleDataWebPostgresMapper gardsSampleDataWebPostgresMapper;
@Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private DataSource dataSource;
private DbType databaseType;
@PostConstruct
public void initDbType() throws SQLException {
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
String databaseProductName =
ds.getDataSource("ora").getConnection().getMetaData().getDatabaseProductName();
databaseType = DbType.getDbType(databaseProductName);
}
@Override @Override
public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie, public Result findAutoPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie,
String sampleType, Date startTime, Date endTime) { String sampleType, Date startTime, Date endTime) {
@ -76,12 +56,23 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
result.error500("The start time cannot be empty"); result.error500("The start time cannot be empty");
return result; return result;
} }
String startDate = DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00";
if (Objects.isNull(endTime)) { if (Objects.isNull(endTime)) {
result.error500("The end time cannot be empty"); result.error500("The end time cannot be empty");
return result; return result;
} }
String endDate = DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59"; // 开始时间当天零点
LocalDateTime startLdt = startTime.toInstant()
.atZone(ZoneId.of("Asia/Shanghai")) // 北京时间
.toLocalDate()
.atStartOfDay();
Date startDate = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
// 结束时间23:59:59.999
LocalDateTime endLdt = endTime.toInstant()
.atZone(ZoneId.of("Asia/Shanghai"))
.toLocalDate()
.atTime(LocalTime.of(23, 59, 59, 999_000_000));
Date endDate = Date.from(endLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
List<Integer> stationIdList; List<Integer> stationIdList;
if (Objects.isNull(stationIds)) { if (Objects.isNull(stationIds)) {
stationIdList = new LinkedList<>(); stationIdList = new LinkedList<>();
@ -91,16 +82,8 @@ public class AutoServiceImpl extends ServiceImpl<GardsAnalysesAutoMapper, GardsA
Page<GardsSampleDataWeb> page = Page<GardsSampleDataWeb> page =
new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
Page<GardsSampleDataWeb> sampleDataPage = Page<GardsSampleDataWeb> sampleDataPage =
new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList,
if (databaseType == DbType.POSTGRE_SQL) { qualifie, sampleType, page);
sampleDataPage =
gardsSampleDataWebPostgresMapper.findAutoPage(startDate, endDate, stationIdList,
qualifie, sampleType, page);
} else if (databaseType == DbType.ORACLE) {
sampleDataPage =
gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList,
qualifie, sampleType, page);
}
sampleDataPage.getRecords().forEach(item -> { sampleDataPage.getRecords().forEach(item -> {
item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode())); item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode()));

View File

@ -13,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.common.api.QueryRequest; import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result; import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.ExportUtil; import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.rnman.GardsAnalyses; import org.jeecg.modules.base.entity.rnman.GardsAnalyses;
@ -21,7 +20,6 @@ import org.jeecg.modules.entity.GardsSampleDataWeb;
import org.jeecg.modules.entity.dto.SampleDataDto; import org.jeecg.modules.entity.dto.SampleDataDto;
import org.jeecg.modules.mapper.GardsAnalysesManMapper; import org.jeecg.modules.mapper.GardsAnalysesManMapper;
import org.jeecg.modules.mapper.GardsSampleDataWebMapper; import org.jeecg.modules.mapper.GardsSampleDataWebMapper;
import org.jeecg.modules.mapper.GardsSampleDataWebPostgresMapper;
import org.jeecg.modules.service.IGardsSampleDataWebService; import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecg.modules.service.IReviewedService; import org.jeecg.modules.service.IReviewedService;
import org.jeecgframework.poi.excel.ExcelExportUtil; import org.jeecgframework.poi.excel.ExcelExportUtil;
@ -35,12 +33,16 @@ import javax.sql.DataSource;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service("reviewedService") @Service("reviewedService")
@DS("ora") @DS("ora")
public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, GardsAnalyses> implements IReviewedService { public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, GardsAnalyses>
implements IReviewedService {
@Autowired @Autowired
private IGardsSampleDataWebService gardsSampleDataService; private IGardsSampleDataWebService gardsSampleDataService;
@ -49,8 +51,6 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private GardsSampleDataWebPostgresMapper postgresMapper;
@Autowired @Autowired
private DataSource dataSource; private DataSource dataSource;
private DbType databaseType; private DbType databaseType;
@ -65,31 +65,48 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
} }
@Override @Override
public Result findReviewedPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie, Date startTime, Date endTime) { public Result findReviewedPage(QueryRequest queryRequest, Integer[] stationIds, String qualifie,
Date startTime, Date endTime) {
Result result = new Result(); Result result = new Result();
//获取redis中缓存的台站信息 //获取redis中缓存的台站信息
Map<String, String> stationMap = (Map<String, String>)redisUtil.get("stationMap"); Map<String, String> stationMap = (Map<String, String>) redisUtil.get("stationMap");
if (Objects.isNull(startTime)){ if (Objects.isNull(startTime)) {
result.error500("The start time cannot be empty"); result.error500("The start time cannot be empty");
return result; return result;
} }
String startDate = DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00"; if (Objects.isNull(endTime)) {
if (Objects.isNull(endTime)){
result.error500("The end time cannot be empty"); result.error500("The end time cannot be empty");
return result; return result;
} }
String endDate = DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59"; // 开始时间当天零点
LocalDateTime startLdt = startTime.toInstant()
.atZone(ZoneId.of("Asia/Shanghai")) // 北京时间
.toLocalDate()
.atStartOfDay();
Date startDate = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
// 结束时间23:59:59.999
LocalDateTime endLdt = endTime.toInstant()
.atZone(ZoneId.of("Asia/Shanghai"))
.toLocalDate()
.atTime(LocalTime.of(23, 59, 59, 999_000_000));
Date endDate = Date.from(endLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant());
List<Integer> stationIdList; List<Integer> stationIdList;
if (Objects.isNull(stationIds)){ if (Objects.isNull(stationIds)) {
stationIdList = new LinkedList<>(); stationIdList = new LinkedList<>();
}else { } else {
stationIdList = Arrays.asList(stationIds); stationIdList = Arrays.asList(stationIds);
} }
Page<GardsSampleDataWeb> page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); Page<GardsSampleDataWeb> page =
Page<GardsSampleDataWeb> sampleDataPage =databaseType==DbType.POSTGRE_SQL?postgresMapper.findReviewedPage(startDate, endDate, stationIdList, qualifie, page): gardsSampleDataWebMapper.findReviewedPage(startDate, endDate, stationIdList, qualifie, page); new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize());
sampleDataPage.getRecords().forEach(item->{ Page<GardsSampleDataWeb> sampleDataPage =
gardsSampleDataWebMapper.findReviewedPage(startDate, endDate, stationIdList,
qualifie, page);
sampleDataPage.getRecords().forEach(item -> {
item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode())); item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode()));
if (stationMap.containsKey(item.getStationId().toString()) && CollectionUtils.isNotEmpty(stationMap)){ if (stationMap.containsKey(item.getStationId().toString()) &&
CollectionUtils.isNotEmpty(stationMap)) {
String stationName = stationMap.get(item.getStationId().toString()); String stationName = stationMap.get(item.getStationId().toString());
item.setStationName(stationName); item.setStationName(stationName);
} }
@ -102,7 +119,7 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
@Override @Override
public GardsAnalyses getOne(Integer sampleId) { public GardsAnalyses getOne(Integer sampleId) {
LambdaQueryWrapper<GardsAnalyses> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GardsAnalyses> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalyses::getSampleId,sampleId); wrapper.eq(GardsAnalyses::getSampleId, sampleId);
GardsAnalyses gardsAnalyses = getOne(wrapper); GardsAnalyses gardsAnalyses = getOne(wrapper);
return Optional.ofNullable(gardsAnalyses) return Optional.ofNullable(gardsAnalyses)
.orElse(new GardsAnalyses()); .orElse(new GardsAnalyses());
@ -121,7 +138,9 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
.stream() .stream()
.map(GardsAnalyses::getSampleId) .map(GardsAnalyses::getSampleId)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isEmpty(sampleIds)) return; if (CollUtil.isEmpty(sampleIds)) {
return;
}
// 查询全部样品基础数据 // 查询全部样品基础数据
List<GardsSampleDataWeb> sampleData = gardsSampleDataService.listBySampleIds(stationIds, List<GardsSampleDataWeb> sampleData = gardsSampleDataService.listBySampleIds(stationIds,
@ -138,18 +157,20 @@ public class ReviewedServiceImpl extends ServiceImpl<GardsAnalysesManMapper, Gar
OutputStream outputStream = null; OutputStream outputStream = null;
try { try {
// 设置文件名Excel类型(xls|xlsx) // 设置文件名Excel类型(xls|xlsx)
outputStream = ExportUtil.xls(response,"RRR.xls"); outputStream = ExportUtil.xls(response, "RRR.xls");
workbook = ExcelExportUtil. workbook = ExcelExportUtil.
exportExcel(params, SampleDataDto.class, sampleDataDtos); exportExcel(params, SampleDataDto.class, sampleDataDtos);
workbook.write(outputStream); workbook.write(outputStream);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
if (ObjectUtil.isNotNull(outputStream)) if (ObjectUtil.isNotNull(outputStream)) {
outputStream.close(); outputStream.close();
if (ObjectUtil.isNotNull(workbook)) }
if (ObjectUtil.isNotNull(workbook)) {
workbook.close(); workbook.close();
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }