@ -1,5 +1,6 @@
package com.ping.chuan.apiservice.controller ;
import java.io.IOException ;
import java.math.BigDecimal ;
import java.time.LocalDateTime ;
import java.util.ArrayList ;
@ -32,7 +33,7 @@ import com.ping.chuan.apiservice.util.RequestResult;
@RequestMapping ( "baseData" )
public class BaseDataController {
private final ObjectMapper objectMapper = new ObjectMapper ( ) ;
private final static ObjectMapper objectMapper = new ObjectMapper ( ) ;
private final IDataService dataService ;
public BaseDataController ( IDataService dataService ) {
this . dataService = dataService ;
@ -53,16 +54,16 @@ public class BaseDataController {
}
Object initialTimeValue = convertTime ( initialTime ) ;
if ( initialTimeValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( initialTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) initialTimeValu e) ;
}
Object forecastTimeValue = convertTime ( forecastTime ) ;
if ( forecastTimeValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( forecastTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) forecastTimeValu e) ;
}
Object latLonValue = convertLatLon ( latLons ) ;
if ( latLonValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( latLonValue instanceof String ) {
return RequestResult . fail ( ( String ) latLonValu e) ;
}
Map . Entry < MetaInfo , Coordinate > entry = CacheTemplate . findOne ( "SPCC" , elementCode , "BEHF" , 180 , 4320 , 1010 ) ;
@ -87,16 +88,16 @@ public class BaseDataController {
}
Object initialTimeValue = convertTime ( realTime ) ;
if ( initialTimeValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( initialTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) initialTimeValu e) ;
}
Object forecastTimeValue = convertTime ( realTime ) ;
if ( forecastTimeValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( forecastTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) forecastTimeValu e) ;
}
Object latLonValue = convertLatLon ( latLons ) ;
if ( latLonValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( latLonValue instanceof String ) {
return RequestResult . fail ( ( String ) latLonValu e) ;
}
Map . Entry < MetaInfo , Coordinate > entry = CacheTemplate . findOne ( "CLDAS" , elementCode , "BABJ" , 60 , 60 , 1010 ) ;
@ -121,16 +122,16 @@ public class BaseDataController {
}
Object initialTimeValue = convertTime ( realTime ) ;
if ( initialTimeValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( initialTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) initialTimeValu e) ;
}
Object forecastTimeValue = convertTime ( realTime ) ;
if ( forecastTimeValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( forecastTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) forecastTimeValu e) ;
}
Object latLonValue = convertLatLon ( latLons ) ;
if ( latLonValue instanceof String e ) {
return RequestResult . fail ( e ) ;
if ( latLonValue instanceof String ) {
return RequestResult . fail ( ( String ) latLonValu e) ;
}
Map . Entry < MetaInfo , Coordinate > entry = CacheTemplate . findOne ( "CMPA" , elementCode , "BABJ" , 60 , 60 , 1010 ) ;
@ -141,6 +142,44 @@ public class BaseDataController {
return RequestResult . success ( dataService . findPoints ( entry , ( LocalDateTime ) initialTimeValue , ( LocalDateTime ) forecastTimeValue , ( List < BigDecimal [ ] > ) latLonValue ) ) ;
}
@ApiOperation ( value = "根据扫描配置项获取相关雷达数据" , notes = "根据扫描配置项获取相关雷达数据" , produces = "application/json" , httpMethod = "POST" )
@ApiImplicitParams ( {
@ApiImplicitParam ( name = "radarType" , value = "雷达类型" , example = "SAD" , required = true , paramType = "query" ) ,
@ApiImplicitParam ( name = "station" , value = "站点" , example = "Z9558" , required = true , paramType = "query" ) ,
@ApiImplicitParam ( name = "realTime" , value = "雷达时间" , example = "20220402104823" , required = true , paramType = "query" ) ,
@ApiImplicitParam ( name = "productType" , value = "雷达数据类型" , example = "dBT" , required = true , paramType = "query" ) ,
@ApiImplicitParam ( name = "cutConfigurationIndex" , value = "扫描配置索引,可通过 baseInfo/getRadarCutConfigurations 接口获取相关扫描配置" , example = "0" , required = true , paramType = "query" ) ,
} )
@PostMapping ( "getRadarByCutConfiguration" )
public RequestResult getRadarByCutConfiguration ( String realTime , String radarType , String station , String productType , Integer cutConfigurationIndex ) throws IOException {
if ( Objects . isNull ( radarType ) ) {
return RequestResult . fail ( "radarType不能为空" ) ;
}
if ( Objects . isNull ( station ) ) {
return RequestResult . fail ( "station不能为空" ) ;
}
if ( Objects . isNull ( realTime ) ) {
return RequestResult . fail ( "realTime不能为空" ) ;
}
if ( Objects . isNull ( productType ) ) {
return RequestResult . fail ( "radarElementType不能为空" ) ;
}
if ( Objects . isNull ( cutConfigurationIndex ) ) {
return RequestResult . fail ( "cutConfigurationIndex不能为空" ) ;
}
Object initialTimeValue = BaseDataController . convertTime ( realTime ) ;
if ( initialTimeValue instanceof String ) {
return RequestResult . fail ( ( String ) initialTimeValue ) ;
}
return RequestResult . success ( dataService . getRadarByCutConfiguration ( productType , radarType , station , ( LocalDateTime ) initialTimeValue , cutConfigurationIndex ) ) ;
}
private String verifyParams ( String elementCode , String initialTime , String forecastTime , String latLons ) {
List < String > errors = new ArrayList < > ( 4 ) ;
if ( Objects . isNull ( elementCode ) ) {
@ -166,7 +205,7 @@ public class BaseDataController {
return errors . stream ( ) . collect ( Collectors . joining ( ", " ) ) ;
}
private Object convertTime ( String timeStr ) {
public static Object convertTime ( String timeStr ) {
try {
return LocalDateTime . parse ( timeStr , TimeConstant . YYYYMMDDHHMMSS ) ;
} catch ( Exception e ) {
@ -174,7 +213,7 @@ public class BaseDataController {
}
}
private Object convertLatLon ( String latLons ) {
public static Object convertLatLon ( String latLons ) {
try {
List < BigDecimal [ ] > newLocations = new ArrayList < > ( ) ;
List < BigDecimal [ ] > locations = objectMapper . readValue ( latLons , new TypeReference < List < BigDecimal [ ] > > ( ) { } ) ;