Browse Source

#数据关联增加分页

zhongwei
yang_shj 1 year ago
parent
commit
e23e969fb3
  1. 78
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/controller/TargetController.java
  2. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java
  3. 162
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java

78
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.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO;
import com.hnac.hzims.operational.census.service.TargetService; import com.hnac.hzims.operational.census.service.TargetService;
import com.hnac.hzims.operational.census.vo.CompleteGenerationVo; import com.hnac.hzims.operational.census.vo.*;
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.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -37,7 +34,8 @@ public class TargetController {
@ApiOperation("装机容量统计:区分填报/接入站点") @ApiOperation("装机容量统计:区分填报/接入站点")
@PostMapping("/installed-capacity") @PostMapping("/installed-capacity")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<IPage<InstalledCapacityVo>> installedCapacity(Query query,@RequestParam(value = "stationName",required = false) String stationName, public R<IPage<InstalledCapacityVo>> installedCapacity(Query query,
@RequestParam(value = "stationName",required = false) String stationName,
@RequestParam(value = "type") Integer type) { @RequestParam(value = "type") Integer type) {
return R.data(service.installedCapacity(Condition.getPage(query),stationName,type)); return R.data(service.installedCapacity(Condition.getPage(query),stationName,type));
} }
@ -45,7 +43,8 @@ public class TargetController {
@ApiOperation("发电量统计:区分填报/接入站点") @ApiOperation("发电量统计:区分填报/接入站点")
@PostMapping("/electric-generation") @PostMapping("/electric-generation")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R<IPage<ElectricGenerationVo>> electricGeneration(Query query, @RequestParam(value = "stationName",required = false) String stationName, public R<IPage<ElectricGenerationVo>> electricGeneration(Query query,
@RequestParam(value = "stationName",required = false) String stationName,
@RequestParam(value = "type") Integer type) { @RequestParam(value = "type") Integer type) {
return R.data(service.electricGeneration(Condition.getPage(query),stationName,type)); return R.data(service.electricGeneration(Condition.getPage(query),stationName,type));
} }
@ -55,7 +54,8 @@ public class TargetController {
@ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点") @ApiOperation("计划发电量/实际发电量统计:区分填报/接入站点")
@PostMapping("/complete-generation") @PostMapping("/complete-generation")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R<IPage<CompleteGenerationVo>> completeGeneration(Query query, @RequestParam(value = "stationName",required = false) String stationName, public R<IPage<CompleteGenerationVo>> completeGeneration(Query query,
@RequestParam(value = "stationName",required = false) String stationName,
@RequestParam(value = "type") Integer type) { @RequestParam(value = "type") Integer type) {
return R.data(service.completeGeneration(Condition.getPage(query),stationName,type)); return R.data(service.completeGeneration(Condition.getPage(query),stationName,type));
} }
@ -65,7 +65,8 @@ public class TargetController {
@ApiOperation("两票统计:区分填报/平台业务数据") @ApiOperation("两票统计:区分填报/平台业务数据")
@PostMapping("/complete-ticket") @PostMapping("/complete-ticket")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R<IPage<CompleteTicketVo>> completeTicket(Query query,@RequestParam(value = "areaName",required = false) String areaName, public R<IPage<CompleteTicketVo>> completeTicket(Query query,
@RequestParam(value = "areaName",required = false) String areaName,
@RequestParam(value = "type") Integer type) { @RequestParam(value = "type") Integer type) {
return R.data(service.completeTicket(Condition.getPage(query),areaName,type)); return R.data(service.completeTicket(Condition.getPage(query),areaName,type));
} }
@ -74,8 +75,10 @@ public class TargetController {
@ApiOperation("缺陷率统计:区分填报/平台业务数据") @ApiOperation("缺陷率统计:区分填报/平台业务数据")
@GetMapping("/complete-defect") @GetMapping("/complete-defect")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
public R completeDefect(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Integer type) { public R<IPage<CompleteDefectVo>> completeDefect(Query query,
return R.data(service.defect(areaName,type)); @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投入条数统计") @ApiOperation("上线率/Fa投入条数统计")
@GetMapping("/complete-other") @GetMapping("/complete-other")
@ApiOperationSupport(order = 6) @ApiOperationSupport(order = 6)
public R completeOther(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type,@RequestParam(value = "queryType") Integer queryType) { public R<IPage<CompleteOtherVo>> completeOther(Query query,
return R.data(service.completeOther(stationName,type,queryType)); @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 @ApiLog
@ApiOperation("日常维护统计") @ApiOperation("日常维护统计")
@GetMapping("/routine-maintenance") @GetMapping("/routine-maintenance")
@ApiOperationSupport(order = 7) @ApiOperationSupport(order = 7)
public R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params,Query query,Integer type) { public R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params,
Query query,
Integer type) {
return service.routineMaintenance(params,query,type); return service.routineMaintenance(params,query,type);
} }
@ -100,7 +108,9 @@ public class TargetController {
@ApiOperation("检修任务统计") @ApiOperation("检修任务统计")
@GetMapping("/examine-repair") @GetMapping("/examine-repair")
@ApiOperationSupport(order = 8) @ApiOperationSupport(order = 8)
public R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { public R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params,
Query query,
Integer type) {
return service.examineRepair(params, query,type); return service.examineRepair(params, query,type);
} }
@ -109,16 +119,21 @@ public class TargetController {
@ApiOperation("检修卡统计") @ApiOperation("检修卡统计")
@GetMapping("/examineCard") @GetMapping("/examineCard")
@ApiOperationSupport(order = 9) @ApiOperationSupport(order = 9)
public R examineCard(@RequestParam(value = "stationName",required = false) String stationName,@RequestParam(value = "type") Integer type) { public R<IPage<ExamineCardVo>> examineCard(Query query,
return R.data(service.examineCard(stationName,type)); @RequestParam(value = "stationName",required = false) String stationName,
@RequestParam(value = "type") Integer type) {
return R.data(service.examineCard(Condition.getPage(query),stationName,type));
} }
@ApiLog @ApiLog
@ApiOperation("设备统计") @ApiOperation("设备统计")
@GetMapping("/device-classify") @GetMapping("/device-classify")
@ApiOperationSupport(order = 10) @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) { public R<IPage<DeviceClassifyVo>> deviceClassify(Query query,
return R.data(service.deviceClassify(stationName,deptId,status)); @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("水电集团、区域指标关联") @ApiOperation("水电集团、区域指标关联")
@GetMapping("/hydropower-target") @GetMapping("/hydropower-target")
@ApiOperationSupport(order = 11) @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) { public R<IPage<HydropowerTargetVo>> hydropowerTarget(Query query,
return R.data(service.hydropowerTarget(stationName,deptId,target)); @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 @ApiLog
@ApiOperation("水利集团、区域指标关联") @ApiOperation("水利集团、区域指标关联")
@GetMapping("/water-target") @GetMapping("/water-target")
@ApiOperationSupport(order = 12) @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) { public R<IPage<WaterTargetVo>> waterTarget(Query query,
return R.data(service.waterTarget(stationName,deptId,target)); @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 @ApiLog
@ApiOperation("光伏集团、区域指标关联") @ApiOperation("光伏集团、区域指标关联")
@GetMapping("/photovoltaic-target") @GetMapping("/photovoltaic-target")
@ApiOperationSupport(order = 13) @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) { public R<IPage<PhotovoTargetVo>> photovoltaicTarget(Query query,
return R.data(service.photovoltaicTarget(stationName,deptId,target)); @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 @ApiLog
@ApiOperation("集团当班数据") @ApiOperation("集团当班数据")
@GetMapping("/duty-group") @GetMapping("/duty-group")
@ApiOperationSupport(order = 14) @ApiOperationSupport(order = 14)
public R dutygroup(@RequestParam(value = "areaName",required = false) String areaName,@RequestParam(value = "type") Long type) { public R<IPage<DutyGroupVo>> dutygroup(Query query,
return R.data(service.dutyGroup(areaName,type)); @RequestParam(value = "areaName",required = false) String areaName,
@RequestParam(value = "type") Long type) {
return R.data(service.dutyGroup(Condition.getPage(query),areaName,type));
} }
} }

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/TargetService.java

@ -31,13 +31,13 @@ public interface TargetService {
IPage<CompleteTicketVo> completeTicket(IPage<CompleteTicketVo> page,String areaName,Integer type); IPage<CompleteTicketVo> completeTicket(IPage<CompleteTicketVo> page,String areaName,Integer type);
// 缺陷率统计 // 缺陷率统计
List<CompleteDefectVo> defect(String areaName, Integer type); IPage<CompleteDefectVo> defect(IPage<CompleteDefectVo> page,String areaName, Integer type);
// 检修卡统计 // 检修卡统计
List<ExamineCardVo> examineCard(String stationName, Integer type); IPage<ExamineCardVo> examineCard(IPage<ExamineCardVo> page,String stationName, Integer type);
// 设备在线率/Fa投入条数统计 // 设备在线率/Fa投入条数统计
List<CompleteOtherVo> completeOther(String stationName, Integer type,Integer queryType); IPage<CompleteOtherVo> completeOther(IPage<CompleteOtherVo> page,String stationName, Integer type,Integer queryType);
// 日常维护统计 // 日常维护统计
R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type); R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type);
@ -46,20 +46,17 @@ public interface TargetService {
R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type); R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type);
// 设备分类统计 // 设备分类统计
List<DeviceClassifyVo> deviceClassify(String stationName, Long deptId,Integer status); IPage<DeviceClassifyVo> deviceClassify(IPage<DeviceClassifyVo> page,String stationName, Long deptId,Integer status);
// 水电指标关联数据 // 水电指标关联数据
List<HydropowerTargetVo> hydropowerTarget(String stationName, Long deptId,Integer target); IPage<HydropowerTargetVo> hydropowerTarget(IPage<HydropowerTargetVo> page,String stationName, Long deptId,Integer target);
// 水利指标关联数据 // 水利指标关联数据
List<WaterTargetVo> waterTarget(String stationName, Long deptId,Integer target); IPage<WaterTargetVo> waterTarget(IPage<WaterTargetVo> page,String stationName, Long deptId,Integer target);
// 光伏指标关联数据 // 光伏指标关联数据
List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target); IPage<PhotovoTargetVo> photovoltaicTarget(IPage<PhotovoTargetVo> page,String stationName, Long deptId, Integer target);
// 集团设备
List<DeviceGroupVo> deviceGroup(String areaName);
// 集团工作牌/操作票 // 集团工作牌/操作票
List<DutyGroupVo> dutyGroup(String areaName, Long type); IPage<DutyGroupVo> dutyGroup(IPage<DutyGroupVo> page,String areaName, Long type);
} }

162
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 * @return
*/ */
@Override @Override
public List<CompleteDefectVo> defect(String areaName, Integer type) { public IPage<CompleteDefectVo> defect(IPage<CompleteDefectVo> page,String areaName, Integer type) {
if(HomePageConstant.DISTRIBUTION_NETWORK.equals(type)){ if(HomePageConstant.DISTRIBUTION_NETWORK.equals(type)){
return this.getFillDefect(areaName,type); List<CompleteDefectVo> 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<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE,true); Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if(MapUtils.isEmpty(areas)){ if(MapUtils.isEmpty(areas)){
return new ArrayList<>(); return page;
} }
List<Dept> depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList()); List<Dept> depts = areas.keySet().stream().filter(dept -> StringUtils.isEmpty(areaName) || dept.getDeptName().contains(areaName)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(depts)){ if(CollectionUtils.isEmpty(depts)){
return new ArrayList<>(); return page;
} }
String startTime = this.getFristDayByYear(); String startTime = this.getFristDayByYear();
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME);
@ -571,7 +572,9 @@ public class TargetServiceImpl implements TargetService {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
exe.shutdown(); 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 * @return
*/ */
@Override @Override
public List<ExamineCardVo> examineCard(String stationName, Integer type) { public IPage<ExamineCardVo> examineCard(IPage<ExamineCardVo> page,String stationName, Integer type) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getType, type);
@ -592,7 +595,7 @@ public class TargetServiceImpl implements TargetService {
} }
List<StationEntity> stations = stationService.list(wappers); List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return page;
} }
// 查询检修卡 // 查询检修卡
String startTime = this.getFristDayByYear(); String startTime = this.getFristDayByYear();
@ -603,19 +606,22 @@ public class TargetServiceImpl implements TargetService {
.le(OverEntity::getCreateTime,endTime) .le(OverEntity::getCreateTime,endTime)
); );
if(CollectionUtils.isEmpty(overs)){ if(CollectionUtils.isEmpty(overs)){
return new ArrayList<>(); return page;
} }
List<OverDetailsEntity> overDetails = overDetailsService.list(Wrappers.<OverDetailsEntity>lambdaQuery() List<OverDetailsEntity> overDetails = overDetailsService.list(Wrappers.<OverDetailsEntity>lambdaQuery()
.in(OverDetailsEntity::getOverId,overs.stream().map(OverEntity::getId).collect(Collectors.toList())) .in(OverDetailsEntity::getOverId,overs.stream().map(OverEntity::getId).collect(Collectors.toList()))
); );
return overs.stream().collect(Collectors.groupingBy(OverEntity::getCreateDept)).entrySet().stream().map(entry->{ List<ExamineCardVo> cards = overs.stream().collect(Collectors.groupingBy(OverEntity::getCreateDept)).entrySet().stream().map(entry->{
ExamineCardVo examineCard = new ExamineCardVo(); ExamineCardVo examineCard = new ExamineCardVo();
examineCard.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); 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.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()); examineCard.setCardCount(overDetails.stream().filter(detail-> entry.getValue().stream().map(OverEntity::getId).collect(Collectors.toList()).contains(detail.getOverId())).mapToInt(OverDetailsEntity::getQuantity).sum());
return examineCard; return examineCard;
}).collect(Collectors.toList()); }).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 * @return
*/ */
@Override @Override
public List<CompleteOtherVo> completeOther(String stationName, Integer type, Integer queryType) { public IPage<CompleteOtherVo> completeOther(IPage<CompleteOtherVo> page,String stationName, Integer type, Integer queryType) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type); wappers.eq(StationEntity::getType, type);
@ -636,7 +642,7 @@ public class TargetServiceImpl implements TargetService {
} }
List<StationEntity> stations = stationService.list(wappers); List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return page;
} }
// 查询设备在线率/Fa投入条数 // 查询设备在线率/Fa投入条数
String startTime = this.getFristDayByYear(); String startTime = this.getFristDayByYear();
@ -647,9 +653,9 @@ public class TargetServiceImpl implements TargetService {
.le(OtherEntity::getCreateTime,endTime) .le(OtherEntity::getCreateTime,endTime)
); );
if(CollectionUtils.isEmpty(others)){ if(CollectionUtils.isEmpty(others)){
return new ArrayList<>(); return page;
} }
return others.stream().collect(Collectors.groupingBy(OtherEntity::getCreateDept)).entrySet().stream().map(entry -> { List<CompleteOtherVo> records = others.stream().collect(Collectors.groupingBy(OtherEntity::getCreateDept)).entrySet().stream().map(entry -> {
CompleteOtherVo other = new CompleteOtherVo(); CompleteOtherVo other = new CompleteOtherVo();
other.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); other.setStationName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName());
if(CensusConstant.QUERY_TYPE_DEFAULT.equals(queryType)){ if(CensusConstant.QUERY_TYPE_DEFAULT.equals(queryType)){
@ -659,6 +665,9 @@ public class TargetServiceImpl implements TargetService {
} }
return other; return other;
}).collect(Collectors.toList()); }).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 * @return
*/ */
@Override @Override
public List<DeviceClassifyVo> deviceClassify(String stationName, Long deptId,Integer status) { public IPage<DeviceClassifyVo> deviceClassify(IPage<DeviceClassifyVo> page,String stationName, Long deptId,Integer status) {
// 获取区域设备统计 // 获取区域设备统计
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_key); Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_key);
List<String> faultList = deviceClassifyMap.get(HomePageConstant.FAULT); List<String> faultList = deviceClassifyMap.get(HomePageConstant.FAULT);
@ -759,21 +768,21 @@ public class TargetServiceImpl implements TargetService {
//根据用户权限获取机构 //根据用户权限获取机构
R<List<Dept>> result = sysClient.getDeptByCurrentUser(); R<List<Dept>> result = sysClient.getDeptByCurrentUser();
if (!result.isSuccess() || ObjectUtil.isEmpty(result.getData())) { if (!result.isSuccess() || ObjectUtil.isEmpty(result.getData())) {
return new ArrayList<>(); return page;
} }
// 站点 // 站点
List<StationEntity> stations = stationService.getStationList(result.getData(),deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true); List<StationEntity> stations = stationService.getStationList(result.getData(),deptId,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return page;
} }
List<Long> detpIds = stations.stream().filter(o-> StringUtils.isEmpty(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList()); List<Long> detpIds = stations.stream().filter(o-> StringUtils.isEmpty(stationName) || o.getName().contains(stationName)).map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtils.isEmpty(detpIds)){ if(CollectionUtils.isEmpty(detpIds)){
return new ArrayList<>(); return page;
} }
// 设备 // 设备
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList(); List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList();
if(CollectionUtils.isEmpty(devices)){ if(CollectionUtils.isEmpty(devices)){
return new ArrayList<>(); return page;
} }
// 获取设备集合 // 获取设备集合
List<DeviceClassifyVo> deviceClassifys = devices.stream().filter(device->detpIds.contains(device.getCreateDept())).sorted(Comparator.comparing(EminfoAndEmParamVo::getCreateDept)).map(device -> { List<DeviceClassifyVo> 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; return deviceClassify;
}).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList()); }).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList());
List<DeviceClassifyVo> records = new ArrayList<>();
// 状态过滤 // 状态过滤
if(ObjectUtil.isEmpty(status)){ 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 * @return
*/ */
@Override @Override
public List<HydropowerTargetVo> hydropowerTarget(String stationName, Long deptId,Integer target) { public IPage<HydropowerTargetVo> hydropowerTarget(IPage<HydropowerTargetVo> page,String stationName, Long deptId,Integer target) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER); wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER);
@ -818,13 +832,13 @@ public class TargetServiceImpl implements TargetService {
} }
List<StationEntity> stations = stationService.list(wappers); List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return page;
} }
// 功率 // 功率
if(HomePageConstant.POWER.equals(target)){ if(HomePageConstant.POWER.equals(target)){
// 实时数据 // 实时数据
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
return stations.stream().map(station->{ List<HydropowerTargetVo> records = stations.stream().map(station->{
HydropowerTargetVo hydropower = new HydropowerTargetVo(); HydropowerTargetVo hydropower = new HydropowerTargetVo();
hydropower.setStationName(station.getName()); hydropower.setStationName(station.getName());
if(CollectionUtil.isEmpty(reals)){ if(CollectionUtil.isEmpty(reals)){
@ -834,11 +848,14 @@ public class TargetServiceImpl implements TargetService {
} }
return hydropower; return hydropower;
})/*.filter(hydropower -> Math.abs(hydropower.getPower()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getPower).reversed()).collect(Collectors.toList()); })/*.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<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
// 发电量 // 发电量
return stations.stream().map(station->{ List<HydropowerTargetVo> records = stations.stream().map(station->{
HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo(); HydropowerTargetVo hydropowerTarget = new HydropowerTargetVo();
hydropowerTarget.setStationName(station.getName()); hydropowerTarget.setStationName(station.getName());
if(CollectionUtils.isEmpty(targets)){ if(CollectionUtils.isEmpty(targets)){
@ -860,6 +877,9 @@ public class TargetServiceImpl implements TargetService {
} }
return hydropowerTarget; return hydropowerTarget;
})/*.filter(hydropower -> Math.abs(hydropower.getElectric()) > 0)*/.sorted(Comparator.comparing(HydropowerTargetVo::getElectric).reversed()).collect(Collectors.toList()); })/*.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 * @return
*/ */
@Override @Override
public List<WaterTargetVo> waterTarget(String stationName, Long deptId,Integer target) { public IPage<WaterTargetVo> waterTarget(IPage<WaterTargetVo> page,String stationName, Long deptId,Integer target) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.in(StationEntity::getType, HomePageConstant.waterList); wappers.in(StationEntity::getType, HomePageConstant.waterList);
@ -883,12 +903,12 @@ public class TargetServiceImpl implements TargetService {
} }
List<StationEntity> stations = stationService.list(wappers); List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return page;
} }
// 负荷 // 负荷
if(HomePageConstant.LOADING.equals(target)){ if(HomePageConstant.LOADING.equals(target)){
List<WaterPumpRealVo> pumps = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(load_waterpump_real_key); List<WaterPumpRealVo> pumps = (List<WaterPumpRealVo>) redisTemplate.opsForValue().get(load_waterpump_real_key);
return stations.stream().map(station->{ List<WaterTargetVo> records = stations.stream().map(station->{
WaterTargetVo water = new WaterTargetVo(); WaterTargetVo water = new WaterTargetVo();
water.setStationName(station.getName()); water.setStationName(station.getName());
if(CollectionUtil.isEmpty(pumps)){ if(CollectionUtil.isEmpty(pumps)){
@ -899,10 +919,13 @@ public class TargetServiceImpl implements TargetService {
water.setLoad(Optional.ofNullable(use).orElse(0.0)); water.setLoad(Optional.ofNullable(use).orElse(0.0));
return water; return water;
})/*.filter(water -> Math.abs(water.getLoad()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getLoad).reversed()).collect(Collectors.toList()); })/*.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<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(load_waterpump_target_key); List<WaterPumpTargetVo> targets = (List<WaterPumpTargetVo>) redisTemplate.opsForValue().get(load_waterpump_target_key);
return stations.stream().map(station->{ List<WaterTargetVo> records = stations.stream().map(station->{
WaterTargetVo water = new WaterTargetVo(); WaterTargetVo water = new WaterTargetVo();
water.setStationName(station.getName()); water.setStationName(station.getName());
if(CollectionUtil.isEmpty(targets)){ if(CollectionUtil.isEmpty(targets)){
@ -924,10 +947,13 @@ public class TargetServiceImpl implements TargetService {
} }
return water; return water;
})/*.filter(water -> Math.abs(water.getUse()) > 0)*/.sorted(Comparator.comparing(WaterTargetVo::getUse).reversed()).collect(Collectors.toList()); })/*.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 @Override
public List<PhotovoTargetVo> photovoltaicTarget(String stationName, Long deptId, Integer target) { public IPage<PhotovoTargetVo> photovoltaicTarget(IPage<PhotovoTargetVo> page,String stationName, Long deptId, Integer target) {
// 站点 // 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery(); LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC); wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC);
@ -941,13 +967,13 @@ public class TargetServiceImpl implements TargetService {
} }
List<StationEntity> stations = stationService.list(wappers); List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){ if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>(); return page;
} }
// 负荷 // 负荷
if(HomePageConstant.LOADING.equals(target)){ if(HomePageConstant.LOADING.equals(target)){
// 实时数据 // 实时数据
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key); List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
return stations.stream().map(station->{ List<PhotovoTargetVo> records = stations.stream().map(station->{
PhotovoTargetVo photovo = new PhotovoTargetVo(); PhotovoTargetVo photovo = new PhotovoTargetVo();
photovo.setStationName(station.getName()); photovo.setStationName(station.getName());
if(CollectionUtil.isEmpty(reals)){ if(CollectionUtil.isEmpty(reals)){
@ -957,10 +983,13 @@ public class TargetServiceImpl implements TargetService {
} }
return photovo; return photovo;
})/*.filter(photovoltaic -> Math.abs(photovoltaic.getLoad()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getLoad).reversed()).collect(Collectors.toList()); })/*.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<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
return stations.stream().map(station->{ List<PhotovoTargetVo> records = stations.stream().map(station->{
PhotovoTargetVo photovo = new PhotovoTargetVo(); PhotovoTargetVo photovo = new PhotovoTargetVo();
photovo.setStationName(station.getName()); photovo.setStationName(station.getName());
if(CollectionUtil.isEmpty(targets)){ if(CollectionUtil.isEmpty(targets)){
@ -982,61 +1011,9 @@ public class TargetServiceImpl implements TargetService {
} }
return photovo; return photovo;
})/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate).reversed()).collect(Collectors.toList()); })/*.filter(photovo -> Math.abs(photovo.getGenerate()) > 0)*/.sorted(Comparator.comparing(PhotovoTargetVo::getGenerate).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;
* 集团设备统计
* @param areaName
* @return
*/
@Override
public List<DeviceGroupVo> deviceGroup(String areaName) {
// 获取区域机构
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if(MapUtils.isEmpty(areas)){
return null;
}
// 获取设备
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList();
// 获取设备状态
Map<String, List<String>> deviceClassifyMap = (Map<String, List<String>>) redisTemplate.opsForValue().get(device_classify_key);
List<String> faultList = deviceClassifyMap.get(HomePageConstant.FAULT);
List<String> overhaultList = deviceClassifyMap.get(HomePageConstant.OVERHAUL);
List<String> 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<String> 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());
} }
/** /**
@ -1046,15 +1023,15 @@ public class TargetServiceImpl implements TargetService {
* @return * @return
*/ */
@Override @Override
public List<DutyGroupVo> dutyGroup(String areaName, Long type) { public IPage<DutyGroupVo> dutyGroup(IPage<DutyGroupVo> page,String areaName, Long type) {
// 获取区域机构 // 获取区域机构
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true); Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE,true);
if(MapUtils.isEmpty(areas)){ if(MapUtils.isEmpty(areas)){
return null; return page;
} }
// redis中取区域数据 // redis中取区域数据
List<AreaDutyVo> areaDutyVoList = (List<AreaDutyVo>) redisTemplate.opsForValue().get(areaDutyInfoKey); List<AreaDutyVo> areaDutyVoList = (List<AreaDutyVo>) redisTemplate.opsForValue().get(areaDutyInfoKey);
return areas.keySet().stream().filter(stationEntities -> StringUtil.isEmpty(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> { List<DutyGroupVo> records = areas.keySet().stream().filter(stationEntities -> StringUtil.isEmpty(areaName) || stationEntities.getDeptName().contains(areaName)).map(stationEntities -> {
DutyGroupVo duty = new DutyGroupVo(); DutyGroupVo duty = new DutyGroupVo();
duty.setDeptId(stationEntities.getId()); duty.setDeptId(stationEntities.getId());
duty.setAreaName(stationEntities.getDeptName()); duty.setAreaName(stationEntities.getDeptName());
@ -1080,6 +1057,9 @@ public class TargetServiceImpl implements TargetService {
} }
return duty; return duty;
}).collect(Collectors.toList()); }).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;
} }
/** /**

Loading…
Cancel
Save