Browse Source

#数据关联

zhongwei
yang_shj 1 year ago
parent
commit
2669e18f3b
  1. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java
  2. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java
  3. 51
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java

@ -33,15 +33,21 @@ public class TargetController {
@ApiOperation("装机容量统计:区分填报/接入站点") @ApiOperation("装机容量统计:区分填报/接入站点")
@PostMapping("/installed-capacity") @PostMapping("/installed-capacity")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { public R installedCapacity(@RequestParam(value = "stationName",required = false) String stationName,
return R.data(service.installedCapacity(stationName,type)); @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("发电量统计:区分填报/接入站点") @ApiOperation("发电量统计:区分填报/接入站点")
@PostMapping("/electric-generation") @PostMapping("/electric-generation")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { public R electricGeneration(@RequestParam(value = "stationName",required = false) String stationName,
return R.data(service.electricGeneration(stationName,type)); @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("计划发电量/实际发电量统计:区分填报/接入站点") @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点")
@PostMapping("/complete-generation") @PostMapping("/complete-generation")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { public R completeGeneration(@RequestParam(value = "stationName",required = false) String stationName,
return R.data(service.completeGeneration(stationName,type)); @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("两票统计:区分填报/平台业务数据") @ApiOperation("两票统计:区分填报/平台业务数据")
@PostMapping("/complete-ticket") @PostMapping("/complete-ticket")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { public R completeTicket(@RequestParam(value = "areaName",required = false) String areaName,
return R.data(service.completeTicket(areaName,type)); @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 @ApiLog

8
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 { public interface TargetService {
// 获取站点装机容量 // 获取站点装机容量
List<InstalledCapacityVo> installedCapacity(String stationName,Integer type); List<InstalledCapacityVo> installedCapacity(String stationName,Integer type,Integer current,Integer size);
// 发电量统计 // 发电量统计
List<ElectricGenerationVo> electricGeneration(String stationName,Integer type); List<ElectricGenerationVo> electricGeneration(String stationName,Integer type,Integer current,Integer size);
// 计划发电量/实际发电量统计 // 计划发电量/实际发电量统计
List<CompleteGenerationVo> completeGeneration(String stationName,Integer type); List<CompleteGenerationVo> completeGeneration(String stationName,Integer type,Integer current,Integer size);
// 两票统计 // 两票统计
List<CompleteTicketVo> completeTicket(String areaName,Integer type); List<CompleteTicketVo> completeTicket(String areaName,Integer type,Integer current,Integer size);
// 缺陷率统计 // 缺陷率统计
List<CompleteDefectVo> defect(String areaName, Integer type); List<CompleteDefectVo> defect(String areaName, Integer type);

51
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 * @return
*/ */
@Override @Override
public List<InstalledCapacityVo> installedCapacity(String stationName,Integer type) { public List<InstalledCapacityVo> installedCapacity(String stationName,Integer type,Integer current,Integer size) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getType, type);
@ -148,7 +148,7 @@ public class TargetServiceImpl implements TargetService {
List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList());
item.setDetail(String.join("|",details)); item.setDetail(String.join("|",details));
return item; 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 * @return
*/ */
@Override @Override
public List<ElectricGenerationVo> electricGeneration(String stationName,Integer type) { public List<ElectricGenerationVo> electricGeneration(String stationName,Integer type,Integer current,Integer size) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getType, type);
@ -191,7 +191,7 @@ public class TargetServiceImpl implements TargetService {
List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getPowerYear() +"kWh]").collect(Collectors.toList()); List<String> 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)); item.setDetail(String.join("|",details));
return item; 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)){ }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isEmpty(targets)){ if(CollectionUtil.isEmpty(targets)){
@ -213,7 +213,7 @@ public class TargetServiceImpl implements TargetService {
List<String> details = targets.stream().filter(target->target.getDeptId().equals(station.getRefDept())).map(target-> "[" + Optional.ofNullable(target.getDeviceCode()).orElse("填报电量") + " " + target.getGenerationYear() +"kWh]").collect(Collectors.toList()); List<String> 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)); item.setDetail(String.join("|",details));
return item; 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("站点为填报数据,暂无设备装机发电量信息!"); item.setDetail("站点为填报数据,暂无设备装机发电量信息!");
return item; 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 * @return
*/ */
@Override @Override
public List<CompleteGenerationVo> completeGeneration(String stationName,Integer type) { public List<CompleteGenerationVo> completeGeneration(String stationName,Integer type,Integer current,Integer size) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getType, type);
@ -292,7 +292,8 @@ public class TargetServiceImpl implements TargetService {
item.setCompleteRate(0.0); item.setCompleteRate(0.0);
} }
return item; 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)){ }else if(HomePageConstant.PHOTOVOLTAIC.equals(type)){
// 计划发电量 // 计划发电量
String mon = DateUtil.format(new Date(),"yyyy"); String mon = DateUtil.format(new Date(),"yyyy");
@ -335,7 +336,7 @@ public class TargetServiceImpl implements TargetService {
item.setCompleteRate(0.0); item.setCompleteRate(0.0);
} }
return item; 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"); String mon = DateUtil.format(new Date(),"yyyy");
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>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())); item.setCompleteRate(Double.valueOf(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerRateYear()));
} }
return item; 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 * @return
*/ */
@Override @Override
public List<CompleteTicketVo> completeTicket(String areaName,Integer type) { public List<CompleteTicketVo> completeTicket(String areaName,Integer type,Integer current,Integer size) {
// 光伏/风电双票填报数据 // 光伏/风电双票填报数据
if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){ if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){
return this.getcompleteFillTicket(areaName,type); return this.getcompleteFillTicket(areaName,type,current,size);
} }
// 平台业务数据 // 平台业务数据
List<Integer> types; List<Integer> types;
@ -390,6 +391,25 @@ public class TargetServiceImpl implements TargetService {
CountDownLatch countDownLatch = new CountDownLatch(areas.size()); CountDownLatch countDownLatch = new CountDownLatch(areas.size());
List<CompleteTicketVo> completeTickets = new ArrayList<>(); List<CompleteTicketVo> completeTickets = new ArrayList<>();
exe.execute(()-> { exe.execute(()-> {
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) { for (Dept dept: areas) {
// 双票 // 双票
DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now()); DoublePassRateVO doublePass = ticketInfoAllClient.getDoublePassRate(Collections.singletonList(dept.getId()), firstDateTime, LocalDateTime.now());
@ -406,6 +426,7 @@ public class TargetServiceImpl implements TargetService {
completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); completeTicketVo.setCompleteRate(doublePass.getDoublePassRate());
} }
completeTickets.add(completeTicketVo); completeTickets.add(completeTicketVo);
}
countDownLatch.countDown(); countDownLatch.countDown();
} }
}); });
@ -417,7 +438,7 @@ public class TargetServiceImpl implements TargetService {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
exe.shutdown(); 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 * @param type
* @return * @return
*/ */
private List<CompleteTicketVo> getcompleteFillTicket(String stationName, Integer type) { private List<CompleteTicketVo> getcompleteFillTicket(String stationName, Integer type,Integer current,Integer size) {
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getType, type) .eq(StationEntity::getType, type)
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) .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())); item.setCompleteRate(String.valueOf(BigDecimal.valueOf(rate/ stationPower.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()));
} }
return item; return item;
}).collect(Collectors.toList()); }).skip((long) (current - 1) * size).limit(size).collect(Collectors.toList());
} }
/** /**

Loading…
Cancel
Save