From 135f4ebd21e2b44ef3f408674c016588cfe8c938 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Thu, 1 Aug 2024 11:04:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0beta=E8=B0=B1=20savetodb?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E=E7=BB=93?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/util/SelfStationUtil.java | 79 +++++++++++++++++++ .../service/impl/SelfStationServiceImpl.java | 34 ++++---- 2 files changed, 93 insertions(+), 20 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java index ddb57f0c..62670a25 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.google.common.cache.Cache; +import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.cache.SelfCache; import org.jeecg.modules.base.abstracts.AbstractLogOrReport; @@ -1025,4 +1026,82 @@ public class SelfStationUtil extends AbstractLogOrReport { } return phd; } + public HashMap DetailedInfo(Integer sampleId, String status, EnergySpectrumStruct struct) { + try { + HashMap detailedMap = Maps.newHashMap(); + //Data Type + String dataType = struct.data_type; + //Collection Start + Date CollectionStart = null; + if ( StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) ){ + CollectionStart = DateUtils.parseDate(struct.collection_start_date + StringPool.SPACE + struct.collection_start_time); + } + //Collection Stop + Date CollectionStop = null; + if ( StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) ){ + CollectionStop = DateUtils.parseDate(struct.collection_stop_date + StringPool.SPACE + struct.collection_stop_time); + } + //Collection Time + String CollectionTime = ""; + if ( Objects.nonNull(CollectionStart) && Objects.nonNull(CollectionStop) ){ + CollectionTime = String.format ("%.2f",Double.valueOf((CollectionStop.getTime() - CollectionStart.getTime())/ 1000)); + } + //Acquisition Start + Date AcquisitionStart = null; + if ( StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) ){ + AcquisitionStart = DateUtils.parseDate(struct.acquisition_start_date + StringPool.SPACE + struct.acquisition_start_time); + } + //Acq Real Time + double AcquisitionRealTime = struct.acquisition_real_time; + //Acq live Time + double AcquisitionLiveTime = struct.acquisition_live_time; + //Air Volume[m3] + double airVolume = struct.air_volume; + //Xe Volume[m3] + double xeVolume = struct.sample_volume_of_Xe; + //xeCollectionYield + double xeCollectionYield = struct.Xe_collection_yield; + //gasBkMeasurementId + String gasBkMeasurementId = struct.gas_bk_measurement_id; + //detectorBkMeasurementId + String detectorBkMeasurementId = struct.detector_bk_measurement_id; + //measurementId + String measurementId = struct.measurement_id; + detailedMap.put("sampleId", sampleId); + detailedMap.put("stationCode",struct.site_code); + detailedMap.put("detectorCode", struct.detector_code); + detailedMap.put("systemType", struct.system_type); + detailedMap.put("dataType", dataType); + detailedMap.put("spectralQualifier", struct.spectrum_quantity); + detailedMap.put("SRID", struct.sample_ref_id); + detailedMap.put("status", status); + detailedMap.put("collectionStart", CollectionStart); + detailedMap.put("collectionStop", CollectionStop); + detailedMap.put("collectionTime", CollectionTime); + double timeSpan = 0.0; + if (Objects.nonNull(CollectionStart) && Objects.nonNull(CollectionStop)) { + timeSpan = (CollectionStop.getTime()/1000 - CollectionStart.getTime()/1000) / 3600.0; + } + detailedMap.put("samplingTime", String.format("%.2f", timeSpan)); + detailedMap.put("airVolume", String.format("%.5f", airVolume)); + detailedMap.put("xeVolume", String.format("%.5f", xeVolume)); + detailedMap.put("yeild", xeCollectionYield); + detailedMap.put("detectorBkMeasurementId", detectorBkMeasurementId); + detailedMap.put("measurementId", measurementId); + detailedMap.put("acquisitionStart", AcquisitionStart); + detailedMap.put("acquisitionRealTime", String.format("%.2f", AcquisitionRealTime)); + detailedMap.put("acquisitionLiveTime", String.format("%.2f", AcquisitionLiveTime)); + double timespan = 0.0; + if (Objects.nonNull(AcquisitionStart) && Objects.nonNull(CollectionStop)) { + timespan = (AcquisitionStart.getTime()/1000 - CollectionStop.getTime()/1000); + } + detailedMap.put("acquisitionDecayTime", String.format("%.2f", timespan / 3600.0)); + // todo 分级暂时定为1 + detailedMap.put("category", "1"); + return detailedMap; + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java index b683ad51..17b07b7e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java @@ -4849,6 +4849,8 @@ public class SelfStationServiceImpl implements ISelfStationService { } //获取当前操作的台站的id EnergySpectrumStruct sampleStruct = selfStationData.getSampleStruct(); + EnergySpectrumStruct qcStruct = selfStationData.getQcStruct(); + EnergySpectrumStruct detStruct = selfStationData.getDetStruct(); String siteCode = sampleStruct.site_code; Integer stationId = spectrumAnalysisMapper.getStationId(siteCode); //判断当前分析员当天是否有对应台站的排班任务 @@ -5000,26 +5002,18 @@ public class SelfStationServiceImpl implements ISelfStationService { } Map map = new HashMap<>(); //更新detial Information - List detailedInfo = gammaFileUtil.DetailedInfo(sampleId.toString(), phd); - HashMap detailedMap = Maps.newHashMap(); - detailedMap.put("sampleId",detailedInfo.get(0)); - detailedMap.put("stationCode",detailedInfo.get(1)); - detailedMap.put("detectorCode",detailedInfo.get(2)); - detailedMap.put("systemType",detailedInfo.get(3)); - detailedMap.put("dataType",detailedInfo.get(4)); - detailedMap.put("spectralQualifier",detailedInfo.get(5)); - detailedMap.put("SRID",detailedInfo.get(6)); - detailedMap.put("sampleStatus",detailedInfo.get(7)); - detailedMap.put("collectStart",detailedInfo.get(8)); - detailedMap.put("samplingTime",detailedInfo.get(9)); - detailedMap.put("airVolume",detailedInfo.get(10)); - detailedMap.put("flowRate",detailedInfo.get(11)); - detailedMap.put("acquisitionStart",detailedInfo.get(12)); - detailedMap.put("acquisitionRealTime",detailedInfo.get(13)); - detailedMap.put("acquisitionLiveTime",detailedInfo.get(14)); - detailedMap.put("acquisitionDecayTime",detailedInfo.get(15)); - detailedMap.put("category",detailedInfo.get(16)); - map.put("DetailedInformation", detailedMap); + HashMap detailedInfo = selfStationUtil.DetailedInfo(sampleId, phd.getStatus(), sampleStruct); + HashMap qcDetailedInfo = Maps.newHashMap(); + HashMap detDetailedInfo = Maps.newHashMap(); + if (null != qcStruct) { + qcDetailedInfo = selfStationUtil.DetailedInfo(sampleId, phd.getStatus(), qcStruct); + } + if (null != detStruct) { + detDetailedInfo = selfStationUtil.DetailedInfo(sampleId, phd.getStatus(), detStruct); + } + map.put("sample", detailedInfo); + map.put("qc", qcDetailedInfo); + map.put("det", detDetailedInfo); //发送数据到redis /*middleData.setSample_stationID(String.valueOf(stationId)); middleData.setSample_id(String.valueOf(phd.getId_sample()));