fix:1.优化Alert、Met、SOH谱存储数据校验保障和S、D、Q、G谱使用一致便于统一异常处理
This commit is contained in:
parent
7350b50c23
commit
79300438d8
|
@ -10,8 +10,8 @@ import org.jeecg.modules.base.entity.configuration.GardsStations;
|
|||
import org.jeecg.modules.base.entity.original.GardsAlertData;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import org.jeecg.modules.mapper.GardsAlertDataMapper;
|
||||
import org.jeecg.modules.mapper.GardsStationsMapper;
|
||||
import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
|
||||
import org.jeecg.modules.service.GardsStationsService;
|
||||
import org.jeecg.modules.service.IAlertSpectrumService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -25,7 +25,7 @@ import org.springframework.util.Assert;
|
|||
@RequiredArgsConstructor
|
||||
public class AlertSpectrumServiceImpl extends ServiceImpl<GardsAlertDataMapper, GardsAlertData> implements IAlertSpectrumService {
|
||||
|
||||
private final GardsStationsMapper gardsStationsMapper;
|
||||
private final GardsStationsService stationsService;
|
||||
|
||||
/**
|
||||
* 保存报警谱信息
|
||||
|
@ -38,14 +38,11 @@ public class AlertSpectrumServiceImpl extends ServiceImpl<GardsAlertDataMapper,
|
|||
public GardsAlertData create(AlertSpectrumStruct struct, String fileName) throws Exception{
|
||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
|
||||
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
|
||||
gardsStationsQuery.select(GardsStations::getStationId);
|
||||
gardsStationsQuery.eq(GardsStations::getStationCode,struct.station_code);
|
||||
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
|
||||
Assert.notNull(stations,"此台站代码:"+struct.station_code+"所属台站不存在");
|
||||
//校验台站是否存在,不存在则报异常
|
||||
final GardsStations station = stationsService.check(struct.station_code);
|
||||
|
||||
GardsAlertData alertData = new GardsAlertData();
|
||||
alertData.setStationId(stations.getStationId());
|
||||
alertData.setStationId(station.getStationId());
|
||||
alertData.setStationCode(struct.station_code);
|
||||
alertData.setTime(DateUtils.parseDate(struct.date+" "+struct.time));
|
||||
alertData.setAlertType(struct.alert_type);
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.jeecg.modules.file.FileOperation;
|
|||
import org.jeecg.modules.mapper.GardsMetDataMapper;
|
||||
import org.jeecg.modules.mapper.GardsStationsMapper;
|
||||
import org.jeecg.modules.native_jni.struct.MetSpectrumStruct;
|
||||
import org.jeecg.modules.service.GardsStationsService;
|
||||
import org.jeecg.modules.service.IMetSpectrumService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -29,7 +30,7 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, GardsMetData> implements IMetSpectrumService {
|
||||
|
||||
private final GardsStationsMapper gardsStationsMapper;
|
||||
private final GardsStationsService stationsService;
|
||||
|
||||
/**
|
||||
* 保存气象谱数据
|
||||
|
@ -43,16 +44,13 @@ public class MetSpectrumServiceImpl extends ServiceImpl<GardsMetDataMapper, Gard
|
|||
public List<GardsMetData> create(MetSpectrumStruct struct,String fileName) throws Exception{
|
||||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
|
||||
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
|
||||
gardsStationsQuery.select(GardsStations::getStationId);
|
||||
gardsStationsQuery.eq(GardsStations::getStationCode,struct.station_code);
|
||||
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
|
||||
Assert.notNull(stations,"此台站代码:"+struct.station_code+"所属台站不存在");
|
||||
//校验台站是否存在,不存在则报异常
|
||||
final GardsStations station = stationsService.check(struct.station_code);
|
||||
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(stations.getStationId());
|
||||
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)));
|
||||
|
|
|
@ -10,16 +10,15 @@ import org.jeecg.modules.base.entity.configuration.GardsDetectors;
|
|||
import org.jeecg.modules.base.entity.configuration.GardsStations;
|
||||
import org.jeecg.modules.base.entity.original.GardsSohData;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
import org.jeecg.modules.mapper.GardsDetectorsMapper;
|
||||
import org.jeecg.modules.mapper.GardsSohDataMapper;
|
||||
import org.jeecg.modules.mapper.GardsStationsMapper;
|
||||
import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct;
|
||||
import org.jeecg.modules.service.GardsDetectorsService;
|
||||
import org.jeecg.modules.service.GardsStationsService;
|
||||
import org.jeecg.modules.service.ISOHSpectrumService;
|
||||
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;
|
||||
|
||||
|
@ -31,8 +30,8 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, GardsSohData> implements ISOHSpectrumService {
|
||||
|
||||
private final GardsStationsMapper gardsStationsMapper;
|
||||
private final GardsDetectorsMapper gardsDetectorsMapper;
|
||||
private final GardsStationsService stationsService;
|
||||
private final GardsDetectorsService detectorsService;
|
||||
|
||||
/**
|
||||
* 保存健康谱数据
|
||||
|
@ -47,29 +46,23 @@ public class SOHSpectrumServiceImpl extends ServiceImpl<GardsSohDataMapper, Gard
|
|||
Assert.notNull(struct.station_code,"此次解析结构体中的台站“台站代码”为空");
|
||||
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
|
||||
|
||||
LambdaQueryWrapper<GardsStations> gardsStationsQuery = new LambdaQueryWrapper<>();
|
||||
gardsStationsQuery.select(GardsStations::getStationId);
|
||||
gardsStationsQuery.eq(GardsStations::getStationCode,struct.station_code);
|
||||
final GardsStations stations = gardsStationsMapper.selectOne(gardsStationsQuery);
|
||||
Assert.notNull(stations,"此台站代码:"+struct.station_code+"所属台站不存在");
|
||||
//校验台站是否存在,不存在则报异常
|
||||
final GardsStations station = stationsService.check(struct.station_code);
|
||||
//校验探测器是否存在,不存在则创建
|
||||
final GardsDetectors detector = detectorsService.check(struct.detector_code);
|
||||
|
||||
LambdaQueryWrapper<GardsDetectors> gardsGardsDetectorsQuery = new LambdaQueryWrapper<>();
|
||||
gardsGardsDetectorsQuery.select(GardsDetectors::getDetectorId);
|
||||
gardsGardsDetectorsQuery.eq(GardsDetectors::getDetectorCode,struct.detector_code);
|
||||
final GardsDetectors gardsDetectors = gardsDetectorsMapper.selectOne(gardsGardsDetectorsQuery);
|
||||
Assert.notNull(gardsDetectors,"此探测器代码:"+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(stations.getStationId());
|
||||
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(struct.af_interval_duration.get(i).doubleValue());
|
||||
sohData.setAvgflowrate(struct.average_flow_rate.get(i));
|
||||
sohData.setFlowratedev(struct.flow_rate_standard_deviation.get(i));
|
||||
sohData.setInputFileName(FileOperation.separatorConvert(fileName));
|
||||
sohData.setDetectorId(gardsDetectors.getDetectorId());
|
||||
sohData.setDetectorId(detector.getDetectorId());
|
||||
sohData.setModdate(new Date());
|
||||
list.add(sohData);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user