MET、SOH普文件去重
This commit is contained in:
parent
227466ab0a
commit
eded0b3cfd
|
@ -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<GardsMetDataMapper, Gard
|
|||
|
||||
/**
|
||||
* 保存气象谱数据
|
||||
*
|
||||
* @param struct
|
||||
* @param fileName
|
||||
* @return
|
||||
|
@ -43,33 +45,40 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public List<GardsMetData> create(MetSpectrumStruct struct,String fileName) throws Exception{
|
||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
public List<GardsMetData> 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<GardsMetData> list = Lists.newArrayList();
|
||||
if(struct.record_count > 0){
|
||||
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);
|
||||
});
|
||||
if (struct.record_count > 0) {
|
||||
String finalFileName = FileOperation.separatorConvert(fileName);
|
||||
LambdaQueryWrapper<GardsMetData> 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;
|
||||
|
|
|
@ -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<GardsSohDataMapper, Gard
|
|||
|
||||
/**
|
||||
* 保存健康谱数据
|
||||
*
|
||||
* @param struct
|
||||
* @param fileName
|
||||
* @return
|
||||
|
@ -44,34 +47,40 @@ public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, Gard
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public List<GardsSohData> create(SOHSpectrumStruct struct,String fileName) throws Exception{
|
||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
|
||||
public List<GardsSohData> 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<GardsSohData> list = Lists.newArrayList();
|
||||
if(struct.af_record_count > 0){
|
||||
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);
|
||||
});
|
||||
if (struct.af_record_count > 0) {
|
||||
String finalFileName = FileOperation.separatorConvert(fileName);
|
||||
LambdaQueryWrapper<GardsSohData> 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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user