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 d1ea07f..1b9e41a 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 @@ -33,15 +33,21 @@ public class TargetController { @ApiOperation("装机容量统计:区分填报/接入站点") @PostMapping("/installed-capacity") @ApiOperationSupport(order = 1) - public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.installedCapacity(stationName,type)); + public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.installedCapacity(stationName,type,current,size)); } @ApiOperation("发电量统计:区分填报/接入站点") @PostMapping("/electric-generation") @ApiOperationSupport(order = 2) - public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.electricGeneration(stationName,type)); + public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.electricGeneration(stationName,type,current,size)); } @@ -49,8 +55,11 @@ public class TargetController { @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点") @PostMapping("/complete-generation") @ApiOperationSupport(order = 3) - public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { - return R.data(service.completeGeneration(stationName,type)); + public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.completeGeneration(stationName,type,current,size)); } @@ -58,8 +67,11 @@ public class TargetController { @ApiOperation("两票统计:区分填报/平台业务数据") @PostMapping("/complete-ticket") @ApiOperationSupport(order = 4) - public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { - return R.data(service.completeTicket(areaName,type)); + public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName, + @RequestParam(value = "type") Integer type, + @RequestParam(value = "current") Integer current, + @RequestParam(value = "size") Integer size) { + return R.data(service.completeTicket(areaName,type,current,size)); } @ApiLog 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 6009791..0ad73ef 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 @@ -19,16 +19,16 @@ import java.util.List; public interface TargetService { // 获取站点装机容量 - List installedCapacity(String stationName,Integer type); + List installedCapacity(String stationName,Integer type,Integer current,Integer size); // 发电量统计 - List electricGeneration(String stationName,Integer type); + List electricGeneration(String stationName,Integer type,Integer current,Integer size); // 计划发电量/实际发电量统计 - List completeGeneration(String stationName,Integer type); + List completeGeneration(String stationName,Integer type,Integer current,Integer size); // 两票统计 - List completeTicket(String areaName,Integer type); + List completeTicket(String areaName,Integer type,Integer current,Integer size); // 缺陷率统计 List defect(String areaName, Integer 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 fd77958..12f67a2 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 @@ -118,7 +118,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List installedCapacity(String stationName,Integer type) { + public List installedCapacity(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -148,7 +148,7 @@ public class TargetServiceImpl implements TargetService { List details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).collect(Collectors.toList()); + }).filter(capacity->Math.abs(capacity.getInstalledCapacity()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -156,7 +156,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List electricGeneration(String stationName,Integer type) { + public List electricGeneration(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -191,7 +191,7 @@ public class TargetServiceImpl implements TargetService { List details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); + }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); if(CollectionUtil.isEmpty(targets)){ @@ -213,7 +213,7 @@ public class TargetServiceImpl implements TargetService { List details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() +"kWh]").collect(Collectors.toList()); item.setDetail(String.join("|",details)); return item; - }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).collect(Collectors.toList()); + }).filter(generate->Math.abs(generate.getElectricGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } // 查询填报数据 @@ -234,7 +234,7 @@ public class TargetServiceImpl implements TargetService { } item.setDetail("站点为填报数据,暂无设备装机发电量信息!"); return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -242,7 +242,7 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeGeneration(String stationName,Integer type) { + public List completeGeneration(String stationName,Integer type,Integer current,Integer size) { // 站点 LambdaQueryWrapper wappers = Wrappers.lambdaQuery(); wappers.eq(StationEntity::getType, type); @@ -292,7 +292,8 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(0.0); } return item; - }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); + }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0) + .skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){ // 计划发电量 String mon = DateUtil.format(new Date(),"yyyy"); @@ -335,7 +336,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(0.0); } return item; - }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); + }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } String mon = DateUtil.format(new Date(),"yyyy"); List powers = powerService.list(Wrappers.lambdaQuery() @@ -357,7 +358,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(Double.valueOf(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerRateYear())); } return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -365,10 +366,10 @@ public class TargetServiceImpl implements TargetService { * @return */ @Override - public List completeTicket(String areaName,Integer type) { + public List completeTicket(String areaName,Integer type,Integer current,Integer size) { // 光伏/风电双票填报数据 if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){ - return this.getcompleteFillTicket(areaName,type); + return this.getcompleteFillTicket(areaName,type,current,size); } // 平台业务数据 List types; @@ -390,22 +391,42 @@ public class TargetServiceImpl implements TargetService { CountDownLatch countDownLatch = new CountDownLatch(areas.size()); List completeTickets = new ArrayList<>(); exe.execute(()-> { - for (Dept dept: areas) { - // 双票 - DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); - CompleteTicketVo completeTicketVo = new CompleteTicketVo(); - if (ObjectUtil.isEmpty(doublePass)) { - completeTicketVo.setAreaName(dept.getDeptName()); - completeTicketVo.setTicketCount("0"); - completeTicketVo.setCompleteCount("0"); - completeTicketVo.setCompleteRate("0.0"); - } else { - completeTicketVo.setAreaName(dept.getDeptName()); - completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); - completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); - completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + if(StringUtil.isEmpty(areaName)){ + for (Dept dept: areas.stream().filter(area->area.getDeptName().equals(areaName)).collect(Collectors.toList())) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount("0"); + completeTicketVo.setCompleteCount("0"); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); + } + }else{ + for (Dept dept: areas) { + // 双票 + DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); + CompleteTicketVo completeTicketVo = new CompleteTicketVo(); + if (ObjectUtil.isEmpty(doublePass)) { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount("0"); + completeTicketVo.setCompleteCount("0"); + completeTicketVo.setCompleteRate("0.0"); + } else { + completeTicketVo.setAreaName(dept.getDeptName()); + completeTicketVo.setTicketCount(doublePass.getDoubleTicketCount().toString()); + completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount().toString()); + completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); + } + completeTickets.add(completeTicketVo); } - completeTickets.add(completeTicketVo); countDownLatch.countDown(); } }); @@ -417,7 +438,7 @@ public class TargetServiceImpl implements TargetService { Thread.currentThread().interrupt(); } exe.shutdown(); - return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).collect(Collectors.toList()); + return completeTickets.stream().filter(complete->Math.abs(Integer.parseInt(complete.getTicketCount())) > 0 || Math.abs(Integer.parseInt(complete.getCompleteCount())) > 0).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /** @@ -451,7 +472,7 @@ public class TargetServiceImpl implements TargetService { * @param type * @return */ - private List getcompleteFillTicket(String stationName, Integer type) { + private List getcompleteFillTicket(String stationName, Integer type,Integer current,Integer size) { List stations = stationService.list(Wrappers.lambdaQuery() .eq(StationEntity::getType, type) .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) @@ -478,7 +499,7 @@ public class TargetServiceImpl implements TargetService { item.setCompleteRate(String.valueOf(BigDecimal.valueOf(rate/ stationPower.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())); } return item; - }).collect(Collectors.toList()); + }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList()); } /**