diff --git a/hzims-service-api/dam-safety-api/pom.xml b/hzims-service-api/dam-safety-api/pom.xml index ad10528..6d4ee93 100644 --- a/hzims-service-api/dam-safety-api/pom.xml +++ b/hzims-service-api/dam-safety-api/pom.xml @@ -3,6 +3,12 @@ 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"> 4.0.0 + + + com.hnac.hzinfo.data + hzinfo-data-sdk + + com.hnac.hzims hzims-service-api diff --git a/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java b/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java index 081a64c..874e072 100644 --- a/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java +++ b/hzims-service-api/dam-safety-api/src/main/java/com/hnac/hzims/damsafety/feign/IWrpSectionBClient.java @@ -1,6 +1,7 @@ package com.hnac.hzims.damsafety.feign; import com.hnac.hzims.damsafety.vo.WrpSectionBVO; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @@ -15,6 +16,7 @@ import java.util.Map; public interface IWrpSectionBClient { String API_PREFIX = "/wrpSectionBClient"; String LIST = API_PREFIX + "/list"; + String GET_REAL_DATA = API_PREFIX + "/getRealData"; /** * 获取断面列表 @@ -23,4 +25,7 @@ public interface IWrpSectionBClient { */ @GetMapping(LIST) R> list(Map param); + + @GetMapping(GET_REAL_DATA) + R> getRealData(String deviceCode); } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/entity/HiddenDanger.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/entity/HiddenDanger.java new file mode 100644 index 0000000..1924629 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/entity/HiddenDanger.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.safeproduct.hiddendanger.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("hidden_danger") +public class HiddenDanger { + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 危险行为 + */ + @TableField("danger_behavior") + private String dangerBehavior; + + /** + * 发生次数 + */ + @TableField("times") + private Integer times; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/vo/HiddenDangerQueryVo.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/vo/HiddenDangerQueryVo.java new file mode 100644 index 0000000..384bab9 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/vo/HiddenDangerQueryVo.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.safeproduct.hiddendanger.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +@Data +public class HiddenDangerQueryVo { + /** + * 危险行为 + */ + @TableField("danger_behavior") + private String dangerBehavior; +} diff --git a/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java b/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java index fa703eb..4e1916a 100644 --- a/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java +++ b/hzims-service/dam-safety/src/main/java/com/hnac/hzims/damsafety/feign/WrpSectionBClient.java @@ -2,10 +2,12 @@ package com.hnac.hzims.damsafety.feign; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.damsafety.entity.WrpSectionB; +import com.hnac.hzims.damsafety.service.IDamSafetyDataService; import com.hnac.hzims.damsafety.service.IWrpSectionBService; import com.hnac.hzims.damsafety.util.ParamUtil; import com.hnac.hzims.damsafety.vo.WrpSectionBVO; import com.hnac.hzims.damsafety.wrapper.WrpSectionBWrapper; +import com.hnac.hzinfo.datasearch.analyse.domain.FieldsData; import org.springblade.core.tool.api.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RestController; @@ -19,10 +21,18 @@ public class WrpSectionBClient implements IWrpSectionBClient { @Autowired private IWrpSectionBService wrpSectionBService; + @Autowired + private IDamSafetyDataService damSafetyDataService; + @Override public R> list(Map param) { LambdaQueryWrapper wrapper= ParamUtil.conditionWrpSectionB(param); List list = wrpSectionBService.list(wrapper); return R.data(WrpSectionBWrapper.build().listVO(list)); } + + @Override + public R> getRealData(String deviceCode) { + return R.data(damSafetyDataService.getRealData(deviceCode)); + } } diff --git a/hzims-service/digital-twin-display/pom.xml b/hzims-service/digital-twin-display/pom.xml index 7cd795d..af85fc2 100644 --- a/hzims-service/digital-twin-display/pom.xml +++ b/hzims-service/digital-twin-display/pom.xml @@ -67,12 +67,11 @@ ${hzims.project.version} - - + com.hnac.hzims 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 index f3027fd..e5893f6 100644 --- 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 @@ -49,9 +49,11 @@ public class BaseInfoController { @ApiOperation(notes = "获取设备实时信息接口", value = "获取设备实时信息接口") @RequestMapping(value = "/getRealData", method = RequestMethod.GET) - public R getRealData(String deviceCode){ + public Map getRealData(String deviceCode){ + Map result = new HashMap<>(); List data = digitalBaseInfoService.getRealData(deviceCode); - return R.data(data,"查询成功"); + result.put(deviceCode, data); + return result; } @ApiOperation(notes = "获取降雨量信息", value = "获取降雨量信息") @@ -60,4 +62,18 @@ public class BaseInfoController { public Map> getRainFallInfo(String year,String location) { return digitalBaseInfoService.getRainFallInfo(year,location); } + + @ApiOperation(notes = "获取电站发电运行信息", value = "获取电站发电运行信息") + @RequestMapping(value = "/getPowerStationHisInfo", method = RequestMethod.GET) + public Map getPowerStationHisInfo(String deviceCode){ + //有功功率属性名 + String activePower = "activePower"; + //无功功率属性名 + String reactivePower = "reactivePower"; + //发电量 + String power = "power"; + Map data = digitalBaseInfoService.getPowerStationHisInfo(deviceCode,activePower,reactivePower,power); + + return data; + } } 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 index bf8ba4d..514c751 100644 --- 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 @@ -44,4 +44,14 @@ public interface IDigitalBaseInfoService { * @return */ Map> getRainFallInfo(String year, String location); + + /** + * 获取电站发电运行信息 + * @param deviceCode + * @param activePower + * @param reactivePower + * @param power + * @return + */ + Map getPowerStationHisInfo(String deviceCode, String activePower, String reactivePower, String power); } 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 index efd85a8..db70c87 100644 --- 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 @@ -1,12 +1,18 @@ package com.hnac.hzims.twindisplay.service.impl; +import com.hnac.hzims.damsafety.feign.IWrpSectionBClient; 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.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.hnac.hzinfo.datasearch.real.po.RealDataSearchPO; +import com.hnac.hzinfo.sdk.analyse.AnalyseDataSearchClient; +import com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; @@ -16,6 +22,9 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.*; @Service @@ -24,9 +33,11 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService { private final IHeWeatherWeatherClient heWeatherWeatherClient; - private final IAnalyseDataSearchClient analyseDataSearchClient; + private final IAnalyseDataSearchClient ianalyseDataSearchClient; - //private final IWrpSectionBClient wrpSectionBClient; + private final IWrpSectionBClient wrpSectionBClient; + + private final AnalyseDataSearchClient analyseDataSearchClient; @Override public Map getDateInfo() { @@ -65,7 +76,7 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService { List signages = Collections.singletonList(signage); realData.setSignages(signages); // 调用fegin接口查询实时数据 - R> R = analyseDataSearchClient.getRealDataByAnalyzeCode(realData); + R> R = ianalyseDataSearchClient.getRealDataByAnalyzeCode(realData); if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ return 0.0; } @@ -83,12 +94,11 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService { @Override public List getRealData(String deviceCode) { - /*R> realData = wrpSectionBClient.getRealData(deviceCode); + R> realData = wrpSectionBClient.getRealData(deviceCode); if(!realData.isSuccess() || CollectionUtil.isEmpty(realData.getData())){ return null; } - return realData.getData();*/ - return null; + return realData.getData(); } @Override @@ -100,5 +110,94 @@ public class DigitalBaseInfoServiceImpl implements IDigitalBaseInfoService { return result.getData(); } + @Override + public Map getPowerStationHisInfo(String deviceCode, String activePower, String reactivePower, String power) { + R> realData = wrpSectionBClient.getRealData(deviceCode); + + Map result = new HashMap<>(); + if(realData.isSuccess() && CollectionUtil.isNotEmpty(realData.getData())){ + List datas = realData.getData(); + datas.stream().forEach(data -> { + if (activePower.equals(data.getSignage())) { + //有功功率 + result.put(activePower, data.getValue()); + } + if (reactivePower.equals(data.getSignage())) { + //无功功率 + result.put(reactivePower, data.getValue()); + } + }); + } + + //当前年的第一天 2023-1-1 + LocalDate year = LocalDate.now().withDayOfYear(1); + //当前月的第一天 2023-8-1 + LocalDate month = LocalDate.now().withDayOfMonth(1); + //当天 2023-8-29 + LocalDate day = LocalDate.now(); + LocalTime startTime = LocalTime.MIN; + + + LocalDateTime end = LocalDateTime.now(); + + //年累计 + LocalDateTime start = LocalDateTime.of(year, startTime); + AnalyseCodeByAnalyseDataPO poForYear = getPowerByParam(deviceCode, start, end, 4, 6, 1); + Result> listForYear = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(poForYear); + + //月累计 + start = LocalDateTime.of(month, startTime); + AnalyseCodeByAnalyseDataPO poForMonth = getPowerByParam(deviceCode, start, end, 4, 5, 1); + Result> listForMonth = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(poForMonth); + + //日累计 + start = LocalDateTime.of(day, startTime); + AnalyseCodeByAnalyseDataPO poForDay = getPowerByParam(deviceCode, start, end, 4, 4, 1); + Result> listForDay = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(poForDay); + + //日发电计划完成率 + result.put("dayPowerRate",null); + //月发电计划完成率 + result.put("monthPowerRate",null); + //日累计发电量 + result.put("dayPowerSum",null); + //月累计发电量 + result.put("monthPowerSum",null); + //年累计发电量 + result.put("yearPowerSum",null); + return result; + } + + /** + * 根据入参查询设备信息 + * @param deviceCode 设备编号 + * @param start 开始时间 + * @param end 结束时间 + * @param accessRules 取数规则0=最早值、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值 + * @param saveTimeType 周期类型: 0-> s(秒) 1->m(分) 2->h(小时) 3->d(天) 4->w(周) 5->n(自然月) 6->y(自然年) + * @param timeInterval 间隔时间 + * @return + */ + public AnalyseCodeByAnalyseDataPO getPowerByParam(String deviceCode, LocalDateTime start, LocalDateTime end, + Integer accessRules, Integer saveTimeType, Integer timeInterval) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + po.setDeviceCode(deviceCode); + + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO conditionPO = new AnalyzeDataConditionPO(); + + conditionPO.setBeginTime(start); + conditionPO.setEndTime(end); + conditionPO.setSignages(deviceCode); +// conditionPO.setKeepFigures(3); + conditionPO.setAccessRules(accessRules); + conditionPO.setSaveTimeType(saveTimeType); + conditionPO.setTimeInterval(timeInterval); + conditionPO.setFull(1); + signboardConditions.add(conditionPO); + po.setSignboardConditions(signboardConditions); + return po; + } + } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/controller/HiddenDangerController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/controller/HiddenDangerController.java new file mode 100644 index 0000000..bea8663 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/controller/HiddenDangerController.java @@ -0,0 +1,63 @@ +package com.hnac.hzims.safeproduct.hiddendanger.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.hnac.hzims.safeproduct.hiddendanger.entity.HiddenDanger; +import com.hnac.hzims.safeproduct.hiddendanger.service.HiddenDangerService; +import com.hnac.hzims.safeproduct.hiddendanger.vo.HiddenDangerQueryVo; +import lombok.RequiredArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/hiddendanger") +public class HiddenDangerController { + + @Autowired + HiddenDangerService hiddenDangerService; + + /** + * 分页查询 + */ + @GetMapping("/listPage/{page}/{size}") + public R listPage(@PathVariable Long page, + @PathVariable Long size, + HiddenDangerQueryVo hiddenDangerQueryVo) { + Page pageParam = new Page<>(page, size); + IPage resultParams = + hiddenDangerService.selectPage(pageParam, + hiddenDangerQueryVo); + return R.data(resultParams); + } + + /** + * 新增指标项管理 + */ + @PostMapping("/save") + public R save(@RequestBody HiddenDanger hiddenDanger) { + hiddenDangerService.save(hiddenDanger); + return R.success("新增成功"); + } + + + /** + * 更新指标项管理 + */ + @PutMapping("/update") + public R update(@RequestBody HiddenDanger hiddenDanger) { + hiddenDangerService.updateById(hiddenDanger); + return R.success("修改成功"); + } + + + /** + * 删除指标项管理 + */ + @DeleteMapping("/remove/{id}") + public R remove(@PathVariable Long id) { + hiddenDangerService.removeById(id); + return R.success("删除成功"); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/mapper/HiddenDangerMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/mapper/HiddenDangerMapper.java new file mode 100644 index 0000000..a7a4c7a --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/mapper/HiddenDangerMapper.java @@ -0,0 +1,7 @@ +package com.hnac.hzims.safeproduct.hiddendanger.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.hiddendanger.entity.HiddenDanger; + +public interface HiddenDangerMapper extends BaseMapper { +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/service/HiddenDangerService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/service/HiddenDangerService.java new file mode 100644 index 0000000..35b3dc9 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/service/HiddenDangerService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.safeproduct.hiddendanger.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.hiddendanger.entity.HiddenDanger; +import com.hnac.hzims.safeproduct.hiddendanger.vo.HiddenDangerQueryVo; + +public interface HiddenDangerService extends IService { + + + /** + * 分页查询 + * @param pageParam + * @param hiddenDangerQueryVo + * @return + */ + IPage selectPage(Page pageParam, HiddenDangerQueryVo hiddenDangerQueryVo); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/service/impl/HiddenDangerServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/service/impl/HiddenDangerServiceImpl.java new file mode 100644 index 0000000..2632dbc --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddendanger/service/impl/HiddenDangerServiceImpl.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.safeproduct.hiddendanger.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.safeproduct.hiddendanger.entity.HiddenDanger; +import com.hnac.hzims.safeproduct.hiddendanger.mapper.HiddenDangerMapper; +import com.hnac.hzims.safeproduct.hiddendanger.service.HiddenDangerService; +import com.hnac.hzims.safeproduct.hiddendanger.vo.HiddenDangerQueryVo; +import org.springframework.stereotype.Service; + +@Service +public class HiddenDangerServiceImpl extends ServiceImpl implements HiddenDangerService { + @Override + public IPage selectPage(Page pageParam, HiddenDangerQueryVo hiddenDangerQueryVo) { + String dangerBehavior = hiddenDangerQueryVo.getDangerBehavior(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotBlank(dangerBehavior)) { + queryWrapper.like(HiddenDanger::getDangerBehavior,dangerBehavior); + } + IPage hiddenDangerIPage = baseMapper.selectPage(pageParam, queryWrapper); + + return hiddenDangerIPage; + } +}