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.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<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) {
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<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) {
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<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) {
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<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) {
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<IPage<CompleteDefectVo>> 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<IPage<CompleteOtherVo>> 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<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);
}
@ -100,7 +108,9 @@ public class TargetController {
@ApiOperation("检修任务统计")
@GetMapping("/examine-repair")
@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);
}
@ -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<IPage<ExamineCardVo>> 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<IPage<DeviceClassifyVo>> 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<IPage<HydropowerTargetVo>> 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<IPage<WaterTargetVo>> 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<IPage<PhotovoTargetVo>> 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<IPage<DutyGroupVo>> 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));
}
}

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);
// 缺陷率统计
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投入条数统计
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);
@ -46,20 +46,17 @@ public interface TargetService {
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);
// 集团设备
List<DeviceGroupVo> deviceGroup(String areaName);
IPage<PhotovoTargetVo> photovoltaicTarget(IPage<PhotovoTargetVo> page,String stationName, Long deptId, Integer target);
// 集团工作牌/操作票
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
*/
@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)){
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);
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());
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<ExamineCardVo> examineCard(String stationName, Integer type) {
public IPage<ExamineCardVo> examineCard(IPage<ExamineCardVo> page,String stationName, Integer type) {
// 站点
LambdaQueryWrapper<StationEntity> wappers = Wrappers.lambdaQuery();
wappers.eq(StationEntity::getType, type);
@ -592,7 +595,7 @@ public class TargetServiceImpl implements TargetService {
}
List<StationEntity> 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<OverDetailsEntity> overDetails = overDetailsService.list(Wrappers.<OverDetailsEntity>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<ExamineCardVo> 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<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();
wappers.eq(StationEntity::getType, type);
@ -636,7 +642,7 @@ public class TargetServiceImpl implements TargetService {
}
List<StationEntity> 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<CompleteOtherVo> 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<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);
List<String> faultList = deviceClassifyMap.get(HomePageConstant.FAULT);
@ -759,21 +768,21 @@ public class TargetServiceImpl implements TargetService {
//根据用户权限获取机构
R<List<Dept>> result = sysClient.getDeptByCurrentUser();
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);
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());
if(CollectionUtils.isEmpty(detpIds)){
return new ArrayList<>();
return page;
}
// 设备
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList();
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 -> {
@ -791,11 +800,16 @@ public class TargetServiceImpl implements TargetService {
}
return deviceClassify;
}).filter(deviceClass -> StringUtils.isEmpty(stationName) || deviceClass.getStationName().contains(stationName)).collect(Collectors.toList());
List<DeviceClassifyVo> 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<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();
wappers.eq(StationEntity::getType, HomePageConstant.HYDROPOWER);
@ -818,13 +832,13 @@ public class TargetServiceImpl implements TargetService {
}
List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>();
return page;
}
// 功率
if(HomePageConstant.POWER.equals(target)){
// 实时数据
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();
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<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();
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<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();
wappers.in(StationEntity::getType, HomePageConstant.waterList);
@ -883,12 +903,12 @@ public class TargetServiceImpl implements TargetService {
}
List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>();
return page;
}
// 负荷
if(HomePageConstant.LOADING.equals(target)){
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();
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<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();
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<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();
wappers.eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC);
@ -941,13 +967,13 @@ public class TargetServiceImpl implements TargetService {
}
List<StationEntity> stations = stationService.list(wappers);
if(CollectionUtils.isEmpty(stations)){
return new ArrayList<>();
return page;
}
// 负荷
if(HomePageConstant.LOADING.equals(target)){
// 实时数据
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();
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<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();
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<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());
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<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);
if(MapUtils.isEmpty(areas)){
return null;
return page;
}
// redis中取区域数据
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();
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;
}
/**

Loading…
Cancel
Save