H.X
2 years ago
29 changed files with 1197 additions and 19 deletions
@ -0,0 +1,13 @@
|
||||
package com.hnac.hzims.operational.census.constants; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
public interface CensusConstant { |
||||
|
||||
String WATER_SIGNAGE = "front_water_level"; |
||||
|
||||
Integer QUERY_TYPE_DEFAULT = 0; |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class CompleteDefectVo { |
||||
|
||||
@ApiModelProperty("区域名称") |
||||
private String areaName; |
||||
|
||||
@ApiModelProperty("缺陷总数") |
||||
private Integer defectCount; |
||||
|
||||
@ApiModelProperty("消缺数") |
||||
private Integer completeCount; |
||||
|
||||
@ApiModelProperty("消缺率") |
||||
private Double completeRate; |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class CompleteGenerationVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String stationName; |
||||
|
||||
@ApiModelProperty("计划发电量") |
||||
private Double planGeneration; |
||||
|
||||
@ApiModelProperty("实际发电量") |
||||
private Double realityGeneration; |
||||
|
||||
@ApiModelProperty("完成率") |
||||
private Double completeRate; |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class CompleteOtherVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String stationName; |
||||
|
||||
@ApiModelProperty("设备在线率") |
||||
private Double onlineRate; |
||||
|
||||
@ApiModelProperty("Fa投入条数") |
||||
private Double faCount; |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class CompleteTicketVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String areaName; |
||||
|
||||
@ApiModelProperty("两票数量") |
||||
private Integer ticketCount; |
||||
|
||||
@ApiModelProperty("合格票据数量") |
||||
private Integer completeCount; |
||||
|
||||
@ApiModelProperty("合格率") |
||||
private String completeRate; |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class ElectricGenerationVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String stationName; |
||||
|
||||
@ApiModelProperty("发容量") |
||||
private Double electricGeneration; |
||||
|
||||
@ApiModelProperty("详情") |
||||
private String detail; |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class ExamineCardVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String stationName; |
||||
|
||||
@ApiModelProperty("检修卡数量") |
||||
private Integer cardCount; |
||||
|
||||
@ApiModelProperty("检修卡总额") |
||||
private Double cardTotal; |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class InstalledCapacityVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String stationName; |
||||
|
||||
@ApiModelProperty("装机容量") |
||||
private Double installedCapacity; |
||||
|
||||
@ApiModelProperty("详情") |
||||
private String detail; |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class WaterFlowDataVo { |
||||
|
||||
@ApiModelProperty("时间") |
||||
private String time; |
||||
|
||||
@ApiModelProperty("值") |
||||
private String value; |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class WaterFlowResponseVo { |
||||
|
||||
@ApiModelProperty("站点名称") |
||||
private String station; |
||||
|
||||
@ApiModelProperty("站点集合") |
||||
private List<WaterFlowDataVo> datas; |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.hnac.hzims.operational.census.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Data |
||||
public class WaterFlowVo { |
||||
|
||||
@ApiModelProperty("站点集合") |
||||
private List<String> stations; |
||||
|
||||
@ApiModelProperty("监测类型:水位/流量") |
||||
private String type; |
||||
|
||||
@ApiModelProperty("时间跨域单位:2->h(小时)/3->d(天)/5->n(自然月)/6->y(自然年)") |
||||
private Integer timeType; |
||||
|
||||
@ApiModelProperty("开始时间") |
||||
private String startDate; |
||||
|
||||
@ApiModelProperty("结束时间") |
||||
private String endDate; |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.hnac.hzims.operational.census.controller; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.operational.census.service.CensusService; |
||||
import com.hnac.hzims.operational.census.vo.WaterFlowVo; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/census") |
||||
@Api(value = "统计", tags = "数据统计") |
||||
public class CensusController { |
||||
|
||||
private final CensusService service; |
||||
|
||||
@ApiOperation("水位-流量统计") |
||||
@PostMapping("/water-flow") |
||||
@ApiOperationSupport(order = 1) |
||||
public R waterFlow(@RequestBody WaterFlowVo waterFlow) { |
||||
return R.data(service.waterFlow(waterFlow)); |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
package com.hnac.hzims.operational.census.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
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.maintenance.dto.OperMaintenanceTaskDTO; |
||||
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.mp.support.Condition; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/03/01 16:12:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/target") |
||||
@Api(value = "指标关联数据", tags = "指标关联数据") |
||||
public class TargetController { |
||||
|
||||
private final TargetService service; |
||||
|
||||
@ApiOperation("装机容量统计") |
||||
@PostMapping("/installed-capacity") |
||||
@ApiOperationSupport(order = 1) |
||||
public R installedCapacity(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { |
||||
return R.data(service.installedCapacity(stationName,type)); |
||||
} |
||||
|
||||
@ApiOperation("发电量统计") |
||||
@PostMapping("/electric-generation") |
||||
@ApiOperationSupport(order = 2) |
||||
public R electricGeneration() { |
||||
return R.data(service.electricGeneration()); |
||||
} |
||||
|
||||
@ApiOperation("计划发电量/实际发电量统计") |
||||
@PostMapping("/complete-generation") |
||||
@ApiOperationSupport(order = 3) |
||||
public R completeGeneration() { |
||||
return R.data(service.completeGeneration()); |
||||
} |
||||
|
||||
@ApiOperation("两票统计") |
||||
@PostMapping("/complete-ticket") |
||||
@ApiOperationSupport(order = 4) |
||||
public R completeTicket(@RequestParam(value = "areaName") String areaName,@RequestParam(value = "type") Integer type) { |
||||
return R.data(service.completeTicket(areaName,type)); |
||||
} |
||||
|
||||
@ApiOperation("缺陷率统计") |
||||
@GetMapping("/complete-defect") |
||||
@ApiOperationSupport(order = 6) |
||||
public R completeDefect(@RequestParam(value = "areaName") String areaName,@RequestParam(value = "type") Integer type) { |
||||
return R.data(service.defect(areaName,type)); |
||||
} |
||||
|
||||
@ApiOperation("上线率/Fa投入条数统计") |
||||
@GetMapping("/complete-other") |
||||
@ApiOperationSupport(order = 6) |
||||
public R completeOther(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type,@RequestParam(value = "queryType") Integer queryType) { |
||||
return R.data(service.completeOther(stationName,type,queryType)); |
||||
} |
||||
|
||||
@ApiOperation("日常维护统计") |
||||
@GetMapping("/routine-maintenance") |
||||
@ApiOperationSupport(order = 5) |
||||
public R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params,Query query,Integer type) { |
||||
return service.routineMaintenance(params,query,type); |
||||
} |
||||
|
||||
@ApiOperation("检修任务统计") |
||||
@GetMapping("/examine-repair") |
||||
@ApiOperationSupport(order = 6) |
||||
public R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { |
||||
return service.examineRepair(params, query,type); |
||||
} |
||||
|
||||
@ApiOperation("检修卡统计") |
||||
@GetMapping("/examineCard") |
||||
@ApiOperationSupport(order = 6) |
||||
public R examineCard(@RequestParam(value = "stationName") String stationName,@RequestParam(value = "type") Integer type) { |
||||
return R.data(service.examineCard(stationName,type)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.hnac.hzims.operational.census.service; |
||||
|
||||
import com.hnac.hzims.operational.census.vo.WaterFlowResponseVo; |
||||
import com.hnac.hzims.operational.census.vo.WaterFlowVo; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
public interface CensusService { |
||||
|
||||
|
||||
// 查询水位/流量数据
|
||||
List<WaterFlowResponseVo> waterFlow(WaterFlowVo waterFlow); |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.hnac.hzims.operational.census.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; |
||||
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; |
||||
import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; |
||||
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; |
||||
import com.hnac.hzims.operational.census.vo.*; |
||||
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; |
||||
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/03/01 16:12:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
public interface TargetService { |
||||
|
||||
// 获取站点装机容量
|
||||
List<InstalledCapacityVo> installedCapacity(String stationName,Integer type); |
||||
|
||||
// 发电量统计
|
||||
List<ElectricGenerationVo> electricGeneration(); |
||||
|
||||
// 计划发电量/实际发电量统计
|
||||
List<CompleteGenerationVo> completeGeneration(); |
||||
|
||||
// 两票统计
|
||||
List<CompleteTicketVo> completeTicket(String areaName,Integer type); |
||||
|
||||
// 缺陷率统计
|
||||
List<CompleteDefectVo> defect(String areaName, Integer type); |
||||
|
||||
// 检修卡统计
|
||||
List<ExamineCardVo> examineCard(String stationName, Integer type); |
||||
|
||||
// 设备在线率/Fa投入条数统计
|
||||
List<CompleteOtherVo> completeOther(String stationName, Integer type,Integer queryType); |
||||
|
||||
// 日常维护统计
|
||||
R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type); |
||||
|
||||
// 检修任务统计
|
||||
R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type); |
||||
} |
@ -0,0 +1,137 @@
|
||||
package com.hnac.hzims.operational.census.service.impl; |
||||
|
||||
import com.hnac.hzims.EquipmentConstants; |
||||
import com.hnac.hzims.operational.census.constants.CensusConstant; |
||||
import com.hnac.hzims.operational.census.service.CensusService; |
||||
import com.hnac.hzims.operational.census.vo.WaterFlowDataVo; |
||||
import com.hnac.hzims.operational.census.vo.WaterFlowResponseVo; |
||||
import com.hnac.hzims.operational.census.vo.WaterFlowVo; |
||||
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; |
||||
import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; |
||||
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; |
||||
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; |
||||
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; |
||||
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.CollectionUtils; |
||||
import org.springframework.util.ObjectUtils; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Optional; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Service |
||||
@RequiredArgsConstructor |
||||
public class CensusServiceImpl implements CensusService { |
||||
|
||||
private final IAnalyseDataSearchClient dateSearch; |
||||
|
||||
private final IHzimsAnalyzeModelStationService analyzeStationService; |
||||
|
||||
/** |
||||
* 查询水位/流量统计数据 |
||||
* @param waterFlow |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<WaterFlowResponseVo> waterFlow(WaterFlowVo waterFlow) { |
||||
// 查询参数设置
|
||||
List<String> instances = this.getDefaultStations(waterFlow.getStations()); |
||||
if(CollectionUtils.isEmpty(instances)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
List<AnalyseCodeByAnalyseDataPO> params = instances.stream().map(instance->{ |
||||
AnalyseCodeByAnalyseDataPO analyseCodeByAnalyseData = new AnalyseCodeByAnalyseDataPO(); |
||||
analyseCodeByAnalyseData.setDeviceCode(instance); |
||||
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); |
||||
AnalyzeDataConditionPO analyzeDataCondition = new AnalyzeDataConditionPO(); |
||||
analyzeDataCondition.setFull(1); |
||||
analyzeDataCondition.setSignages(Optional.ofNullable(waterFlow.getType()).orElse(CensusConstant.WATER_SIGNAGE)); |
||||
// 取数规则: 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值
|
||||
analyzeDataCondition.setAccessRules(EquipmentConstants.AccessRulesEnum.AVG_CYCLE.getType()); |
||||
// 周期类型: 0-> s(秒) 1->、m(分)、2->h(小时)3->、d(天)4->、w(周)5->、n(自然月)、6->y(自然年)
|
||||
analyzeDataCondition.setSaveTimeType(Optional.ofNullable(waterFlow.getTimeType()).orElse(3)); |
||||
// 间隔
|
||||
analyzeDataCondition.setTimeInterval(1); |
||||
analyzeDataCondition.setBeginTime(this.getSearchStartTime(waterFlow.getStartDate())); |
||||
analyzeDataCondition.setEndTime(this.getSearchEndTime(waterFlow.getEndDate())); |
||||
signboardConditions.add(analyzeDataCondition); |
||||
analyseCodeByAnalyseData.setSignboardConditions(signboardConditions); |
||||
return analyseCodeByAnalyseData; |
||||
}).collect(Collectors.toList()); |
||||
|
||||
// 查询数据
|
||||
return params.stream().map(o->{ |
||||
WaterFlowResponseVo waterFlowResponse = new WaterFlowResponseVo(); |
||||
waterFlowResponse.setStation(o.getDeviceCode()); |
||||
List<AnalyzeDataConditionVO> data = dateSearch.getAnalyzeDataByAnalyzeCodeAndSignages(o).getData(); |
||||
if(CollectionUtils.isEmpty(data)){ |
||||
waterFlowResponse.setDatas(null); |
||||
}else{ |
||||
List<WaterFlowDataVo> datas = data.get(0).getList().stream().map(m->{ |
||||
WaterFlowDataVo waterFlowDataVo = new WaterFlowDataVo(); |
||||
waterFlowDataVo.setTime(m.getTs()); |
||||
waterFlowDataVo.setValue(m.getVal()); |
||||
return waterFlowDataVo; |
||||
}).collect(Collectors.toList()); |
||||
waterFlowResponse.setDatas(datas); |
||||
} |
||||
return waterFlowResponse; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询默认水位/流量站点 |
||||
* @return |
||||
*/ |
||||
private List<String> getDefaultStations(List<String> stations) { |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
List<HzimsAnalyzeModelStationEntity> models = analyzeStationService.list(); |
||||
if(CollectionUtils.isEmpty(models)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
return models.stream().map(HzimsAnalyzeModelStationEntity::getInstanceCode).collect(Collectors.toList()); |
||||
} |
||||
return stations; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取开始时间 |
||||
* @param date |
||||
* @return |
||||
*/ |
||||
private LocalDateTime getSearchStartTime(String date) { |
||||
if(ObjectUtils.isEmpty(date)){ |
||||
Date startDate = new Date(); |
||||
startDate.setMonth(startDate.getMonth()-1); |
||||
date = DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss"); |
||||
} |
||||
return LocalDateTime.parse(DateUtil.format(new Date(), date), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
||||
} |
||||
|
||||
/** |
||||
* 获取结束时间 |
||||
* @param date |
||||
* @return |
||||
*/ |
||||
private LocalDateTime getSearchEndTime(String date) { |
||||
if(ObjectUtils.isEmpty(date)){ |
||||
date = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); |
||||
} |
||||
return LocalDateTime.parse(DateUtil.format(new Date(), date), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
||||
} |
||||
} |
@ -0,0 +1,519 @@
|
||||
package com.hnac.hzims.operational.census.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.hnac.hzims.equipment.entity.EmInfoEntity; |
||||
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
||||
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; |
||||
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
||||
import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; |
||||
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; |
||||
import com.hnac.hzims.operational.access.service.IOperAccessStatisticsService; |
||||
import com.hnac.hzims.operational.access.service.IOperAccessTaskService; |
||||
import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; |
||||
import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; |
||||
import com.hnac.hzims.operational.census.constants.CensusConstant; |
||||
import com.hnac.hzims.operational.census.service.TargetService; |
||||
import com.hnac.hzims.operational.census.vo.*; |
||||
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; |
||||
import com.hnac.hzims.operational.fill.entity.*; |
||||
import com.hnac.hzims.operational.fill.service.*; |
||||
import com.hnac.hzims.operational.main.service.AreaService; |
||||
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; |
||||
import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo; |
||||
import com.hnac.hzims.operational.maintenance.constants.HomePageConstant; |
||||
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; |
||||
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; |
||||
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; |
||||
import com.hnac.hzims.operational.report.vo.DutyDefectVO; |
||||
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||
import com.hnac.hzims.operational.station.service.IStationService; |
||||
import com.hnac.hzims.ticket.allTicket.fegin.ITicketInfoAllClient; |
||||
import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; |
||||
import io.swagger.models.auth.In; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springblade.core.mp.support.Query; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.DateUtil; |
||||
import org.springblade.core.tool.utils.ObjectUtil; |
||||
import org.springblade.system.entity.Dept; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.CollectionUtils; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.text.SimpleDateFormat; |
||||
import java.time.LocalDate; |
||||
import java.time.LocalDateTime; |
||||
import java.time.LocalTime; |
||||
import java.util.*; |
||||
import java.util.concurrent.CountDownLatch; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author ysj |
||||
* @date 2023/02/23 13:37:22 |
||||
* @version 4.0.0 |
||||
*/ |
||||
@Service |
||||
@RequiredArgsConstructor |
||||
public class TargetServiceImpl implements TargetService { |
||||
|
||||
private final IStationService stationService; |
||||
|
||||
private final IMainSystemMonitoringService maintenanceService; |
||||
|
||||
private final PowerService powerService; |
||||
|
||||
private final AreaService areaService; |
||||
|
||||
private final IOperMaintenanceTaskService maintenanceTaskService; |
||||
|
||||
private final IOperPhenomenonService phenomenonService; |
||||
|
||||
private final OverService overService; |
||||
|
||||
private final OverDetailsService overDetailsService; |
||||
|
||||
private final SolveService solveService; |
||||
|
||||
private final OtherService otherService; |
||||
|
||||
private final IOperAccessTaskService accessTaskService; |
||||
|
||||
private final IPlanGenertionClient planClient; |
||||
|
||||
private final ITicketInfoAllClient ticketInfoAllClient; |
||||
|
||||
private final RedisTemplate redisTemplate; |
||||
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); |
||||
|
||||
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
||||
|
||||
/** |
||||
* 获取站点装机容量 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<InstalledCapacityVo> installedCapacity(String stationName,Integer type) { |
||||
// 站点
|
||||
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
||||
.eq(StationEntity::getType, type) |
||||
.eq(StationEntity::getServeType,2) |
||||
.like(StationEntity::getName,stationName) |
||||
); |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
if(HomePageConstant.HYDROPOWER.equals(type)){ |
||||
// 设备
|
||||
List<EminfoAndEmParamVo> devices = maintenanceService.getEmInfoList(); |
||||
return stations.stream().map(station->{ |
||||
InstalledCapacityVo item = new InstalledCapacityVo(); |
||||
item.setStationName(station.getName()); |
||||
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
||||
if(CollectionUtils.isEmpty(stationDevices)){ |
||||
item.setInstalledCapacity(0.0); |
||||
item.setDetail("站点暂无设备!"); |
||||
return item; |
||||
} |
||||
// 装机容量
|
||||
double sum = stationDevices.stream().mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); |
||||
item.setInstalledCapacity(sum); |
||||
// 装机容量详情
|
||||
List<String> details = stationDevices.stream().map(device-> "[" + device.getName() + " " +device.getInstalledCapacity() +"kw]").collect(Collectors.toList()); |
||||
item.setDetail(String.join("|",details)); |
||||
return item; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
// 查询填报数据
|
||||
String mon = DateUtil.format(new Date(),"yyyy"); |
||||
List<PowerEntity> powers = powerService.list(Wrappers.<PowerEntity>lambdaQuery() |
||||
.in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) |
||||
.ge(PowerEntity::getMon, mon + "-01") |
||||
); |
||||
return stations.stream().map(station -> { |
||||
InstalledCapacityVo item = new InstalledCapacityVo(); |
||||
item.setStationName(station.getName()); |
||||
// 装机容量
|
||||
List<PowerEntity> stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); |
||||
if(CollectionUtils.isEmpty(stationPowers)){ |
||||
item.setInstalledCapacity(0.0); |
||||
}else{ |
||||
item.setInstalledCapacity(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getInstalledCapacity()); |
||||
} |
||||
item.setDetail("站点为填报数据,暂无设备装机容量信息!"); |
||||
return item; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* 发电量 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<ElectricGenerationVo> electricGeneration() { |
||||
// 站点
|
||||
List<StationEntity> stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
// 设备指标数据
|
||||
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
||||
if(CollectionUtils.isEmpty(targets)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
return stations.stream().map(station->{ |
||||
ElectricGenerationVo item = new ElectricGenerationVo(); |
||||
item.setStationName(station.getName()); |
||||
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
||||
if(CollectionUtils.isEmpty(stationTargets)){ |
||||
item.setElectricGeneration(0.0); |
||||
item.setDetail("站点暂无发电"); |
||||
return item; |
||||
} |
||||
// 年发电量
|
||||
double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
||||
item.setElectricGeneration(sum); |
||||
// 装机容量详情
|
||||
List<String> details = targets.stream().map(target-> "[" + target.getDeviceCode() + " " + target.getPowerYear() +"kw]").collect(Collectors.toList()); |
||||
item.setDetail(String.join("|",details)); |
||||
return item; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* 电量完成率 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<CompleteGenerationVo> completeGeneration() { |
||||
// 站点
|
||||
List<StationEntity> stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
// 计划发电量
|
||||
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy")); |
||||
// 设备指标数据
|
||||
List<HydropowerUnitTargetVo> targets = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); |
||||
if(CollectionUtils.isEmpty(targets)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
return stations.stream().map(station->{ |
||||
CompleteGenerationVo item = new CompleteGenerationVo(); |
||||
item.setStationName(station.getName()); |
||||
List<HydropowerUnitTargetVo> stationTargets = targets.stream().filter(device->device.getDeptId().equals(station.getRefDept())).collect(Collectors.toList()); |
||||
// 实际发电量
|
||||
if(CollectionUtils.isEmpty(stationTargets)){ |
||||
item.setRealityGeneration(0.0); |
||||
}else { |
||||
double sum = targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
||||
item.setRealityGeneration(sum); |
||||
} |
||||
// 计划发电量
|
||||
List<Float> planGenerations = plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).map(PlanGenerationEntity::getPlanGeneration).collect(Collectors.toList()); |
||||
if(CollectionUtils.isEmpty(planGenerations)){ |
||||
item.setPlanGeneration(0.0); |
||||
}else{ |
||||
item.setPlanGeneration(BigDecimal.valueOf(planGenerations.get(0)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
||||
} |
||||
// 完成率
|
||||
if(Math.abs(item.getPlanGeneration()) <= 0){ |
||||
item.setCompleteRate(0.0); |
||||
}else{ |
||||
item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
||||
} |
||||
return item; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* 双票合格率 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<CompleteTicketVo> completeTicket(String areaName,Integer type) { |
||||
// 获取水电站区域机构
|
||||
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE); |
||||
if(MapUtils.isEmpty(areas)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
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<>(); |
||||
} |
||||
// 开始时间
|
||||
LocalDate firstDay = LocalDate.now().withDayOfYear(1); |
||||
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); |
||||
ExecutorService pool = Executors.newFixedThreadPool(depts.size()); |
||||
//监控线程执行完后返回结果
|
||||
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); |
||||
List<CompleteTicketVo> completeTickets = new ArrayList<>(); |
||||
pool.execute(()-> { |
||||
for (Dept dept: depts) { |
||||
// 双票
|
||||
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()); |
||||
completeTicketVo.setCompleteCount(doublePass.getDoubleTicketPassCount()); |
||||
completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); |
||||
} |
||||
completeTickets.add(completeTicketVo); |
||||
countDownLatch.countDown(); |
||||
} |
||||
}); |
||||
// 等待所有线程执行完成
|
||||
try { |
||||
countDownLatch.await(); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
Thread.currentThread().interrupt(); |
||||
} |
||||
pool.shutdown(); |
||||
return completeTickets; |
||||
} |
||||
|
||||
/** |
||||
* 缺陷统计 |
||||
* @param areaName |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<CompleteDefectVo> defect(String areaName, Integer type) { |
||||
if(HomePageConstant.DISTRIBUTION_NETWORK.equals(type)){ |
||||
return this.getFillDefect(areaName,type); |
||||
} |
||||
|
||||
// 获取区域机构
|
||||
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE); |
||||
if(MapUtils.isEmpty(areas)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
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<>(); |
||||
} |
||||
String startTime = this.getFristDayByYear(); |
||||
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
||||
ExecutorService pool = Executors.newFixedThreadPool(depts.size()); |
||||
//监控线程执行完后返回结果
|
||||
CountDownLatch countDownLatch = new CountDownLatch(depts.size()); |
||||
List<CompleteDefectVo> completeDefects = new ArrayList<>(); |
||||
pool.execute(()-> { |
||||
for (Dept dept: depts) { |
||||
// 缺陷
|
||||
DutyDefectVO defectVO = phenomenonService.getDutyDefect(startTime, endTime, Collections.singletonList(dept.getId())); |
||||
CompleteDefectVo defect = new CompleteDefectVo(); |
||||
defect.setDefectCount(defectVO.getDefectSum()); |
||||
defect.setCompleteCount(defectVO.getDefect()); |
||||
if (defect.getDefectCount() <= 0) { |
||||
defect.setCompleteRate(0.0); |
||||
} else { |
||||
defect.setCompleteRate(BigDecimal.valueOf(defect.getCompleteCount() / defect.getDefectCount() * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
||||
} |
||||
completeDefects.add(defect); |
||||
countDownLatch.countDown(); |
||||
} |
||||
}); |
||||
// 等待所有线程执行完成
|
||||
try { |
||||
countDownLatch.await(); |
||||
} catch (InterruptedException e) { |
||||
e.printStackTrace(); |
||||
Thread.currentThread().interrupt(); |
||||
} |
||||
pool.shutdown(); |
||||
return completeDefects; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 检修卡统计 |
||||
* @param stationName |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<ExamineCardVo> examineCard(String stationName, Integer type) { |
||||
// 站点
|
||||
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
||||
.eq(StationEntity::getType, type) |
||||
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) |
||||
.like(StationEntity::getName,stationName) |
||||
); |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
// 查询检修卡
|
||||
String startTime = this.getFristDayByYear(); |
||||
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
||||
List<OverEntity> overs = overService.list(Wrappers.<OverEntity>lambdaQuery() |
||||
.in(OverEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) |
||||
.ge(OverEntity::getCreateTime,startTime) |
||||
.le(OverEntity::getCreateTime,endTime) |
||||
); |
||||
if(CollectionUtils.isEmpty(overs)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
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->{ |
||||
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.valueOf(over.getTotalPrice().toString())).sum()); |
||||
examineCard.setCardCount(overDetails.stream().filter(detail-> detail.getOverId().equals(entry.getKey())).mapToInt(OverDetailsEntity::getQuantity).sum()); |
||||
return examineCard; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* 配网设备在线率/Fa投入条数 |
||||
* @param stationName |
||||
* @param type |
||||
* @param queryType |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<CompleteOtherVo> completeOther(String stationName, Integer type, Integer queryType) { |
||||
// 站点
|
||||
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
||||
.eq(StationEntity::getType, type) |
||||
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) |
||||
.like(StationEntity::getName,stationName) |
||||
); |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
// 查询设备在线率/Fa投入条数
|
||||
String startTime = this.getFristDayByYear(); |
||||
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
||||
List<OtherEntity> others = otherService.list(Wrappers.<OtherEntity>lambdaQuery() |
||||
.in(OtherEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) |
||||
.ge(OtherEntity::getCreateTime,startTime) |
||||
.le(OtherEntity::getCreateTime,endTime) |
||||
); |
||||
if(CollectionUtils.isEmpty(others)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
return 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(0)){ |
||||
other.setOnlineRate(entry.getValue().stream().mapToDouble(value ->Double.valueOf(value.getOnlineRate())).average().orElse(0.0)); |
||||
}else{ |
||||
other.setFaCount(entry.getValue().stream().mapToDouble(OtherEntity::getFaQuantity).sum()); |
||||
} |
||||
return other; |
||||
}).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* 配网消缺 |
||||
* @param areaName |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
private List<CompleteDefectVo> getFillDefect(String areaName, Integer type) { |
||||
// 站点
|
||||
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
||||
.eq(StationEntity::getType, type) |
||||
.eq(StationEntity::getServeType,2) |
||||
.like(StationEntity::getName,areaName) |
||||
); |
||||
if(CollectionUtils.isEmpty(stations)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
// 缺陷填报记录
|
||||
String startTime = this.getFristDayByYear(); |
||||
String endTime = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); |
||||
List<SolveEntity> solves = solveService.list(Wrappers.<SolveEntity>lambdaQuery() |
||||
.in(SolveEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) |
||||
.ge(SolveEntity::getCreateTime,startTime) |
||||
.le(SolveEntity::getCreateTime,endTime) |
||||
); |
||||
if(CollectionUtils.isEmpty(solves)){ |
||||
return new ArrayList<>(); |
||||
} |
||||
return solves.stream().collect(Collectors.groupingBy(SolveEntity::getCreateDept)).entrySet().stream().map(entry -> { |
||||
CompleteDefectVo defect = new CompleteDefectVo(); |
||||
defect.setAreaName(stations.stream().filter(station -> station.getRefDept().equals(entry.getKey())).collect(Collectors.toList()).get(0).getName()); |
||||
defect.setDefectCount(entry.getValue().stream().mapToInt(SolveEntity::getSolveQuantity).sum()); |
||||
defect.setCompleteCount(entry.getValue().stream().mapToInt(SolveEntity::getSolveSucQuantity).sum()); |
||||
if (Math.abs(defect.getDefectCount()) <= 0) { |
||||
defect.setCompleteRate(0.0); |
||||
} else { |
||||
defect.setCompleteRate(BigDecimal.valueOf(defect.getCompleteCount() / defect.getDefectCount() * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
||||
} |
||||
return defect; |
||||
}).collect(Collectors.toList()); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 日常维护统计 |
||||
* @param param |
||||
* @param query |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public R<IPage<OperMaintenanceTaskVO>> routineMaintenance(OperMaintenanceTaskDTO params, Query query, Integer type) { |
||||
// 获取区域机构
|
||||
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE); |
||||
if(MapUtils.isEmpty(areas)){ |
||||
return null; |
||||
} |
||||
// 查询日常维护任务
|
||||
params.setDeptIds(areas.entrySet().stream().map(entry->entry.getKey().getId()).collect(Collectors.toList())); |
||||
return maintenanceTaskService.list(params,query); |
||||
} |
||||
|
||||
/** |
||||
* 检修任务统计 |
||||
* @param params |
||||
* @param query |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public R<IPage<OperAccessTaskVO>> examineRepair(OperAccessTaskDTO params, Query query, Integer type) { |
||||
// 获取区域机构
|
||||
Map<Dept, List<StationEntity>> areas = areaService.getAuthArea(null,null,Collections.singletonList(type),HomePageConstant.HYDROPOWER_SERVETYPE); |
||||
if(MapUtils.isEmpty(areas)){ |
||||
return null; |
||||
} |
||||
// 查询检修任务
|
||||
params.setDeptIds(areas.keySet().stream().map(key-> key.getId()).collect(Collectors.toList())); |
||||
return accessTaskService.list(params,query); |
||||
} |
||||
|
||||
/** |
||||
* 获取当年的第一天 |
||||
* @return |
||||
*/ |
||||
private String getFristDayByYear() { |
||||
Calendar calendar = Calendar.getInstance(); |
||||
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); |
||||
calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); |
||||
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY)); |
||||
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); |
||||
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); |
||||
return sdf.format(calendar.getTime()); |
||||
} |
||||
} |
Loading…
Reference in new issue