@ -13,11 +13,9 @@ import com.cuit.solarenergy.service.DataImportService;
import com.cuit.solarenergy.service.GeoServerPubService ;
import com.cuit.solarenergy.service.SolarenergyService ;
import com.github.xiaoymin.knife4j.annotations.ApiSupport ;
import io.swagger.annotations.Api ;
import io.swagger.annotations.ApiOperation ;
import io.swagger.annotations.ApiResponse ;
import io.swagger.annotations.ApiResponses ;
import io.swagger.annotations.* ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.security.access.prepost.PreAuthorize ;
import org.springframework.web.bind.annotation.RequestMapping ;
@ -55,19 +53,25 @@ public class SimulAndPredicController {
@ApiResponse ( code = 500 , message = "服务器内部错误" ) ,
@ApiResponse ( code = 900 , message = "失败" )
} )
public RetResult < List< TGeoserverinfo> > getSolarSimulation ( SolarPredicReq solarReq ) {
public RetResult < TGeoserverinfo> getSolarSimulation ( SolarPredicReq solarReq ) {
try {
//检验参数
if ( StringUtils . isEmpty ( solarReq . getRegionname ( ) ) | | solarReq . getRegionname ( ) . equals ( "" ) ) {
throw new ParamsException ( "区域名称不能为空" ) ;
}
log . info ( "太阳能日总辐射实时模拟" ) ;
// 获取当前日期和时间的 Calendar 对象
String time = solarReq . getTime ( ) ;
//1.辐射出图
String pathFile = solarenergyService . calSolarRadiation ( RasterSolarRadiationOperation . SolarEadiationAnalysisType . DAY_TOTAL_SOLARRADIATION_AMOUNT , "" , 0 , 2000 ) ;
String pathFile = solarenergyService . calSolarRadiation ( RasterSolarRadiationOperation . SolarEadiationAnalysisType . DAY_TOTAL_SOLARRADIATION_AMOUNT , time , solarReq . getCloudcoverof10parts ( ) , 15 00) ;
//2.发布geoserverter服务并存入数据库
Long aLong = geoServerPubService . pubGeoServerAndSavetoDB ( "style_tyn ", "EPSG:3857" , pathFile , solarReq . getRegionname ( ) ) ;
Long aLong = geoServerPubService . pubGeoServerAndSavetoDB ( "style_tyn day ", "EPSG:3857" , pathFile , solarReq . getRegionname ( ) ) ;
if ( Objects . isNull ( aLong ) | | aLong = = - 1 ) {
return RetResponse . makeErrRsp ( "太阳能日总辐射实时模拟服务有误" ) ;
}
//3.查询tif
log . info ( "Tif查询" ) ;
List< TGeoserverinfo> regionInfo = dataImportService . getTifByRegion ( solarReq . getRegionname ( ) ) ;
TGeoserverinfo regionInfo = dataImportService . getTifByRegion AndTime ( solarReq . getRegionname ( ) ) ;
return RetResponse . makeOKRsp ( regionInfo ) ;
} catch ( RuntimeException e ) {
return RetResponse . makeErrRsp ( "太阳能日总辐射实时模拟有误!" + e . getMessage ( ) ) ;
@ -87,21 +91,25 @@ public class SimulAndPredicController {
@ApiResponse ( code = 500 , message = "服务器内部错误" ) ,
@ApiResponse ( code = 900 , message = "失败" )
} )
public RetResult < List< TGeoserverinfo> > getSolarPrediction ( SolarPredicReq solarReq ) {
public RetResult < TGeoserverinfo> getSolarPrediction ( SolarPredicReq solarReq ) {
try {
//检验参数
if ( StringUtils . isEmpty ( solarReq . getRegionname ( ) ) | | solarReq . getRegionname ( ) . equals ( "" ) ) {
throw new ParamsException ( "区域名称不能为空" ) ;
}
log . info ( "太阳能日总辐射预报" ) ;
// 获取当前日期和时间的 Calendar 对象
String time = solarReq . getTime ( ) ;
//1.辐射出图
String pathFile = solarenergyService . calSolarRadiation ( RasterSolarRadiationOperation . SolarEadiationAnalysisType . DAY_TOTAL_SOLARRADIATION_AMOUNT , time , 0 , 20 00) ;
String pathFile = solarenergyService . calSolarRadiation ( RasterSolarRadiationOperation . SolarEadiationAnalysisType . DAY_TOTAL_SOLARRADIATION_AMOUNT , time , solarReq . getCloudcoverof10parts ( ) , 15 00) ;
//2.发布geoserverter服务并存入数据库
Long aLong = geoServerPubService . pubGeoServerAndSavetoDB ( "style_tyn ", "EPSG:3857" , pathFile , solarReq . getRegionname ( ) ) ;
Long aLong = geoServerPubService . pubGeoServerAndSavetoDB ( "style_tyn day ", "EPSG:3857" , pathFile , solarReq . getRegionname ( ) ) ;
if ( Objects . isNull ( aLong ) | | aLong = = - 1 ) {
return RetResponse . makeErrRsp ( "太阳能日总辐射实时模拟服务有误" ) ;
}
//3.查询tif
log . info ( "Tif查询" ) ;
List< TGeoserverinfo> regionInfo = dataImportService . getTifByRegion ( solarReq . getRegionname ( ) ) ;
TGeoserverinfo regionInfo = dataImportService . getTifByRegion AndTime ( solarReq . getRegionname ( ) ) ;
return RetResponse . makeOKRsp ( regionInfo ) ;
} catch ( RuntimeException e ) {
return RetResponse . makeErrRsp ( "太阳能日总辐射实时模拟有误!" + e . getMessage ( ) ) ;