diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryAbnormalAlarmEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryAbnormalAlarmEntity.java index 058e0eb..9768788 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryAbnormalAlarmEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/entity/HistoryAbnormalAlarmEntity.java @@ -11,10 +11,13 @@ import java.util.Date; @Data @TableName("hzims_history_abnormal_alarm") -@EqualsAndHashCode(callSuper = true) +@EqualsAndHashCode(callSuper = false) @ApiModel(value = "数据中断告警对象") public class HistoryAbnormalAlarmEntity extends BaseEntity { + @ApiModelProperty("ID") + private Long id; + @ApiModelProperty("站点编码") private String stationId; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/DeviceClassifyVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/DeviceClassifyVo.java index 58b69e4..29ff595 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/DeviceClassifyVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/DeviceClassifyVo.java @@ -18,5 +18,5 @@ public class DeviceClassifyVo { private String deviceName; @ApiModelProperty("设备状态") - private String deviceStatus; + private Integer deviceStatus; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetVo.java new file mode 100644 index 0000000..4d322a5 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/HydropowerTargetVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/03/14 15:01:17 + * @version 4.0.0 + */ +@Data +public class HydropowerTargetVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("发电量") + private Double electric; + + @ApiModelProperty("功率") + private Double power; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterTargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterTargetVo.java new file mode 100644 index 0000000..86ee588 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/census/vo/WaterTargetVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.census.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/03/14 15:01:17 + * @version 4.0.0 + */ +@Data +public class WaterTargetVo { + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("用电量") + private Double use; + + @ApiModelProperty("功率") + private Double load; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/constants/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/constants/HomePageConstant.java index 1bfca64..be2367d 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/constants/HomePageConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/constants/HomePageConstant.java @@ -54,6 +54,10 @@ public interface HomePageConstant { */ List waterList = Arrays.asList(HomePageConstant.WATER_CONSERVANCY,HomePageConstant.PUMPING,HomePageConstant.GATE); + List types = Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.WIND_POWER,HomePageConstant.WATER_CONSERVANCY,HomePageConstant.ENERGY_STORAGE, + HomePageConstant.DISTRIBUTION_NETWORK,HomePageConstant.PHOTOVOLTAIC,HomePageConstant.WATER_AFFAIRS,HomePageConstant.CHARGE,HomePageConstant.PUMPING, + HomePageConstant.GATE); + List SIGNAGES = Arrays.asList(HomePageConstant.JOINT_RELAY,HomePageConstant.SWITCH_ON_OFF,HomePageConstant.ELECTRICITY_CONSUMPTION, HomePageConstant.ACTIVE_POWER,HomePageConstant.REACTIVE_POWER,HomePageConstant.POWER_FACTOR,HomePageConstant.VOLTAGE,HomePageConstant.CURRENT, HomePageConstant.HYDROPOWER_GENERATE_POWER,HomePageConstant.HYDROPOWER_POWERFACTOR,HomePageConstant.HYDROPOWER_FREQUENCY,HomePageConstant.HYDROPOWER_GUIDEOPEN, @@ -65,6 +69,11 @@ public interface HomePageConstant { Integer HYDROPOWER_SERVETYPE = 2; /** + * 站点类型 : 云服务 + */ + Integer CLOUD_SERVETYPE = 1; + + /** * 0-风电 */ Integer WIND_POWER_TYPE = 0; @@ -166,4 +175,11 @@ public interface HomePageConstant { /**遥信1**/ String PV_JOINT_RELAY = "joint_relay"; /*==========================================================================================*/ + // 水电集团、区域指标关联 + /**功率**/ + Integer POWER = 0; +/*==========================================================================================*/ + // 水利集团、区域指标关联 + /**功率**/ + Integer LOADING = 0; } diff --git a/hzims-service-api/hzims-service-api.iml b/hzims-service-api/hzims-service-api.iml deleted file mode 100644 index c4065f6..0000000 --- a/hzims-service-api/hzims-service-api.iml +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java index 7ef4e77..1b9fdf3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; +import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -25,14 +26,34 @@ import javax.validation.Valid; public class AbnormalAlarmController extends BladeController { private final HistoryAbnormalAlarmService service; + /** + * 统计通讯中断时间 + */ + @GetMapping("/statisticsTime") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "统计通讯中断时间", notes = "传入imsDutyMainEntity") + public R> statisticsTime(HistoryAbnormalAlarmEntity entity, Query query) { + IPage pages = service.getAlarmTime(query,entity); + return R.data(pages); + } + /** + * 统计通讯中断二级目录查询 + */ + @GetMapping("/queryByEntity") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "统计通讯中断二级目录查询", notes = "传入imsDutyMainEntity") + public R> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { + IPage pages = service.queryByEntity(entity,query); + return R.data(pages); + } /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) - @ApiOperation(value = "详情", notes = "传入imsDutyMainEntity") + @ApiOperation(value = "详情", notes = "传入HistoryAbnormalAlarmEntity") public R detail(HistoryAbnormalAlarmEntity entity) { HistoryAbnormalAlarmEntity detail = service.getOne(Condition.getQueryWrapper(entity)); return R.data(detail); @@ -43,7 +64,7 @@ public class AbnormalAlarmController extends BladeController { */ @GetMapping("/list") @ApiOperationSupport(order = 2) - @ApiOperation(value = "分页", notes = "传入imsDutyMain") + @ApiOperation(value = "分页", notes = "传入HistoryAbnormalAlarmEntity") public R> list(HistoryAbnormalAlarmEntity entity, Query query) { IPage pages = service.page(Condition.getPage(query), Condition.getQueryWrapper(entity)); return R.data(pages); @@ -54,7 +75,7 @@ public class AbnormalAlarmController extends BladeController { */ @PostMapping("/submit") @ApiOperationSupport(order = 3) - @ApiOperation(value = "新增或修改", notes = "传入imsDutyMain") + @ApiOperation(value = "新增或修改", notes = "传入HistoryAbnormalAlarmEntity") public R submit(@Valid @RequestBody HistoryAbnormalAlarmEntity entity) { return R.status(service.saveOrUpdate(entity)); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.java index be67201..3f330b4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.java @@ -19,4 +19,6 @@ public interface HistoryAbnormalAlarmMapper extends UserDataScopeBaseMapper selectPageList(IPage page, String type, List stations); + + List getAlarmEntity(@Param("type") String type,@Param("stationName") String stationName,@Param("startTime") Date startTime,@Param("endTime") Date endTime); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.xml index 76d3599..a8e7014 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/mapper/HistoryAbnormalAlarmMapper.xml @@ -11,7 +11,7 @@ + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java index 33670db..11145a6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java @@ -18,4 +18,8 @@ public interface HistoryAbnormalAlarmService extends BaseService list(IPage page, String type); + + IPage getAlarmTime(Query query, HistoryAbnormalAlarmEntity entity); + + IPage queryByEntity(HistoryAbnormalAlarmEntity entity,Query query); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index 5fa834f..efdc489 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.alert.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.mapper.HistoryAbnormalAlarmMapper; @@ -10,12 +12,18 @@ import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils; +import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; -import java.util.Date; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; import java.util.stream.Collectors; /** @@ -56,4 +64,91 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl getAlarmTime(Query query, HistoryAbnormalAlarmEntity entity) { + List historyAbnormalAlarmVos= this.baseMapper.getAlarmEntity(entity.getType(),entity.getStationName(),entity.getStartTime(),entity.getEndTime()); + if (historyAbnormalAlarmVos==null){ + return null; + } + //赋值空的endTime + if(ObjectUtils.isNotEmpty(entity.getEndTime())){ + historyAbnormalAlarmVos.stream().filter(s->s.getEndTime()==null).forEach(s->s.setEndTime(entity.getEndTime())); + }else { + historyAbnormalAlarmVos.stream().filter(s -> s.getEndTime() == null).forEach(s -> s.setEndTime(new Date())); + } + List voList = historyAbnormalAlarmVos.parallelStream().map(s -> { + s.setTimes((s.getEndTime().getTime() - s.getStartTime().getTime())); + return s; + }).collect(Collectors.toList()); + //次数统计 + Map timesList = voList.stream().collect(Collectors.groupingBy(HistoryAbnormalAlarmEntity::getStationName, + Collectors.counting())); + //时间统计 + Map durationList = voList.stream().collect(Collectors.groupingBy(HistoryAbnormalAlarmEntity::getStationName, + Collectors.summingLong(HistoryAbnormalAlarmVo::getTimes))); + + List res=new ArrayList<>(); + for (Map.Entry entry : durationList.entrySet()) { + //累计时长 + double v = BigDecimal.valueOf(entry.getValue() / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + HistoryAbnormalAlarmVo historyAbnormalAlarmVo = new HistoryAbnormalAlarmVo(); + historyAbnormalAlarmVo.setDuration(v); + String key = entry.getKey(); + historyAbnormalAlarmVo.setStationName(key); + historyAbnormalAlarmVo.setTimes(timesList.get(key)); + if(StringUtils.isNotEmpty(entity.getType())){ + historyAbnormalAlarmVo.setType(entity.getType()); + } + res.add(historyAbnormalAlarmVo); + } + //根据电站名字排序 + res=res.stream(). + sorted(Comparator.comparing(HistoryAbnormalAlarmVo::getStationName)) + .collect(Collectors.toList()); + IPage page = Condition.getPage(query); + page.setTotal(res.size()); + if (query==null){ + page.setRecords(res); + }else { + if (res.size()>query.getCurrent()* query.getSize()) { + page.setRecords(res.subList((query.getCurrent() - 1) * query.getSize(), query.getCurrent() * query.getSize())); + }else { + page.setRecords(res.subList((query.getCurrent() - 1) * query.getSize(), res.size())); + } + } + return page; + } + + + private QueryWrapper getAlarmEntityQueryWrapper(HistoryAbnormalAlarmEntity entity) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (entity.getStationName()!=null) { + queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getStationName, entity.getStationName()); + } + if (entity.getType()!=null) { + queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getType, entity.getType()); + } + if (entity.getStartTime()!=null) { + queryWrapper.lambda().le(HistoryAbnormalAlarmEntity::getStartTime, entity.getStartTime()); + } + if (entity.getEndTime()!=null) { + queryWrapper.lambda().ge(HistoryAbnormalAlarmEntity::getStartTime, entity.getEndTime()); + } + return queryWrapper; + } + + @Override + public IPage queryByEntity(HistoryAbnormalAlarmEntity entity,Query query) { + QueryWrapper alarmEntityQueryWrapper = getAlarmEntityQueryWrapper(entity); + IPage historyAbnormalAlarmEntityIPage = this.baseMapper.selectPage(Condition.getPage(query), alarmEntityQueryWrapper); + return historyAbnormalAlarmEntityIPage; + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java index 0d5092a..3fde44e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java @@ -9,6 +9,7 @@ import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.models.auth.In; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -31,42 +32,42 @@ public class TargetController { @ApiOperation("装机容量统计:区分填报/接入站点") @PostMapping("/installed-capacity") @ApiOperationSupport(order = 1) - public R installedCapacity(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { + public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { return R.data(service.installedCapacity(stationName,type)); } @ApiOperation("发电量统计:区分填报/接入站点") @PostMapping("/electric-generation") @ApiOperationSupport(order = 2) - public R electricGeneration(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { + public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { return R.data(service.electricGeneration(stationName,type)); } @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点") @PostMapping("/complete-generation") @ApiOperationSupport(order = 3) - public R completeGeneration(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { + public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { return R.data(service.completeGeneration(stationName,type)); } @ApiOperation("两票统计:区分填报/平台业务数据") @PostMapping("/complete-ticket") @ApiOperationSupport(order = 4) - public R completeTicket(@RequestParam(value = "areaName") String areaName,@RequestParam(value = "type") Integer type) { + public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { return R.data(service.completeTicket(areaName,type)); } @ApiOperation("缺陷率统计:区分填报/平台业务数据") @GetMapping("/complete-defect") @ApiOperationSupport(order = 5) - public R completeDefect(@RequestParam(value = "areaName") String areaName,@RequestParam(value = "type") Integer type) { + public R completeDefect(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { return R.data(service.defect(areaName,type)); } @ApiOperation("上线率/Fa投入条数统计") @GetMapping("/complete-other") @ApiOperationSupport(order = 6) - public R completeOther(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type,@RequestParam(value = "queryType") Integer queryType) { + public R completeOther(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type,@RequestParam(value = "queryType") Integer queryType) { return R.data(service.completeOther(stationName,type,queryType)); } @@ -87,15 +88,30 @@ public class TargetController { @ApiOperation("检修卡统计") @GetMapping("/examineCard") @ApiOperationSupport(order = 9) - public R examineCard(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { + public R examineCard(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { return R.data(service.examineCard(stationName,type)); } @ApiOperation("设备统计") @GetMapping("/device-classify") @ApiOperationSupport(order = 10) - public R deviceClassify(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "deptId") Long deptId) { - return R.data(service.deviceClassify(stationName,deptId)); + public R deviceClassify(@RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "deptId",required = false) Long deptId,@RequestParam(value="status")Integer status) { + return R.data(service.deviceClassify(stationName,deptId,status)); + } + + @ApiOperation("水电集团、区域指标关联") + @GetMapping("/hydropower-target") + @ApiOperationSupport(order = 10) + public R hydropowerTarget(@RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "deptId",required = false) Long deptId,@RequestParam(value = "target") Integer target) { + return R.data(service.hydropowerTarget(stationName,deptId,target)); + } + + + @ApiOperation("水利集团、区域指标关联") + @GetMapping("/water-target") + @ApiOperationSupport(order = 10) + public R waterTarget(@RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "deptId",required = false) Long deptId,@RequestParam(value = "target") Integer target) { + return R.data(service.waterTarget(stationName,deptId,target)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java index ad30169..63479f1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java @@ -1,9 +1,7 @@ package com.hnac.hzims.operational.census.service; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; -import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.census.vo.*; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; @@ -48,5 +46,9 @@ public interface TargetService { R> examineRepair(OperAccessTaskDTO params, Query query, Integer type); // 设备分类统计 - List deviceClassify(String stationName, Long deptId); + List deviceClassify(String stationName, Long deptId,Integer status); + + List hydropowerTarget(String stationName, Long deptId,Integer target); + + List waterTarget(String stationName, Long deptId,Integer target); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 15bdbf3..6d9b388 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.census.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.equipment.entity.EmInfoEntity; @@ -16,12 +17,13 @@ import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.census.constants.CensusConstant; import com.hnac.hzims.operational.census.service.TargetService; import com.hnac.hzims.operational.census.vo.*; +import com.hnac.hzims.operational.census.vo.WaterTargetVo; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.fill.entity.*; import com.hnac.hzims.operational.fill.service.*; import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; -import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo; +import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.maintenance.constants.HomePageConstant; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; @@ -36,6 +38,7 @@ import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.MapUtils; import org.springblade.core.mp.support.Query; 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.system.entity.Dept; @@ -100,9 +103,18 @@ public class TargetServiceImpl implements TargetService { private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; + private final static String KEY_INDICATORS_INFO = "hzims:operation:key:indicators:info"; + @Value("${hzims.operation.region.deviceClassifyKey}") private String device_classify_key; + @Value("${hzims.operation.homePage.activePowerKey}") + public String activePowerKey; + + private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; + + private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; + /** * 获取站点装机容量 * @return @@ -110,11 +122,13 @@ public class TargetServiceImpl implements TargetService { @Override public List installedCapacity(String stationName,Integer type) { // 站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) - .eq(StationEntity::getServeType,2) - .like(StationEntity::getName,stationName) - ); + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } @@ -166,12 +180,15 @@ public class TargetServiceImpl implements TargetService { */ @Override public List electricGeneration(String stationName,Integer type) { - // 接入站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) - .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) - .like(StationEntity::getName,stationName) - );if(CollectionUtils.isEmpty(stations)){ + // 站点 + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + List stations = stationService.list(wappers); + if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } // 填报数据 @@ -227,10 +244,13 @@ public class TargetServiceImpl implements TargetService { @Override public List completeGeneration(String stationName,Integer type) { // 站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) - .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) - .like(StationEntity::getName,stationName)); + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } @@ -450,11 +470,13 @@ public class TargetServiceImpl implements TargetService { @Override public List examineCard(String stationName, Integer type) { // 站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) - .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) - .like(StationEntity::getName,stationName) - ); + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } @@ -492,11 +514,13 @@ public class TargetServiceImpl implements TargetService { @Override public List completeOther(String stationName, Integer type, Integer queryType) { // 站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) - .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) - .like(StationEntity::getName,stationName) - ); + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } @@ -531,11 +555,13 @@ public class TargetServiceImpl implements TargetService { */ private List getFillDefect(String areaName, Integer type) { // 站点 - List stations = stationService.list(Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) - .eq(StationEntity::getServeType,2) - .like(StationEntity::getName,areaName) - ); + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(areaName)){ + wappers.like(StationEntity::getName,areaName); + } + List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ return new ArrayList<>(); } @@ -567,7 +593,7 @@ public class TargetServiceImpl implements TargetService { /** * 日常维护统计 - * @param param + * @param params * @param query * @param type * @return @@ -610,7 +636,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List deviceClassify(String stationName, Long deptId) { + public List deviceClassify(String stationName, Long deptId,Integer status) { // 获取区域设备统计 Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_key); List faultList = deviceClassifyMap.get(HomePageConstant.FAULT); @@ -635,21 +661,157 @@ public class TargetServiceImpl implements TargetService { if(CollectionUtils.isEmpty(devices)){ return new ArrayList<>(); } - return devices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { + // 获取设备集合 + List deviceClassifys = devices.stream().sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { DeviceClassifyVo deviceClassify = new DeviceClassifyVo(); deviceClassify.setStationName(stations.stream().filter(o-> o.getRefDept().equals(o.getCreateDept())).collect(Collectors.toList()).get(0).getName()); deviceClassify.setDeviceName(device.getName()); if(faultList.contains(device.getEmCode())){ - deviceClassify.setDeviceStatus(HomePageConstant.FAULT); + deviceClassify.setDeviceStatus(4); }else if(overhaultList.contains(device.getEmCode())){ - deviceClassify.setDeviceStatus(HomePageConstant.OVERHAUL); + deviceClassify.setDeviceStatus(0); }else if(runtList.contains(device.getEmCode())){ - deviceClassify.setDeviceStatus(HomePageConstant.RUN); + deviceClassify.setDeviceStatus(1); }else{ - deviceClassify.setDeviceStatus(HomePageConstant.SPARE); + deviceClassify.setDeviceStatus(2); } return deviceClassify; - }).collect(Collectors.toList()); + }).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList()); + // 状态过滤 + if(ObjectUtil.isEmpty(status)){ + return deviceClassifys.stream().sorted(Comparator.comparing(DeviceClassifyVo::getDeviceStatus)).collect(Collectors.toList()); + } + return deviceClassifys.stream().filter(o->o.getDeviceStatus().equals(status)).sorted(Comparator.comparing(DeviceClassifyVo::getDeviceStatus)).collect(Collectors.toList()); + } + + /** + * 水电指标关联数据 + * @param stationName + * @param deptId + * @return + */ + @Override + public List hydropowerTarget(String stationName, Long deptId,Integer target) { + // 站点 + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + if(!ObjectUtil.isEmpty(deptId)){ + List deptIds = sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); + wappers.in(StationEntity::getRefDept,deptIds); + } + List stations = stationService.list(wappers); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 功率 + if(HomePageConstant.POWER.equals(target)){ + Map activePowerMap = (Map) redisTemplate.opsForValue().get(activePowerKey); + return stations.stream().map(station->{ + HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); + hydropowerTarget.setStationName(station.getName()); + if(MapUtils.isEmpty(activePowerMap)){ + hydropowerTarget.setPower(0.0); + return hydropowerTarget; + } + Double power = activePowerMap.get(station.getCode()); + hydropowerTarget.setPower(power); + return hydropowerTarget; + }).sorted(Comparator.comparing(HydropowerTargetVo::getPower)).collect(Collectors.toList()); + } + // 发电量 + KeyIndicatorsVo keyIndicatorsVo = (KeyIndicatorsVo) redisTemplate.opsForValue().get(KEY_INDICATORS_INFO); + // 水电站 + List powers = keyIndicatorsVo.getPowerStationTotalVoList(); + return stations.stream().map(station->{ + HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); + hydropowerTarget.setStationName(station.getName()); + if(CollectionUtils.isEmpty(powers)){ + hydropowerTarget.setElectric(0.0); + return hydropowerTarget; + } + List stationTargets = powers.stream().filter(o-> o.getStationId().equals(station.getId())).collect(Collectors.toList()); + if(CollectionUtils.isEmpty(stationTargets)){ + hydropowerTarget.setElectric(0.0); + return hydropowerTarget; + } + switch (target){ + case 3: + hydropowerTarget.setElectric(new BigDecimal(stationTargets.get(0).getCurrentYearPowerGeneration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + break; + case 2: + hydropowerTarget.setElectric(stationTargets.get(0).getPowerGeneration()); + break; + case 1: + hydropowerTarget.setElectric(new BigDecimal(stationTargets.get(0).getCurrentDayPowerGeneration()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + break; + } + return hydropowerTarget; + }).sorted(Comparator.comparing(HydropowerTargetVo::getElectric)).collect(Collectors.toList()); + } + + /** + * 水利指标关联数据 + * @param stationName + * @param deptId + * @return + */ + @Override + public List waterTarget(String stationName, Long deptId,Integer target) { + // 站点 + LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); + wappers.in(StationEntity::getType, HomePageConstant.waterList); + wappers.eq(StationEntity::getServeType,2); + if(!StringUtils.isEmpty(stationName)){ + wappers.like(StationEntity::getName,stationName); + } + if(!ObjectUtil.isEmpty(deptId)){ + List deptIds = sysClient.getDeptByCurrentUser().getData().stream().filter(dept -> dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList()); + wappers.in(StationEntity::getRefDept,deptIds); + } + List stations = stationService.list(wappers); + if(CollectionUtils.isEmpty(stations)){ + return new ArrayList<>(); + } + // 负荷 + if(HomePageConstant.LOADING.equals(target)){ + List pumps = (List) redisTemplate.opsForValue().get(loadwaterpump_real_key); + return stations.stream().map(station->{ + WaterTargetVo water = new WaterTargetVo(); + water.setStationName(station.getName()); + if(CollectionUtil.isEmpty(pumps)){ + water.setUse(0.0); + return water; + } + water.setUse(pumps.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpRealVo::getActivePower).sum()); + return water; + }).sorted(Comparator.comparing(WaterTargetVo::getLoad)).collect(Collectors.toList()); + } + // 用电量 + List targets = (List) redisTemplate.opsForValue().get(loadwaterpump_target_key); + return stations.stream().map(station->{ + WaterTargetVo water = new WaterTargetVo(); + water.setStationName(station.getName()); + if(CollectionUtil.isEmpty(targets)){ + water.setUse(0.0); + return water; + } + switch (target){ + case 3: + water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerYear).sum()); + break; + case 2: + water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerMon).sum()); + break; + case 1: + water.setUse(targets.stream().filter(o->o.getDeptId().equals(station.getRefDept())).mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum()); + break; + } + return water; + }).sorted(Comparator.comparing(WaterTargetVo::getUse)).collect(Collectors.toList()); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/NotInsertPowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/NotInsertPowerServiceImpl.java index 9730904..1198ed9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/NotInsertPowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/NotInsertPowerServiceImpl.java @@ -53,8 +53,7 @@ public class NotInsertPowerServiceImpl extends BaseServiceImpl> select(@RequestParam(value = "type",required = false) Integer type,@RequestParam(value = "serveType",required = false) Integer serveType){ + return R.data(stationService.select(type,serveType)); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index b35f413..fe3cb6c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -102,4 +102,6 @@ public interface IStationService extends BaseService { Integer getStationMaxOrder(); List getStationCount(); + + List select(Integer type, Integer serveType); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index fe0809c..8ecb0a7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -9,6 +9,7 @@ import com.hnac.hzims.operational.OperationalConstants; import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.main.vo.StationCountVo; import com.hnac.hzims.operational.station.StationConstants; +import com.hnac.hzims.operational.maintenance.constants.HomePageConstant; import com.hnac.hzims.operational.station.entity.ControlUsersEntity; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.mapper.ControlUsersMapper; @@ -19,8 +20,7 @@ import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.wrapper.StationWrapper; import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.project.ProjectClient; -import com.hnac.hzinfo.sdk.project.dto.ProjectDTO; +import com.hnac.hzims.spare.entity.WtSpBasicEntity; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -571,4 +571,30 @@ public class StationServiceImpl extends BaseServiceImpl select(Integer type, Integer serveType) { + List types; + if(ObjectUtil.isEmpty(type)){ + types = HomePageConstant.types; + }else{ + types = Collections.singletonList(type); + } + List serveTypes; + if(ObjectUtil.isEmpty(serveType)){ + serveTypes = Arrays.asList(HomePageConstant.HYDROPOWER_SERVETYPE,HomePageConstant.CLOUD_SERVETYPE); + }else{ + serveTypes = Collections.singletonList(serveType); + } + return this.list(Wrappers.lambdaQuery() + .in(StationEntity::getType, types) + .in(StationEntity::getServeType,serveTypes) + ); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HistoryAbnormalAlarmVo.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HistoryAbnormalAlarmVo.java index 93a460a..5f71f64 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HistoryAbnormalAlarmVo.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/vo/HistoryAbnormalAlarmVo.java @@ -1,9 +1,17 @@ package com.hnac.hzims.operational.station.vo; +import com.baomidou.mybatisplus.annotation.TableField; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data public class HistoryAbnormalAlarmVo extends HistoryAbnormalAlarmEntity{ + @TableField(exist=false) + @ApiModelProperty("告警次数") + private Long times; + @TableField(exist=false) + @ApiModelProperty("告警时长") + private Double duration; }