diff --git a/hzims-service-api/digital-twin-display-api/pom.xml b/hzims-service-api/digital-twin-display-api/pom.xml new file mode 100644 index 0000000..ce02d54 --- /dev/null +++ b/hzims-service-api/digital-twin-display-api/pom.xml @@ -0,0 +1,22 @@ + + + + hzims-service-api + com.hnac.hzims + 4.0.0-SNAPSHOT + + 4.0.0 + + digital-twin-display-api + jar + ${hzims.project.version} + + + 8 + 8 + UTF-8 + + + \ No newline at end of file diff --git a/hzims-service-api/pom.xml b/hzims-service-api/pom.xml index 3f05497..fdae5c6 100644 --- a/hzims-service-api/pom.xml +++ b/hzims-service-api/pom.xml @@ -28,6 +28,7 @@ common-api middle-api base-info-api + digital-twin-display-api diff --git a/hzims-service/digital-twin-display/pom.xml b/hzims-service/digital-twin-display/pom.xml new file mode 100644 index 0000000..8490913 --- /dev/null +++ b/hzims-service/digital-twin-display/pom.xml @@ -0,0 +1,77 @@ + + + + hzims-service + com.hnac.hzims + 4.0.0-SNAPSHOT + + 4.0.0 + + digital-twin-display + jar + ${hzims.project.version} + + + 8 + 8 + UTF-8 + + + + + + + org.springblade + blade-core-boot + + + org.springblade + blade-starter-swagger + + + org.springblade + blade-starter-oss-all + + + com.baomidou + dynamic-datasource-spring-boot-starter + + + org.springblade + blade-core-test + test + + + org.springblade + blade-core-auto + compile + + + + + com.hnac.hzims + digital-twin-display-api + ${hzims.project.version} + + + + com.hnac.hzinfo.data + hzinfo-data-sdk + + + + com.hnac.hzims + weather-api + ${hzims.project.version} + + + + + + \ No newline at end of file diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/DigitalTwinDisplayApplication.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/DigitalTwinDisplayApplication.java new file mode 100644 index 0000000..9263235 --- /dev/null +++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/DigitalTwinDisplayApplication.java @@ -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); + } +} \ No newline at end of file diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java new file mode 100644 index 0000000..f3027fd --- /dev/null +++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/controller/BaseInfoController.java @@ -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 getDateInfo(String areaCode) { + return digitalBaseInfoService.getDateInfo(); + } + + @ApiOperation(notes = "获取气象信息", value = "获取气象信息") + @RequestMapping(value = "/getWeatherInfo", method = RequestMethod.GET) + @ResponseBody + public Map getWeatherInfo(String location) { + Map 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 data = digitalBaseInfoService.getRealData(deviceCode); + return R.data(data,"查询成功"); + } + + @ApiOperation(notes = "获取降雨量信息", value = "获取降雨量信息") + @RequestMapping(value = "/getRainFallInfo", method = RequestMethod.GET) + @ResponseBody + public Map> getRainFallInfo(String year,String location) { + return digitalBaseInfoService.getRainFallInfo(year,location); + } +} diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java new file mode 100644 index 0000000..bf8ba4d --- /dev/null +++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/IDigitalBaseInfoService.java @@ -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 getDateInfo(); + + /** + * 获取气象信息 + * @param location + * @return + */ + HeWeatherWeatherNowResponse getWeatherInfo(String location); + + /** + * 获取水位信息 + * @param instanceCode + * @param signage + * @return + */ + double getWaterLevel(String instanceCode, String signage); + + /** + * 获取设备信息 + * @param deviceCode + * @return + */ + List getRealData(String deviceCode); + + /** + * 获取地区降雨量信息 + * @param year + * @param location + * @return + */ + Map> getRainFallInfo(String year, String location); +} diff --git a/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java new file mode 100644 index 0000000..efd85a8 --- /dev/null +++ b/hzims-service/digital-twin-display/src/main/java/com/hnac/hzims/twindisplay/service/impl/DigitalBaseInfoServiceImpl.java @@ -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 getDateInfo() { + Map 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 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 signages = Collections.singletonList(signage); + realData.setSignages(signages); + // 调用fegin接口查询实时数据 + R> 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 getRealData(String deviceCode) { + /*R> realData = wrpSectionBClient.getRealData(deviceCode); + if(!realData.isSuccess() || CollectionUtil.isEmpty(realData.getData())){ + return null; + } + return realData.getData();*/ + return null; + } + + @Override + public Map> getRainFallInfo(String year, String location) { + R>> result = heWeatherWeatherClient.getRainFallMonthCount(year, location); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return null; + } + return result.getData(); + } + + +} diff --git a/hzims-service/pom.xml b/hzims-service/pom.xml index f20d297..1f3e83c 100644 --- a/hzims-service/pom.xml +++ b/hzims-service/pom.xml @@ -28,6 +28,7 @@ hzims-middle hzims-scheduled base-info + digital-twin-display