From f72f4d7a7afadb4b9aa85924790004bdc7780e40 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Sat, 23 May 2026 11:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9LocalDateTime=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BD=BF=E7=94=A8Date=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/modules/base/dto/Info.java | 4 +- .../base/entity/GardsNuclThresholds.java | 4 +- .../mapper/ThresholdRnAutoResultMapper.java | 3 +- .../mapper/ThresholdRnManResultMapper.java | 3 +- .../impl/RnAutoThresholdServiceImpl.java | 17 +- .../impl/RnManThresholdServiceImpl.java | 5 +- .../impl/ThresholdCalculationBaseService.java | 14 +- .../modules/redisStream/AnalysisConsumer.java | 147 +++-- .../modules/spectrum/Sample_B_Analysis.java | 4 +- .../modules/spectrum/Sample_G_Analysis.java | 6 +- .../jeecg/modules/mapper/IDCDataMapper.java | 6 +- .../modules/service/impl/DataServiceImpl.java | 30 +- .../service/impl/GammaServiceImpl.java | 27 +- .../impl/SpectrumAnalysisServiceImpl.java | 83 +-- .../mapper/GardsSampleDataWebMapper.java | 23 +- .../mapper/xml/GardsSampleDataWebMapper.xml | 26 +- .../modules/service/impl/AutoServiceImpl.java | 53 +- .../impl/GardsSampleDataWebServiceImpl.java | 600 +++++++++++------- .../service/impl/ReviewedServiceImpl.java | 67 +- 19 files changed, 655 insertions(+), 467 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/Info.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/Info.java index 0bed9e2e..715baf93 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/Info.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/dto/Info.java @@ -4,10 +4,8 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; -import org.jeecg.modules.base.enums.SourceType; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; import java.util.Map; import java.util.Set; @@ -29,7 +27,7 @@ public class Info implements Serializable { private String sampleName; // 采样时间 - private LocalDateTime collectionDate; + private Date collectionDate; //采集停止时间 private Date collectStop; // 数据源类型(ARMDARR=1|ARMDRRR=2|IDCARR=3|IDCRRR=4) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/GardsNuclThresholds.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/GardsNuclThresholds.java index 5e3c09d9..9eba0d05 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/GardsNuclThresholds.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/GardsNuclThresholds.java @@ -3,7 +3,7 @@ package org.jeecg.modules.base.entity; import lombok.Data; import java.io.Serializable; -import java.time.LocalDateTime; +import java.util.Date; @Data public class GardsNuclThresholds implements Serializable { @@ -12,6 +12,6 @@ public class GardsNuclThresholds implements Serializable { private String stationId; private Double thresholdValue; private String nuclideName; - private LocalDateTime calculationTime; + private Date calculationTime; } \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnAutoResultMapper.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnAutoResultMapper.java index 92578abd..fed076f0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnAutoResultMapper.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnAutoResultMapper.java @@ -7,6 +7,7 @@ import org.jeecg.modules.base.entity.ThresholdMetric; import org.jeecg.modules.base.entity.rnauto.GardsThresholdResult; import java.sql.Timestamp; +import java.util.Date; import java.util.List; @Mapper @@ -20,5 +21,5 @@ public interface ThresholdRnAutoResultMapper extends BaseMapper selectByRnAutoStationIds(@Param("stationIds") List stationIds, @Param("oneYearAgo") - Timestamp oneYearAgo); + Date oneYearAgo); } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnManResultMapper.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnManResultMapper.java index fb4388ed..caad8e65 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnManResultMapper.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/ThresholdRnManResultMapper.java @@ -7,6 +7,7 @@ import org.jeecg.modules.base.entity.ThresholdMetric; import org.jeecg.modules.base.entity.rnman.GardsThresholdResult; import java.sql.Timestamp; +import java.util.Date; import java.util.List; @Mapper @@ -19,5 +20,5 @@ public interface ThresholdRnManResultMapper extends BaseMapper selectByStationId(String stationId); List selectByRnManStationIds(@Param("stationIds") List stationIds, - @Param("oneYearAgo") Timestamp oneYearAgo); + @Param("oneYearAgo") Date oneYearAgo); } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnAutoThresholdServiceImpl.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnAutoThresholdServiceImpl.java index 1b1b277a..4e6ba6e3 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnAutoThresholdServiceImpl.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnAutoThresholdServiceImpl.java @@ -26,7 +26,8 @@ import java.util.stream.Collectors; @Service @Slf4j @DS("ora") -public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService { +public class RnAutoThresholdServiceImpl + extends ThresholdCalculationBaseService { @Autowired @@ -118,7 +119,8 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService< /** * 构建ThresholdResult列表 */ - private List buildThresholdResultList(Info info, Map thresholds, + private List buildThresholdResultList(Info info, + Map thresholds, Map statistics) { List results = new ArrayList<>(thresholds.size()); @@ -137,7 +139,8 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService< String concStr = info.getNuclides().get(nuclideName); if (StringUtils.hasText(concStr)) { try { - double concValue = Double.parseDouble(NumberFormatUtil.numberFormat(concStr)); + double concValue = + Double.parseDouble(NumberFormatUtil.numberFormat(concStr)); category = concValue < thresholdValue ? "B" : "C"; } catch (Exception ignored) { // 解析失败保持 A @@ -146,7 +149,7 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService< } GardsThresholdResult result = new GardsThresholdResult(); result.setId(UUID.randomUUID().toString()); - result.setStationId(Integer.parseInt(info.getStationId()) ); + result.setStationId(Integer.parseInt(info.getStationId())); result.setNuclideName(nuclideName); result.setCategory(category); result.setThresholdValue(thresholdValue); @@ -208,11 +211,9 @@ public class RnAutoThresholdServiceImpl extends ThresholdCalculationBaseService< * @param startDate 开始时间 * @return List ThresholdMetric */ - public List queryMetricsByDataType(List stationIds, String startDate) { + public List queryMetricsByDataType(List stationIds, Date startDate) { try { - Timestamp timestamp = Timestamp.valueOf(startDate); - return this.baseMapper.selectByRnAutoStationIds(stationIds, timestamp); - + return this.baseMapper.selectByRnAutoStationIds(stationIds, startDate); } catch (Exception e) { log.error("查询核素度量数据失败:,台站{}", stationIds, e); return Collections.emptyList(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnManThresholdServiceImpl.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnManThresholdServiceImpl.java index 74219763..72d90ab0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnManThresholdServiceImpl.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/RnManThresholdServiceImpl.java @@ -177,10 +177,9 @@ public class RnManThresholdServiceImpl extends ThresholdCalculationBaseService ThresholdMetric */ - public List queryMetricsByDataType(List stationIds, String startDate) { + public List queryMetricsByDataType(List stationIds, Date startDate) { try { - Timestamp timestamp = Timestamp.valueOf(startDate); - return this.baseMapper.selectByRnManStationIds(stationIds, timestamp); + return this.baseMapper.selectByRnManStationIds(stationIds, startDate); } catch (Exception e) { log.error("查询核素度量数据失败:,台站{}", stationIds, e); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/ThresholdCalculationBaseService.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/ThresholdCalculationBaseService.java index ca6ae611..a992249a 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/ThresholdCalculationBaseService.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/service/impl/ThresholdCalculationBaseService.java @@ -25,6 +25,8 @@ import java.io.File; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -280,9 +282,8 @@ public abstract class ThresholdCalculationBaseService, T } //查询核素浓度 // 计算查询时间范围(近1年) - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DAY_OF_YEAR, -getDayValue()); - String startDate = DateUtils.formatDate(calendar.getTime(), "yyyy-MM-dd HH:mm:ss"); + Date startDate = Date.from(LocalDateTime.now().minusDays(getDayValue()) + .atZone(ZoneId.systemDefault()).toInstant()); log.debug("查询核素度量数据:台站{}个,时间范围{}至今", stationIds.size(), startDate); @@ -345,9 +346,8 @@ public abstract class ThresholdCalculationBaseService, T 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"); + Date startDate = Date.from(LocalDateTime.now().minusDays(getDayValue()) + .atZone(ZoneId.systemDefault()).toInstant()); log.debug("查询核素度量数据:台站{}个,时间范围{}至今", stationIds.size(), startDate); @@ -391,7 +391,7 @@ public abstract class ThresholdCalculationBaseService, T * @param startDate 开始时间 * @return 度量数据列表 */ - protected abstract List queryMetricsByDataType(List stationIds, String startDate); + protected abstract List queryMetricsByDataType(List stationIds, Date startDate); /** * 解析度量数据到分层映射 diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java index d8e1f3d8..8c157f92 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/redisStream/AnalysisConsumer.java @@ -38,10 +38,11 @@ import org.springframework.stereotype.Component; import static org.jeecg.common.constant.enums.MessageTypeEnum.*; 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.time.LocalDate; +import java.time.ZoneId; import java.util.*; import java.util.stream.Collectors; @@ -94,56 +95,70 @@ public class AnalysisConsumer implements StreamListener infoNuclideMap = info.getNuclides(); - if (StrUtil.isBlank(stationId)) return; - if (StrUtil.isBlank(sampleId)) return; - if (MapUtil.isEmpty(infoNuclideMap)) return; + if (StrUtil.isBlank(stationId)) { + return; + } + if (StrUtil.isBlank(sampleId)) { + return; + } + if (MapUtil.isEmpty(infoNuclideMap)) { + return; + } List rules = ruleService.allAnalysisRule(); for (AlarmAnalysisRule rule : rules) { // 当前规则是否有报警条件 String conditionStr = rule.getConditions(); - if (StrUtil.isBlank(conditionStr)) + if (StrUtil.isBlank(conditionStr)) { continue; + } // 是否在当前规则关注的台站列表内 String stations = rule.getStations(); - if (!StrUtil.contains(stations, stationId)) + if (!StrUtil.contains(stations, stationId)) { continue; + } // 是否在当前规则关注的数据源内 String source = rule.getSource(); - if (!StrUtil.contains(source,datasource)) + if (!StrUtil.contains(source, datasource)) { continue; + } // 是否在当前规则关注的谱类型内 String spectralQualifier = rule.getSpectralQualifier(); - if (!StrUtil.contains(spectralQualifier,fullOrPrel)) + if (!StrUtil.contains(spectralQualifier, fullOrPrel)) { continue; + } // 是否有当前规则关注的核素 String nuclidesStr = rule.getNuclides(); - if (StrUtil.isBlank(nuclidesStr)) continue; + if (StrUtil.isBlank(nuclidesStr)) { + continue; + } Set names = infoNuclideMap.keySet(); List follow = ListUtil.toList(nuclidesStr.split(COMMA)); // 因数据库 Xe核素名称 M大小写不统一,先统一大小写再进行比较 Collection follows = follow.stream().map(f -> { - if(f.toLowerCase().contains("xe")){ - return f.replace("M", "m"); + if (f.toLowerCase().contains("xe")) { + return f.replace("M", "m"); } return f; }).collect(Collectors.toList()); // 推送过来的核素集合与所关注核素集合取交集 Collection cross = CollectionUtil.intersection(names, follows); - if (CollUtil.isEmpty(cross)) continue; + if (CollUtil.isEmpty(cross)) { + continue; + } Map nuclidesCross = infoNuclideMap.entrySet().stream() .filter(entry -> cross.contains(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); @@ -155,7 +170,7 @@ public class AnalysisConsumer implements StreamListener= 1) { info.setIdentifyNuclideSet(Arrays.stream(inSplit).map(f -> { - if(f.toLowerCase().contains("xe")){ + if (f.toLowerCase().contains("xe")) { return f.replace("M", "m"); } return f; @@ -166,20 +181,24 @@ public class AnalysisConsumer implements StreamListener nuclidesCross){ + private void judge(Info info, Map nuclidesCross) { Set nuclideNames = nuclidesCross.keySet(); String conditionStr = info.getConditions(); String betaOrGamma = info.getBetaOrGamma(); String datasource = info.getDatasource(); String stationId = info.getStationId(); - String stationCode=""; - HashMap stationMap = (HashMap)redisUtil.get(RedisConstant.STATION_CODE_MAP); + String stationCode = ""; + HashMap stationMap = + (HashMap) redisUtil.get(RedisConstant.STATION_CODE_MAP); String sampleId = info.getSampleId(); String sampleName = info.getSampleName(); Set identifyNuclideSet = info.getIdentifyNuclideSet(); // 获取谱文件采样日期 如果为null 则默认为LocalDate.now() - LocalDate collDate = ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() : - info.getCollectionDate().toLocalDate(); + LocalDate localDate = info.getCollectionDate().toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + LocalDate collDate = + ObjectUtil.isNull(info.getCollectionDate()) ? LocalDate.now() : localDate; List conditions = ListUtil.toList(conditionStr.split(COMMA)); List firstDetected = new ArrayList<>(); // 首次发现 @@ -189,20 +208,26 @@ public class AnalysisConsumer implements StreamListener identifyNuclideResult = new ArrayList<>(); for (String con : conditions) { Condition condition = Condition.valueOf1(con); - if (ObjectUtil.isNull(condition)) continue; - switch (condition){ + if (ObjectUtil.isNull(condition)) { + continue; + } + switch (condition) { case FIRST_FOUND: // 首次发现该元素 - firstDetected = this.firstDetected(betaOrGamma, datasource, stationId, sampleId, nuclidesCross); + firstDetected = this.firstDetected(betaOrGamma, datasource, stationId, sampleId, + nuclidesCross); break; case ABOVE_AVERAGE: // 元素浓度高于均值 moreThanAvg = this.moreThanAvg(datasource, stationId, collDate, nuclidesCross); break; case MEANWHILE: // 同时出现两种及以上核素 meanWhile = this.meanWhile(betaOrGamma, datasource, sampleId, nuclidesCross); - if (meanWhile.size() < 2) meanWhile = ListUtil.empty(); + if (meanWhile.size() < 2) { + meanWhile = ListUtil.empty(); + } break; case IDENTIFY_NUCLIDES: // 识别到某个核素 - identifyNuclideResult = this.meanWhile(info.getNuclides(), datasource, identifyNuclideSet); + identifyNuclideResult = + this.meanWhile(info.getNuclides(), datasource, identifyNuclideSet); break; default: break; @@ -219,7 +244,7 @@ public class AnalysisConsumer implements StreamListener item.getNuclide() + "(" + item.getValue() + ")" + " > " + item.getThreshold()) + .map(item -> item.getNuclide() + "(" + item.getValue() + ")" + " > " + + item.getThreshold()) .collect(Collectors.joining(StrUtil.COMMA + StrUtil.SPACE)); dataTool.put("moreThanAvg", above); for (NuclideInfo nuclideInfo : moreThanAvg) { @@ -247,23 +273,26 @@ public class AnalysisConsumer implements StreamListener firstDetected(String betaOrGamma, String dataSourceType, - String stationId, String sampleId, Map nuclidesCross){ + String stationId, String sampleId, + Map nuclidesCross) { List result = Lists.newArrayList(); /* 查询用户关注的核素是否存在 如果不存在则为首次发现该核素 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 @@ -293,11 +323,12 @@ public class AnalysisConsumer implements StreamListener nuclideNames = nuclidesCross.keySet(); - List list = analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId, - detectorId, sampleId, nuclideNames); - if(CollUtil.isNotEmpty(list)){ + List list = + analysisResultService.nuclideFirst(betaOrGamma, dataSourceType, stationId, + detectorId, sampleId, nuclideNames); + if (CollUtil.isNotEmpty(list)) { for (Map.Entry f : nuclidesCross.entrySet()) { - if(list.contains(f.getKey())){ + if (list.contains(f.getKey())) { NuclideInfo nuclideInfo = new NuclideInfo(); nuclideInfo.setNuclide(f.getKey()); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType)); @@ -325,13 +356,15 @@ public class AnalysisConsumer implements StreamListener meanWhile(String betaOrGamma, String dataSourceType, - String sampleId, Map nuclidesCross){ + String sampleId, Map nuclidesCross) { List result = Lists.newArrayList(); /* 查询用户关注的核素中 该谱中是否存在两种及以上核素 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 */ Set nuclideNames = nuclidesCross.keySet(); - List list = analysisResultService.nuclideExist(betaOrGamma, dataSourceType, sampleId, nuclideNames); - if(CollUtil.isNotEmpty(list)){ + List list = + analysisResultService.nuclideExist(betaOrGamma, dataSourceType, sampleId, + nuclideNames); + if (CollUtil.isNotEmpty(list)) { for (Map.Entry f : nuclidesCross.entrySet()) { - if(list.contains(f.getKey())){ + if (list.contains(f.getKey())) { NuclideInfo nuclideInfo = new NuclideInfo(); nuclideInfo.setNuclide(f.getKey()); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType)); @@ -368,16 +403,18 @@ public class AnalysisConsumer implements StreamListener meanWhile(Map nuclideMap, String dataSourceType, Set nuclideNames){ + * 是否同时存在两种及以上核素 + * */ + private List meanWhile(Map nuclideMap, String dataSourceType, + Set nuclideNames) { List result = Lists.newArrayList(); /* 查询用户关注的核素中 该谱中是否存在两种及以上核素 判断核素是否存在的条件: 该核素的Conc值是否大于MDC值 */ for (String name : nuclideNames) { - if(nuclideMap.containsKey(name)){ + if (nuclideMap.containsKey(name)) { NuclideInfo nuclideInfo = new NuclideInfo(); nuclideInfo.setNuclide(name); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType)); @@ -401,7 +438,7 @@ public class AnalysisConsumer implements StreamListener getGardsSampleData(@Param("siteDetCode") String siteDetCode, @Param("stationId") Integer stationId, @Param("spectralQualifier") String spectralQualifier, - @Param("collectStart") LocalDateTime collectStart, - @Param("acquisitionStop") LocalDateTime acquisitionStop); + @Param("collectStart") Date collectStart, + @Param("acquisitionStop") Date acquisitionStop); List getGardsPeaksSpectrum(@Param("sampleId") Integer sampleId); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/DataServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/DataServiceImpl.java index 907185aa..d4e7ad49 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/DataServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/DataServiceImpl.java @@ -1,5 +1,6 @@ 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.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -20,13 +21,16 @@ import org.springframework.stereotype.Service; import java.sql.*; import java.text.SimpleDateFormat; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.*; +import java.util.Date; import java.util.stream.Collectors; @Service @Slf4j +@DS("ora") public class DataServiceImpl implements IDataService { // 日期格式常量 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; List peakInfoList = new LinkedList<>(); try { - // 字符串转 LocalDateTime - LocalDateTime collectStartDate = parseToLocalDateTime(collectStart); - LocalDateTime acquisitionStopDate = parseToLocalDateTime(acquisitionStop); + // 字符串转 Date + Date collectStartDate = parseToDateTime(collectStart); + Date acquisitionStopDate = parseToDateTime(acquisitionStop); //根据探测器编码,台站id,采样开始时间,采集结束时间 查询 sampleId List sampleIds = @@ -101,9 +105,9 @@ public class DataServiceImpl implements IDataService { Integer sampleId = null; List nuclideActivityList = new LinkedList<>(); try { - // 字符串转 LocalDateTime - LocalDateTime collectStartDate = parseToLocalDateTime(collectStart); - LocalDateTime acquisitionStopDate = parseToLocalDateTime(acquisitionStop); + // 字符串转 Date + Date collectStartDate = parseToDateTime(collectStart); + Date acquisitionStopDate = parseToDateTime(acquisitionStop); List sampleIds = idcDataMapper.getGardsSampleData(siteDetCode, stationId, spectralQualifier, @@ -159,9 +163,9 @@ public class DataServiceImpl implements IDataService { List xeResultsViewList = new LinkedList<>(); try { //根据探测器编码,台站id,采样开始时间,采集结束时间 查询 sampleId - // 字符串转 LocalDateTime - LocalDateTime collectStartDate = parseToLocalDateTime(collectStart); - LocalDateTime acquisitionStopDate = parseToLocalDateTime(acquisitionStop); + // 字符串转 DateTime + Date collectStartDate = parseToDateTime(collectStart); + Date acquisitionStopDate = parseToDateTime(acquisitionStop); List sampleIds = idcDataMapper.getGardsSampleData(siteDetCode, stationId, spectralQualifier, 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('/', '-'); 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) { throw new IllegalArgumentException("日期时间格式解析错误: " + dateTimeStr, e); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 891fde4a..2512a493 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -803,17 +803,20 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi result.error500("The end time cannot be empty"); return result; } - LocalDateTime startTime = startDate - .toInstant() - .atZone(ZoneId.systemDefault()) + // 开始时间:当天零点 + LocalDateTime startLdt = startDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) // 北京时间 .toLocalDate() .atStartOfDay(); + Date startTime = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); - LocalDateTime endTime = endDate - .toInstant() - .atZone(ZoneId.systemDefault()) + // 结束时间:23:59:59.999 + LocalDateTime endLdt = endDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) .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 menuTypeList = Arrays.asList(menuTypes); if (CollectionUtils.isEmpty(menuTypeList)) { 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.setSampleName(middleData.analyses_save_filePath.substring( middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH) + 1)); - final Instant instant = - DateUtils.parseDate(middleData.sample_collection_start).toInstant(); - final LocalDateTime collectTime = - instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); + Date collectTime = DateUtils.parseDate(middleData.sample_collection_start); info.setCollectionDate(collectTime); - final Instant instantStop = - DateUtils.parseDate(middleData.sample_collection_stop).toInstant(); - info.setCollectStop(Date.from(instantStop)); + Date collectStopTime = DateUtils.parseDate(middleData.sample_collection_stop); + info.setCollectStop(collectStopTime); info.setDatasource(DSType.ARMDRRR.getType()); info.setFullOrPrel(phd.getHeader().getSpectrum_quantity()); info.setBetaOrGamma(SpectrumType.GAMMA.getType()); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index a0b2ddf4..ac757d73 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -7,9 +7,7 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; -import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; 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.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; @@ -57,11 +55,9 @@ import org.thymeleaf.context.Context; import org.thymeleaf.spring5.SpringTemplateEngine; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; -import javax.annotation.PostConstruct; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.sql.DataSource; import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; @@ -285,17 +281,19 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport result.error500("The end time cannot be empty"); return result; } - LocalDateTime startTime = startDate - .toInstant() - .atZone(ZoneId.systemDefault()) + // 开始时间:当天零点 + LocalDateTime startLdt = startDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) // 北京时间 .toLocalDate() .atStartOfDay(); + Date startTime = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); - LocalDateTime endTime = endDate - .toInstant() - .atZone(ZoneId.systemDefault()) + // 结束时间:23:59:59.999 + LocalDateTime endLdt = endDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) .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 menuTypeList = Arrays.asList(menuTypes); if (CollectionUtils.isEmpty(menuTypeList)) { @@ -524,13 +522,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport String qcFileName = ""; if (Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode())) { - LocalDateTime collectStart = dbSpectrumFilePath - .getCollectStart() - .toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDateTime(); + String collectStartStr = + DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), + "yyyy/MM/dd HH:mm:ss"); dbQcFilePath = spectrumAnalysisMapper.getQCFilePath( - dbSpectrumFilePath.getSiteDetCode(), collectStart); + dbSpectrumFilePath.getSiteDetCode(), + collectStartStr); if (StringUtils.isNotBlank(dbQcFilePath)) { qc = spectrumAnalysisMapper.findSampleByFilePath(dbQcFilePath); qcFileName = dbQcFilePath.substring( @@ -964,16 +961,13 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport detBgMap.put("fileName", betaDataFile.getDetFileName()); resultMap.put("detBg", detBgMap); } - - LocalDateTime collectStart = sampleData - .getCollectStart() - .toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDateTime(); // 查询Qc谱 + String collectStartStr = + DateUtils.formatDate(sampleData.getCollectStart(), + "yyyy/MM/dd HH:mm:ss"); String qcFilePath = spectrumAnalysisMapper.getQCFilePath(sampleData.getSiteDetCode(), - collectStart); + collectStartStr); if (StringUtils.isNotBlank(qcFilePath)) { GardsSampleData qcSampleData = spectrumAnalysisMapper.findSampleByFilePath(qcFilePath); @@ -2878,8 +2872,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport spectrumAnalysisMapper.selectThresholdDataBySampleId(schemaName, rrrLogInfo.getSampleId().toString()); //获取阈值历史信息 - LocalDateTime startTime = LocalDateTime.now().minusYears(1); - LocalDateTime endTime = LocalDateTime.now(); + Date startTime = Date.from( + LocalDateTime.now().minusYears(1).atZone(ZoneId.systemDefault()) + .toInstant()); + Date endTime = + Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()); + List thresholdHistoryValues = spectrumAnalysisMapper.selectThresholdHistoryBySampleId(schemaName, rrrLogInfo.getSampleId().toString(), startTime); @@ -4791,10 +4789,14 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport .toLocalDate() .atStartOfDay(); + Date startDate = Date.from(start.atZone(ZoneId.systemDefault()).toInstant()); + LocalDateTime end = endTime.toInstant() .atZone(ZoneId.systemDefault()) .toLocalDate() .atTime(23, 59, 59); + Date endDate = Date.from(end.atZone(ZoneId.systemDefault()).toInstant()); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @@ -4811,7 +4813,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport } if (statisticsType.equals("Colloc_Time")) { List statisticsData = - spectrumAnalysisMapper.statisticsQueryCollection(start, end, + spectrumAnalysisMapper.statisticsQueryCollection(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Colloction Time"); @@ -4840,7 +4842,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport result.setResult(stcGraph); } else if (statisticsType.equals("Acq_Time")) { List statisticsData = - spectrumAnalysisMapper.statisticsQueryAcquisition(start, end, + spectrumAnalysisMapper.statisticsQueryAcquisition(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); @@ -4872,7 +4874,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport result.setResult(stcGraph); } else if (statisticsType.equals("Xe_volumn")) { List statisticsData = - spectrumAnalysisMapper.statisticsQueryXeVolumn(start, end, + spectrumAnalysisMapper.statisticsQueryXeVolumn(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Xe Volumn"); @@ -4890,7 +4892,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport result.setResult(stcGraph); } else if (statisticsType.equals("Sample_Volumn")) { List statisticsData = - spectrumAnalysisMapper.statisticsQuerySampleVolumn(start, end, + spectrumAnalysisMapper.statisticsQuerySampleVolumn(startDate, endDate, detectorIdList); StcGraph stcGraph = new StcGraph(); stcGraph.setM_strGraphName("Sample Volumn"); @@ -6665,17 +6667,14 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport info.setSampleId(betaDataFile.getSampleId()); info.setSampleType(betaDataFile.getSampleStruct().system_type); info.setSampleName(betaDataFile.getSampleFileName()); - final Instant instant = DateUtils.parseDate( + Date collectTime = DateUtils.parseDate( betaDataFile.getSampleStruct().collection_start_date + StringPool.SPACE + - betaDataFile.getSampleStruct().collection_start_time).toInstant(); - final LocalDateTime collectTime = - instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); + betaDataFile.getSampleStruct().collection_start_time); info.setCollectionDate(collectTime); - - final Instant instantStop = DateUtils.parseDate( + Date collectStopTime = DateUtils.parseDate( betaDataFile.getSampleStruct().collection_stop_date + StringPool.SPACE + - betaDataFile.getSampleStruct().collection_stop_time).toInstant(); - info.setCollectStop(Date.from(instantStop)); + betaDataFile.getSampleStruct().collection_stop_time); + info.setCollectStop(collectStopTime); info.setDatasource(DSType.ARMDRRR.getType()); info.setFullOrPrel(betaDataFile.getSampleStruct().spectrum_quantity); info.setBetaOrGamma(SpectrumType.BETA.getType()); @@ -8976,8 +8975,12 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport List> thresholdValues = spectrumAnalysisMapper.selectThresholdDataBySampleId(schemaName, sampleId); //获取阈值历史信息 - LocalDateTime startTime = LocalDateTime.now().minusYears(1); - LocalDateTime endTime = LocalDateTime.now(); + Date startTime = Date.from( + LocalDateTime.now().minusYears(1).atZone(ZoneId.systemDefault()) + .toInstant()); + Date endTime = + Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()); + List thresholdHistoryValues = spectrumAnalysisMapper.selectThresholdHistoryBySampleId(schemaName, sampleId, startTime); diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/GardsSampleDataWebMapper.java b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/GardsSampleDataWebMapper.java index 34a61779..c62e5f69 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/GardsSampleDataWebMapper.java +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/GardsSampleDataWebMapper.java @@ -7,26 +7,33 @@ import org.apache.ibatis.annotations.Param; import org.jeecg.modules.entity.GardsSampleDataWeb; import org.jeecg.modules.entity.vo.SpectrumFileRecord; +import java.util.Date; import java.util.List; import java.util.Map; @Mapper public interface GardsSampleDataWebMapper extends BaseMapper { - Page findAutoPage(String startDate, String endDate, List stationIdList, String qualifie, String sampleType, Page page); + Page findAutoPage(@Param("startDate") Date startDate, + @Param("endDate") Date endDate, + List stationIdList, String qualifie, + String sampleType, Page page); - Page findReviewedPage(String startDate, String endDate, List stationIdList, String qualifie, Page page); - - Page findParticulatePage(String dataType, String spectralQualifie, String startDate, String endDate, List stationIdList, Page page); + Page findReviewedPage(@Param("startDate") Date startDate, + @Param("endDate") Date endDate, + List stationIdList, String qualifie, + Page page); Integer getAnalysisID(@Param(value = "sampleId") Integer sampleId); 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> findNuclideStatistics(@Param(value = "stationId") String stationId, @Param(value = "startTime") String startTime, @Param(value = "endTime") String endTime, @Param(value = "nuclideSql") String nuclideSql); + List> findNuclideStatistics(@Param(value = "stationId") String stationId, + @Param(value = "startTime") Date startTime, + @Param(value = "endTime") Date endTime, + @Param(value = "nuclideSql") String nuclideSql); } diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/xml/GardsSampleDataWebMapper.xml b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/xml/GardsSampleDataWebMapper.xml index 55a472d6..0126ad3a 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/xml/GardsSampleDataWebMapper.xml +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/mapper/xml/GardsSampleDataWebMapper.xml @@ -28,12 +28,12 @@ ORIGINAL.GARDS_SAMPLE_DATA sam INNER JOIN RNAUTO.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID - sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') - and sam.COLLECT_STOP <= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') - - and sam.STATION_ID in ('') + sam.COLLECT_START >= #{startDate} + AND sam.COLLECT_STOP <= #{endDate} + + AND 1 = 0 - + and sam.STATION_ID in #{stationId} @@ -75,13 +75,13 @@ ORIGINAL.GARDS_SAMPLE_DATA sam INNER JOIN RNMAN.GARDS_ANALYSES ana on ana.SAMPLE_ID = sam.SAMPLE_ID - sam.COLLECT_START >= TO_DATE(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') - AND sam.COLLECT_STOP <= TO_DATE(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') + sam.COLLECT_START >= #{startDate} + AND sam.COLLECT_STOP <= #{endDate} AND ana.REPORT_PAHT IS NOT NULL - - and sam.STATION_ID in ('') + + AND 1 = 0 - + and sam.STATION_ID in #{stationId} @@ -166,11 +166,11 @@ FROM ORIGINAL.GARDS_SAMPLE_DATA org_sample_data 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.SPECTRAL_QUALIFIE='FULL' - AND qc_samples.ACQUISITION_START <= TO_DATE('${collectStartStr}', 'YYYY-MM-DD hh24:mi:ss')) - AND org_sample_data.SITE_DET_CODE= '${siteDetCode}' + AND qc_samples.ACQUISITION_START <= #{startTime}) + AND org_sample_data.SITE_DET_CODE= #{siteDetCode} diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/AutoServiceImpl.java b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/AutoServiceImpl.java index b6b7dd2a..2b8308c5 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/AutoServiceImpl.java +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/AutoServiceImpl.java @@ -2,10 +2,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; 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.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 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.jeecg.common.api.QueryRequest; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.ExportUtil; import org.jeecg.common.util.RedisUtil; 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.mapper.GardsAnalysesAutoMapper; import org.jeecg.modules.mapper.GardsSampleDataWebMapper; -import org.jeecg.modules.mapper.GardsSampleDataWebPostgresMapper; import org.jeecg.modules.service.IAutoService; import org.jeecg.modules.service.IGardsSampleDataWebService; 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.stereotype.Service; -import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletResponse; -import javax.sql.DataSource; import java.io.IOException; 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.stream.Collectors; @@ -49,23 +44,8 @@ public class AutoServiceImpl extends ServiceImpl stationIdList; if (Objects.isNull(stationIds)) { stationIdList = new LinkedList<>(); @@ -91,16 +82,8 @@ public class AutoServiceImpl extends ServiceImpl page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); Page sampleDataPage = - new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); - if (databaseType == DbType.POSTGRE_SQL) { - sampleDataPage = - gardsSampleDataWebPostgresMapper.findAutoPage(startDate, endDate, stationIdList, - qualifie, sampleType, page); - } else if (databaseType == DbType.ORACLE) { - sampleDataPage = - gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList, - qualifie, sampleType, page); - } + gardsSampleDataWebMapper.findAutoPage(startDate, endDate, stationIdList, + qualifie, sampleType, page); sampleDataPage.getRecords().forEach(item -> { item.setSiteDetCode(StringUtils.trim(item.getSiteDetCode())); diff --git a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataWebServiceImpl.java b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataWebServiceImpl.java index c8583163..2708027b 100644 --- a/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataWebServiceImpl.java +++ b/jeecg-module-web-statistics/src/main/java/org/jeecg/modules/service/impl/GardsSampleDataWebServiceImpl.java @@ -47,13 +47,18 @@ import java.io.*; import java.net.URLEncoder; import java.sql.SQLException; import java.text.ParseException; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.util.*; import static org.jeecg.modules.base.enums.PageType.*; @Service("gardsSampleDataWebService") @DS("ora") -public class GardsSampleDataWebServiceImpl extends ServiceImpl implements IGardsSampleDataWebService { +public class GardsSampleDataWebServiceImpl + extends ServiceImpl + implements IGardsSampleDataWebService { @Autowired private RedisUtil redisUtil; @@ -70,48 +75,40 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl stationMap = (Map)redisUtil.get("stationMap"); + Map stationMap = (Map) redisUtil.get("stationMap"); if (StringUtils.isBlank(dataType)) { result.error500("The data type cannot be empty"); return result; } - if (Objects.isNull(startTime)){ + if (Objects.isNull(startTime)) { result.error500("The start time cannot be empty"); return result; } - if (Objects.isNull(endTime)){ + if (Objects.isNull(endTime)) { result.error500("The end time cannot be empty"); return result; } - if (Objects.isNull(stationIds)){ + if (Objects.isNull(stationIds)) { result.setSuccess(true); result.setResult(Collections.emptyList()); return result; } - Date startDate = DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss"); - Date endDate = DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss"); + Date startDate = + DateUtils.parseDate(DateUtils.formatDate(startTime, "yyyy-MM-dd") + " 00:00:00", + "yyyy-MM-dd HH:mm:ss"); + Date endDate = + DateUtils.parseDate(DateUtils.formatDate(endTime, "yyyy-MM-dd") + " 23:59:59", + "yyyy-MM-dd HH:mm:ss"); //声明page - Page page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); + Page page = + new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); //声明Lambda 传递参数进行条件查询 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(GardsSampleDataWeb::getDataType, dataType); @@ -120,17 +117,19 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl sampleDataPage = this.baseMapper.selectPage(page, queryWrapper); - sampleDataPage.getRecords().forEach(item->{ + Page sampleDataPage = + this.baseMapper.selectPage(page, queryWrapper); + sampleDataPage.getRecords().forEach(item -> { 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()); item.setStationName(stationName); } @@ -152,9 +151,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl stationMap = (Map)redisUtil.get("stationMap"); + Map stationMap = (Map) redisUtil.get("stationMap"); //根据sample_id查询sample_data内容 LambdaQueryWrapper sampleDataQueryWrapper = new LambdaQueryWrapper<>(); sampleDataQueryWrapper.eq(GardsSampleDataWeb::getSampleId, sampleId); GardsSampleDataWeb gardsSampleData = this.baseMapper.selectOne(sampleDataQueryWrapper); - if (Objects.nonNull(gardsSampleData) && CollectionUtils.isNotEmpty(stationMap)){ + if (Objects.nonNull(gardsSampleData) && CollectionUtils.isNotEmpty(stationMap)) { String stationName = stationMap.get(gardsSampleData.getStationId().toString()); gardsSampleData.setStationName(stationName); } @@ -359,61 +400,72 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl descriptionQueryWrapper = new LambdaQueryWrapper<>(); + LambdaQueryWrapper descriptionQueryWrapper = + new LambdaQueryWrapper<>(); descriptionQueryWrapper.eq(GardsSampleDescription::getSampleId, sampleId); - GardsSampleDescription gardsSampleDescription = gardsSampleDescriptionMapper.selectOne(descriptionQueryWrapper); - if (Objects.nonNull(gardsSampleData)){ + GardsSampleDescription gardsSampleDescription = + gardsSampleDescriptionMapper.selectOne(descriptionQueryWrapper); + if (Objects.nonNull(gardsSampleData)) { acquisition = new Acquisition(); //封装数据内容 - if (StringUtils.isNotBlank(gardsSampleData.getStationName())){ + if (StringUtils.isNotBlank(gardsSampleData.getStationName())) { generalInformation.setSiteCode(gardsSampleData.getStationName()); } - if (StringUtils.isNotBlank(gardsSampleData.getSiteDetCode())){ + if (StringUtils.isNotBlank(gardsSampleData.getSiteDetCode())) { generalInformation.setDetectorCode(gardsSampleData.getSiteDetCode()); } - if (StringUtils.isNotBlank(gardsSampleData.getSampleType())){ + if (StringUtils.isNotBlank(gardsSampleData.getSampleType())) { generalInformation.setSystemType(gardsSampleData.getSampleType()); } - if (StringUtils.isNotBlank(gardsSampleData.getGeometry())){ + if (StringUtils.isNotBlank(gardsSampleData.getGeometry())) { generalInformation.setSampleGeometry(gardsSampleData.getGeometry()); } - if (StringUtils.isNotBlank(gardsSampleData.getSpectralQualifie())){ + if (StringUtils.isNotBlank(gardsSampleData.getSpectralQualifie())) { generalInformation.setSpectrumQualifier(gardsSampleData.getSpectralQualifie()); } - if (Objects.nonNull(gardsSampleData.getTransmitDtg())){ - generalInformation.setTransmitDate(DateUtils.formatDate(gardsSampleData.getTransmitDtg(), "yyyy-MM-dd HH:mm:ss")); + if (Objects.nonNull(gardsSampleData.getTransmitDtg())) { + generalInformation.setTransmitDate( + DateUtils.formatDate(gardsSampleData.getTransmitDtg(), + "yyyy-MM-dd HH:mm:ss")); } - if (Objects.nonNull(gardsSampleData.getAcquisitionStart())){ - acquisition.setAcquisitionStartDate(DateUtils.formatDate(gardsSampleData.getAcquisitionStart(), "yyyy-MM-dd HH:mm:ss")); + if (Objects.nonNull(gardsSampleData.getAcquisitionStart())) { + acquisition.setAcquisitionStartDate( + DateUtils.formatDate(gardsSampleData.getAcquisitionStart(), + "yyyy-MM-dd HH:mm:ss")); } - if (Objects.nonNull(gardsSampleData.getAcquisitionRealSec())){ + if (Objects.nonNull(gardsSampleData.getAcquisitionRealSec())) { acquisition.setAcquisitionRealTime(gardsSampleData.getAcquisitionRealSec()); } - if (Objects.nonNull(gardsSampleData.getAcquisitionLiveSec())){ + if (Objects.nonNull(gardsSampleData.getAcquisitionLiveSec())) { acquisition.setAcquisitionLiveTime(gardsSampleData.getAcquisitionLiveSec()); } } - if (Objects.nonNull(gardsSampleAux)){ + if (Objects.nonNull(gardsSampleAux)) { calibration = new Calibration(); - if (StringUtils.isNotBlank(gardsSampleAux.getSampleRefId())){ - generalInformation.setSampleReferenceIdentification(gardsSampleAux.getSampleRefId()); + if (StringUtils.isNotBlank(gardsSampleAux.getSampleRefId())) { + generalInformation.setSampleReferenceIdentification( + gardsSampleAux.getSampleRefId()); } - if (StringUtils.isNotBlank(gardsSampleAux.getMeasurementId())){ + if (StringUtils.isNotBlank(gardsSampleAux.getMeasurementId())) { generalInformation.setMeasurementIdentification(gardsSampleAux.getMeasurementId()); } - if (StringUtils.isNotBlank(gardsSampleAux.getBkgdMeasurementId())){ - generalInformation.setDetectorBackgroundMeasurementId(gardsSampleAux.getBkgdMeasurementId()); + if (StringUtils.isNotBlank(gardsSampleAux.getBkgdMeasurementId())) { + generalInformation.setDetectorBackgroundMeasurementId( + gardsSampleAux.getBkgdMeasurementId()); } - if (StringUtils.isNotBlank(gardsSampleAux.getGasBkgdMeasurementId())){ - generalInformation.setGasBackgroundMeasurementId(gardsSampleAux.getGasBkgdMeasurementId()); + if (StringUtils.isNotBlank(gardsSampleAux.getGasBkgdMeasurementId())) { + generalInformation.setGasBackgroundMeasurementId( + gardsSampleAux.getGasBkgdMeasurementId()); } - if (Objects.nonNull(gardsSampleAux.getCalibrationDtg())){ - calibration.setDateOfLastCalibration(DateUtils.formatDate(gardsSampleAux.getCalibrationDtg(), "yyyy-MM-dd HH:mm:ss")); + if (Objects.nonNull(gardsSampleAux.getCalibrationDtg())) { + calibration.setDateOfLastCalibration( + DateUtils.formatDate(gardsSampleAux.getCalibrationDtg(), + "yyyy-MM-dd HH:mm:ss")); } } - if (Objects.nonNull(gardsSampleDescription)){ + if (Objects.nonNull(gardsSampleDescription)) { comment = new Comment(); - if (StringUtils.isNotBlank(gardsSampleDescription.getDescription())){ + if (StringUtils.isNotBlank(gardsSampleDescription.getDescription())) { comment.setText(gardsSampleDescription.getDescription()); } } @@ -431,9 +483,11 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigMapper.selectList(calibrationPairsOrigQueryWrapper); // gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigs.stream().filter(item->item.getCaltype().trim().equals("energy")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sourceData.g_energy) && CollectionUtils.isNotEmpty(sourceData.g_centroid_channel) && CollectionUtils.isNotEmpty(sourceData.g_uncertainty)){ + if (CollectionUtils.isNotEmpty(sourceData.g_energy) && + CollectionUtils.isNotEmpty(sourceData.g_centroid_channel) && + CollectionUtils.isNotEmpty(sourceData.g_uncertainty)) { gEnergySubBlock = new LinkedList<>(); - for (int i=0; i gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigMapper.selectList(calibrationPairsOrigQueryWrapper); // gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigs.stream().filter(item->item.getCaltype().trim().equals("energy")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sourceData.b_electron_energy) && CollectionUtils.isNotEmpty(sourceData.b_channel) && CollectionUtils.isNotEmpty(sourceData.b_uncertainty) && CollectionUtils.isNotEmpty(sourceData.b_decay_mode)){ + if (CollectionUtils.isNotEmpty(sourceData.b_electron_energy) && + CollectionUtils.isNotEmpty(sourceData.b_channel) && + CollectionUtils.isNotEmpty(sourceData.b_uncertainty) && + CollectionUtils.isNotEmpty(sourceData.b_decay_mode)) { bEnergySubBlock = new LinkedList<>(); - for (int i=0; i gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigMapper.selectList(calibrationPairsOrigQueryWrapper); // gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigs.stream().filter(item->item.getCaltype().trim().equals("Resolution")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sourceData.g_r_energy) && CollectionUtils.isNotEmpty(sourceData.g_r_FWHM) && CollectionUtils.isNotEmpty(sourceData.g_r_uncertainty)){ + if (CollectionUtils.isNotEmpty(sourceData.g_r_energy) && + CollectionUtils.isNotEmpty(sourceData.g_r_FWHM) && + CollectionUtils.isNotEmpty(sourceData.g_r_uncertainty)) { gResolutionSubBlock = new LinkedList<>(); - for (int i=0; i gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigMapper.selectList(calibrationPairsOrigQueryWrapper); // gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigs.stream().filter(item->item.getCaltype().trim().equals("Resolution")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sourceData.b_r_electron_energy) && CollectionUtils.isNotEmpty(sourceData.b_r_FWHM) && CollectionUtils.isNotEmpty(sourceData.b_r_uncertainty)){ + if (CollectionUtils.isNotEmpty(sourceData.b_r_electron_energy) && + CollectionUtils.isNotEmpty(sourceData.b_r_FWHM) && + CollectionUtils.isNotEmpty(sourceData.b_r_uncertainty)) { bResolutionSubBlock = new LinkedList<>(); - for (int i=0; i gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigMapper.selectList(calibrationPairsOrigQueryWrapper); // gardsCalibrationPairsOrigs = gardsCalibrationPairsOrigs.stream().filter(item->item.getCaltype().trim().equals("efficiency")).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(sourceData.g_e_energy) && CollectionUtils.isNotEmpty(sourceData.g_e_efficiency) && CollectionUtils.isNotEmpty(sourceData.g_e_uncertainty)){ + if (CollectionUtils.isNotEmpty(sourceData.g_e_energy) && + CollectionUtils.isNotEmpty(sourceData.g_e_efficiency) && + CollectionUtils.isNotEmpty(sourceData.g_e_uncertainty)) { gEfficiencySubBlock = new LinkedList<>(); - for (int i=0; i bgEfficiencyPairsQueryWrapper = new LambdaQueryWrapper<>(); // bgEfficiencyPairsQueryWrapper.eq(GardsBgEfficiencyPairs::getSampleId, sampleId); // List gardsBgEfficiencyPairs = gardsBgEfficiencyPairsMapper.selectList(bgEfficiencyPairsQueryWrapper); - if (CollectionUtils.isNotEmpty(sourceData.bg_ROI_number) && CollectionUtils.isNotEmpty(sourceData.bg_nuclide_name) && CollectionUtils.isNotEmpty(sourceData.bg_efficiency) && CollectionUtils.isNotEmpty(sourceData.bg_uncertainty)){ + if (CollectionUtils.isNotEmpty(sourceData.bg_ROI_number) && + CollectionUtils.isNotEmpty(sourceData.bg_nuclide_name) && + CollectionUtils.isNotEmpty(sourceData.bg_efficiency) && + CollectionUtils.isNotEmpty(sourceData.bg_uncertainty)) { bgEfficiencySubBlock = new LinkedList<>(); - for (int i=0; i gardsRoiLimitsList = gardsRoiLimitsMapper.selectList(roiLimitsQueryWrapper); - if (CollectionUtils.isNotEmpty(sourceData.ROI_number) && CollectionUtils.isNotEmpty(sourceData.POI_B_x1) && CollectionUtils.isNotEmpty(sourceData.POI_B_x2) && CollectionUtils.isNotEmpty(sourceData.POI_G_y1) && CollectionUtils.isNotEmpty(sourceData.POI_G_y2)){ + if (CollectionUtils.isNotEmpty(sourceData.ROI_number) && + CollectionUtils.isNotEmpty(sourceData.POI_B_x1) && + CollectionUtils.isNotEmpty(sourceData.POI_B_x2) && + CollectionUtils.isNotEmpty(sourceData.POI_G_y1) && + CollectionUtils.isNotEmpty(sourceData.POI_G_y2)) { roiLimitsSubBlock = new LinkedList<>(); - for (int i=0; i sampleRatiosList = gardsSampleRatiosMapper.selectList(ratiosQueryWrapper); - if (CollectionUtils.isNotEmpty(sourceData.count_ratio) && CollectionUtils.isNotEmpty(sourceData.ratio_id) && CollectionUtils.isNotEmpty(sourceData.count_ratio_uncertainty) && CollectionUtils.isNotEmpty(sourceData.ROI_num_lower_G_energy_ROI) && CollectionUtils.isNotEmpty(sourceData.ROI_num_highter_G_energy_ROI)){ + if (CollectionUtils.isNotEmpty(sourceData.count_ratio) && + CollectionUtils.isNotEmpty(sourceData.ratio_id) && + CollectionUtils.isNotEmpty(sourceData.count_ratio_uncertainty) && + CollectionUtils.isNotEmpty(sourceData.ROI_num_lower_G_energy_ROI) && + CollectionUtils.isNotEmpty(sourceData.ROI_num_highter_G_energy_ROI)) { ratiosSubBlock = new LinkedList<>(); - for (int i=0; i map = readLineUtil.readLine(gardsSpectrum.getFilename(), SampleFileHeader.GSPECTRUM.getMessage()); // List gSpectrumSubBlock = new LinkedList<>(); @@ -604,10 +680,10 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl)map.get(SampleFileHeader.GSPECTRUM.getMessage()); // } gSpectrumBlock.setGSpectrumSubBlock(sourceData.g_counts); - if (Objects.nonNull(sourceData.g_energy_span)){ + if (Objects.nonNull(sourceData.g_energy_span)) { gSpectrumBlock.setEnergySpan(sourceData.g_energy_span); } - if (Objects.nonNull(sourceData.num_g_channel)){ + if (Objects.nonNull(sourceData.num_g_channel)) { gSpectrumBlock.setNumberGChannels(sourceData.num_g_channel); } } @@ -620,7 +696,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl map = readLineUtil.readLine(gardsSpectrum.getFilename(), SampleFileHeader.BSPECTRUM.getMessage()); // List bSpectrumSubBlock = new LinkedList<>(); @@ -628,10 +704,10 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl)map.get(SampleFileHeader.BSPECTRUM.getMessage()); // } bSpectrumBlock.setBSpectrumSubBlock(sourceData.b_counts); - if (Objects.nonNull(sourceData.b_energy_span)){ + if (Objects.nonNull(sourceData.b_energy_span)) { bSpectrumBlock.setEnergySpan(sourceData.b_energy_span); } - if (Objects.nonNull(sourceData.num_b_channel)){ + if (Objects.nonNull(sourceData.num_b_channel)) { bSpectrumBlock.setNumberBChannels(sourceData.num_b_channel); } } @@ -643,7 +719,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl histogramQueryWrapper = new LambdaQueryWrapper<>(); // histogramQueryWrapper.eq(GardsHistogram::getSampleId, sampleId); // GardsHistogram gardsHistogram = gardsHistogramMapper.selectOne(histogramQueryWrapper); - if (CollectionUtils.isNotEmpty(sourceData.h_counts)){ + if (CollectionUtils.isNotEmpty(sourceData.h_counts)) { histogramBlock = new Histogram(); List histogramSubBlock = readValue(sourceData); // Map map = readLineUtil.readLine(gardsHistogram.getFilename(), SampleFileHeader.HISTOGRAM.getMessage()); @@ -652,16 +728,16 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl)map.get(SampleFileHeader.HISTOGRAM.getMessage()); // } histogramBlock.setHistogramSubBlock(histogramSubBlock); - if (Objects.nonNull(sourceData.b_channels)){ + if (Objects.nonNull(sourceData.b_channels)) { histogramBlock.setBChannels(sourceData.b_channels); } - if (Objects.nonNull(sourceData.b_h_energy_span)){ + if (Objects.nonNull(sourceData.b_h_energy_span)) { histogramBlock.setBEnergySpan(sourceData.b_h_energy_span); } - if (Objects.nonNull(sourceData.g_channels)){ + if (Objects.nonNull(sourceData.g_channels)) { histogramBlock.setGChannels(sourceData.g_channels); } - if (Objects.nonNull(sourceData.g_h_energy_span)){ + if (Objects.nonNull(sourceData.g_h_energy_span)) { histogramBlock.setGEnergySpan(sourceData.g_h_energy_span); } } @@ -674,32 +750,45 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl sampleCertLineQueryWrapper = new LambdaQueryWrapper<>(); // sampleCertLineQueryWrapper.eq(GardsSampleCertLine::getSampleId, sampleId); // List gardsSampleCertLines = gardsSampleCertLineMapper.selectList(sampleCertLineQueryWrapper); - if (CollectionUtils.isNotEmpty(sourceData.nuclide_name) && CollectionUtils.isNotEmpty(sourceData.half_life_time) && CollectionUtils.isNotEmpty(sourceData.activity_nuclide_time_assay) - && CollectionUtils.isNotEmpty(sourceData.uncertainty) && CollectionUtils.isNotEmpty(sourceData.cer_g_energy) && CollectionUtils.isNotEmpty(sourceData.g_intensity) - && CollectionUtils.isNotEmpty(sourceData.electron_decay_mode) && CollectionUtils.isNotEmpty(sourceData.maximum_energy) && CollectionUtils.isNotEmpty(sourceData.intensity_b_particle)) { - if (Objects.isNull(certificateBlock)){ + if (CollectionUtils.isNotEmpty(sourceData.nuclide_name) && + CollectionUtils.isNotEmpty(sourceData.half_life_time) && + CollectionUtils.isNotEmpty(sourceData.activity_nuclide_time_assay) + && CollectionUtils.isNotEmpty(sourceData.uncertainty) && + CollectionUtils.isNotEmpty(sourceData.cer_g_energy) && + CollectionUtils.isNotEmpty(sourceData.g_intensity) + && CollectionUtils.isNotEmpty(sourceData.electron_decay_mode) && + CollectionUtils.isNotEmpty(sourceData.maximum_energy) && + CollectionUtils.isNotEmpty(sourceData.intensity_b_particle)) { + if (Objects.isNull(certificateBlock)) { certificateBlock = new Certificate(); } List certificateSubBlock = new LinkedList<>(); - for (int i=0; i readValue(EnergySpectrumStruct sourceData) { List result = new LinkedList<>(); - if (CollectionUtils.isNotEmpty(sourceData.h_counts) && Objects.nonNull(sourceData.g_channels) && Objects.nonNull(sourceData.b_channels)) { - for (int i=0; i subList = sourceData.h_counts.subList((int) (i * sourceData.b_channels), (int) ((i + 1) * sourceData.b_channels)); - if (!"0".equals(String.valueOf(subList.get(j)))){ + if (CollectionUtils.isNotEmpty(sourceData.h_counts) && + Objects.nonNull(sourceData.g_channels) && Objects.nonNull(sourceData.b_channels)) { + for (int i = 0; i < sourceData.g_channels; i++) { + for (int j = 0; j < sourceData.b_channels; j++) { + List subList = + sourceData.h_counts.subList((int) (i * sourceData.b_channels), + (int) ((i + 1) * sourceData.b_channels)); + if (!"0".equals(String.valueOf(subList.get(j)))) { HistogramData histogramData = new HistogramData(); histogramData.setG(i); histogramData.setB(j); @@ -734,7 +826,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(GardsSampleDataWeb::getSampleId,sampleId); + wrapper.eq(GardsSampleDataWeb::getSampleId, sampleId); return Optional.ofNullable(getOne(wrapper)).orElse(new GardsSampleDataWeb()); } @@ -748,10 +840,10 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl commonFiled = ListUtil - .toList("no","stationName","siteDetCode","spectralQualifie"); + .toList("no", "stationName", "siteDetCode", "spectralQualifie"); // 根据页面类型导出不同列字段的Execl文档 ExportParams params = new ExportParams(); params.setSheetName("Radionuclide"); @@ -796,34 +888,37 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl listBySampleIds(Integer[] stationIds, - String startTime, - String endTime, - List sampleIds) { + String startTime, + String endTime, + List sampleIds) { Date startDate = DateUtil - .parse(startTime + " 00:00:00","yyyy-MM-dd HH:mm:ss") + .parse(startTime + " 00:00:00", "yyyy-MM-dd HH:mm:ss") .toJdkDate(); Date endDate = DateUtil - .parse(endTime + " 23:59:59","yyyy-MM-dd HH:mm:ss") + .parse(endTime + " 23:59:59", "yyyy-MM-dd HH:mm:ss") .toJdkDate(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(GardsSampleDataWeb::getStationId, stationIds); @@ -849,14 +944,14 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl sampleData = this.list(wrapper); // 获取redis中缓存的台站信息 - Map stationMap = (Map)redisUtil.get("stationMap"); + Map stationMap = (Map) redisUtil.get("stationMap"); int no = 1; boolean emptyMap = MapUtil.isEmpty(stationMap); for (GardsSampleDataWeb sampleDatum : sampleData) { sampleDatum.setNo(no++); String stationId = sampleDatum.getStationId().toString(); - boolean hasKey = emptyMap ? false : stationMap.containsKey(stationId) ; - if (hasKey){ + boolean hasKey = emptyMap ? false : stationMap.containsKey(stationId); + if (hasKey) { String stationName = stationMap.get(stationId); sampleDatum.setStationName(stationName); } @@ -892,25 +987,39 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl resultMap = new HashMap<>(); //从redis中获取台站信息 - Map stationMap = (Map)redisUtil.get("stationMap"); + Map stationMap = (Map) redisUtil.get("stationMap"); //判断开始时间是否为空 - if (Objects.isNull(startDate)){ + if (Objects.isNull(startDate)) { result.error500("The start time cannot be empty"); return result; } - String startTime = DateUtils.formatDate(startDate, "yyyy-MM-dd") + " 00:00:00"; //判断结束时间是否为空 if (Objects.isNull(endDate)) { result.error500("The end time cannot be empty"); return result; } - String endTime = DateUtils.formatDate(endDate, "yyyy-MM-dd") + " 23:59:59"; - List allDayTime = DateUtils.getAllDay(DateUtils.formatDate(startDate, "yyyy-MM-dd"), DateUtils.formatDate(endDate, "yyyy-MM-dd")); + // 开始时间:当天零点 + LocalDateTime startLdt = startDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) // 北京时间 + .toLocalDate() + .atStartOfDay(); + Date startTime = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); + + // 结束时间:23:59:59.999 + LocalDateTime endLdt = endDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) + .toLocalDate() + .atTime(LocalTime.of(23, 59, 59, 999_000_000)); + Date endTime = Date.from(endLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); + + List allDayTime = DateUtils.getAllDay(DateUtils.formatDate(startDate, "yyyy-MM-dd"), + DateUtils.formatDate(endDate, "yyyy-MM-dd")); //判断查询的核素内容是否为空 List nuclideNameList = new LinkedList<>(); if (nuclideNames != null && nuclideNames.length > 0) { @@ -926,40 +1035,40 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl concList = new LinkedList<>(); List mdcList = new LinkedList<>(); - resultMap.put(nuclideName+"Conc", concList); - resultMap.put(nuclideName+"MDC", mdcList); + resultMap.put(nuclideName + "Conc", concList); + resultMap.put(nuclideName + "MDC", mdcList); } } } else if (systemType.equals("gamma")) { nuclideSql = gammaNuclideSql(dbName, nuclideNameList); - for (int i=0; i< nuclideNameList.size(); i++) { + for (int i = 0; i < nuclideNameList.size(); i++) { String nuclideName = nuclideNameList.get(i); if (StringUtils.isNotBlank(nuclideName)) { List concList = new LinkedList<>(); List mdcList = new LinkedList<>(); - resultMap.put(nuclideName+"Conc", concList); - resultMap.put(nuclideName+"MDC", mdcList); + resultMap.put(nuclideName + "Conc", concList); + resultMap.put(nuclideName + "MDC", mdcList); } } } else if (systemType.equals("Particulate")) { nuclideSql = particulateSql(dbName, nuclideNameList); - for (int i=0; i< nuclideNameList.size(); i++) { + for (int i = 0; i < nuclideNameList.size(); i++) { String nuclideName = nuclideNameList.get(i); if (StringUtils.isNotBlank(nuclideName)) { List concList = new LinkedList<>(); - resultMap.put(nuclideName+"Conc", concList); + resultMap.put(nuclideName + "Conc", concList); List mdcList = new LinkedList<>(); - resultMap.put(nuclideName+"MDC", mdcList); + resultMap.put(nuclideName + "MDC", mdcList); } } } //拼接sql查询结果 - List> nuclideStatisticsMap =databaseType==DbType.POSTGRE_SQL?postgresMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql): + List> nuclideStatisticsMap = this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql); //处理查询结果 handleNuclideData(nuclideStatisticsMap, systemType, nuclideNameList, allDayTime, resultMap); @@ -972,20 +1081,33 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl>> resultMap = new HashMap<>(); //从redis中获取台站信息 - Map stationMap = (Map)redisUtil.get("stationMap"); + Map stationMap = (Map) redisUtil.get("stationMap"); //判断开始时间是否为空 - if (Objects.isNull(startDate)){ + if (Objects.isNull(startDate)) { return; } - String startTime = DateUtils.formatDate(startDate, "yyyy-MM-dd") + " 00:00:00"; //判断结束时间是否为空 if (Objects.isNull(endDate)) { return; } - String endTime = DateUtils.formatDate(endDate, "yyyy-MM-dd") + " 23:59:59"; + // 开始时间:当天零点 + LocalDateTime startLdt = startDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) // 北京时间 + .toLocalDate() + .atStartOfDay(); + Date startTime = Date.from(startLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); + + // 结束时间:23:59:59.999 + LocalDateTime endLdt = endDate.toInstant() + .atZone(ZoneId.of("Asia/Shanghai")) + .toLocalDate() + .atTime(LocalTime.of(23, 59, 59, 999_000_000)); + Date endTime = Date.from(endLdt.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); //判断查询的核素内容是否为空 List nuclideNameList = new LinkedList<>(); if (nuclideNames != null && nuclideNames.length > 0) { @@ -1013,7 +1135,7 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl stationNameList = new LinkedList<>(); - for (String stationId:stationIds) { + for (String stationId : stationIds) { //返回台站名称 String stationName = stationMap.get(stationId); //拼接sql查询结果 - List> nuclideStatisticsMap =databaseType==DbType.POSTGRE_SQL?postgresMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql): - this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, nuclideSql); + List> nuclideStatisticsMap = + this.baseMapper.findNuclideStatistics(stationId, startTime, endTime, + nuclideSql); resultMap.put(stationName, nuclideStatisticsMap); //添加台站名称到集合 stationNameList.add(stationName); @@ -1084,17 +1207,19 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl nuclideSqls = new LinkedList<>(); //遍历核素名称拼接sql语句 - for (int i=0; i nuclideSqls = new LinkedList<>(); //遍历核素名称 - for (int i=0; i nuclideSqls = new LinkedList<>(); //遍历核素信息 - for (int i=0; i> nuclideStatisticsMap, String systemType, List nuclideNameList, List allDateTime, Map resultMap) { + private void handleNuclideData(List> nuclideStatisticsMap, + String systemType, List nuclideNameList, + List allDateTime, Map resultMap) { //存储横坐标采集开始时间 List collectStartList = new LinkedList<>(); //存储横坐标对应体积 @@ -1212,13 +1339,13 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl acqLiveSecList = new LinkedList<>(); //遍历日期时间 - for (int i=0; i< allDateTime.size(); i++) { + for (int i = 0; i < allDateTime.size(); i++) { //根据下标获取日期时间 String dayTime = allDateTime.get(i); //新增标识判断是否包含 可能存在一天有多条数据的情况 boolean isHave = false; //遍历查询结果数组 - for (int j=0; j< nuclideStatisticsMap.size(); j++) { + for (int j = 0; j < nuclideStatisticsMap.size(); j++) { //根据下标获取核素查询结果 Map nuclideStatistics = nuclideStatisticsMap.get(j); //获取采集开始时间 @@ -1248,16 +1375,19 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl concList = (List) resultMap.get(nuclideName + "Conc"); - List mdcList = (List) resultMap.get(nuclideName + "MDC"); + for (String nuclideName : nuclideNameList) { + List concList = + (List) resultMap.get(nuclideName + "Conc"); + List mdcList = + (List) resultMap.get(nuclideName + "MDC"); //将核素名称转为全部大写 String columnName = StringUtils.upperCase(nuclideName); //读取查询出的浓度 Object conc = nuclideStatistics.get(columnName); //判断如果浓度不为空 正常存储 if (Objects.nonNull(conc)) { - if (conc.toString().toLowerCase().contains("inf") || conc.toString().toLowerCase().contains("nan")) { + if (conc.toString().toLowerCase().contains("inf") || + conc.toString().toLowerCase().contains("nan")) { concList.add(null); } else { concList.add(Double.valueOf(conc.toString())); @@ -1269,7 +1399,8 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl concList = (List) resultMap.get(nuclideName + "Conc"); - List mdcList = (List) resultMap.get(nuclideName + "MDC"); + for (String nuclideName : nuclideNameList) { + List concList = + (List) resultMap.get(nuclideName + "Conc"); + List mdcList = + (List) resultMap.get(nuclideName + "MDC"); //将核素名称转为全部大写 String columnName = StringUtils.upperCase(nuclideName); //读取查询出的浓度 Object conc = nuclideStatistics.get(columnName); //判断如果浓度不为空 正常存储 if (Objects.nonNull(conc)) { - if (conc.toString().toLowerCase().contains("inf") || conc.toString().toLowerCase().contains("nan")) { + if (conc.toString().toLowerCase().contains("inf") || + conc.toString().toLowerCase().contains("nan")) { concList.add(null); } else { concList.add(Double.valueOf(conc.toString())); @@ -1300,7 +1434,8 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl concList = (List) resultMap.get(nuclideName + "Conc"); - List mdcList = (List) resultMap.get(nuclideName + "MDC"); + for (String nuclideName : nuclideNameList) { + List concList = + (List) resultMap.get(nuclideName + "Conc"); + List mdcList = + (List) resultMap.get(nuclideName + "MDC"); concList.add(null); mdcList.add(null); } } else if (systemType.equals("Particulate")) { - for (String nuclideName: nuclideNameList) { - List concList = (List) resultMap.get(nuclideName + "Conc"); - List mdcList = (List) resultMap.get(nuclideName + "MDC"); + for (String nuclideName : nuclideNameList) { + List concList = + (List) resultMap.get(nuclideName + "Conc"); + List mdcList = + (List) resultMap.get(nuclideName + "MDC"); concList.add(null); mdcList.add(null); } @@ -1343,5 +1482,4 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl implements IReviewedService { +public class ReviewedServiceImpl extends ServiceImpl + implements IReviewedService { @Autowired private IGardsSampleDataWebService gardsSampleDataService; @@ -49,8 +51,6 @@ public class ReviewedServiceImpl extends ServiceImpl stationMap = (Map)redisUtil.get("stationMap"); - if (Objects.isNull(startTime)){ + Map stationMap = (Map) redisUtil.get("stationMap"); + if (Objects.isNull(startTime)) { result.error500("The start time cannot be empty"); 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"); 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 stationIdList; - if (Objects.isNull(stationIds)){ + if (Objects.isNull(stationIds)) { stationIdList = new LinkedList<>(); - }else { + } else { stationIdList = Arrays.asList(stationIds); } - Page page = new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); - Page sampleDataPage =databaseType==DbType.POSTGRE_SQL?postgresMapper.findReviewedPage(startDate, endDate, stationIdList, qualifie, page): gardsSampleDataWebMapper.findReviewedPage(startDate, endDate, stationIdList, qualifie, page); - sampleDataPage.getRecords().forEach(item->{ + Page page = + new Page<>(queryRequest.getPageNo(), queryRequest.getPageSize()); + Page sampleDataPage = + gardsSampleDataWebMapper.findReviewedPage(startDate, endDate, stationIdList, + qualifie, page); + sampleDataPage.getRecords().forEach(item -> { 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()); item.setStationName(stationName); } @@ -102,7 +119,7 @@ public class ReviewedServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(GardsAnalyses::getSampleId,sampleId); + wrapper.eq(GardsAnalyses::getSampleId, sampleId); GardsAnalyses gardsAnalyses = getOne(wrapper); return Optional.ofNullable(gardsAnalyses) .orElse(new GardsAnalyses()); @@ -121,7 +138,9 @@ public class ReviewedServiceImpl extends ServiceImpl sampleData = gardsSampleDataService.listBySampleIds(stationIds, @@ -138,18 +157,20 @@ public class ReviewedServiceImpl extends ServiceImpl