From e23e969fb317d2da74cd0dc35c4fcb5491cb8c05 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 8 Aug 2023 15:23:18 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=95=B0=E6=8D=AE=E5=85=B3=E8=81=94=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../census/controller/TargetController.java | 78 ++++++---- .../operational/census/service/TargetService.java | 19 +-- .../census/service/impl/TargetServiceImpl.java | 162 +++++++++------------ 3 files changed, 131 insertions(+), 128 deletions(-) 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 0785651..ce0d3c6 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 @@ -5,10 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.census.service.TargetService; -import com.hnac.hzims.operational.census.vo.CompleteGenerationVo; -import com.hnac.hzims.operational.census.vo.CompleteTicketVo; -import com.hnac.hzims.operational.census.vo.ElectricGenerationVo; -import com.hnac.hzims.operational.census.vo.InstalledCapacityVo; +import com.hnac.hzims.operational.census.vo.*; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import io.swagger.annotations.Api; @@ -37,7 +34,8 @@ public class TargetController { @ApiOperation("装机容量统计:区分填报/接入站点") @PostMapping("/installed-capacity") @ApiOperationSupport(order = 1) - public R> installedCapacity(Query query,@RequestParam(value = "stationName",required = false) String stationName, + public R> installedCapacity(Query query, + @RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "type") Integer type) { return R.data(service.installedCapacity(Condition.getPage(query),stationName,type)); } @@ -45,7 +43,8 @@ public class TargetController { @ApiOperation("发电量统计:区分填报/接入站点") @PostMapping("/electric-generation") @ApiOperationSupport(order = 2) - public R> electricGeneration(Query query, @RequestParam(value = "stationName",required = false) String stationName, + public R> electricGeneration(Query query, + @RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "type") Integer type) { return R.data(service.electricGeneration(Condition.getPage(query),stationName,type)); } @@ -55,7 +54,8 @@ public class TargetController { @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点") @PostMapping("/complete-generation") @ApiOperationSupport(order = 3) - public R> completeGeneration(Query query, @RequestParam(value = "stationName",required = false) String stationName, + public R> completeGeneration(Query query, + @RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "type") Integer type) { return R.data(service.completeGeneration(Condition.getPage(query),stationName,type)); } @@ -65,7 +65,8 @@ public class TargetController { @ApiOperation("两票统计:区分填报/平台业务数据") @PostMapping("/complete-ticket") @ApiOperationSupport(order = 4) - public R> completeTicket(Query query,@RequestParam(value = "areaName",required = false) String areaName, + public R> completeTicket(Query query, + @RequestParam(value = "areaName",required = false) String areaName, @RequestParam(value = "type") Integer type) { return R.data(service.completeTicket(Condition.getPage(query),areaName,type)); } @@ -74,8 +75,10 @@ public class TargetController { @ApiOperation("缺陷率统计:区分填报/平台业务数据") @GetMapping("/complete-defect") @ApiOperationSupport(order = 5) - public R completeDefect(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { - return R.data(service.defect(areaName,type)); + public R> completeDefect(Query query, + @RequestParam(value = "areaName",required = false) String areaName, + @RequestParam(value = "type") Integer type) { + return R.data(service.defect(Condition.getPage(query),areaName,type)); } @@ -83,15 +86,20 @@ public class TargetController { @ApiOperation("上线率/Fa投入条数统计") @GetMapping("/complete-other") @ApiOperationSupport(order = 6) - 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)); + public R> completeOther(Query query, + @RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "queryType") Integer queryType) { + return R.data(service.completeOther(Condition.getPage(query),stationName,type,queryType)); } @ApiLog @ApiOperation("日常维护统计") @GetMapping("/routine-maintenance") @ApiOperationSupport(order = 7) - public R> routineMaintenance(OperMaintenanceTaskDTO params,Query query,Integer type) { + public R> routineMaintenance(OperMaintenanceTaskDTO params, + Query query, + Integer type) { return service.routineMaintenance(params,query,type); } @@ -100,7 +108,9 @@ public class TargetController { @ApiOperation("检修任务统计") @GetMapping("/examine-repair") @ApiOperationSupport(order = 8) - public R> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { + public R> examineRepair(OperAccessTaskDTO params, + Query query, + Integer type) { return service.examineRepair(params, query,type); } @@ -109,16 +119,21 @@ public class TargetController { @ApiOperation("检修卡统计") @GetMapping("/examineCard") @ApiOperationSupport(order = 9) - public R examineCard(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.examineCard(stationName,type)); + public R> examineCard(Query query, + @RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type) { + return R.data(service.examineCard(Condition.getPage(query),stationName,type)); } @ApiLog @ApiOperation("设备统计") @GetMapping("/device-classify") @ApiOperationSupport(order = 10) - 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)); + public R> deviceClassify(Query query, + @RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "deptId",required = false) Long deptId, + @RequestParam(value="status")Integer status) { + return R.data(service.deviceClassify(Condition.getPage(query),stationName,deptId,status)); } @@ -126,31 +141,42 @@ public class TargetController { @ApiOperation("水电集团、区域指标关联") @GetMapping("/hydropower-target") @ApiOperationSupport(order = 11) - 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)); + public R> hydropowerTarget(Query query, + @RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "deptId",required = false) Long deptId, + @RequestParam(value = "target") Integer target) { + return R.data(service.hydropowerTarget(Condition.getPage(query),stationName,deptId,target)); } @ApiLog @ApiOperation("水利集团、区域指标关联") @GetMapping("/water-target") @ApiOperationSupport(order = 12) - 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)); + public R> waterTarget(Query query, + @RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "deptId",required = false) Long deptId, + @RequestParam(value = "target") Integer target) { + return R.data(service.waterTarget(Condition.getPage(query),stationName,deptId,target)); } @ApiLog @ApiOperation("光伏集团、区域指标关联") @GetMapping("/photovoltaic-target") @ApiOperationSupport(order = 13) - public R photovoltaicTarget(@RequestParam(value = "stationName",required = false) String stationName, @RequestParam(value = "deptId",required = false) Long deptId,@RequestParam(value = "target") Integer target) { - return R.data(service.photovoltaicTarget(stationName,deptId,target)); + public R> photovoltaicTarget(Query query, + @RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "deptId",required = false) Long deptId, + @RequestParam(value = "target") Integer target) { + return R.data(service.photovoltaicTarget(Condition.getPage(query),stationName,deptId,target)); } @ApiLog @ApiOperation("集团当班数据") @GetMapping("/duty-group") @ApiOperationSupport(order = 14) - public R dutygroup(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Long type) { - return R.data(service.dutyGroup(areaName,type)); + public R> dutygroup(Query query, + @RequestParam(value = "areaName",required = false) String areaName, + @RequestParam(value = "type") Long type) { + return R.data(service.dutyGroup(Condition.getPage(query),areaName,type)); } } 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 b475d65..9e1f889 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 @@ -31,13 +31,13 @@ public interface TargetService { IPage completeTicket(IPage page,String areaName,Integer type); // 缺陷率统计 - List defect(String areaName, Integer type); + IPage defect(IPage page,String areaName, Integer type); // 检修卡统计 - List examineCard(String stationName, Integer type); + IPage examineCard(IPage page,String stationName, Integer type); // 设备在线率/Fa投入条数统计 - List completeOther(String stationName, Integer type,Integer queryType); + IPage completeOther(IPage page,String stationName, Integer type,Integer queryType); // 日常维护统计 R> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type); @@ -46,20 +46,17 @@ public interface TargetService { R> examineRepair(OperAccessTaskDTO params, Query query, Integer type); // 设备分类统计 - List deviceClassify(String stationName, Long deptId,Integer status); + IPage deviceClassify(IPage page,String stationName, Long deptId,Integer status); // 水电指标关联数据 - List hydropowerTarget(String stationName, Long deptId,Integer target); + IPage hydropowerTarget(IPage page,String stationName, Long deptId,Integer target); // 水利指标关联数据 - List waterTarget(String stationName, Long deptId,Integer target); + IPage waterTarget(IPage page,String stationName, Long deptId,Integer target); // 光伏指标关联数据 - List photovoltaicTarget(String stationName, Long deptId, Integer target); - - // 集团设备 - List deviceGroup(String areaName); + IPage photovoltaicTarget(IPage page,String stationName, Long deptId, Integer target); // 集团工作牌/操作票 - List dutyGroup(String areaName, Long type); + IPage dutyGroup(IPage page,String areaName, Long type); } 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 ec83c93..1693d5d 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 @@ -525,19 +525,20 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List defect(String areaName, Integer type) { + public IPage defect(IPage page,String areaName, Integer type) { if(HomePageConstant.DISTRIBUTION_NETWORK.equals(type)){ - return this.getFillDefect(areaName,type); + List defects = this.getFillDefect(areaName,type); + page.setTotal(defects.size()); + page.setRecords(defects.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); } - // 获取区域机构 Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE,true); if(MapUtils.isEmpty(areas)){ - return new ArrayList<>(); + return page; } List depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); if(CollectionUtils.isEmpty(depts)){ - return new ArrayList<>(); + return page; } String startTime = this.getFristDayByYear(); String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); @@ -571,7 +572,9 @@ public class TargetServiceImpl implements TargetService { Thread.currentThread().interrupt(); } exe.shutdown(); - return completeDefects; + page.setTotal(completeDefects.size()); + page.setRecords(completeDefects.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } @@ -582,7 +585,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List examineCard(String stationName, Integer type) { + public IPage examineCard(IPage page,String stationName, Integer type) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -592,7 +595,7 @@ public class TargetServiceImpl implements TargetService { } List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ - return new ArrayList<>(); + return page; } // 查询检修卡 String startTime = this.getFristDayByYear(); @@ -603,19 +606,22 @@ public class TargetServiceImpl implements TargetService { .le(OverEntity::getCreateTime,endTime) ); if(CollectionUtils.isEmpty(overs)){ - return new ArrayList<>(); + return page; } List overDetails = overDetailsService.list(Wrappers.lambdaQuery() .in(OverDetailsEntity::getOverId,overs.stream().map(OverEntity::getId).collect(Collectors.toList())) ); - return overs.stream().collect(Collectors.groupingBy(OverEntity::getCreateDept)).entrySet().stream().map(entry->{ + List cards = overs.stream().collect(Collectors.groupingBy(OverEntity::getCreateDept)).entrySet().stream().map(entry->{ ExamineCardVo examineCard = new ExamineCardVo(); examineCard.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); examineCard.setCardTotal(entry.getValue().stream().mapToDouble(over-> Double.parseDouble(over.getTotalPrice().toString())).sum()); examineCard.setCardCount(overDetails.stream().filter(detail-> entry.getValue().stream().map(OverEntity::getId).collect(Collectors.toList()).contains(detail.getOverId())).mapToInt(OverDetailsEntity::getQuantity).sum()); return examineCard; }).collect(Collectors.toList()); + page.setTotal(cards.size()); + page.setRecords(cards.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } /** @@ -626,7 +632,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeOther(String stationName, Integer type, Integer queryType) { + public IPage completeOther(IPage page,String stationName, Integer type, Integer queryType) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -636,7 +642,7 @@ public class TargetServiceImpl implements TargetService { } List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ - return new ArrayList<>(); + return page; } // 查询设备在线率/Fa投入条数 String startTime = this.getFristDayByYear(); @@ -647,9 +653,9 @@ public class TargetServiceImpl implements TargetService { .le(OtherEntity::getCreateTime,endTime) ); if(CollectionUtils.isEmpty(others)){ - return new ArrayList<>(); + return page; } - return others.stream().collect(Collectors.groupingBy(OtherEntity::getCreateDept)).entrySet().stream().map(entry -> { + List records = others.stream().collect(Collectors.groupingBy(OtherEntity::getCreateDept)).entrySet().stream().map(entry -> { CompleteOtherVo other = new CompleteOtherVo(); other.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); if(CensusConstant.QUERY_TYPE_DEFAULT.equals(queryType)){ @@ -659,6 +665,9 @@ public class TargetServiceImpl implements TargetService { } return other; }).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } /** @@ -750,7 +759,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List deviceClassify(String stationName, Long deptId,Integer status) { + public IPage deviceClassify(IPage page,String stationName, Long deptId,Integer status) { // 获取区域设备统计 Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_key); List faultList = deviceClassifyMap.get(HomePageConstant.FAULT); @@ -759,21 +768,21 @@ public class TargetServiceImpl implements TargetService { //根据用户权限获取机构 R> result = sysClient.getDeptByCurrentUser(); if (!result.isSuccess() || ObjectUtil.isEmpty(result.getData())) { - return new ArrayList<>(); + return page; } // 站点 List stations = stationService.getStationList(result.getData(),deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true); if(CollectionUtils.isEmpty(stations)){ - return new ArrayList<>(); + return page; } List detpIds = stations.stream().filter(o-> StringUtils.isEmpty(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList()); if(CollectionUtils.isEmpty(detpIds)){ - return new ArrayList<>(); + return page; } // 设备 List devices = maintenanceService.getEmInfoList(); if(CollectionUtils.isEmpty(devices)){ - return new ArrayList<>(); + return page; } // 获取设备集合 List deviceClassifys = devices.stream().filter(device->detpIds.contains(device.getCreateDept())).sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { @@ -791,11 +800,16 @@ public class TargetServiceImpl implements TargetService { } return deviceClassify; }).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList()); + List records = new ArrayList<>(); // 状态过滤 if(ObjectUtil.isEmpty(status)){ - return deviceClassifys.stream().sorted(Comparator.comparing(DeviceClassifyVo::getDeviceStatus)).collect(Collectors.toList()); + records = deviceClassifys.stream().sorted(Comparator.comparing(DeviceClassifyVo::getDeviceStatus)).collect(Collectors.toList()); + }else{ + records = deviceClassifys.stream().filter(o->o.getDeviceStatus().equals(status)).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()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } /** @@ -805,7 +819,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List hydropowerTarget(String stationName, Long deptId,Integer target) { + public IPage hydropowerTarget(IPage page,String stationName, Long deptId,Integer target) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); @@ -818,13 +832,13 @@ public class TargetServiceImpl implements TargetService { } List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ - return new ArrayList<>(); + return page; } // 功率 if(HomePageConstant.POWER.equals(target)){ // 实时数据 List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); - return stations.stream().map(station->{ + List records = stations.stream().map(station->{ HydropowerTargetVo hydropower = new HydropowerTargetVo(); hydropower.setStationName(station.getName()); if(CollectionUtil.isEmpty(reals)){ @@ -834,11 +848,14 @@ public class TargetServiceImpl implements TargetService { } return hydropower; })/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower).reversed()).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } // 指标数据 List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); // 发电量 - return stations.stream().map(station->{ + List records = stations.stream().map(station->{ HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); hydropowerTarget.setStationName(station.getName()); if(CollectionUtils.isEmpty(targets)){ @@ -860,6 +877,9 @@ public class TargetServiceImpl implements TargetService { } return hydropowerTarget; })/*.filter(hydropower -> Math.abs(hydropower.getElectric()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getElectric).reversed()).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } /** @@ -869,7 +889,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List waterTarget(String stationName, Long deptId,Integer target) { + public IPage waterTarget(IPage page,String stationName, Long deptId,Integer target) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.in(StationEntity::getType, HomePageConstant.waterList); @@ -883,12 +903,12 @@ public class TargetServiceImpl implements TargetService { } List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ - return new ArrayList<>(); + return page; } // 负荷 if(HomePageConstant.LOADING.equals(target)){ List pumps = (List) redisTemplate.opsForValue().get(load_waterpump_real_key); - return stations.stream().map(station->{ + List records = stations.stream().map(station->{ WaterTargetVo water = new WaterTargetVo(); water.setStationName(station.getName()); if(CollectionUtil.isEmpty(pumps)){ @@ -899,10 +919,13 @@ public class TargetServiceImpl implements TargetService { water.setLoad(Optional.ofNullable(use).orElse(0.0)); return water; })/*.filter(water -> Math.abs(water.getLoad()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getLoad).reversed()).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } // 用电量 List targets = (List) redisTemplate.opsForValue().get(load_waterpump_target_key); - return stations.stream().map(station->{ + List records = stations.stream().map(station->{ WaterTargetVo water = new WaterTargetVo(); water.setStationName(station.getName()); if(CollectionUtil.isEmpty(targets)){ @@ -924,10 +947,13 @@ public class TargetServiceImpl implements TargetService { } return water; })/*.filter(water -> Math.abs(water.getUse()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getUse).reversed()).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } @Override - public List photovoltaicTarget(String stationName, Long deptId, Integer target) { + public IPage photovoltaicTarget(IPage page,String stationName, Long deptId, Integer target) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC); @@ -941,13 +967,13 @@ public class TargetServiceImpl implements TargetService { } List stations = stationService.list(wappers); if(CollectionUtils.isEmpty(stations)){ - return new ArrayList<>(); + return page; } // 负荷 if(HomePageConstant.LOADING.equals(target)){ // 实时数据 List reals = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); - return stations.stream().map(station->{ + List records = stations.stream().map(station->{ PhotovoTargetVo photovo = new PhotovoTargetVo(); photovo.setStationName(station.getName()); if(CollectionUtil.isEmpty(reals)){ @@ -957,10 +983,13 @@ public class TargetServiceImpl implements TargetService { } return photovo; })/*.filter(photovoltaic -> Math.abs(photovoltaic.getLoad()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getLoad).reversed()).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } // 发电量 List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); - return stations.stream().map(station->{ + List records = stations.stream().map(station->{ PhotovoTargetVo photovo = new PhotovoTargetVo(); photovo.setStationName(station.getName()); if(CollectionUtil.isEmpty(targets)){ @@ -982,61 +1011,9 @@ public class TargetServiceImpl implements TargetService { } return photovo; })/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate).reversed()).collect(Collectors.toList()); - } - - /** - * 集团设备统计 - * @param areaName - * @return - */ - @Override - public List deviceGroup(String areaName) { - // 获取区域机构 - Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true); - if(MapUtils.isEmpty(areas)){ - return null; - } - // 获取设备 - List devices = maintenanceService.getEmInfoList(); - // 获取设备状态 - Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_key); - List faultList = deviceClassifyMap.get(HomePageConstant.FAULT); - List overhaultList = deviceClassifyMap.get(HomePageConstant.OVERHAUL); - List runtList = deviceClassifyMap.get(HomePageConstant.RUN); - return areas.entrySet().stream().map(entry->{ - DeviceGroupVo group = new DeviceGroupVo(); - group.setDeptId(entry.getKey().getId()); - group.setAreaName(entry.getKey().getDeptName()); - if(CollectionUtils.isEmpty(devices)){ - group.setFaultCount(0L); - group.setOverhaultCount(0L); - group.setRunCount(0L); - group.setReserveCount(0L); - return group; - } - List numbers = devices.stream().filter(device-> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getCreateDept())).map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList()); - // 故障 - if(CollectionUtils.isEmpty(faultList)){ - group.setFaultCount(0L); - }else{ - group.setFaultCount(numbers.stream().filter(faultList::contains).count()); - } - // 检修 - if(CollectionUtils.isEmpty(overhaultList)){ - group.setFaultCount(0L); - }else{ - group.setFaultCount(numbers.stream().filter(overhaultList::contains).count()); - } - // 运行 - if(CollectionUtils.isEmpty(runtList)){ - group.setFaultCount(0L); - }else{ - group.setFaultCount(numbers.stream().filter(runtList::contains).count()); - } - // 备用 - group.setReserveCount(numbers.size() - group.getFaultCount() - group.getOverhaultCount() - group.getRunCount()); - return group; - }).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } /** @@ -1046,15 +1023,15 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List dutyGroup(String areaName, Long type) { + public IPage dutyGroup(IPage page,String areaName, Long type) { // 获取区域机构 Map> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true); if(MapUtils.isEmpty(areas)){ - return null; + return page; } // redis中取区域数据 List areaDutyVoList = (List) redisTemplate.opsForValue().get(areaDutyInfoKey); - return areas.keySet().stream().filter(stationEntities -> StringUtil.isEmpty(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> { + List records = areas.keySet().stream().filter(stationEntities -> StringUtil.isEmpty(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> { DutyGroupVo duty = new DutyGroupVo(); duty.setDeptId(stationEntities.getId()); duty.setAreaName(stationEntities.getDeptName()); @@ -1080,6 +1057,9 @@ public class TargetServiceImpl implements TargetService { } return duty; }).collect(Collectors.toList()); + page.setTotal(records.size()); + page.setRecords(records.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); + return page; } /**