diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java new file mode 100644 index 0000000..c58f1f1 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/AlarmVideoVo.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.alarm.show.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; + +/** + * @author ysj + * @date 2023/03/17 10:02:33 + * @version 4.0.0 + */ +@Data +public class AlarmVideoVo { + + @ApiModelProperty("视频设备编码") + private String pointCode; + + @ApiModelProperty("视频名称") + @QueryField(condition = SqlCondition.LIKE) + private String videoName; + + @ApiModelProperty("视频服务器host") + private String videoHost; + + @ApiModelProperty("运管中心appSecret") + private String videoAppSecret; + + @ApiModelProperty("运管中心appKey") + private String videoAppKey; +} + diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 45145c9..b209fd0 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -87,6 +87,8 @@ public interface IEmInfoClient { String RIDE_DEVICES = API_PREFIX + "/rideDevices"; + String CREWS_DEVICES = API_PREFIX + "/crewsDevices"; + @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -176,4 +178,7 @@ public interface IEmInfoClient { @GetMapping(RIDE_DEVICES) List rideDevices(@RequestParam("deptIds") List deptIds); + + @GetMapping(CREWS_DEVICES) + List crewsDevices(@RequestParam("refDept") Long refDept); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index 104d494..c84c6eb 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -120,4 +120,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public List rideDevices(List longs) { return new ArrayList<>(); } + + @Override + public List crewsDevices(Long refDept) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java new file mode 100644 index 0000000..736f7ce --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationDeviceVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationDeviceVo { + + @ApiModelProperty("设备编号") + private String deviceCode; + + @ApiModelProperty("设备名称") + private String deviceName; + + @ApiModelProperty("属性时间范围统计数据") + private List attributes; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java new file mode 100644 index 0000000..1540fae --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportTimeVo.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationReportTimeVo { + + @ApiModelProperty("时间") + private String time; + + @ApiModelProperty("值") + private Double value; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java new file mode 100644 index 0000000..13847b5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/GenerationReportVo.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel("发电量报表") +public class GenerationReportVo { + + @ApiModelProperty("属性") + private String attribute; + + @ApiModelProperty("属性名称") + private String attributeName; + + @ApiModelProperty("属性时间范围统计数据") + private List times; +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index de29497..adfc78e 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -162,6 +162,12 @@ public class EmInfoClient implements IEmInfoClient { return service.rideDevices(deptIds); } + @Override + @GetMapping(CREWS_DEVICES) + public List crewsDevices(@RequestParam("refDept") Long refDept) { + return service.list(Wrappers.lambdaQuery().eq(EmInfoEntity::getEmType,2).eq(EmInfoEntity::getCreateDept,refDept)); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index ac42e2c..a059740 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -55,7 +55,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); return false; } - // 步骤2.查询当天处理的告警 + // 步骤2.查询1小时内处理的告警 List handlers = handleService.sameDayContent(); // 步骤3.查询延后未完成的告警 List delays = handleService.incompleteContent(); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java index 162c113..8deca55 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.show.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.alarm.source.service.SystemAlarmService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; @@ -54,12 +55,13 @@ public class ShowAlarmController extends BladeController { return R.data(alarmService.counts(alarm)); } - @GetMapping("/getVideosByStationAndRealId") + @GetMapping("/alarmVideos") @ApiOperationSupport(order = 4) @ApiOperation(value = "站点") - public R> getVideosByStationAndRealId(@ApiParam("站点编号") @RequestParam String stationCode, - @ApiParam("监测点ID") @RequestParam String realId) { - return R.data(alarmService.getVideosByStationAndRealId(stationCode,realId)); + public R> alarmVideos(@ApiParam("站点编号") @RequestParam String stationCode, + @ApiParam("设备编号") @RequestParam String deviceCode, + @ApiParam("监测点ID") @RequestParam String realId) { + return R.data(alarmService.alarmVideos(stationCode,deviceCode,realId)); } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index 8b62437..0bc7f77 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.show.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.config.vo.AlarmCountVo; +import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import org.springblade.core.mp.base.BaseService; import org.springframework.web.socket.TextMessage; @@ -22,11 +23,5 @@ public interface AlarmService extends BaseService { TextMessage majorAlarm(List depts); - /** - * 根据站点、realId 获取视频列表 - * @param stationCode 站点编号 - * @param realId hz3000点位信息 - * @return 视频列表 - */ - List getVideosByStationAndRealId(String stationCode,String realId); + List alarmVideos(String stationCode, String deviceCode, String realId); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 0a954e2..0cbb3a4 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -176,7 +176,7 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl sameDayContent() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR_OF_DAY,-1); - String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); return this.baseMapper.sameDayContent(start,end); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 1e3838e..f822a0a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -11,6 +11,7 @@ import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; +import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.alarm.source.service.MessageService; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; @@ -227,7 +228,8 @@ public class AlarmServiceImpl extends BaseServiceImpl return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList()))); } - @Override + + /* @Override public List getVideosByStationAndRealId(String stationCode, String realId) { R stationR = stationClient.getStationByCode(stationCode); Assert.isTrue(stationR.isSuccess() && Func.isNotEmpty(stationR.getData()), () -> { @@ -254,7 +256,7 @@ public class AlarmServiceImpl extends BaseServiceImpl throw new ServiceException("获取设备绑定视频列表失败!"); }); return videoListR.getData().stream().distinct().collect(Collectors.toList()); - } + }*/ /** * 验证设备编号是否绑定视频 @@ -395,4 +397,28 @@ public class AlarmServiceImpl extends BaseServiceImpl } } } + + /** + * 获取告警视频信息 + * @param stationCode + * @param deviceCode + * @param realId + * @return + */ + @Override + public List alarmVideos(String stationCode, String deviceCode, String realId) { + // 根据realId查找 + if(StringUtil.isNotBlank(realId)){ + + } + // 根据设备编号查找 + if(StringUtil.isNotBlank(deviceCode)){ + + } + // 根据站点编号查找 + if(StringUtil.isNotBlank(stationCode)){ + + } + return new ArrayList<>(); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java new file mode 100644 index 0000000..b462792 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/GenerationReportController.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.report.controller; + +import com.hnac.hzims.operational.report.service.IGenerationReportService; +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@Slf4j +@AllArgsConstructor +@RestController +@RequestMapping("/generation/report") +public class GenerationReportController extends BladeController { + + private final IGenerationReportService service; + + @GetMapping("/sameDayReport") + public R> sameDayReport(@RequestParam("stationId") String stationId){ + return R.data(service.sameDayReport(stationId)); + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java new file mode 100644 index 0000000..ec40e5a --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IGenerationReportService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.report.service; + +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; + +import java.util.List; + +/** + * @author ysj + */ +public interface IGenerationReportService { + + List sameDayReport(String stationId); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java new file mode 100644 index 0000000..8433cb1 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/GenerationReportServiceImpl.java @@ -0,0 +1,100 @@ +package com.hnac.hzims.operational.report.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.operational.report.service.IGenerationReportService; +import com.hnac.hzims.operational.report.vo.GenerationDeviceVo; +import com.hnac.hzims.operational.report.vo.GenerationReportTimeVo; +import com.hnac.hzims.operational.report.vo.GenerationReportVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class GenerationReportServiceImpl implements IGenerationReportService { + + private final IStationService stationService; + + private final IEmInfoClient deviceClient; + + /** + * 当天报表 + * @param stationId + * @return + */ + @Override + public List sameDayReport(String stationId) { + // 查询站点 + StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getCode,stationId)); + if(ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到站点信息!"); + } + // 查询站点机组设备 + List devices = deviceClient.crewsDevices(station.getRefDept()); + if(CollectionUtil.isEmpty(devices)){ + throw new ServiceException("未查询到站点机组类型设备!"); + } + // FIXME 属性标识 + Map signages = new HashMap<>(); + signages.put("active_power","有功功率"); + signages.put("reactive_power","无功功率"); + signages.put("generation_capacity","正向有功电量"); + signages.put("reactive_generation_capacity","正向无功电量"); + List times = this.sameDayValues(); + Random random = new Random(); + return devices.stream().map(device->{ + GenerationDeviceVo item = new GenerationDeviceVo(); + item.setDeviceCode(device.getNumber()); + item.setDeviceName(device.getName()); + item.setAttributes(signages.entrySet().stream().map(entry->{ + GenerationReportVo attribute = new GenerationReportVo(); + attribute.setAttribute(entry.getKey()); + attribute.setAttributeName(entry.getValue()); + // FIXME : 使用随机数 + attribute.setTimes(times.stream().map(time->{ + GenerationReportTimeVo generation = new GenerationReportTimeVo(); + generation.setTime(time); + generation.setValue(random.nextDouble() * 1000); + return generation; + }).collect(Collectors.toList())); + return attribute; + }).collect(Collectors.toList())); + return item; + }).collect(Collectors.toList()); + } + + /** + * 当天数据值 + * @return + */ + private List sameDayValues() { + Calendar calendar = Calendar.getInstance(); + Date end = calendar.getTime(); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + calendar.add(Calendar.MILLISECOND,-calendar.get(Calendar.MILLISECOND)); + Date start = calendar.getTime(); + List times = new ArrayList<>(); + while (start.compareTo(end) <= 0){ + calendar.add(Calendar.HOUR_OF_DAY,1); + times.add(start.getHours() + "时"); + start = calendar.getTime(); + } + return times; + } +} \ No newline at end of file