diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java index e5066f5f..905ad2d5 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java @@ -22,6 +22,7 @@ import org.springframework.util.CollectionUtils; import java.util.Date; import java.util.List; +import java.util.Objects; /** * 处理气象谱 @@ -36,6 +37,7 @@ public class MetSpectrumServiceImpl extends ServiceImpl create(MetSpectrumStruct struct,String fileName) throws Exception{ - Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空"); + public List create(MetSpectrumStruct struct, String fileName) throws Exception { + Assert.notNull(struct.station_code, "此次解析结构体中的台站“台站代码”为空"); //校验台站是否存在,不存在则报异常 - final GardsStations station = stationsService.check(struct.station_code,fileName); + final GardsStations station = stationsService.check(struct.station_code, fileName); List list = Lists.newArrayList(); - if(struct.record_count > 0){ - for(int i=0;i{ - this.save(metData); - }); + if (struct.record_count > 0) { + String finalFileName = FileOperation.separatorConvert(fileName); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.select(GardsMetData::getMetId); + queryWrapper.eq(GardsMetData::getInputFileName, finalFileName); + GardsMetData metDataOne = this.getOne(queryWrapper, false); + if (Objects.isNull(metDataOne)) { + for (int i = 0; i < struct.record_count; i++) { + GardsMetData metData = new GardsMetData(); + metData.setStationId(station.getStationId()); + metData.setStationCode(struct.station_code); + metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i) + " " + struct.met_start_time.get(i))); + metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i) + " " + struct.met_end_time.get(i))); + metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i))); + metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i))); + metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i))); + metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i))); + metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i))); + metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i))); + metData.setInputFileName(FileOperation.separatorConvert(fileName)); + metData.setModdate(new Date()); + list.add(metData); + } + if (!CollectionUtils.isEmpty(list)) { + list.forEach(metData -> { + this.save(metData); + }); + } } } return list; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/SOHSpectrumServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/SOHSpectrumServiceImpl.java index 2e60b809..0532129e 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/SOHSpectrumServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/SOHSpectrumServiceImpl.java @@ -20,8 +20,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; + import java.util.Date; import java.util.List; +import java.util.Objects; /** * 健康谱数据处理 @@ -37,6 +39,7 @@ public class SOHSpectrumServiceImpl extends ServiceImpl create(SOHSpectrumStruct struct,String fileName) throws Exception{ - Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空"); - Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空"); + public List create(SOHSpectrumStruct struct, String fileName) throws Exception { + Assert.notNull(struct.station_code, "此次解析结构体中的台站“台站代码”为空"); + Assert.notNull(struct.detector_code, "此次解析结构体中的台站“探测器代码”为空"); //校验台站是否存在,不存在则报异常 - final GardsStations station = stationsService.check(struct.station_code,fileName); + final GardsStations station = stationsService.check(struct.station_code, fileName); //校验探测器是否存在,不存在则创建 final GardsDetectors detector = detectorsService.check(struct.detector_code); List list = Lists.newArrayList(); - if(struct.af_record_count > 0){ - for(int i=0;i{ - this.save(sohData); - }); + if (struct.af_record_count > 0) { + String finalFileName = FileOperation.separatorConvert(fileName); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(GardsSohData::getInputFileName, finalFileName); + GardsSohData sohDataOne = this.getOne(queryWrapper, false); + if (Objects.isNull(sohDataOne)) { + for (int i = 0; i < struct.af_record_count; i++) { + GardsSohData sohData = new GardsSohData(); + sohData.setStationId(station.getStationId()); + sohData.setStationCode(struct.station_code); + sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i) + " " + struct.af_start_time.get(i))); + sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue())); + sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i))); + sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i))); + sohData.setInputFileName(FileOperation.separatorConvert(fileName)); + sohData.setDetectorId(detector.getDetectorId()); + sohData.setModdate(new Date()); + list.add(sohData); + } + if (!CollectionUtils.isEmpty(list)) { + list.forEach(sohData -> { + this.save(sohData); + }); + } } } return list;