zhaiqm
1 year ago
8 changed files with 353 additions and 0 deletions
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>hzims-service-api</artifactId> |
||||
<groupId>com.hnac.hzims</groupId> |
||||
<version>4.0.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>digital-twin-display-api</artifactId> |
||||
<packaging>jar</packaging> |
||||
<version>${hzims.project.version}</version> |
||||
|
||||
<properties> |
||||
<maven.compiler.source>8</maven.compiler.source> |
||||
<maven.compiler.target>8</maven.compiler.target> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
</properties> |
||||
|
||||
</project> |
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>hzims-service</artifactId> |
||||
<groupId>com.hnac.hzims</groupId> |
||||
<version>4.0.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>digital-twin-display</artifactId> |
||||
<packaging>jar</packaging> |
||||
<version>${hzims.project.version}</version> |
||||
|
||||
<properties> |
||||
<maven.compiler.source>8</maven.compiler.source> |
||||
<maven.compiler.target>8</maven.compiler.target> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
</properties> |
||||
|
||||
|
||||
<dependencies> |
||||
|
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-boot</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-swagger</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-starter-oss-all</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.baomidou</groupId> |
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>blade-core-auto</artifactId> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
|
||||
|
||||
<dependency> |
||||
<groupId>com.hnac.hzims</groupId> |
||||
<artifactId>digital-twin-display-api</artifactId> |
||||
<version>${hzims.project.version}</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.hnac.hzinfo.data</groupId> |
||||
<artifactId>hzinfo-data-sdk</artifactId> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>com.hnac.hzims</groupId> |
||||
<artifactId>weather-api</artifactId> |
||||
<version>${hzims.project.version}</version> |
||||
</dependency> |
||||
|
||||
<!--<dependency> |
||||
<groupId>com.hnac.hzims</groupId> |
||||
<artifactId>dam-safety-api</artifactId> |
||||
<version>${hzims.project.version}</version> |
||||
</dependency>--> |
||||
|
||||
</dependencies> |
||||
</project> |
@ -0,0 +1,38 @@
|
||||
package com.hnac.hzims.twindisplay; |
||||
|
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.springblade.core.cloud.feign.EnableBladeFeign; |
||||
import org.springblade.core.launch.BladeApplication; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||
import org.springframework.cloud.client.SpringCloudApplication; |
||||
import org.springframework.context.annotation.ComponentScan; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
||||
//数据孪生展示服务
|
||||
@EnableBladeFeign(basePackages = {"org.springblade","com.hnac"}) |
||||
@SpringCloudApplication |
||||
@MapperScan("com.hnac.h zims.**.mapper.**") |
||||
@EnableScheduling |
||||
@ComponentScan(basePackages = {"com.hnac.hzims.*"}) |
||||
public class DigitalTwinDisplayApplication extends SpringBootServletInitializer { |
||||
public final static String APP_NAME = "digital-twin-display"; |
||||
|
||||
static { |
||||
System.setProperty("spring.cloud.nacos.discovery.server-addr", "http://192.168.65.105:8848"); |
||||
System.setProperty("spring.cloud.nacos.config.server-addr", "http://192.168.65.105:8848"); |
||||
System.setProperty("spring.cloud.nacos.username", "nacos"); |
||||
System.setProperty("spring.cloud.nacos.password", "nacos"); |
||||
} |
||||
|
||||
|
||||
public static void main(String[] args) { |
||||
// System.setProperty("nacos.standalone", "true");
|
||||
BladeApplication.run(APP_NAME, DigitalTwinDisplayApplication.class, args); |
||||
} |
||||
|
||||
@Override |
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||
return BladeApplication.createSpringApplicationBuilder(builder, APP_NAME, DigitalTwinDisplayApplication.class); |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.hnac.hzims.twindisplay.controller; |
||||
|
||||
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; |
||||
import com.hnac.hzims.twindisplay.service.IDigitalBaseInfoService; |
||||
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@Api(description = "数字孪生水电站一张图系统基本信息控制器") |
||||
@RequestMapping(value = "/digital/baseInfo/") |
||||
public class BaseInfoController { |
||||
|
||||
@Autowired |
||||
private IDigitalBaseInfoService digitalBaseInfoService; |
||||
|
||||
@ApiOperation(notes = "获取当前日期信息", value = "获取当前日期信息") |
||||
@RequestMapping(value = "/getDateInfo", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
public Map<String, Object> getDateInfo(String areaCode) { |
||||
return digitalBaseInfoService.getDateInfo(); |
||||
} |
||||
|
||||
@ApiOperation(notes = "获取气象信息", value = "获取气象信息") |
||||
@RequestMapping(value = "/getWeatherInfo", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
public Map<String, Object> getWeatherInfo(String location) { |
||||
Map<String, Object> result = new HashMap<>(1); |
||||
result.put(location, digitalBaseInfoService.getWeatherInfo(location)); |
||||
return result; |
||||
} |
||||
|
||||
@ApiOperation(notes = "获取水位信息", value = "获取水位信息") |
||||
@RequestMapping(value = "/getWaterLevel", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
public double getWaterLevel(String instanceCode, String signage) { |
||||
return digitalBaseInfoService.getWaterLevel(instanceCode, signage); |
||||
} |
||||
|
||||
@ApiOperation(notes = "获取设备实时信息接口", value = "获取设备实时信息接口") |
||||
@RequestMapping(value = "/getRealData", method = RequestMethod.GET) |
||||
public R getRealData(String deviceCode){ |
||||
List<FieldsData> data = digitalBaseInfoService.getRealData(deviceCode); |
||||
return R.data(data,"查询成功"); |
||||
} |
||||
|
||||
@ApiOperation(notes = "获取降雨量信息", value = "获取降雨量信息") |
||||
@RequestMapping(value = "/getRainFallInfo", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
public Map<String,List<RainFallCountByMonthVo>> getRainFallInfo(String year,String location) { |
||||
return digitalBaseInfoService.getRainFallInfo(year,location); |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.hnac.hzims.twindisplay.service; |
||||
|
||||
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; |
||||
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; |
||||
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface IDigitalBaseInfoService { |
||||
|
||||
/** |
||||
* 获取日期时间信息 |
||||
* @return |
||||
*/ |
||||
Map<String, Object> getDateInfo(); |
||||
|
||||
/** |
||||
* 获取气象信息 |
||||
* @param location |
||||
* @return |
||||
*/ |
||||
HeWeatherWeatherNowResponse getWeatherInfo(String location); |
||||
|
||||
/** |
||||
* 获取水位信息 |
||||
* @param instanceCode |
||||
* @param signage |
||||
* @return |
||||
*/ |
||||
double getWaterLevel(String instanceCode, String signage); |
||||
|
||||
/** |
||||
* 获取设备信息 |
||||
* @param deviceCode |
||||
* @return |
||||
*/ |
||||
List<FieldsData> getRealData(String deviceCode); |
||||
|
||||
/** |
||||
* 获取地区降雨量信息 |
||||
* @param year |
||||
* @param location |
||||
* @return |
||||
*/ |
||||
Map<String, List<RainFallCountByMonthVo>> getRainFallInfo(String year, String location); |
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.hnac.hzims.twindisplay.service.impl; |
||||
|
||||
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; |
||||
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; |
||||
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; |
||||
import com.hnac.hzims.twindisplay.service.IDigitalBaseInfoService; |
||||
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
||||
import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; |
||||
import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.CollectionUtil; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.core.tool.utils.ObjectUtil; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.*; |
||||
|
||||
@Service |
||||
@RequiredArgsConstructor |
||||
public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService { |
||||
|
||||
private final IHeWeatherWeatherClient heWeatherWeatherClient; |
||||
|
||||
private final IAnalyseDataSearchClient analyseDataSearchClient; |
||||
|
||||
//private final IWrpSectionBClient wrpSectionBClient;
|
||||
|
||||
@Override |
||||
public Map<String, Object> getDateInfo() { |
||||
Map<String, Object> info = new HashMap<>(3); |
||||
Date now = new Date(); |
||||
SimpleDateFormat dateFm1 = new SimpleDateFormat("EEEE"); |
||||
SimpleDateFormat dateFm2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
//获取当前日期是星期几,中文展示 e.g. 星期二
|
||||
String week = dateFm1.format(now); |
||||
String dateTime = dateFm2.format(now); |
||||
String[] s = dateTime.split(" "); |
||||
info.put("date", s[0]); |
||||
info.put("time", s[1]); |
||||
info.put("week", week); |
||||
return info; |
||||
} |
||||
|
||||
@Override |
||||
public HeWeatherWeatherNowResponse getWeatherInfo(String location) { |
||||
if(StringUtil.isEmpty(location)){ |
||||
return null; |
||||
} |
||||
// 天气feign接口查询实时天气
|
||||
R<HeWeatherWeatherNowResponse> result = heWeatherWeatherClient.getWeatherNowWithCache(location); |
||||
if(!result.isSuccess() || ObjectUtil.isEmpty(result)){ |
||||
return null; |
||||
} |
||||
return result.getData(); |
||||
} |
||||
|
||||
@Override |
||||
public double getWaterLevel(String instanceCode, String signage) { |
||||
|
||||
RealDataSearchPO realData = new RealDataSearchPO(); |
||||
realData.setAnalyzeCode(instanceCode); |
||||
List<String> signages = Collections.singletonList(signage); |
||||
realData.setSignages(signages); |
||||
// 调用fegin接口查询实时数据
|
||||
R<List<FieldsData>> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); |
||||
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ |
||||
return 0.0; |
||||
} |
||||
// 时间限制
|
||||
String time = R.getData().get(0).getTime(); |
||||
if(StringUtil.isEmpty(time) || "-".equals(time)){ |
||||
return 0.0; |
||||
} |
||||
Date date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss"); |
||||
if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ |
||||
return 0.0; |
||||
} |
||||
return Double.parseDouble(R.getData().get(0).getValue()); |
||||
} |
||||
|
||||
@Override |
||||
public List<FieldsData> getRealData(String deviceCode) { |
||||
/*R<List<FieldsData>> realData = wrpSectionBClient.getRealData(deviceCode); |
||||
if(!realData.isSuccess() || CollectionUtil.isEmpty(realData.getData())){ |
||||
return null; |
||||
} |
||||
return realData.getData();*/ |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public Map<String, List<RainFallCountByMonthVo>> getRainFallInfo(String year, String location) { |
||||
R<Map<String, List<RainFallCountByMonthVo>>> result = heWeatherWeatherClient.getRainFallMonthCount(year, location); |
||||
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
||||
return null; |
||||
} |
||||
return result.getData(); |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue