|
|
|
@ -4,9 +4,13 @@ package com.cuit.solarenergy.controller;
|
|
|
|
|
import com.cuit.gis.analysis.solarradiation.RasterSolarRadiationOperation;
|
|
|
|
|
import com.cuit.solarenergy.base.annotation.AopLog;
|
|
|
|
|
import com.cuit.solarenergy.base.annotation.AuthToken;
|
|
|
|
|
import com.cuit.solarenergy.entity.TGeoserverinfo;
|
|
|
|
|
import com.cuit.solarenergy.entity.vo.req.SolarPredicReq;
|
|
|
|
|
import com.cuit.solarenergy.entity.vo.ret.RetResponse;
|
|
|
|
|
import com.cuit.solarenergy.entity.vo.ret.RetResult;
|
|
|
|
|
import com.cuit.solarenergy.exception.ParamsException;
|
|
|
|
|
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;
|
|
|
|
@ -20,8 +24,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "3、实时模拟与预报")
|
|
|
|
|
@ApiSupport(order = 3)
|
|
|
|
@ -31,12 +37,16 @@ public class SimulAndPredicController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
SolarenergyService solarenergyService;
|
|
|
|
|
@Autowired
|
|
|
|
|
GeoServerPubService geoServerPubService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private DataImportService dataImportService;
|
|
|
|
|
|
|
|
|
|
@AopLog
|
|
|
|
|
@AuthToken
|
|
|
|
|
@ApiOperation("1、辐射实时模拟")
|
|
|
|
|
@PreAuthorize("hasAuthority('minio:upload')")
|
|
|
|
|
@RequestMapping(value = "/solarenergy/getSolarSimulation", method = {RequestMethod.GET})
|
|
|
|
|
@RequestMapping(value = "/solarenergy/getSolarSimulation", method = {RequestMethod.POST})
|
|
|
|
|
@ApiResponses({
|
|
|
|
|
@ApiResponse(code = 200, message = "成功"),
|
|
|
|
|
@ApiResponse(code = 401, message = "访问未经授权"),
|
|
|
|
@ -45,11 +55,20 @@ public class SimulAndPredicController {
|
|
|
|
|
@ApiResponse(code = 500, message = "服务器内部错误"),
|
|
|
|
|
@ApiResponse(code = 900, message = "失败")
|
|
|
|
|
})
|
|
|
|
|
public RetResult<String> getSolarSimulation() {
|
|
|
|
|
public RetResult<List<TGeoserverinfo>> getSolarSimulation(SolarPredicReq solarReq) {
|
|
|
|
|
try {
|
|
|
|
|
log.info("太阳能日总辐射实时模拟");
|
|
|
|
|
String s = solarenergyService.calSolarRadiation(RasterSolarRadiationOperation.SolarEadiationAnalysisType.DAY_TOTAL_SOLARRADIATION_AMOUNT, Calendar.getInstance(), 0, 2000);
|
|
|
|
|
return RetResponse.makeOKRsp(s);
|
|
|
|
|
//1.辐射出图
|
|
|
|
|
String pathFile = solarenergyService.calSolarRadiation(RasterSolarRadiationOperation.SolarEadiationAnalysisType.DAY_TOTAL_SOLARRADIATION_AMOUNT,"", 0, 2000);
|
|
|
|
|
//2.发布geoserverter服务并存入数据库
|
|
|
|
|
Long aLong = geoServerPubService.pubGeoServerAndSavetoDB("style_tyn", "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());
|
|
|
|
|
return RetResponse.makeOKRsp(regionInfo);
|
|
|
|
|
}catch (RuntimeException e){
|
|
|
|
|
return RetResponse.makeErrRsp("太阳能日总辐射实时模拟有误!"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
@ -59,7 +78,7 @@ public class SimulAndPredicController {
|
|
|
|
|
@AuthToken
|
|
|
|
|
@ApiOperation("2、辐射预报")
|
|
|
|
|
@PreAuthorize("hasAuthority('minio:upload')")
|
|
|
|
|
@RequestMapping(value = "/solarenergy/getSolarPrediction", method = {RequestMethod.GET})
|
|
|
|
|
@RequestMapping(value = "/solarenergy/getSolarPrediction", method = {RequestMethod.POST})
|
|
|
|
|
@ApiResponses({
|
|
|
|
|
@ApiResponse(code = 200, message = "成功"),
|
|
|
|
|
@ApiResponse(code = 401, message = "访问未经授权"),
|
|
|
|
@ -68,15 +87,22 @@ public class SimulAndPredicController {
|
|
|
|
|
@ApiResponse(code = 500, message = "服务器内部错误"),
|
|
|
|
|
@ApiResponse(code = 900, message = "失败")
|
|
|
|
|
})
|
|
|
|
|
public RetResult<String> getSolarPrediction() {
|
|
|
|
|
public RetResult<List<TGeoserverinfo>> getSolarPrediction(SolarPredicReq solarReq) {
|
|
|
|
|
try {
|
|
|
|
|
log.info("太阳能日总辐射预报");
|
|
|
|
|
// 获取当前日期和时间的 Calendar 对象
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
// 给当前日期加3天
|
|
|
|
|
calendar.add(Calendar.DATE, 3);
|
|
|
|
|
String s = solarenergyService.calSolarRadiation(RasterSolarRadiationOperation.SolarEadiationAnalysisType.DAY_TOTAL_SOLARRADIATION_AMOUNT, calendar, 0, 2000);
|
|
|
|
|
return RetResponse.makeOKRsp(s);
|
|
|
|
|
String time = solarReq.getTime();
|
|
|
|
|
//1.辐射出图
|
|
|
|
|
String pathFile = solarenergyService.calSolarRadiation(RasterSolarRadiationOperation.SolarEadiationAnalysisType.DAY_TOTAL_SOLARRADIATION_AMOUNT, time, 0, 2000);
|
|
|
|
|
//2.发布geoserverter服务并存入数据库
|
|
|
|
|
Long aLong = geoServerPubService.pubGeoServerAndSavetoDB("style_tyn", "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());
|
|
|
|
|
return RetResponse.makeOKRsp(regionInfo);
|
|
|
|
|
}catch (RuntimeException e){
|
|
|
|
|
return RetResponse.makeErrRsp("太阳能日总辐射实时模拟有误!"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|