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.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理气象谱
|
* 处理气象谱
|
||||||
|
@ -36,6 +37,7 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存气象谱数据
|
* 保存气象谱数据
|
||||||
|
*
|
||||||
* @param struct
|
* @param struct
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
|
@ -43,33 +45,40 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public List<GardsMetData> create(MetSpectrumStruct struct,String fileName) throws Exception{
|
public List<GardsMetData> create(MetSpectrumStruct struct, String fileName) throws Exception {
|
||||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
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();
|
List<GardsMetData> list = Lists.newArrayList();
|
||||||
if(struct.record_count > 0){
|
if (struct.record_count > 0) {
|
||||||
for(int i=0;i<struct.record_count;i++){
|
String finalFileName = FileOperation.separatorConvert(fileName);
|
||||||
GardsMetData metData = new GardsMetData();
|
LambdaQueryWrapper<GardsMetData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
metData.setStationId(station.getStationId());
|
queryWrapper.select(GardsMetData::getMetId);
|
||||||
metData.setStationCode(struct.station_code);
|
queryWrapper.eq(GardsMetData::getInputFileName, finalFileName);
|
||||||
metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i)+" "+struct.met_start_time.get(i)));
|
GardsMetData metDataOne = this.getOne(queryWrapper, false);
|
||||||
metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i)+" "+struct.met_end_time.get(i)));
|
if (Objects.isNull(metDataOne)) {
|
||||||
metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i)));
|
for (int i = 0; i < struct.record_count; i++) {
|
||||||
metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i)));
|
GardsMetData metData = new GardsMetData();
|
||||||
metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i)));
|
metData.setStationId(station.getStationId());
|
||||||
metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i)));
|
metData.setStationCode(struct.station_code);
|
||||||
metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i)));
|
metData.setStartTime(DateUtils.parseDate(struct.met_start_date.get(i) + " " + struct.met_start_time.get(i)));
|
||||||
metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i)));
|
metData.setEndTime(DateUtils.parseDate(struct.met_end_date.get(i) + " " + struct.met_end_time.get(i)));
|
||||||
metData.setInputFileName(FileOperation.separatorConvert(fileName));
|
metData.setAveHumidity(numberFormatUtil.DoubleLimit(struct.humidity.get(i)));
|
||||||
metData.setModdate(new Date());
|
metData.setAvgtemperature(numberFormatUtil.DoubleLimit(struct.average_outside_temperature.get(i)));
|
||||||
list.add(metData);
|
metData.setAvePressure(numberFormatUtil.DoubleLimit(struct.average_barometric_reading.get(i)));
|
||||||
}
|
metData.setAveWindDir(numberFormatUtil.DoubleLimit(struct.average_wind_direction.get(i)));
|
||||||
if(!CollectionUtils.isEmpty(list)){
|
metData.setAveWindSpeed(numberFormatUtil.DoubleLimit(struct.average_wind_speed.get(i)));
|
||||||
list.forEach(metData->{
|
metData.setRainfall(numberFormatUtil.DoubleLimit(struct.rainfall.get(i)));
|
||||||
this.save(metData);
|
metData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||||
});
|
metData.setModdate(new Date());
|
||||||
|
list.add(metData);
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
list.forEach(metData -> {
|
||||||
|
this.save(metData);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -20,8 +20,10 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 健康谱数据处理
|
* 健康谱数据处理
|
||||||
|
@ -37,6 +39,7 @@ public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, Gard
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存健康谱数据
|
* 保存健康谱数据
|
||||||
|
*
|
||||||
* @param struct
|
* @param struct
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @return
|
* @return
|
||||||
|
@ -44,34 +47,40 @@ public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, Gard
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public List<GardsSohData> create(SOHSpectrumStruct struct,String fileName) throws Exception{
|
public List<GardsSohData> create(SOHSpectrumStruct struct, String fileName) throws Exception {
|
||||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
Assert.notNull(struct.station_code, "此次解析结构体中的台站“台站代码”为空");
|
||||||
Assert.notNull(struct.detector_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);
|
final GardsDetectors detector = detectorsService.check(struct.detector_code);
|
||||||
|
|
||||||
List<GardsSohData> list = Lists.newArrayList();
|
List<GardsSohData> list = Lists.newArrayList();
|
||||||
if(struct.af_record_count > 0){
|
if (struct.af_record_count > 0) {
|
||||||
for(int i=0;i<struct.af_record_count;i++){
|
String finalFileName = FileOperation.separatorConvert(fileName);
|
||||||
GardsSohData sohData = new GardsSohData();
|
LambdaQueryWrapper<GardsSohData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
sohData.setStationId(station.getStationId());
|
queryWrapper.eq(GardsSohData::getInputFileName, finalFileName);
|
||||||
sohData.setStationCode(struct.station_code);
|
GardsSohData sohDataOne = this.getOne(queryWrapper, false);
|
||||||
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i)+" "+struct.af_start_time.get(i)));
|
if (Objects.isNull(sohDataOne)) {
|
||||||
sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue()));
|
for (int i = 0; i < struct.af_record_count; i++) {
|
||||||
sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i)));
|
GardsSohData sohData = new GardsSohData();
|
||||||
sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i)));
|
sohData.setStationId(station.getStationId());
|
||||||
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
|
sohData.setStationCode(struct.station_code);
|
||||||
sohData.setDetectorId(detector.getDetectorId());
|
sohData.setStartTime(DateUtils.parseDate(struct.af_start_date.get(i) + " " + struct.af_start_time.get(i)));
|
||||||
sohData.setModdate(new Date());
|
sohData.setTime(numberFormatUtil.DoubleLimit(struct.af_interval_duration.get(i).doubleValue()));
|
||||||
list.add(sohData);
|
sohData.setAvgflowrate(numberFormatUtil.DoubleLimit(struct.average_flow_rate.get(i)));
|
||||||
}
|
sohData.setFlowratedev(numberFormatUtil.DoubleLimit(struct.flow_rate_standard_deviation.get(i)));
|
||||||
if(!CollectionUtils.isEmpty(list)){
|
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||||
list.forEach(sohData->{
|
sohData.setDetectorId(detector.getDetectorId());
|
||||||
this.save(sohData);
|
sohData.setModdate(new Date());
|
||||||
});
|
list.add(sohData);
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
list.forEach(sohData -> {
|
||||||
|
this.save(sohData);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user