diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/IInspectReportClient.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/IInspectReportClient.java index 2c52b77..50d12d5 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/IInspectReportClient.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/IInspectReportClient.java @@ -2,6 +2,8 @@ package com.hnac.hzinfo.inspect.report.feign; import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.report.vo.AlarmRoutReportVO; +import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; +import com.hnac.hzinfo.inspect.task.vo.TaskReportVO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -16,7 +18,10 @@ import java.util.Map; public interface IInspectReportClient { String API_PREFIX = "/feign/report"; String GET_ALARAM_REPORT = API_PREFIX + "/getAlarmReport"; + String GET_INSPECT_STATISTCS_BY_NAME = API_PREFIX + "/getInspectStatisticsByName"; @PostMapping(GET_ALARAM_REPORT) Map getAlarmReport(@RequestParam("depts") List depts, @RequestParam("date") String date); + @PostMapping(GET_INSPECT_STATISTCS_BY_NAME) + List getInspectStatisticsByName(@RequestParam("depts") List depts, @RequestParam("date") String startTime, @RequestParam("date") String endTime); } diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/InspectReportClientFallback.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/InspectReportClientFallback.java index 4ea23c3..183c6f9 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/InspectReportClientFallback.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/report/feign/InspectReportClientFallback.java @@ -1,9 +1,11 @@ package com.hnac.hzinfo.inspect.report.feign; import com.hnac.hzinfo.inspect.report.vo.AlarmRoutReportVO; +import com.hnac.hzinfo.inspect.task.vo.TaskReportVO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -16,4 +18,9 @@ public class InspectReportClientFallback implements IInspectReportClient{ public Map getAlarmReport(List depts, String date) { return new HashMap<>(); } + + @Override + public List getInspectStatisticsByName(List depts, String startTime, String endTime) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/TicketInfoStatisticVO.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/TicketInfoStatisticVO.java index 0c8d90e..42df792 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/TicketInfoStatisticVO.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/allTicket/vo/TicketInfoStatisticVO.java @@ -20,7 +20,8 @@ public class TicketInfoStatisticVO implements Serializable { private static final long serialVersionUID = -8870464581684939369L; @ApiModelProperty("日期") private String dateTime; - + @ApiModelProperty("序号") + private Integer index; @ApiModelProperty("本月票据合格率") @JsonSerialize(nullsUsing = NullSerializer.class) private Double ticketInfoProportion; @@ -29,23 +30,26 @@ public class TicketInfoStatisticVO implements Serializable { private String ticketInfoType; @ApiModelProperty("开票数量") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Integer ticketInfoNumber; +// @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer ticketInfoNumber=0; @ApiModelProperty("本月完成开票数") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Integer ticketInfoCompleteNum; +// @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer ticketInfoCompleteNum=0; @ApiModelProperty("本月未完成开票数") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Integer ticketInfoStartNum; +// @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer ticketInfoStartNum=0; @ApiModelProperty("本月延期开票数") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Integer ticketInfoDelayNum; +// @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer ticketInfoDelayNum=0; @ApiModelProperty("工作票合格数量") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Integer ticketInfoQualifiedNum; +// @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer ticketInfoQualifiedNum=0; + @ApiModelProperty("废票数") +// @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer ticketInfoInvalidatedNum=0; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/gather/feigns/InspectReportClient.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/gather/feigns/InspectReportClient.java deleted file mode 100644 index b09f167..0000000 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/gather/feigns/InspectReportClient.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzinfo.inspect.gather.feigns; - -import com.hnac.hzinfo.inspect.report.feign.IInspectReportClient; -import com.hnac.hzinfo.inspect.report.service.InspectReportService; -import com.hnac.hzinfo.inspect.report.vo.AlarmRoutReportVO; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; -import java.util.Map; - -public class InspectReportClient implements IInspectReportClient { - - @Autowired - private InspectReportService inspectReportService; - - @Override - public Map getAlarmReport(List depts, String date) { - return inspectReportService.getAlarnReport(date,depts); - } -} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/report/feigns/InspectReportClient.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/report/feigns/InspectReportClient.java index 960ca7a..c8cc7fa 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/report/feigns/InspectReportClient.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/report/feigns/InspectReportClient.java @@ -3,6 +3,8 @@ package com.hnac.hzinfo.inspect.report.feigns; import com.hnac.hzinfo.inspect.report.feign.IInspectReportClient; import com.hnac.hzinfo.inspect.report.service.InspectReportService; import com.hnac.hzinfo.inspect.report.vo.AlarmRoutReportVO; +import com.hnac.hzinfo.inspect.task.service.ITaskService; +import com.hnac.hzinfo.inspect.task.vo.TaskReportVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -15,10 +17,18 @@ public class InspectReportClient implements IInspectReportClient { @Autowired private InspectReportService inspectReportService; - + @Autowired + private ITaskService taskService; @PostMapping(GET_ALARAM_REPORT) @Override public Map getAlarmReport(List depts, String date) { return inspectReportService.getAlarnReport(date,depts); } + + @PostMapping(GET_INSPECT_STATISTCS_BY_NAME) + @Override + public List getInspectStatisticsByName(List depts, String startTime, String endTime) { + List inspectTaskReport = taskService.getInspectTaskReport(startTime, endTime, depts); + return inspectTaskReport; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java index 696eb63..ab5089b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java @@ -8,6 +8,7 @@ import com.hnac.hzims.operational.access.vo.AccessTaskExportVo; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.RepairBillVO; import com.hnac.hzims.operational.report.vo.AccessReportVO; +import com.hnac.hzims.operational.report.vo.AccessRunReportVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; import com.hnac.hzims.vo.VoteChartVo; import org.springblade.core.mp.base.BaseService; @@ -48,6 +49,7 @@ public interface IOperAccessTaskService extends BaseService getAccessTaskByDisposer(LocalDate startDate, LocalDate endDate, List deptIdList); List getAccessTaskByDisposer(Map params); + List getAccessTaskByName(Map params); List> getAccessConclusion(Map params); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java index c456de8..dc2d35e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java @@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.message.enums.PushStatEnum; import com.hnac.hzims.message.fegin.IMessagePushClient; import com.hnac.hzims.message.req.PushExtrasReq; import com.hnac.hzims.operational.OperationalConstants; @@ -36,6 +37,7 @@ import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService; import com.hnac.hzims.operational.report.vo.AccessReportVO; +import com.hnac.hzims.operational.report.vo.AccessRunReportVO; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import com.hnac.hzims.spare.entity.SpRecordEntity; @@ -59,6 +61,7 @@ import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.vo.ComleteTask; +import org.springblade.system.cache.DictCache; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; @@ -302,6 +305,53 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl getAccessTaskByName(Map params) { + LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + List deptIdList = (List) params.get("deptId"); + List operAccessTaskEntityList = this.list(new LambdaQueryWrapper() {{ + ge(OperAccessTaskEntity::getPlanStartTime, startDate); + le(OperAccessTaskEntity::getPlanStartTime, endDate); + in(OperAccessTaskEntity::getCreateDept, deptIdList); + }}); + List res =new ArrayList<>(); + if(CollectionUtil.isNotEmpty(operAccessTaskEntityList)) { + for (int i = 0; i < operAccessTaskEntityList.size(); i++) { + OperAccessTaskEntity operAccessTaskEntity= operAccessTaskEntityList.get(i); + AccessRunReportVO accessReportVO = new AccessRunReportVO(); + accessReportVO.setIndex(i+1); + accessReportVO.setUserName(operAccessTaskEntity.getHandlerName()); + accessReportVO.setMaintenanceItem(operAccessTaskEntity.getName()); + switch (operAccessTaskEntity.getStatus()) { + case AccessConstants.ACCESS_TASK_STATUS_0: + accessReportVO.setCompleteSituation("未开始"); + break; + case AccessConstants.ACCESS_TASK_STATUS_1: + accessReportVO.setCompleteSituation("进行中"); + break; + case AccessConstants.ACCESS_TASK_STATUS_2: + accessReportVO.setCompleteSituation("待审核"); + break; + case AccessConstants.ACCESS_TASK_STATUS_3: + accessReportVO.setCompleteSituation("审核未通过"); + break; + case AccessConstants.ACCESS_TASK_STATUS_4: + accessReportVO.setCompleteSituation("已完成"); + break; + case AccessConstants.ACCESS_TASK_STATUS_5: + accessReportVO.setCompleteSituation("未完成"); + break; + default: + accessReportVO.setCompleteSituation("未开始"); + break; + } + res.add(accessReportVO); + } + } + return res; + } + + @Override public List> getAccessConclusion(Map params) { return mapper.getAccessConclusion(params); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java index 98c5c30..4456413 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java @@ -7,6 +7,7 @@ import com.hnac.hzims.operational.defect.entity.OperDefectEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.vo.OperDefectVO; import com.hnac.hzims.operational.report.vo.DefectReportsVO; +import com.hnac.hzims.operational.report.vo.DefectRunReportsVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -69,6 +70,8 @@ public interface IOperDefectService extends BaseService { List getFaultByFaultCode(Map params); + List getDefectByName(Map params); + List> getDefectConclusion(Map params); /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java index cdcd04c..797e6e6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java @@ -21,8 +21,11 @@ import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.defect.vo.OperDefectVO; import com.hnac.hzims.operational.defect.wrapper.OperDefectWrapper; +import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; import com.hnac.hzims.operational.report.vo.DefectReportsVO; +import com.hnac.hzims.operational.report.vo.DefectRunReportsVO; import com.hnac.hzims.safeproduct.Constants; +import com.hnac.hzims.spare.entity.WtSpManagementEntity; import com.hnac.hzims.vo.SafeCheckStatisticVO; import lombok.AllArgsConstructor; import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils; @@ -354,6 +357,40 @@ public class OperDefectServiceImpl extends BaseServiceImpl getDefectByName(Map params) { + LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + List deptIdList = (List) params.get("deptId"); + List res=new ArrayList<>(); + + List operPhenomenonEntities = operPhenomenonMapper.selectList( + Wrappers.query().lambda() + .ge(OperPhenomenonEntity::getCreateTime, startDate) + .le(OperPhenomenonEntity::getCreateTime, endDate) + .in(OperPhenomenonEntity::getCreateDept, deptIdList) + .eq(OperPhenomenonEntity::getIsDeleted, 0) + .eq(OperPhenomenonEntity::getIsDefect, 1)); + if (CollectionUtil.isNotEmpty(operPhenomenonEntities)){ + for (int i = 0; i < operPhenomenonEntities.size(); i++) { + DefectRunReportsVO reportsVO=new DefectRunReportsVO(); + OperPhenomenonEntity operPhenomenonEntity = operPhenomenonEntities.get(i); + reportsVO.setIndex(i+1); + reportsVO.setFinder(operPhenomenonEntity.getFinderName()); + reportsVO.setFinderTime(DateUtil.formatDateTime(operPhenomenonEntity.getFindTime())); + reportsVO.setDescription(operPhenomenonEntity.getDescripiton()); + if ("1".equals(operPhenomenonEntity.getHandleStatus())) { + reportsVO.setHandleTime(DateUtil.formatDateTime(operPhenomenonEntity.getActStartTime())); + reportsVO.setHandleSituation(operPhenomenonEntity.getDisposeDesc()); + }else { + reportsVO.setHandleSituation("未处理"); + } + res.add(reportsVO); + } + } + return res; + } + + @Override public List> getDefectConclusion(Map params) { return operDefectMapper.getDefectConclusion(params); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java index 09b8598..014bede 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java @@ -6,6 +6,7 @@ import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; import com.hnac.hzims.operational.duty.vo.*; import com.hnac.hzims.operational.main.vo.DutyPersonalReportVO; import com.hnac.hzims.operational.report.vo.DutyReportVO; +import com.hnac.hzims.operational.report.vo.DutyRunReportVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -80,8 +81,8 @@ public interface IImsDutyMainService extends BaseService { */ List getDutyMainStatisticsByClassId(LocalDate startDate, LocalDate endDate, List deptIdList); - List getDutyMainStatisticsByClassId(Map params); - +// List getDutyMainStatisticsByClassId(Map params); + List getDutyMainRunReport(Map params); List> getDutyConclusion(Map params); DutyPersonalReportVO getPersonalDutyMain(Map params); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index fafd0e9..cdf8795 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -19,6 +19,7 @@ import com.hnac.hzims.operational.duty.service.*; import com.hnac.hzims.operational.duty.vo.*; import com.hnac.hzims.operational.main.vo.DutyPersonalReportVO; import com.hnac.hzims.operational.report.vo.DutyReportVO; +import com.hnac.hzims.operational.report.vo.DutyRunReportVO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springblade.core.log.exception.ServiceException; @@ -44,6 +45,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; @@ -1022,13 +1024,144 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getDutyMainStatisticsByClassId(Map params) { - LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - List deptId = (List) params.get("deptId"); - return getDutyMainStatisticsByClassId(startDate, endDate, deptId); - } + + private void getDutyRunReportByPerson(LocalDate startDate, LocalDate endDate, List deptIdList, List imsDutyMainEntityList, List dutyReportVOList,AtomicInteger index) { + //无班组的值班数据: + List personDutyMainEntity = imsDutyMainEntityList.stream().filter(o -> ObjectUtil.isEmpty(o.getDutyGroupId())).collect(Collectors.toList()); + //获取班组名 + if (ObjectUtil.isNotEmpty(personDutyMainEntity)) { + DutyRunReportVO dutyReportVO = new DutyRunReportVO(); + dutyReportVO.setGroupName("灵活排班"); + dutyReportVO.setIndex(index.get()); + dutyReportVO.setDutyNum(personDutyMainEntity.size()); + //获取值班ID + List dutyIdList = personDutyMainEntity.stream().map(ImsDutyMainEntity::getId).collect(Collectors.toList()); + dutyReportVO.setDutyList(dutyIdList.stream().map(s->String.valueOf(s)).collect(Collectors.toList())); + //发现问题数量 + List operPhenomenonEntityList = operPhenomenonMapper.selectList(new LambdaQueryWrapper() {{ + ge(OperPhenomenonEntity::getCreateTime, startDate); + le(OperPhenomenonEntity::getCreateTime, endDate); + in(OperPhenomenonEntity::getCreateDept, deptIdList); + eq(OperPhenomenonEntity::getSourceCode, DefectConstant.DefectSourceEnum.ZB.getStatus()); + eq(OperPhenomenonEntity::getIsDeleted, 0); + }}); + dutyReportVO.setFindProblemNum(operPhenomenonEntityList.size()); + + //获取交接班异常记录 + List imsDutyRecEntityList = imsDutyRecMapper.selectList(new LambdaQueryWrapper() {{ + in(ImsDutyRecEntity::getDutyId, dutyIdList); + }}); + //延迟交接班 + List delayList = imsDutyRecEntityList.stream().filter(rec -> rec.getDelayStatus() == 1).collect(Collectors.toList()); + //异常交接班 + List exceptionList = imsDutyRecEntityList.stream().filter(rec -> DutyRecStatus.ANOMALY.getVal().equals(rec.getStatus())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(delayList)) { + dutyReportVO.setDelayChangeShifts(delayList.size()); + List delayIdsList = delayList.stream().map(ImsDutyRecEntity::getDutyId).map(s -> String.valueOf(s)).collect(Collectors.toList()); + dutyReportVO.setDelayChangeList(delayIdsList); + } + if (CollectionUtil.isNotEmpty(exceptionList)) { + dutyReportVO.setExceptionChangeShifts(exceptionList.size()); + List exceptionIdsList = exceptionList.stream().map(ImsDutyRecEntity::getDutyId).map(s -> String.valueOf(s)).collect(Collectors.toList()); + dutyReportVO.setExceptionChangeList(exceptionIdsList); + } + dutyReportVOList.add(dutyReportVO); + } + } + + private void getDutyRunReportByGroup(LocalDate startDate, LocalDate endDate, List deptIdList, List imsDutyMainEntityList, List dutyReportVOList,AtomicInteger index) { + + //按班组组合值班记录 + Map> listByGroup = imsDutyMainEntityList.stream().filter(o -> ObjectUtil.isNotEmpty(o.getDutyGroupId())).collect(Collectors.groupingBy(ImsDutyMainEntity::getDutyGroupId)); + listByGroup.forEach((k, v) -> { + //获取班组名 + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(k); + if (ObjectUtil.isNotEmpty(imsDutyGroupEntity)) { + DutyRunReportVO dutyReportVO = new DutyRunReportVO(); + dutyReportVO.setIndex(index.get()); + index.getAndIncrement(); + dutyReportVO.setGroupName(imsDutyGroupEntity.getGroupName()); + User user = UserCache.getUser(imsDutyGroupEntity.getManagerId()); + if (ObjectUtil.isNotEmpty(user)){ + dutyReportVO.setManagerName(user.getName()); + } + dutyReportVO.setDutyNum(v.size()); + //获取值班ID + List dutyIdList = v.stream().map(ImsDutyMainEntity::getId).collect(Collectors.toList()); + dutyReportVO.setDutyList(dutyIdList.stream().map(s->String.valueOf(s)).collect(Collectors.toList())); + //发现问题数量 + List imsDutyGroupPEntities = imsDutyGroupPMapper.selectByGroupId(k); + List person = imsDutyGroupPEntities.stream().map(s -> s.getPersonId()).collect(Collectors.toList()); + List operPhenomenonEntityList = operPhenomenonMapper.selectList(new LambdaQueryWrapper() {{ + ge(OperPhenomenonEntity::getCreateTime, startDate); + le(OperPhenomenonEntity::getCreateTime, endDate); + in(OperPhenomenonEntity::getCreateDept, deptIdList); + in(OperPhenomenonEntity::getFinder,person); + eq(OperPhenomenonEntity::getSourceCode, DefectConstant.DefectSourceEnum.ZB.getStatus()); + eq(OperPhenomenonEntity::getIsDeleted, 0); + }}); + dutyReportVO.setFindProblemNum(operPhenomenonEntityList.size()); + + //获取交接班异常记录 + List imsDutyRecEntityList = imsDutyRecMapper.selectList(new LambdaQueryWrapper() {{ + in(ImsDutyRecEntity::getDutyId, dutyIdList); + }}); + //延迟交接班 + List delayList = imsDutyRecEntityList.stream().filter(rec -> rec.getDelayStatus() == 1).collect(Collectors.toList()); + //异常交接班 + List exceptionList = imsDutyRecEntityList.stream().filter(rec -> DutyRecStatus.ANOMALY.getVal().equals(rec.getStatus())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(delayList)) { + dutyReportVO.setDelayChangeShifts(delayList.size()); + List delayIdsList = delayList.stream().map(ImsDutyRecEntity::getDutyId).map(s -> String.valueOf(s)).collect(Collectors.toList()); + dutyReportVO.setDelayChangeList(delayIdsList); + } + if (CollectionUtil.isNotEmpty(exceptionList)) { + dutyReportVO.setExceptionChangeShifts(exceptionList.size()); + List exceptionIdsList = exceptionList.stream().map(ImsDutyRecEntity::getDutyId).map(s -> String.valueOf(s)).collect(Collectors.toList()); + dutyReportVO.setExceptionChangeList(exceptionIdsList); + } + dutyReportVOList.add(dutyReportVO); + } + }); + } + + @Override + public List getDutyMainRunReport(Map params) { + LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + List deptIdList = (List) params.get("deptId"); + List dutyReportVOList = new ArrayList<>(); + //获取当月值班记录 + List imsDutyMainEntityList = this.baseMapper.selectList(new LambdaQueryWrapper() {{ + ge(ImsDutyMainEntity::getDutyDate, startDate); + le(ImsDutyMainEntity::getDutyDate, endDate); + in(ImsDutyMainEntity::getCreateDept, deptIdList); + ne(ImsDutyMainEntity::getStatus, -1); + eq(ImsDutyMainEntity::getIsDeleted, 0); + }}); + AtomicInteger index= new AtomicInteger(1); + if(CollectionUtil.isNotEmpty(imsDutyMainEntityList)) { + //带班组的值班数据 + this.getDutyRunReportByGroup(startDate, endDate, deptIdList, imsDutyMainEntityList, dutyReportVOList,index); + //灵活排班的值班数据 + this.getDutyRunReportByPerson(startDate, endDate, deptIdList, imsDutyMainEntityList, dutyReportVOList,index); + } + DutyRunReportVO dutyReportVO = new DutyRunReportVO(); + dutyReportVO.setGroupName("合计"); + if (CollectionUtil.isNotEmpty(dutyReportVOList)){ + dutyReportVO.setDutyNum(dutyReportVOList.stream().mapToInt(DutyRunReportVO::getDutyNum).sum()); + dutyReportVO.setFindProblemNum(dutyReportVOList.stream().mapToInt(DutyRunReportVO::getFindProblemNum).sum()); + dutyReportVO.setDelayChangeShifts(dutyReportVOList.stream().mapToInt(DutyRunReportVO::getDelayChangeShifts).sum()); + dutyReportVO.setExceptionChangeShifts(dutyReportVOList.stream().mapToInt(DutyRunReportVO::getExceptionChangeShifts).sum()); + }else { + dutyReportVO.setDutyNum(0); + dutyReportVO.setFindProblemNum(0); + dutyReportVO.setDelayChangeShifts(0); + dutyReportVO.setExceptionChangeShifts(0); + } + + return dutyReportVOList; + } @Override public List> getDutyConclusion(Map params) { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IMainSystemMonitoringService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IMainSystemMonitoringService.java index 7fbfffb..3dfbb39 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IMainSystemMonitoringService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IMainSystemMonitoringService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.main.service; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.report.vo.StationReportVO; +import com.hnac.hzims.operational.report.vo.StationRunReportVO; import com.hnac.hzims.operational.station.entity.StationEntity; import org.springblade.core.tool.api.R; import org.springblade.system.entity.Dept; @@ -66,7 +67,8 @@ public interface IMainSystemMonitoringService { List getElectricSituation(String month, String stationId); - + List getElectricSituationV2(String yearAndMonth, String code); + void getElectricSituationByRedis(String month, List reportVOS, List stationEntityList); InDustryVo getUserDataScopeHomePage(String businessType,String stationType,String deptIds,String refTerminal); List classifyUserDataScopeType(String deptIds, String stationType,List types,boolean bool); @@ -87,4 +89,5 @@ public interface IMainSystemMonitoringService { List getEmInfoList(); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java index bff519a..c176274 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java @@ -24,8 +24,10 @@ import com.hnac.hzims.operational.main.service.IMainWorkBenchService; import com.hnac.hzims.operational.main.service.IUnitRunningTimeService; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.report.vo.StationReportVO; +import com.hnac.hzims.operational.report.vo.StationRunReportVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.operational.util.TimeUtils; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; @@ -50,6 +52,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDate; @@ -1340,7 +1343,167 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer } } + private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; + /** + * 获取部门站点发电量情况 + * @param month 2024-01 月份 + */ + @Override + public void getElectricSituationByRedis(String month,List reportVOS, List stationEntityList) { + String[] yearMon = month.split("-"); + Integer year = Integer.valueOf(yearMon[0]); + Integer mon = Integer.valueOf(yearMon[1]); + List listByYear = TimeUtils.getListByYearMon(year, mon); + String currentMon = TimeUtils.getMon(year, mon); + Integer count=0; + Map> powerMapThree = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + for (Map.Entry> deviceMap : powerMapThree.entrySet()) { + for (StationEntity stationEntity : stationEntityList) { + if (stationEntity.getId().equals(deviceMap.getKey())) { + StationRunReportVO stationReportVO = new StationRunReportVO(); + count++; + stationReportVO.setIndex(count); + stationReportVO.setStationName(stationEntity.getName()); + //当前机构近三年的数据 + Map value = deviceMap.getValue(); + //当月发电量 + BigDecimal powerMon = value.entrySet().stream().filter(s -> currentMon.equals(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1,BigDecimal.ROUND_UP)).reduce(BigDecimal.ZERO, BigDecimal::add); + stationReportVO.setFinishPowerMon(powerMon.toString()); + //获取计划月发电量 + R planPowerMonR = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month); + double planPowerMon =0; + if (planPowerMonR.isSuccess()&&ObjectUtil.isNotEmpty(planPowerMonR.getData())) { + planPowerMon = planPowerMonR.getData().doubleValue(); + } + stationReportVO.setPowerMonPlan(planPowerMon); + //当年发电量 + BigDecimal powerYear = value.entrySet().stream().filter(s -> listByYear.contains(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1,BigDecimal.ROUND_UP)).reduce(BigDecimal.ZERO, BigDecimal::add); + stationReportVO.setFinishPowerYear(powerYear.toString()); + //获取计划年发电量 + Double planPowerYear = planGenertionClient.getPlanPowerYear(Arrays.asList(stationEntity.getId().toString()), yearMon[0]); + stationReportVO.setPowerYearPlan(planPowerYear); + if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) + &&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) + &&new BigDecimal(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ + BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) + .divide(new BigDecimal(stationReportVO.getPowerMonPlan()), 2, BigDecimal.ROUND_UP); + stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); + }else { + stationReportVO.setPowerMonRate(new Double(0)+"%"); + } + if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) + &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) + &&new BigDecimal(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ + BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) + .divide(new BigDecimal(stationReportVO.getPowerYearPlan()), 2, BigDecimal.ROUND_UP); + stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); + }else { + stationReportVO.setPowerYearRate(new Double(0)+"%"); + } + reportVOS.add(stationReportVO); + } + } + } + } + @Override + public List getElectricSituationV2(String month, String stationId) { + String year = month.split("-")[0]; + List stationReportVOList = new ArrayList<>(); + DateTimeFormatter df = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); + StationRunReportVO stationReportVO = new StationRunReportVO(); + //获取对应的发电量 + StationEntity stationEntity = stationService.getStationByCode(stationId); + stationReportVO.setStationName(stationEntity.getName()); + AtomicReference powerCount = new AtomicReference<>((float) 0L); + AtomicReference powerCountYear = new AtomicReference<>((float) 0L); + //获取站点所属部门下的设备列表 + List emCodes = emInfoClient.getEmCodeByDeptIdAndHomePage(stationEntity.getRefDept()).getData(); + if (CollectionUtil.isNotEmpty(emCodes)) { + List emCodeList = analyseInstanceClient.getListAnalyseCode(emCodes).getData(); + if (CollectionUtil.isNotEmpty(emCodeList)) { + List data = emInfoClient.getEmInfoByEmCodes(emCodeList).getData(); + for (EmInfoEntity emInfoEntity : data) { + int ct = 0; + int pt = 0; + R EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct"); + if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData()) + && StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { + ct = Integer.valueOf(EmParamEntityCT.getData().getParamValue()); + } + R EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt"); + if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData()) + && StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { + pt = Integer.valueOf(EmParamEntityPT.getData().getParamValue()); + } + //TODO + int rideCount = ct * pt; + MainVo vo = new MainVo(); + MainVo yearVo = new MainVo(); + R paramByEmId = emParamClient.getParamByEmId(emInfoEntity.getId(), EquipmentConstants.MainEnum.INSTALLED_CAPACITY.getVal()); + if (paramByEmId.isSuccess()) { + if (ObjectUtil.isNotEmpty(paramByEmId.getData())) { + vo.setInstalledCapacity(paramByEmId.getData().getParamValue()); + } + } + //循环所有机组 + //根据设备编号 标识 获取 发电量、有功功率数据 + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + po.setDeviceCode(emInfoEntity.getNumber()); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1);//填充 null + analyzeDataConditionPO.setSignages(GENERATE_SIGNAGE); + analyzeDataConditionPO.setAccessRules(EquipmentConstants.AccessRulesEnum.DIFF_CYCLE.getType());//取数规则 0=(整点值/最早值)、1=最大值、2=最小值、3=平均值、4=(累计值/和值)、5=(变化值/差值) 6=最新值 + analyzeDataConditionPO.setTimeInterval(1);//间隔 + //月发电量 + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(month + "-01 00:00:00", df)); + DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; + LocalDate localDateMonth = LocalDate.parse(month + "-01"); + String endDateTime = fmt.format(localDateMonth.with(TemporalAdjusters.lastDayOfMonth())) + " 23:59:59"; + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(endDateTime, df)); + setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), true); + //年发电量 + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(year + "-01-01 00:00:00", df)); + setValueGenerateCount(analyzeDataConditionPO, signboardConditions, po, rideCount, vo, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), true); + powerCount.updateAndGet(v -> new Float(v + vo.getMonthGenerateCount())); + powerCountYear.updateAndGet(v -> new Float(v + yearVo.getYearGenerateCount())); + log.info("------------月发电量:[{}]--------", vo.getMonthGenerateCount()); + } + } + } + Double finishPowerMon = new BigDecimal(powerCount.get()).doubleValue(); + stationReportVO.setFinishPowerMon(finishPowerMon.toString()); + Double finishPowerYear = new BigDecimal(powerCountYear.get()).doubleValue(); + stationReportVO.setFinishPowerYear(finishPowerYear.toString()); + //当年的计划发电量 + Double planPowerYear = planGenertionClient.getPlanPowerYear(Arrays.asList(stationId), year); + stationReportVO.setPowerYearPlan(planPowerYear); + //当月的计划发电量 + R planPowerMonR = planGenertionClient.planGenerationMonthCount(stationId, month); + Double planPowerMon = planPowerMonR.getData().doubleValue(); + stationReportVO.setPowerMonPlan(planPowerMon); + if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) + &&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) + &&new BigDecimal(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ + BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) + .divide(new BigDecimal(stationReportVO.getPowerMonPlan()), 2, BigDecimal.ROUND_UP); + stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); + }else { + stationReportVO.setPowerMonRate(new Double(0)+"%"); + } + if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) + &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) + &&new BigDecimal(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ + BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) + .divide(new BigDecimal(stationReportVO.getPowerYearPlan()), 2, BigDecimal.ROUND_UP); + stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); + }else { + stationReportVO.setPowerYearRate(new Double(0)+"%"); + } + stationReportVOList.add(stationReportVO); + return stationReportVOList; + } /** * 获取部门站点发电量情况 * @@ -1380,12 +1543,12 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer int pt = 0; R EmParamEntityCT = emParamClient.getParamByEmId(emInfoEntity.getId(), "ct"); if (EmParamEntityCT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityCT.getData()) - && StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { + && StringUtil.isNotBlank(EmParamEntityCT.getData().getParamValue())) { ct = Integer.valueOf(EmParamEntityCT.getData().getParamValue()); } R EmParamEntityPT = emParamClient.getParamByEmId(emInfoEntity.getId(), "pt"); if (EmParamEntityPT.isSuccess() && ObjectUtil.isNotEmpty(EmParamEntityPT.getData()) - && StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { + && StringUtil.isNotBlank(EmParamEntityPT.getData().getParamValue())) { pt = Integer.valueOf(EmParamEntityPT.getData().getParamValue()); } //TODO diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java index 145bcb4..bce1e00 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java @@ -8,6 +8,7 @@ import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; +import com.hnac.hzims.operational.report.vo.RunReportVO; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; import com.hnac.hzims.vo.SafeCheckStatisticVO; @@ -48,6 +49,7 @@ public interface IOperMaintenanceTaskService extends BaseService getMaintenanceStatisticsByDisposer(LocalDate startDate,LocalDate endDate,List deptIdList); List getMaintenanceStatisticsByDisposer(Map params); + List getMaintenanceStatisticsByName(Map params); List> getMaintenanceConclusion(Map params); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index 0db6aa0..7f17469 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -24,6 +24,7 @@ import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenanceTaskWrapper; import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; +import com.hnac.hzims.operational.report.vo.RunReportVO; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; @@ -61,6 +62,7 @@ import java.text.DecimalFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -245,6 +247,75 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl getMaintenanceStatisticsByName(Map params) { + LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + List deptIdList = (List) params.get("deptId"); + List maintenanceReportVOList = new ArrayList<>(); + //查询当月日常维护任务 + List operMaintenanceTaskEntityList = this.baseMapper.selectList(new LambdaQueryWrapper() {{ + ge(OperMaintenanceTaskEntity::getDisposeTime, startDate); + le(OperMaintenanceTaskEntity::getDisposeTime, endDate); + in(OperMaintenanceTaskEntity::getCreateDept, deptIdList); + eq(OperMaintenanceTaskEntity::getIsDeleted, 0); + }}); + AtomicInteger index= new AtomicInteger(1); + //按执行人分组 + if (CollectionUtil.isNotEmpty(operMaintenanceTaskEntityList)) { + Map> map = operMaintenanceTaskEntityList.stream().filter(o -> StringUtils.isNotBlank(o.getDisposer())).collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getDisposer)); + map.forEach((k, v) -> { + RunReportVO maintenanceReportVO = new RunReportVO(); + maintenanceReportVO.setIndex(index.get()); + //获取执行人名字 + List userIdList = Arrays.asList(k.split(",")).stream().map(o -> Long.parseLong(o)).collect(Collectors.toList()); + String userName = userIdList.stream().map(userId -> { + User user = UserCache.getUser(userId); + return Optional.ofNullable(user).map(User::getName).orElse(""); + }).collect(Collectors.joining(",")); + maintenanceReportVO.setUserName(userName); + this.fillRunReport(v, maintenanceReportVO); + maintenanceReportVOList.add(maintenanceReportVO); + index.getAndIncrement(); + }); + //合计 + List maintenanceTaskEntityList = operMaintenanceTaskEntityList.stream().filter(o -> StringUtils.isNotBlank(o.getDisposer())).collect(Collectors.toList()); + RunReportVO maintenanceReportVO = new RunReportVO(); + maintenanceReportVO.setUserName("合计"); + this.fillRunReport(maintenanceTaskEntityList, maintenanceReportVO); + maintenanceReportVOList.add(maintenanceReportVO); + } + return maintenanceReportVOList; + } + + private static void fillRunReport(List v, RunReportVO maintenanceReportVO) { + //已完成任务 + List finishTask = v.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); + Map> finishTaskGroupByType = finishTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); + AtomicReference finishSituation = new AtomicReference<>(""); + finishTaskGroupByType.forEach((TypeCode, TypeList) -> { + try { + finishSituation.set(finishSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); + } catch (NullPointerException e) { + e.printStackTrace(); + } + }); + maintenanceReportVO.setCompleteNum(finishTask.size()); + maintenanceReportVO.setCompleteList(finishTask.stream().map(s->String.valueOf(s.getId())).collect(Collectors.toList())); + //未完成任务 + List immatureTask = v.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 != o.getStatus()).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(immatureTask)){ + Map> immatureTaskTaskGroupByType = immatureTask.stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getTypeCode)); +// AtomicReference immatureTaskSituation = new AtomicReference<>(""); + immatureTaskTaskGroupByType.forEach((TypeCode, TypeList) -> { + finishSituation.set(finishSituation.get().concat(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, TypeCode)).concat(":").concat(TypeList.size() + "").concat("\r\n")); + }); + maintenanceReportVO.setIncompleteNum(immatureTask.size()); + maintenanceReportVO.setIncompleteList(immatureTask.stream().map(s->String.valueOf(s.getId())).collect(Collectors.toList())); + maintenanceReportVO.setRemark(finishSituation.get()); + } + } + + @Override public List> getMaintenanceConclusion(Map params) { return operMaintenanceTaskMapper.getMaintenanceConclusion(params); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java index f31fb52..a9f3e2a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java @@ -13,6 +13,7 @@ import com.hnac.hzims.operational.report.schedule.OperStationCreateMonthReport; import com.hnac.hzims.operational.report.service.IMonthReportService; import com.hnac.hzims.operational.report.service.IOperPersonalMonthReportService; import com.hnac.hzims.operational.report.service.IOperStationMonthReportService; +import com.hnac.hzims.operational.report.vo.StationRunReportAllVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import jdk.nashorn.internal.objects.annotations.Getter; @@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.time.LocalDate; @@ -66,38 +68,44 @@ public class MonthReportController { @OperationAnnotation(moduleName = "生产月报", title = "统计月报(对内 对外)",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, action = "根据站点编码获取站点月报") - public R getStationMonthReportByStationCode(@RequestParam("deptId") Long deptId,@RequestParam("month") String month) throws Exception { + public R getStationMonthReportByStationCode(@RequestParam("deptId") Long deptId,@RequestParam("month") String month) throws Exception { // LocalDate startDate = DateUtil.getFirstDayByYearMonth(month); // LocalDate endDate = DateUtil.getLastDayByYearMonth(month); // return R.data(taskMonthService.getStationMonthReport(startDate,endDate,deptId.toString())); - StationReportAllVO stationReportAllVO = monthReportService.getStationMonthReportByStationCode(deptId,month); + StationRunReportAllVO stationReportAllVO = monthReportService.getStationMonthReportByStationCode(deptId,month); return R.data(stationReportAllVO); } - - @ApiLog - @GetMapping("/getPersonalMonthReport") - @ApiOperation(value = "获取当前登录人个人月报",notes = "获取当前登录人个人月报") - @ApiOperationSupport(order = 2) - @OperationAnnotation(moduleName = "生产月报",title = "统计月报-个人",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, - action = "获取当前登录人个人月报") - public R getPersonalMonthReport(@RequestParam("month") String month) throws Exception { - PersonalMonthReportVO personalMonthReportVO = monthReportService.getPersonalMonthReport(month); - return R.data(personalMonthReportVO); - } +// +// @ApiLog +// @GetMapping("/getPersonalMonthReport") +// @ApiOperation(value = "获取当前登录人个人月报",notes = "获取当前登录人个人月报") +// @ApiOperationSupport(order = 2) +// @OperationAnnotation(moduleName = "生产月报",title = "统计月报-个人",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, +// action = "获取当前登录人个人月报") +// public R getPersonalMonthReport(@RequestParam("month") String month) throws Exception { +// PersonalMonthReportVO personalMonthReportVO = monthReportService.getPersonalMonthReport(month); +// return R.data(personalMonthReportVO); +// } @GetMapping("/exportStationMonthReport") @ApiOperation(value = "导出站点月报",notes = "导出站点月报") @ApiOperationSupport(order = 3) - public void exportStationMonthReport(@RequestParam("month") String month,@RequestParam("stationCode") String stationCode,@RequestParam("type") String type) throws UnsupportedEncodingException { - operStationMonthReportService.exportStationMonthReport(month,stationCode,type); - } - - @GetMapping("/exportPersonalMonthReport") - @ApiOperation(value = "导出个人月报",notes = "导出个人月报") - @ApiOperationSupport(order = 4) - public void exportPersonalMonthReport(@RequestParam("month") String month){ - operPersonalMonthReportService.exportPersonalMonthReport(month); + public void exportStationMonthReport(HttpServletResponse response, @RequestParam("deptId") Long deptId, @RequestParam("month") String month) throws Exception { + StationRunReportAllVO stationReportAllVO = monthReportService.getStationMonthReportByStationCode(deptId,month); + operStationMonthReportService.exportStationMonthReport(response, stationReportAllVO,deptId); } +// @GetMapping("/exportStationMonthReport") +// @ApiOperation(value = "导出站点月报",notes = "导出站点月报") +// @ApiOperationSupport(order = 3) +// public void exportStationMonthReport(@RequestParam("month") String month,@RequestParam("stationCode") String stationCode,@RequestParam("type") String type) throws UnsupportedEncodingException { +// operStationMonthReportService.exportStationMonthReport(month,stationCode,type); +// } +// @GetMapping("/exportPersonalMonthReport") +// @ApiOperation(value = "导出个人月报",notes = "导出个人月报") +// @ApiOperationSupport(order = 4) +// public void exportPersonalMonthReport(@RequestParam("month") String month){ +// operPersonalMonthReportService.exportPersonalMonthReport(month); +// } @GetMapping("/getStationMonthReport") @ApiOperation(value = "按机构获取月报测试",notes = "按机构获取月报测试") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/schedule/OperStationCreateMonthReport.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/schedule/OperStationCreateMonthReport.java index 6adea00..f71d305 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/schedule/OperStationCreateMonthReport.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/schedule/OperStationCreateMonthReport.java @@ -9,6 +9,7 @@ import com.hnac.hzims.operational.report.entity.OperMonthReportEntity; import com.hnac.hzims.operational.report.service.IMonthReportService; import com.hnac.hzims.operational.report.service.IOperStationMonthReportService; import com.hnac.hzims.operational.report.utils.ObjectHelper; +import com.hnac.hzims.operational.report.vo.StationRunReportAllVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; import com.xxl.job.core.biz.model.ReturnT; @@ -63,9 +64,7 @@ public class OperStationCreateMonthReport { }}); if(CollectionUtil.isEmpty(operMonthReportEntityList)){ //按站点生成各电站运维月报 - ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); - singleThreadExecutor.execute(() -> { - StationReportAllVO stationReportAllVO = operStationMonthReportService.getStationMonthReport(yearAndMonth, deptVO); + StationRunReportAllVO stationReportAllVO = operStationMonthReportService.getStationMonthReportV2(yearAndMonth, deptVO); if(ObjectUtil.isNotEmpty(stationReportAllVO)){ OperMonthReportEntity operMonthReportEntity = new OperMonthReportEntity(); operMonthReportEntity.setMonth(yearAndMonth); @@ -79,8 +78,6 @@ public class OperStationCreateMonthReport { e.printStackTrace(); } } - }); - singleThreadExecutor.shutdown(); } else{ log.info("该月{}已生成月报",deptVO.getDeptName()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IMonthReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IMonthReportService.java index a1d5928..f9b415f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IMonthReportService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IMonthReportService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.report.service; import com.hnac.hzims.operational.report.vo.PersonalMonthReportVO; import com.hnac.hzims.operational.report.vo.StationReportAllVO; import com.hnac.hzims.operational.report.entity.OperMonthReportEntity; +import com.hnac.hzims.operational.report.vo.StationRunReportAllVO; import org.springblade.core.mp.base.BaseService; public interface IMonthReportService extends BaseService { @@ -13,7 +14,7 @@ public interface IMonthReportService extends BaseService * @return * @throws Exception */ - StationReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception; + StationRunReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception; /** * 查询个人月报 @@ -21,5 +22,5 @@ public interface IMonthReportService extends BaseService * @return * @throws Exception */ - PersonalMonthReportVO getPersonalMonthReport(String month) throws Exception; +// PersonalMonthReportVO getPersonalMonthReport(String month) throws Exception; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java index 21c5501..33f9805 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IOperStationMonthReportService.java @@ -1,8 +1,11 @@ package com.hnac.hzims.operational.report.service; import com.hnac.hzims.operational.report.vo.StationReportAllVO; +import com.hnac.hzims.operational.report.vo.StationRunReportAllVO; import org.springblade.system.vo.DeptVO; +import org.springframework.web.bind.annotation.RequestParam; +import javax.servlet.http.HttpServletResponse; import java.io.UnsupportedEncodingException; public interface IOperStationMonthReportService { @@ -12,11 +15,15 @@ public interface IOperStationMonthReportService { * @return */ StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO); - + /** + * 获取电站月报 + * @param yearAndMonth + * @return + */ + StationRunReportAllVO getStationMonthReportV2(String yearAndMonth, DeptVO deptVO); /** * 导出站点月报 - * @param month - * @param type */ - void exportStationMonthReport(String month,String stationCode,String type); +// void exportStationMonthReport(String month,String stationCode,String type); + void exportStationMonthReport(HttpServletResponse response, StationRunReportAllVO stationReportAllVO,Long deptId) throws Exception; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/MonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/MonthReportServiceImpl.java index e0cc4d5..be01b60 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/MonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/MonthReportServiceImpl.java @@ -9,6 +9,7 @@ import com.hnac.hzims.operational.report.entity.OperMonthReportEntity; import com.hnac.hzims.operational.report.mapper.MonthReportMapper; import com.hnac.hzims.operational.report.service.IMonthReportService; import com.hnac.hzims.operational.report.utils.ObjectHelper; +import com.hnac.hzims.operational.report.vo.StationRunReportAllVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -33,12 +34,12 @@ public class MonthReportServiceImpl extends BaseServiceImpl(){{ - eq(OperMonthReportEntity::getMonth,month); - eq(OperMonthReportEntity::getUserId,user.getUserId()); - }}); - personalMonthReportVO = ObjectUtil.isNotEmpty(operMonthReportEntity) ? (PersonalMonthReportVO) ObjectHelper.byte2obj(operMonthReportEntity.getObject()) : null; - } - return personalMonthReportVO; - } +// @Override +// public PersonalMonthReportVO getPersonalMonthReport(String month) throws Exception { +// PersonalMonthReportVO personalMonthReportVO = new PersonalMonthReportVO(); +// BladeUser user = AuthUtil.getUser(); +// if(month.equals(YearMonth.now().toString())){ +// personalMonthReportVO = operPersonalMonthReportService.getPersonalMonthReport(month,user.getUserId()); +// } +// else{ +// OperMonthReportEntity operMonthReportEntity = this.getOne(new LambdaQueryWrapper(){{ +// eq(OperMonthReportEntity::getMonth,month); +// eq(OperMonthReportEntity::getUserId,user.getUserId()); +// }}); +// personalMonthReportVO = ObjectUtil.isNotEmpty(operMonthReportEntity) ? (PersonalMonthReportVO) ObjectHelper.byte2obj(operMonthReportEntity.getObject()) : null; +// } +// return personalMonthReportVO; +// } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java index a2ff283..9486a83 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.report.service.impl; +import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -22,23 +23,33 @@ import com.hnac.hzims.operational.report.vo.*; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.util.ExcelUtil; +import com.hnac.hzims.operational.util.WordUtils; import com.hnac.hzims.ticket.allTicket.dto.TicketStatisticDTO; import com.hnac.hzims.ticket.allTicket.fegin.ITicketInfoAllClient; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; import com.hnac.hzinfo.inspect.ai.feign.IInspectRobotTaskClient; +import com.hnac.hzinfo.inspect.report.feign.IInspectReportClient; import com.hnac.hzinfo.inspect.task.feign.IInspectTaskReportClient; import com.hnac.hzinfo.inspect.task.vo.TaskReportVO; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; +import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO; +import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.*; +import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springblade.system.vo.DeptVO; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -47,12 +58,14 @@ import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.RoundingMode; +import java.net.URLEncoder; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -63,385 +76,735 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.IntStream; +import static com.hnac.hzims.operational.main.constant.MainConstants.PROJECT_MANAGER; +import static org.springblade.core.tool.utils.DateUtil.DATETIME_FORMATTER; + @Service @Slf4j @RequiredArgsConstructor public class OperStationMonthReportServiceImpl implements IOperStationMonthReportService { - private final IImsDutyMainService iImsDutyMainService; - private final IOperMaintenanceTaskService operMaintenanceTaskService; - private final IOperDefectService operDefectService; - private final IOperAccessTaskService operAccessTaskService; - private final IMainSystemMonitoringService mainSystemMonitoringService; - private final IStationService stationService; - private final IOperPhenomenonService operPhenomenonService; - private final IInspectRobotTaskClient inspectRobotTaskClient; - private final IFdpDiagnoseClient diagnoseClient; - private final ISysClient sysClient; - private final IInspectTaskReportClient taskReportClient; - private final ITicketInfoAllClient ticketInfoAllClient; - private final BladeLogger logger; - - /**统计月报线程数量**/ - private static final int POOL_QUANTITY = 8; - /**通过线程池异步获取月报各模块内容 主要分为八块内容**/ - private static ExecutorService pool = Executors.newFixedThreadPool(POOL_QUANTITY); - - /**统计月报-电站-对内**/ - private static final String STATION_REPORT_INSIDE = "2"; - /**统计月报-电站-对外**/ - private static final String STATION_REPORT_OUTSIDE = "1"; - - @Override - public StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO) { - StationReportAllVO stationReportAllVo = new StationReportAllVO(); - stationReportAllVo.setStationName(deptVO.getDeptName()); - stationReportAllVo.setYearMonth(YearMonth.parse(yearAndMonth).format(DateTimeFormatter.ofPattern("yyyy年MM月"))); - //处理请求参数 - Map params = new HashMap<>(); - //使用预定义实例来转换 - DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; - LocalDate startDate = DateUtil.getFirstDayByYearMonth(yearAndMonth); - LocalDate endDate = DateUtil.getLastDayByYearMonth(yearAndMonth); - params.put("startDate", fmt.format(startDate)); - params.put("endDate", fmt.format(endDate)); - - List deptIdList = new ArrayList<>(); - deptIdList.add(deptVO.getId()); - //获取下属机构 - R> childDeptListR = sysClient.getDeptChild(deptVO.getId()); - if (childDeptListR.isSuccess() && CollectionUtil.isNotEmpty(childDeptListR.getData())) { - deptIdList.addAll(childDeptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); - } - params.put("deptId", deptIdList); - - //获取机构及子机构下的站点 - List stationEntityList = stationService.list(new LambdaQueryWrapper() {{ - in(StationEntity::getRefDept, deptIdList); - }}); - - //监控线程执行完后返回结果 - CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); - - //电站发电情况 - pool.execute(() -> { - try { - List powerList = new ArrayList<>(); - stationEntityList.forEach(stationEntity -> { - List stationReportVOList = mainSystemMonitoringService.getElectricSituation(yearAndMonth, stationEntity.getCode()); - powerList.addAll(stationReportVOList); - }); - stationReportAllVo.setStationReportVOList(powerList); - } - finally { - countDownLatch.countDown(); - } - }); - //值班情况 - pool.execute(() -> { - try { - List dutyReportVOList = iImsDutyMainService.getDutyMainStatisticsByClassId(params); - stationReportAllVo.setDutyReportVOList(dutyReportVOList); - } - finally { - countDownLatch.countDown(); - } - }); - //日常维护 - pool.execute(() -> { - try { - List maintenanceList = operMaintenanceTaskService.getMaintenanceStatisticsByDisposer(params); - stationReportAllVo.setMaintenanceReportVOList(maintenanceList); - } - finally { - countDownLatch.countDown(); - } - }); - //检修 - pool.execute(() -> { - try { - List accessList = operAccessTaskService.getAccessTaskByDisposer(params); - stationReportAllVo.setAccessReportVOList(accessList); - } - finally { - countDownLatch.countDown(); - } - }); - //缺陷 - pool.execute(() -> { - try { - List defectList = operDefectService.getFaultByFaultCode(params); - stationReportAllVo.setDefectReportsVOList(defectList); - } - finally { - countDownLatch.countDown(); - } - }); - //两票统计 - pool.execute(() -> { - try { - String deptIds = deptIdList.stream().map(deptId -> deptId.toString()).collect(Collectors.joining(",")); - TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO(); - ticketStatisticDTO.setStartDate(fmt.format(startDate)); - ticketStatisticDTO.setEndDate(fmt.format(endDate)); - ticketStatisticDTO.setDeptIds(deptIds); - List ticketVOS = ticketInfoAllClient.getTicketReportStatistic(ticketStatisticDTO); - stationReportAllVo.setTicketInfoStatisticVOList(ticketVOS); - } - finally { - countDownLatch.countDown(); - } - }); - //巡检 - pool.execute(() -> { - try { - List taskReportVOS = taskReportClient.getInspectTaskReport(params); - this.fillInspectProblem(startDate,endDate,deptIdList,taskReportVOS); - stationReportAllVo.setInspectReportVOList(taskReportVOS); - } - finally { - countDownLatch.countDown(); - } - }); - //智能诊断 - pool.execute(() -> { - if (CollectionUtil.isNotEmpty(stationEntityList)) { - StatisticStatusDTO statisticStatusDTO = new StatisticStatusDTO(); - List stationIds = stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()); - String[] stationIdArray = new String[stationIds.size()]; - stationIds.toArray(stationIdArray); - statisticStatusDTO.setStationIds(stationIdArray); - statisticStatusDTO.setThreshold(0.3f); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - statisticStatusDTO.setStart(formatter.format(LocalDateTime.of(startDate, LocalTime.MIN))); - statisticStatusDTO.setEnd(formatter.format(LocalDateTime.of(endDate, LocalTime.MAX))); - R>> diagnoseResult = diagnoseClient.getStatisticStatus(statisticStatusDTO); - List diagnoseConclusionList = new ArrayList<>(); - if (diagnoseResult.isSuccess()) { - Map> statisticStatusVOList = diagnoseResult.getData(); - statisticStatusVOList.forEach((k, v) -> { - if (v.size() > 5) { - v = v.subList(0, 5); - } - String diagnoseConclusion = v.stream().map(s -> { - String riskLevel = ""; - if (s.getSeverity() >= 3) { - riskLevel = "高风险"; - } else if (s.getSeverity() == 2) { - riskLevel = "一般"; - } else if (s.getSeverity() == 1) { - riskLevel = "低风险"; - } - String c = "发生在" + s.getOrd() + "的" + s.getName() + ",风险等级:" + riskLevel + ",最后一次出现的时间:" + s.getLastBeginTime() + ";";//,持续时长:"+s.getLongTime()+" - return c; - }).collect(Collectors.joining("\n")); - if (StringUtil.isNotBlank(diagnoseConclusion)) { - StationEntity stationEntity = stationService.getById(k); - if (ObjectUtil.isNotEmpty(stationEntity)) { - diagnoseConclusion = stationEntity.getName() + "本月智能诊断服务预警前五位的可能存在风险的故障信息:\n" + diagnoseConclusion; - diagnoseConclusionList.add(diagnoseConclusion); - } - } - }); - stationReportAllVo.setDiagnoseConclusion(diagnoseConclusionList.stream().collect(Collectors.joining("\n"))); - stationReportAllVo.setStatisticStatusVOList(statisticStatusVOList); - } - } - countDownLatch.countDown(); - }); - //所有模板数据获取完成后释放锁 - try { - countDownLatch.await(); - } catch (InterruptedException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } - //小结 - this.getStationReportConclusion(stationReportAllVo, params); - return stationReportAllVo; - } + private final IImsDutyMainService iImsDutyMainService; + private final IOperMaintenanceTaskService operMaintenanceTaskService; + private final IInspectReportClient inspectReportClient; + private final IOperDefectService operDefectService; + private final IOperAccessTaskService operAccessTaskService; + private final IMainSystemMonitoringService mainSystemMonitoringService; + private final IStationService stationService; + private final IOperPhenomenonService operPhenomenonService; + private final IInspectRobotTaskClient inspectRobotTaskClient; + private final IFdpDiagnoseClient diagnoseClient; + private final ISysClient sysClient; + private final IUserClient userClient; + private final IInspectTaskReportClient taskReportClient; + private final ITicketInfoAllClient ticketInfoAllClient; + private final BladeLogger logger; + private final SoeDataClient soeDataClient; - /** - * 导出统计月报 - * @param month 月份 - * @param stationCode 站点编码 - * @param type 导出类型 - */ - @Override - public void exportStationMonthReport(String month, String stationCode, String type) { - DeptVO deptVO = BeanUtil.copy(sysClient.getDept(Long.parseLong(stationCode)).getData(), DeptVO.class); - StationReportAllVO stationReportAllVO = this.getStationMonthReport(month, deptVO); - Assert.isTrue(ObjectUtil.isNotEmpty(stationReportAllVO),()->{ - throw new ServiceException("电站统计月报查询为空"); - }); - - ExcelData ed = new ExcelData(); - XSSFWorkbook readWb = ed.getWb(); - XSSFSheet readSheet = null; - - ClassPathResource classPathResource = new ClassPathResource("files/运维月度报表内容设计0708.xlsx"); - InputStream inputStream = null; - XSSFWorkbook wb = null; - try { - inputStream = classPathResource.getInputStream(); - wb = new XSSFWorkbook(inputStream); - } catch (IOException e) { - e.printStackTrace(); - } - Assert.isTrue(ObjectUtil.isNotEmpty(inputStream) && ObjectUtil.isNotEmpty(wb),()->{ - throw new ServiceException("站点统计月报excel模板读取失败"); - }); + /** + * 统计月报线程数量 + **/ + private static final int POOL_QUANTITY = 8; + /** + * 通过线程池异步获取月报各模块内容 主要分为八块内容 + **/ + private static ExecutorService pool = Executors.newFixedThreadPool(POOL_QUANTITY); - if(STATION_REPORT_OUTSIDE.equals(type)) { - readSheet = readWb.getSheet("站长月度报告-对外"); - readWb.setSheetHidden(1, true); - readWb.setSheetHidden(2, true); - } - else if(STATION_REPORT_INSIDE.equals(type)) { - readSheet = readWb.getSheet("站长月度报告-对内"); - readWb.setSheetHidden(0, true); - readWb.setSheetHidden(2, true); - } + /** + * 统计月报-电站-对内 + **/ + private static final String STATION_REPORT_INSIDE = "2"; + /** + * 统计月报-电站-对外 + **/ + private static final String STATION_REPORT_OUTSIDE = "1"; - fillReport(readSheet,stationReportAllVO,type); + @Override + public StationReportAllVO getStationMonthReport(String yearAndMonth, DeptVO deptVO) { + StationReportAllVO stationReportAllVo = new StationReportAllVO(); + stationReportAllVo.setStationName(deptVO.getDeptName()); + stationReportAllVo.setYearMonth(YearMonth.parse(yearAndMonth).format(DateTimeFormatter.ofPattern("yyyy年MM月"))); + //处理请求参数 + Map params = new HashMap<>(); + //使用预定义实例来转换 + DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; + LocalDate startDate = DateUtil.getFirstDayByYearMonth(yearAndMonth); + LocalDate endDate = DateUtil.getLastDayByYearMonth(yearAndMonth); + params.put("startDate", fmt.format(startDate)); + params.put("endDate", fmt.format(endDate)); - // 下载导出 - RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); - HttpServletResponse response = ((ServletRequestAttributes) requestAttributes).getResponse(); - String fileName = "(" + month + ")站长月度报告"; - try { - ExcelUtil.exportExcel(readWb,response,fileName); - } catch (IOException e) { - e.printStackTrace(); - } - } + List deptIdList = new ArrayList<>(); + deptIdList.add(deptVO.getId()); + //获取下属机构 + R> childDeptListR = sysClient.getDeptChild(deptVO.getId()); + if (childDeptListR.isSuccess() && CollectionUtil.isNotEmpty(childDeptListR.getData())) { + deptIdList.addAll(childDeptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); + } + params.put("deptId", deptIdList); - /** - * 填充统计月报 - * @param sheet excel sheet - * @param stationReportAllVO 月报对象 - * @param type - */ - private void fillReport(XSSFSheet sheet, StationReportAllVO stationReportAllVO, String type) { - logger.info("hzims:operational:station:report",JSON.toJSONString(stationReportAllVO)); - //当前行数 - int currentRowNum = 0; - //填充标题 - XSSFCell cell_0_0 = sheet.getRow(currentRowNum).getCell(0); - String title = String.format(cell_0_0.getStringCellValue(),stationReportAllVO.getStationName(),stationReportAllVO.getYearMonth()); - cell_0_0.setCellValue(title); - //电站发电情况 - currentRowNum = currentRowNum+2; - currentRowNum = this.fillPowerGeneration(stationReportAllVO.getStationReportVOList(),currentRowNum,sheet,type); - //值班情况 - currentRowNum = currentRowNum+3; - currentRowNum = this.fillDuty(stationReportAllVO.getDutyReportVOList(),currentRowNum,sheet,type); - //日常维护 - currentRowNum = currentRowNum+2; - currentRowNum = this.fillMaintenance(stationReportAllVO.getMaintenanceReportVOList(),currentRowNum,sheet,type); - //巡检 - currentRowNum = currentRowNum+2; - currentRowNum = this.fillInspect(stationReportAllVO.getInspectReportVOList(),currentRowNum,sheet,type); - //检修 - currentRowNum = currentRowNum+2; - currentRowNum = this.fillAccess(stationReportAllVO.getAccessReportVOList(),currentRowNum,sheet,type); - //缺陷 - currentRowNum = currentRowNum+2; - currentRowNum = this.fillDefect(stationReportAllVO.getDefectReportsVOList(),currentRowNum,sheet,type); - //两票 - currentRowNum = currentRowNum+2; - currentRowNum = this.fillTicket(stationReportAllVO.getTicketInfoStatisticVOList(),currentRowNum,sheet,type); - //智能诊断 - currentRowNum = currentRowNum+1; - currentRowNum = this.fillDiagnosis(stationReportAllVO.getDiagnoseConclusion(),currentRowNum,sheet,type); - //小结 - currentRowNum = this.fillConclusion(stationReportAllVO,currentRowNum,sheet,type); - //处理建议合并单元格 - //this.mergeSuggestion(currentRowNum+2,sheet,type); - } + //获取机构及子机构下的站点 + List stationEntityList = stationService.list(new LambdaQueryWrapper() {{ + in(StationEntity::getRefDept, deptIdList); + }}); - private void mergeSuggestion(int currentRowNum, XSSFSheet sheet, String type) { - final int OUTSIDE_COLUMN_NUM = 4; - final int INSIDE_COLUMN_NUM = 5; - if(STATION_REPORT_OUTSIDE.equals(type)) { - CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum, (short) currentRowNum, (short) 0, (short) OUTSIDE_COLUMN_NUM); - sheet.addMergedRegion(cellRangeAddress); - } - else if(STATION_REPORT_INSIDE.equals(type)) { - CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum, (short) currentRowNum, (short) 0, (short) INSIDE_COLUMN_NUM); - sheet.addMergedRegion(cellRangeAddress); - } - } + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); + long startMillis = System.currentTimeMillis(); + //电站发电情况 + pool.execute(() -> { + try { + List powerList = new ArrayList<>(); + stationEntityList.forEach(stationEntity -> { + List stationReportVOList = mainSystemMonitoringService.getElectricSituation(yearAndMonth, stationEntity.getCode()); + powerList.addAll(stationReportVOList); + }); + stationReportAllVo.setStationReportVOList(powerList); + } finally { + countDownLatch.countDown(); + log.info("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //值班情况 + pool.execute(() -> { + try { +// List dutyReportVOList = iImsDutyMainService.getDutyMainStatisticsByClassId(params); +// stationReportAllVo.setDutyReportVOList(dutyReportVOList); + } finally { + countDownLatch.countDown(); + log.info("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //日常维护 + pool.execute(() -> { + try { + List maintenanceList = operMaintenanceTaskService.getMaintenanceStatisticsByDisposer(params); + stationReportAllVo.setMaintenanceReportVOList(maintenanceList); + } finally { + countDownLatch.countDown(); + log.info("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //检修 + pool.execute(() -> { + try { +// List accessList = operAccessTaskService.getAccessTaskByName(params); +// stationReportAllVo.setAccessReportVOList(accessList); + } finally { + countDownLatch.countDown(); + log.info("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //缺陷 + pool.execute(() -> { + try { + List defectList = operDefectService.getFaultByFaultCode(params); + stationReportAllVo.setDefectReportsVOList(defectList); + } finally { + countDownLatch.countDown(); + log.info("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //两票统计 + pool.execute(() -> { + try { + String deptIds = deptIdList.stream().map(deptId -> deptId.toString()).collect(Collectors.joining(",")); + TicketStatisticDTO ticketStatisticDTO = new TicketStatisticDTO(); + ticketStatisticDTO.setStartDate(fmt.format(startDate)); + ticketStatisticDTO.setEndDate(fmt.format(endDate)); + ticketStatisticDTO.setDeptIds(deptIds); + List ticketVOS = ticketInfoAllClient.getTicketReportStatistic(ticketStatisticDTO); + stationReportAllVo.setTicketInfoStatisticVOList(ticketVOS); + } finally { + countDownLatch.countDown(); + log.info("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //巡检 + pool.execute(() -> { + try { + List taskReportVOS = taskReportClient.getInspectTaskReport(params); + this.fillInspectProblem(startDate, endDate, deptIdList, taskReportVOS); + stationReportAllVo.setInspectReportVOList(taskReportVOS); + } finally { + countDownLatch.countDown(); + log.info("巡检:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("巡检:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //智能诊断 + pool.execute(() -> { + if (CollectionUtil.isNotEmpty(stationEntityList)) { + StatisticStatusDTO statisticStatusDTO = new StatisticStatusDTO(); + List stationIds = stationEntityList.stream().map(StationEntity::getCode).collect(Collectors.toList()); + String[] stationIdArray = new String[stationIds.size()]; + stationIds.toArray(stationIdArray); + statisticStatusDTO.setStationIds(stationIdArray); + statisticStatusDTO.setThreshold(0.3f); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + statisticStatusDTO.setStart(formatter.format(LocalDateTime.of(startDate, LocalTime.MIN))); + statisticStatusDTO.setEnd(formatter.format(LocalDateTime.of(endDate, LocalTime.MAX))); + R>> diagnoseResult = diagnoseClient.getStatisticStatus(statisticStatusDTO); + List diagnoseConclusionList = new ArrayList<>(); + if (diagnoseResult.isSuccess()) { + Map> statisticStatusVOList = diagnoseResult.getData(); + statisticStatusVOList.forEach((k, v) -> { + if (v.size() > 5) { + v = v.subList(0, 5); + } + String diagnoseConclusion = v.stream().map(s -> { + String riskLevel = ""; + if (s.getSeverity() >= 3) { + riskLevel = "高风险"; + } else if (s.getSeverity() == 2) { + riskLevel = "一般"; + } else if (s.getSeverity() == 1) { + riskLevel = "低风险"; + } + String c = "发生在" + s.getOrd() + "的" + s.getName() + ",风险等级:" + riskLevel + ",最后一次出现的时间:" + s.getLastBeginTime() + ";";//,持续时长:"+s.getLongTime()+" + return c; + }).collect(Collectors.joining("\n")); + if (StringUtil.isNotBlank(diagnoseConclusion)) { + StationEntity stationEntity = stationService.getById(k); + if (ObjectUtil.isNotEmpty(stationEntity)) { + diagnoseConclusion = stationEntity.getName() + "本月智能诊断服务预警前五位的可能存在风险的故障信息:\n" + diagnoseConclusion; + diagnoseConclusionList.add(diagnoseConclusion); + } + } + }); + stationReportAllVo.setDiagnoseConclusion(diagnoseConclusionList.stream().collect(Collectors.joining("\n"))); + stationReportAllVo.setStatisticStatusVOList(statisticStatusVOList); + } + } + countDownLatch.countDown(); + }); + //所有模板数据获取完成后释放锁 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + //小结 + this.getStationReportConclusion(stationReportAllVo, params); + return stationReportAllVo; + } + @Override + public StationRunReportAllVO getStationMonthReportV2(String yearAndMonth, DeptVO deptVO) { + StationRunReportAllVO stationReportAllVo = new StationRunReportAllVO(); + stationReportAllVo.setStationName(deptVO.getDeptName()); + stationReportAllVo.setYearMonth(YearMonth.parse(yearAndMonth).format(DateTimeFormatter.ofPattern("yyyy年MM月"))); + //处理请求参数 + Map params = new HashMap<>(); + //使用预定义实例来转换 + DateTimeFormatter fmt = DateTimeFormatter.ISO_LOCAL_DATE; + LocalDate startDate = DateUtil.getFirstDayByYearMonth(yearAndMonth); + LocalDate endDate = DateUtil.getLastDayByYearMonth(yearAndMonth); + params.put("startDate", fmt.format(startDate)); + params.put("endDate", fmt.format(endDate)); - private int fillConclusion(StationReportAllVO stationReportAllVO, int currentRowNum, XSSFSheet sheet, String type) { - final int OUTSIDE_COLUMN_NUM = 4; - final int INSIDE_COLUMN_NUM = 5; - sheet.shiftRows(currentRowNum+1, sheet.getLastRowNum(), 1,true,false); - sheet.createRow(currentRowNum+1); - XSSFRow row = sheet.getRow(currentRowNum + 1); - row.setHeight((short) 2400); - XSSFRow lastRow = sheet.getRow(currentRowNum); - if(STATION_REPORT_OUTSIDE.equals(type)) { - IntStream.iterate(0,col_index->col_index+1).limit(OUTSIDE_COLUMN_NUM+1).forEachOrdered(col_index->{ - row.createCell(col_index); - XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); - cellStyle.setAlignment(HorizontalAlignment.LEFT); - cellStyle.setWrapText(true); - row.getCell(col_index).setCellStyle(cellStyle); + List deptIdList = new ArrayList<>(); + deptIdList.add(deptVO.getId()); + //获取下属机构 + R> childDeptListR = sysClient.getDeptChild(deptVO.getId()); + if (childDeptListR.isSuccess() && CollectionUtil.isNotEmpty(childDeptListR.getData())) { + deptIdList.addAll(childDeptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); + } + params.put("deptId", deptIdList); - }); - CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum+1, (short) currentRowNum+1, (short) 0, (short) OUTSIDE_COLUMN_NUM); - sheet.addMergedRegion(cellRangeAddress); - row.getCell(0).setCellValue(stationReportAllVO.getStationOutsideConclusion()); - } - else if(STATION_REPORT_INSIDE.equals(type)) { - IntStream.iterate(0,col_index->col_index+1).limit(INSIDE_COLUMN_NUM+1).forEachOrdered(col_index->{ - row.createCell(col_index); - XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); - cellStyle.setWrapText(true); - cellStyle.setAlignment(HorizontalAlignment.LEFT); - row.getCell(col_index).setCellStyle(cellStyle); - }); - CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum+1, (short) currentRowNum+1, (short) 0, (short) INSIDE_COLUMN_NUM); - sheet.addMergedRegion(cellRangeAddress); - row.getCell(0).setCellValue(stationReportAllVO.getStationInsideConclusion()); - } - return currentRowNum+1; - } + //获取机构及子机构下的站点 + List stationEntityList = stationService.list(new LambdaQueryWrapper() {{ + in(StationEntity::getRefDept, deptIdList); + }}); - private int fillDiagnosis(String diagnoseConclusion, int currentRowNum, XSSFSheet sheet, String type) { - final int OUTSIDE_COLUMN_NUM = 4; - final int INSIDE_COLUMN_NUM = 5; - sheet.shiftRows(currentRowNum+1, sheet.getLastRowNum(), 1,true,false); - sheet.createRow(currentRowNum+1); - XSSFRow row = sheet.getRow(currentRowNum + 1); - row.setHeight((short) 800); - XSSFRow lastRow = sheet.getRow(currentRowNum-1); - if(STATION_REPORT_OUTSIDE.equals(type)) { - IntStream.iterate(0,col_index->col_index+1).limit(OUTSIDE_COLUMN_NUM+1).forEachOrdered(col_index->{ - row.createCell(col_index); - XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); - cellStyle.setWrapText(true); - row.getCell(col_index).setCellStyle(cellStyle); - }); - CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum+1, (short) currentRowNum+1, (short) 0, (short) OUTSIDE_COLUMN_NUM); - sheet.addMergedRegion(cellRangeAddress); - } - else if(STATION_REPORT_INSIDE.equals(type)) { - IntStream.iterate(0,col_index->col_index+1).limit(INSIDE_COLUMN_NUM+1).forEachOrdered(col_index->{ - row.createCell(col_index); - XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); - cellStyle.setWrapText(true); - row.getCell(col_index).setCellStyle(cellStyle); - }); - CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum+1, (short) currentRowNum+1, (short) 0, (short) INSIDE_COLUMN_NUM); - sheet.addMergedRegion(cellRangeAddress); - } - row.getCell(0).setCellValue(diagnoseConclusion); - return currentRowNum+1; - } + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); + long startMillis = System.currentTimeMillis(); + //电站发电情况 + pool.execute(() -> { + try { + List reportVOS = new ArrayList<>(); + String[] yearMon = yearAndMonth.split("-"); + Integer year = Integer.valueOf(yearMon[0]); + Calendar calendar=Calendar.getInstance(); + Integer currentYear = calendar.get(Calendar.YEAR); + if (year>currentYear-3) { + mainSystemMonitoringService.getElectricSituationByRedis(yearAndMonth, reportVOS, stationEntityList); + }else { + stationEntityList.forEach(stationEntity -> { + List stationReportVOList = mainSystemMonitoringService.getElectricSituationV2(yearAndMonth, stationEntity.getCode()); + reportVOS.addAll(stationReportVOList); + }); + } + stationReportAllVo.setStationReportVOList(reportVOS); + }catch (Exception e){ + log.error("", e); + System.out.println(e); + }finally { + countDownLatch.countDown(); + log.info("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("电站发电耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //值班情况 + pool.execute(() -> { + try { + List dutyReportVOList = iImsDutyMainService.getDutyMainRunReport(params); + stationReportAllVo.setDutyReportVOList(dutyReportVOList); + } finally { + countDownLatch.countDown(); + log.info("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("值班情况耗时:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //日常维护 + pool.execute(() -> { + try { + List maintenanceList = operMaintenanceTaskService.getMaintenanceStatisticsByName(params); + stationReportAllVo.setMaintenanceReportVOList(maintenanceList); + } finally { + countDownLatch.countDown(); + log.info("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //巡检 + pool.execute(() -> { + try { + List reportVOS=new ArrayList<>(); + List inspectStatisticsByName = inspectReportClient.getInspectStatisticsByName(deptIdList, fmt.format(startDate), fmt.format(endDate)); + if(CollectionUtil.isNotEmpty(inspectStatisticsByName)) { + for (int i = 0; i < inspectStatisticsByName.size(); i++) { + TaskReportVO taskReportVO = inspectStatisticsByName.get(i); + RunReportVO runReportVO = new RunReportVO(); + runReportVO.setIndex(i+1); + runReportVO.setUserName(taskReportVO.getUserName()); + runReportVO.setCompleteNum(taskReportVO.getCompleteNum()); + runReportVO.setIncompleteNum(taskReportVO.getIncompleteNum()); + runReportVO.setRemark(taskReportVO.getCompleteSituation() + "" + taskReportVO.getIncompleteSituation()); + reportVOS.add(runReportVO); + } + int complete = inspectStatisticsByName.stream().mapToInt(TaskReportVO::getCompleteNum).sum(); + int inComplete = inspectStatisticsByName.stream().mapToInt(TaskReportVO::getIncompleteNum).sum(); + RunReportVO runReportVO = new RunReportVO(); + runReportVO.setUserName("合计"); + runReportVO.setCompleteNum(complete); + runReportVO.setIncompleteNum(inComplete); + reportVOS.add(runReportVO); + }else { + RunReportVO runReportVO = new RunReportVO(); + runReportVO.setUserName("合计"); + runReportVO.setCompleteNum(0); + runReportVO.setIncompleteNum(0); + reportVOS.add(runReportVO); + } + stationReportAllVo.setInspectReportVOList(reportVOS); + } finally { + countDownLatch.countDown(); + log.info("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("日常维护:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //检修 + pool.execute(() -> { + try { + List accessList = operAccessTaskService.getAccessTaskByName(params); + stationReportAllVo.setAccessReportVOList(accessList); + } finally { + countDownLatch.countDown(); + log.info("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("检修:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //缺陷 + pool.execute(() -> { + try { + List defectList = operDefectService.getDefectByName(params); + stationReportAllVo.setDefectReportsVOList(defectList); + } finally { + countDownLatch.countDown(); + log.info("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("缺陷:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //两票统计 + pool.execute(() -> { + try { + String deptIds = deptIdList.stream().map(deptId -> deptId.toString()).collect(Collectors.joining(",")); + TicketStatisticDTO ticketStatisticDTO = new TicketStatisticDTO(); + ticketStatisticDTO.setStartDate(fmt.format(startDate)); + ticketStatisticDTO.setEndDate(fmt.format(endDate)); + ticketStatisticDTO.setDeptIds(deptIds); + List ticketVOS = ticketInfoAllClient.getTicketReportStatistic(ticketStatisticDTO); + if (CollectionUtil.isNotEmpty(ticketVOS)){ + stationReportAllVo.setTicketInfoStatisticVOList(ticketVOS); + } + } finally { + countDownLatch.countDown(); + log.info("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); + System.out.printf("两票统计:"+(System.currentTimeMillis()-startMillis)+"ms"); + } + }); + //智能诊断 + pool.execute(() -> { + List list=new ArrayList<>(); + if (CollectionUtil.isNotEmpty(stationEntityList)) { + StbAnalysisDTO param = new StbAnalysisDTO(); + param.setStartTime(LocalDateTime.parse(fmt.format(startDate)+" 00:00:00", org.springblade.core.tool.utils.DateUtil.DATETIME_FORMATTER)); + param.setEndTime(LocalDateTime.parse(fmt.format(endDate)+" 23:59:59", org.springblade.core.tool.utils.DateUtil.DATETIME_FORMATTER)); +// param.setStartTime(startDate.atStartOfDay()); +// param.setEndTime(endDate.at()); + List collect = stationEntityList.stream().filter(s -> ObjectUtil.isNotEmpty(s.getCode())).map(StationEntity::getCode).collect(Collectors.toList()); + param.setStations(Arrays.asList("902100000026")); +// param.setPageSize(10); +// param.setPage(0); + param.setNeedPage(false); + Result> result = soeDataClient.pageStbAnalysis(param); + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData().getRecords())){ + List data = result.getData().getRecords(); + for (int i = 0; i < data.size(); i++) { + StbAnalysisVO stbAnalysisVO = data.get(i); + FDPRunReportVO fdpRunReportVO=new FDPRunReportVO(); + fdpRunReportVO.setIndex(i+1); + fdpRunReportVO.setLastBeginTime(stbAnalysisVO.getTs()); + fdpRunReportVO.setContent(stbAnalysisVO.getContent()); + fdpRunReportVO.setType(stbAnalysisVO.getFtype()); + Long count = data.stream().filter(s -> stbAnalysisVO.equals(s.getFaultid())).count(); + fdpRunReportVO.setNum(count.toString()); + fdpRunReportVO.setReason(stbAnalysisVO.getFinfo()); + list.add(fdpRunReportVO); + } + } + } + countDownLatch.countDown(); + }); + //所有模板数据获取完成后释放锁 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + logger.error(e.getMessage(), e.toString()); + Thread.currentThread().interrupt(); + } + //小结 + this.getStationReportConclusionV2(stationReportAllVo, params); + return stationReportAllVo; + } + /** + * 导出统计月报 + * + * @param month 月份 + * @param stationCode 站点编码 + * @param type 导出类型 + */ + @Override + public void exportStationMonthReport(HttpServletResponse response, StationRunReportAllVO stationReportAllVO,Long deptId) throws Exception { + Assert.isTrue(ObjectUtil.isNotEmpty(stationReportAllVO), () -> { + throw new ServiceException("电站统计月报查询为空"); + }); + + HashMap map = getHashMap(stationReportAllVO, deptId); + + + XWPFDocument xwpfDocument = WordExportUtil.exportWord07("template/word/stationMonthReport.docx", map); + // 下载导出 + String filename = stationReportAllVO.getYearMonth()+stationReportAllVO.getStationName()+"月报"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream = null; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".docx", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + + //写入数据 + xwpfDocument.write(outputStream); + // 关闭 + outputStream.close(); + xwpfDocument.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private HashMap getHashMap(StationRunReportAllVO stationReportAllVO, Long deptId) throws IllegalAccessException { + HashMap map = new HashMap<>(); + map.put("deptName", stationReportAllVO.getStationName()); + List userListByRoleAlias = userClient.relationUserListByRoleAlias("200000", deptId, PROJECT_MANAGER).getData(); + if (CollectionUtil.isNotEmpty(userListByRoleAlias)){ + User user = userListByRoleAlias.get(0); + map.put("manager", user.getName()); + }else { + map.put("manager",""); + } + //电站发电情况 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getStationReportVOList())) { + ArrayList> list = new ArrayList<>(); + List stationReportVOList = stationReportAllVO.getStationReportVOList(); + for (StationRunReportVO stationRunReportVO : stationReportVOList) { + fillMapByClass(stationRunReportVO, list); + } + map.put("stationReportVOList", list); + } + //值班情况 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getDutyReportVOList())) { + ArrayList> list = new ArrayList<>(); + List dutyReportVOList = stationReportAllVO.getDutyReportVOList(); + for (DutyRunReportVO dutyRunReportVO : dutyReportVOList) { + if ("合计".equals(dutyRunReportVO.getGroupName())){ + ArrayList> sumList = new ArrayList<>(); + HashMap temp=new HashMap<>(); + temp.put("groupName",dutyRunReportVO.getGroupName()); + temp.put("dutyNum",dutyRunReportVO.getDutyNum().toString()); + temp.put("findProblemNum",dutyRunReportVO.getFindProblemNum().toString()); + temp.put("delayChangeShifts",dutyRunReportVO.getDelayChangeShifts().toString()); + temp.put("exceptionChangeShifts",dutyRunReportVO.getExceptionChangeShifts().toString()); + sumList.add(temp); + map.put("dutyReportSum", sumList); + continue; + } + fillMapByClass(dutyRunReportVO,list); + } + map.put("dutyReportVOList", list); + } + //日常维护 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getMaintenanceReportVOList())) { + ArrayList> list = new ArrayList<>(); + List maintenanceReportVOList = stationReportAllVO.getMaintenanceReportVOList(); + for (RunReportVO maintenanceReport : maintenanceReportVOList) { + if ("合计".equals(maintenanceReport.getUserName())){ + ArrayList> sumList = new ArrayList<>(); + HashMap temp=new HashMap<>(); + temp.put("userName",maintenanceReport.getUserName()); + temp.put("completeNum",maintenanceReport.getCompleteNum().toString()); + temp.put("incompleteNum",maintenanceReport.getIncompleteNum().toString()); + temp.put("remark",maintenanceReport.getRemark().toString()); + sumList.add(temp); + map.put("maintenanceSum", sumList); + continue; + } + fillMapByClass(maintenanceReport,list); + } + map.put("maintenanceReportVOList", list); + } + //巡检 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getInspectReportVOList())) { + ArrayList> list = new ArrayList<>(); + List inspectReportVOList = stationReportAllVO.getInspectReportVOList(); + for (RunReportVO inspectReport : inspectReportVOList) { + if ("合计".equals(inspectReport.getUserName())){ + ArrayList> sumList = new ArrayList<>(); + HashMap temp=new HashMap<>(); + temp.put("userName",inspectReport.getUserName()); + temp.put("completeNum",inspectReport.getCompleteNum().toString()); + temp.put("incompleteNum",inspectReport.getIncompleteNum().toString()); + temp.put("remark",""); + sumList.add(temp); + map.put("inspectReportSum", sumList); + continue; + } + fillMapByClass(inspectReportVOList,list); + } + map.put("inspectReportVOList", list); + } + //检修 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getAccessReportVOList())) { + ArrayList> list = new ArrayList<>(); + List accessReportVOList = stationReportAllVO.getAccessReportVOList(); + for (AccessRunReportVO accessRunReportVO : accessReportVOList) { + fillMapByClass(accessRunReportVO, list); + } + map.put("accessReportVOList", list); + } + //缺陷 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getDefectReportsVOList())) { + ArrayList> list = new ArrayList<>(); + List defectReportsVOList = stationReportAllVO.getDefectReportsVOList(); + for (DefectRunReportsVO defectRunReportsVO : defectReportsVOList) { + fillMapByClass(defectRunReportsVO, list); + } + map.put("defectReportsVOList", list); + } + //两票 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getTicketInfoStatisticVOList())) { + ArrayList> list = new ArrayList<>(); + List ticketInfoStatisticVOList = stationReportAllVO.getTicketInfoStatisticVOList(); + for (TicketInfoStatisticVO ticketInfoStatisticVO : ticketInfoStatisticVOList) { + if (!"合计".equals(ticketInfoStatisticVO.getTicketInfoType())){ + fillMapByClass(ticketInfoStatisticVO, list); + continue; + } + ArrayList> sumList = new ArrayList<>(); + HashMap temp=new HashMap<>(); + temp.put("ticketInfoType",ticketInfoStatisticVO.getTicketInfoType()); + temp.put("ticketInfoNumber",ticketInfoStatisticVO.getTicketInfoNumber().toString()); + temp.put("ticketInfoCompleteNum",ticketInfoStatisticVO.getTicketInfoCompleteNum().toString()); + temp.put("ticketInfoInvalidatedNum",ticketInfoStatisticVO.getTicketInfoInvalidatedNum().toString()); + temp.put("ticketInfoQualifiedNum",ticketInfoStatisticVO.getTicketInfoQualifiedNum().toString()); + temp.put("ticketInfoProportion",ticketInfoStatisticVO.getTicketInfoProportion().toString()); + sumList.add(temp); + map.put("ticketInfoSum", sumList); + } + map.put("ticketInfoStatisticVOList", list); + } + //智能诊断 + if (CollectionUtil.isNotEmpty(stationReportAllVO.getFdpRunReportVOList())) { + ArrayList> list = new ArrayList<>(); + List fdpRunReportVOList = stationReportAllVO.getFdpRunReportVOList(); + for (FDPRunReportVO fdpRunReportVO : fdpRunReportVOList) { + fillMapByClass(fdpRunReportVO, list); + } + map.put("fdpRunReportVOList", list); + } + //总结 + map.put("suggestion", stationReportAllVO.getSuggestion()); + return map; + } + + private static void fillMapByClass(Object object, ArrayList> list) throws IllegalAccessException { + Class clazz = object.getClass(); + HashMap temp=new HashMap<>(); + for (Field field : clazz.getDeclaredFields()) { + field.setAccessible(true); + String fieldName = field.getName(); + Object value = field.get(object); + temp.put(fieldName, value); + } + list.add(temp); + } + + /** + * 填充统计月报 + * + * @param sheet excel sheet + * @param stationReportAllVO 月报对象 + * @param type + */ + private void fillReport(XSSFSheet sheet, StationReportAllVO stationReportAllVO, String type) { + logger.info("hzims:operational:station:report", JSON.toJSONString(stationReportAllVO)); + //当前行数 + int currentRowNum = 0; + //填充标题 + XSSFCell cell_0_0 = sheet.getRow(currentRowNum).getCell(0); + String title = String.format(cell_0_0.getStringCellValue(), stationReportAllVO.getStationName(), stationReportAllVO.getYearMonth()); + cell_0_0.setCellValue(title); + //电站发电情况 + currentRowNum = currentRowNum + 2; + currentRowNum = this.fillPowerGeneration(stationReportAllVO.getStationReportVOList(), currentRowNum, sheet, type); + //值班情况 + currentRowNum = currentRowNum + 3; + currentRowNum = this.fillDuty(stationReportAllVO.getDutyReportVOList(), currentRowNum, sheet, type); + //日常维护 + currentRowNum = currentRowNum + 2; + currentRowNum = this.fillMaintenance(stationReportAllVO.getMaintenanceReportVOList(), currentRowNum, sheet, type); + //巡检 + currentRowNum = currentRowNum + 2; + currentRowNum = this.fillInspect(stationReportAllVO.getInspectReportVOList(), currentRowNum, sheet, type); + //检修 + currentRowNum = currentRowNum + 2; + currentRowNum = this.fillAccess(stationReportAllVO.getAccessReportVOList(), currentRowNum, sheet, type); + //缺陷 + currentRowNum = currentRowNum + 2; + currentRowNum = this.fillDefect(stationReportAllVO.getDefectReportsVOList(), currentRowNum, sheet, type); + //两票 + currentRowNum = currentRowNum + 2; + currentRowNum = this.fillTicket(stationReportAllVO.getTicketInfoStatisticVOList(), currentRowNum, sheet, type); + //智能诊断 + currentRowNum = currentRowNum + 1; + currentRowNum = this.fillDiagnosis(stationReportAllVO.getDiagnoseConclusion(), currentRowNum, sheet, type); + //小结 + currentRowNum = this.fillConclusion(stationReportAllVO, currentRowNum, sheet, type); + //处理建议合并单元格 + //this.mergeSuggestion(currentRowNum+2,sheet,type); + } + + private void mergeSuggestion(int currentRowNum, XSSFSheet sheet, String type) { + final int OUTSIDE_COLUMN_NUM = 4; + final int INSIDE_COLUMN_NUM = 5; + if (STATION_REPORT_OUTSIDE.equals(type)) { + CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum, (short) currentRowNum, (short) 0, (short) OUTSIDE_COLUMN_NUM); + sheet.addMergedRegion(cellRangeAddress); + } else if (STATION_REPORT_INSIDE.equals(type)) { + CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum, (short) currentRowNum, (short) 0, (short) INSIDE_COLUMN_NUM); + sheet.addMergedRegion(cellRangeAddress); + } + } + + private int fillConclusion(StationReportAllVO stationReportAllVO, int currentRowNum, XSSFSheet sheet, String type) { + final int OUTSIDE_COLUMN_NUM = 4; + final int INSIDE_COLUMN_NUM = 5; + sheet.shiftRows(currentRowNum + 1, sheet.getLastRowNum(), 1, true, false); + sheet.createRow(currentRowNum + 1); + XSSFRow row = sheet.getRow(currentRowNum + 1); + row.setHeight((short) 2400); + XSSFRow lastRow = sheet.getRow(currentRowNum); + if (STATION_REPORT_OUTSIDE.equals(type)) { + IntStream.iterate(0, col_index -> col_index + 1).limit(OUTSIDE_COLUMN_NUM + 1).forEachOrdered(col_index -> { + row.createCell(col_index); + XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.LEFT); + cellStyle.setWrapText(true); + row.getCell(col_index).setCellStyle(cellStyle); + + }); + CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum + 1, (short) currentRowNum + 1, (short) 0, (short) OUTSIDE_COLUMN_NUM); + sheet.addMergedRegion(cellRangeAddress); + row.getCell(0).setCellValue(stationReportAllVO.getStationOutsideConclusion()); + } else if (STATION_REPORT_INSIDE.equals(type)) { + IntStream.iterate(0, col_index -> col_index + 1).limit(INSIDE_COLUMN_NUM + 1).forEachOrdered(col_index -> { + row.createCell(col_index); + XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); + cellStyle.setWrapText(true); + cellStyle.setAlignment(HorizontalAlignment.LEFT); + row.getCell(col_index).setCellStyle(cellStyle); + }); + CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum + 1, (short) currentRowNum + 1, (short) 0, (short) INSIDE_COLUMN_NUM); + sheet.addMergedRegion(cellRangeAddress); + row.getCell(0).setCellValue(stationReportAllVO.getStationInsideConclusion()); + } + return currentRowNum + 1; + } + + private int fillDiagnosis(String diagnoseConclusion, int currentRowNum, XSSFSheet sheet, String type) { + final int OUTSIDE_COLUMN_NUM = 4; + final int INSIDE_COLUMN_NUM = 5; + sheet.shiftRows(currentRowNum + 1, sheet.getLastRowNum(), 1, true, false); + sheet.createRow(currentRowNum + 1); + XSSFRow row = sheet.getRow(currentRowNum + 1); + row.setHeight((short) 800); + XSSFRow lastRow = sheet.getRow(currentRowNum - 1); + if (STATION_REPORT_OUTSIDE.equals(type)) { + IntStream.iterate(0, col_index -> col_index + 1).limit(OUTSIDE_COLUMN_NUM + 1).forEachOrdered(col_index -> { + row.createCell(col_index); + XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); + cellStyle.setWrapText(true); + row.getCell(col_index).setCellStyle(cellStyle); + }); + CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum + 1, (short) currentRowNum + 1, (short) 0, (short) OUTSIDE_COLUMN_NUM); + sheet.addMergedRegion(cellRangeAddress); + } else if (STATION_REPORT_INSIDE.equals(type)) { + IntStream.iterate(0, col_index -> col_index + 1).limit(INSIDE_COLUMN_NUM + 1).forEachOrdered(col_index -> { + row.createCell(col_index); + XSSFCellStyle cellStyle = lastRow.getCell(col_index).getCellStyle(); + cellStyle.setWrapText(true); + row.getCell(col_index).setCellStyle(cellStyle); + }); + CellRangeAddress cellRangeAddress = new CellRangeAddress((short) currentRowNum + 1, (short) currentRowNum + 1, (short) 0, (short) INSIDE_COLUMN_NUM); + sheet.addMergedRegion(cellRangeAddress); + } + row.getCell(0).setCellValue(diagnoseConclusion); + return currentRowNum + 1; + } private int fillTicket(List ticketInfoStatisticVOList, int currentRowNum, XSSFSheet sheet, String type) { String[] attributes = new String[0]; @@ -723,28 +1086,136 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor conclusion.append(String.format(phenomenonConclusion,problemNum,stationReportAllVo.getDefectReportsVOList().size())).append(";\r\n"); } - //机器人巡检小结 - if (CollectionUtil.isEmpty(robotConclusion) || ObjectUtil.isEmpty(robotConclusion.get("ROBOT_TASK_HOURS"))) { - outsideConclusion.append("3、本月无机器人巡检任务;\r\n"); - conclusion.append("6、本月无机器人巡检任务;\n"); - } else { - outsideConclusion.append("3、本月机器人巡检").append(robotConclusion.get("ROBOT_TASK_HOURS") == null ? "0" : robotConclusion.get("ROBOT_TASK_HOURS")) - .append("小时,执行") - .append(robotConclusion.get("ROBOT_TASK_NUM") == null ? "0" : robotConclusion.get("ROBOT_TASK_NUM")) - .append("个巡检任务;\r\n"); - conclusion.append("6、本月机器人巡检").append(robotConclusion.get("ROBOT_TASK_HOURS")).append("小时") - .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_NUM")).map(o -> { - return ",执行".concat(o.toString().concat("个巡检任务")); - }).orElse("")) - .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_COMPLETE")).map(o -> { - return ",有".concat(o.toString()).concat("个任务运行正常"); - }).orElse("")) - .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_INCOMPLETE")).map(o -> { - return ",有".concat(o.toString()).concat("任务未执行;\r\n"); - }).orElse(";\r\n")); - } - //outsideConclusion.append("4、本月远程协助工作1次,专家会诊1次,新增1个案例,1个知识分享;\r\n"); - stationReportAllVo.setStationInsideConclusion(conclusion.toString()); - stationReportAllVo.setStationOutsideConclusion(outsideConclusion.toString()); - } + //机器人巡检小结 + if (CollectionUtil.isEmpty(robotConclusion) || ObjectUtil.isEmpty(robotConclusion.get("ROBOT_TASK_HOURS"))) { + outsideConclusion.append("3、本月无机器人巡检任务;\r\n"); + conclusion.append("6、本月无机器人巡检任务;\n"); + } else { + outsideConclusion.append("3、本月机器人巡检").append(robotConclusion.get("ROBOT_TASK_HOURS") == null ? "0" : robotConclusion.get("ROBOT_TASK_HOURS")) + .append("小时,执行") + .append(robotConclusion.get("ROBOT_TASK_NUM") == null ? "0" : robotConclusion.get("ROBOT_TASK_NUM")) + .append("个巡检任务;\r\n"); + conclusion.append("6、本月机器人巡检").append(robotConclusion.get("ROBOT_TASK_HOURS")).append("小时") + .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_NUM")).map(o -> { + return ",执行".concat(o.toString().concat("个巡检任务")); + }).orElse("")) + .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_COMPLETE")).map(o -> { + return ",有".concat(o.toString()).concat("个任务运行正常"); + }).orElse("")) + .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_INCOMPLETE")).map(o -> { + return ",有".concat(o.toString()).concat("任务未执行;\r\n"); + }).orElse(";\r\n")); + } + //outsideConclusion.append("4、本月远程协助工作1次,专家会诊1次,新增1个案例,1个知识分享;\r\n"); + stationReportAllVo.setStationInsideConclusion(conclusion.toString()); + stationReportAllVo.setStationOutsideConclusion(outsideConclusion.toString()); + } + /** + * 完善站点月报小结 + * + * @param stationReportAllVo + * @param params + */ + private void getStationReportConclusionV2(StationRunReportAllVO stationReportAllVo, Map params) { + //值班小结 + List> dutyConclusion = iImsDutyMainService.getDutyConclusion(params); + //机器人巡检小结 + Map robotConclusion = inspectRobotTaskClient.getRobotConclusion(params); + StringBuffer conclusion = new StringBuffer("本月电站工作小结:\r\n"); + + //完善值班小结 + if (CollectionUtil.isNotEmpty(stationReportAllVo.getDutyReportVOList())) { + if (CollectionUtil.isEmpty(dutyConclusion) || dutyConclusion.size() == 0) { + conclusion.append("1、本月无值班任务;\r\n"); + } else { + //对内值班小结 + conclusion.append("1、值班") + .append(dutyConclusion.get(0).get(ColumnEnum.duty_conclusion_date_col.getColumnName())) + .append("天,正常交接班") + .append(dutyConclusion.get(0).get(ColumnEnum.duty_conclusion_intime_col.getColumnName())) + .append("次,延迟交接班") + .append(dutyConclusion.get(0).get(ColumnEnum.duty_conclusion_delay_col.getColumnName())) + .append("次;\r\n"); + } + }else { + conclusion.append("1、本月无值班任务;\r\n"); + } + + //日常维护任务统计 + if (CollectionUtil.isNotEmpty(stationReportAllVo.getMaintenanceReportVOList())) { + List maintenanceReportVOList = stationReportAllVo.getMaintenanceReportVOList(); + int completeTaskNum = maintenanceReportVOList.stream().filter(vo -> Func.isNotEmpty(vo.getCompleteNum())).mapToInt(RunReportVO::getCompleteNum).sum(); + int incompleteTaskNum = maintenanceReportVOList.stream().filter(vo -> Func.isNotEmpty(vo.getIncompleteNum())).mapToInt(RunReportVO::getIncompleteNum).sum(); + if (completeTaskNum == 0 && incompleteTaskNum == 0) { + conclusion.append("2、无日常维护任务;\r\n"); + } else { + //对内日常维护小结 + String maintenanceTaskConclusion = "2、%s个日常维护任务,已执行%s个任务,完成率%s%%"; + Double completeRate = new BigDecimal(completeTaskNum / (double) (completeTaskNum + incompleteTaskNum) * 100) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); + conclusion.append(String.format(maintenanceTaskConclusion, (completeTaskNum + incompleteTaskNum), completeTaskNum, completeRate)).append(";\r\n"); + } + } else { + conclusion.append("2、无日常维护任务;\r\n"); + } + + //巡检任务统计 + if (CollectionUtil.isNotEmpty(stationReportAllVo.getInspectReportVOList())) { + List inspectReportVOList = stationReportAllVo.getInspectReportVOList(); + int completeInspectTaskNum = inspectReportVOList.stream().filter(vo -> Func.isNotEmpty(vo.getCompleteNum())).mapToInt(RunReportVO::getCompleteNum).sum(); + int incompleteInspectTaskNum = inspectReportVOList.stream().filter(vo -> Func.isNotEmpty(vo.getIncompleteNum())).mapToInt(RunReportVO::getIncompleteNum).sum(); + if (completeInspectTaskNum == 0 && incompleteInspectTaskNum == 0) { + conclusion.append("3、无巡检任务;\r\n"); + } else { + String inspectTaskConclusion = "3、%s个巡检任务,已执行%s个巡检任务。"; + conclusion.append(String.format(inspectTaskConclusion, (completeInspectTaskNum + incompleteInspectTaskNum), completeInspectTaskNum)).append(";\r\n"); + } + } else { + conclusion.append("3、无巡检任务;\r\n"); + } + //检修任务统计 + if (CollectionUtil.isNotEmpty(stationReportAllVo.getAccessReportVOList())) { + List accessReportVOList = stationReportAllVo.getAccessReportVOList(); + if (CollectionUtil.isNotEmpty(accessReportVOList)) { + conclusion.append("4、无检修任务;\r\n"); + } else { + String accessTaskConclusion = "4、执行%s个检修任务"; + conclusion.append(String.format(accessTaskConclusion, accessReportVOList.size())).append(";\r\n"); + } } else { + conclusion.append("4、无检修任务;\r\n"); + } + // 现象统计 + if (CollectionUtil.isNotEmpty(stationReportAllVo.getDefectReportsVOList())) { + String phenomenonConclusion = "5、本月发现%s个缺陷"; + conclusion.append(String.format(phenomenonConclusion,stationReportAllVo.getDefectReportsVOList().size())).append(";\r\n"); + }else { + conclusion.append("5、本月未发现缺陷;\r\n"); + } + //机器人巡检小结 + if (CollectionUtil.isEmpty(robotConclusion) || ObjectUtil.isEmpty(robotConclusion.get("ROBOT_TASK_HOURS"))) { + conclusion.append("6、本月无机器人巡检任务;\n"); + } else { + conclusion.append("6、本月机器人巡检").append(robotConclusion.get("ROBOT_TASK_HOURS")).append("小时") + .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_NUM")).map(o -> { + return ",执行".concat(o.toString().concat("个巡检任务")); + }).orElse("")) + .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_COMPLETE")).map(o -> { + return ",有".concat(o.toString()).concat("个任务运行正常"); + }).orElse("")) + .append(Optional.ofNullable(robotConclusion.get("ROBOT_TASK_INCOMPLETE")).map(o -> { + return ",有".concat(o.toString()).concat("任务未执行;\r\n"); + }).orElse(";\r\n")); + } + // 两票 + if (CollectionUtil.isNotEmpty(stationReportAllVo.getTicketInfoStatisticVOList())) { + int sum = stationReportAllVo.getTicketInfoStatisticVOList().stream().mapToInt(TicketInfoStatisticVO::getTicketInfoNumber).sum(); + int qualifiedNum = stationReportAllVo.getTicketInfoStatisticVOList().stream().mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum(); + double ticketInfoProportion = new BigDecimal(qualifiedNum / (double) sum * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue(); + String phenomenonConclusion = "5、本月开票%s张,合格率%s;"; + conclusion.append(String.format(phenomenonConclusion,sum,ticketInfoProportion)).append(";\r\n"); + }else { + conclusion.append("5、本月未开票;\r\n"); + } + stationReportAllVo.setSuggestion(conclusion.toString()); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/AccessRunReportVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/AccessRunReportVO.java new file mode 100644 index 0000000..3f793bc --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/AccessRunReportVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.operational.report.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class AccessRunReportVO implements Serializable { + private static final long serialVersionUID = -6752409583963294512L; + + private Integer index; + + @ApiModelProperty("人员ID") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long userId; + + @ApiModelProperty("姓名") + private String userName; + + @ApiModelProperty("检修项目") + private String maintenanceItem; + + @ApiModelProperty("完成情况") + private String completeSituation; + @ApiModelProperty("备注") + private String remark; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DefectRunReportsVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DefectRunReportsVO.java new file mode 100644 index 0000000..04676f5 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DefectRunReportsVO.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DefectRunReportsVO implements Serializable { + + private static final long serialVersionUID = 4172942990070215282L; + + private Integer index; + + @ApiModelProperty("缺陷名称") + private String faultName; + @ApiModelProperty("缺陷等级") + private String seriousSituation; + @ApiModelProperty("发现人") + private String finder; + @ApiModelProperty("发现时间") + private String finderTime; + @ApiModelProperty("缺陷描述") + private String description; + @ApiModelProperty("处理时间") + private String handleTime; + @ApiModelProperty("处理情况") + private String handleSituation; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DutyRunReportVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DutyRunReportVO.java new file mode 100644 index 0000000..1ebac32 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/DutyRunReportVO.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.operational.report.vo; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class DutyRunReportVO implements Serializable { + private static final long serialVersionUID = 3273581622730234931L; + + private Integer index; + + @ApiModelProperty("班组名称") + private String groupName; + @ApiModelProperty("值长") + private String managerName; + @ApiModelProperty("值班次数") + private Integer dutyNum=0; + @ApiModelProperty("值班") + private List dutyList; + @ApiModelProperty("发现问题数量") + private Integer findProblemNum=0; + @ApiModelProperty("发现问题数量") + private List findProblemList; + @ApiModelProperty("延迟交接班") + private Integer delayChangeShifts=0; + @ApiModelProperty("延迟交接班") + private List delayChangeList; + @ApiModelProperty("异常交接班") + private Integer exceptionChangeShifts=0; + @ApiModelProperty("异常交接班") + private List exceptionChangeList; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java new file mode 100644 index 0000000..0b40dc2 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/FDPRunReportVO.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.operational.report.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class FDPRunReportVO implements Serializable { + private static final long serialVersionUID = -4198449565005940501L; + + private Integer index; + @ApiModelProperty("最近出现告警时间") + @JSONField(name = "LASTBEGINTIME") + private String lastBeginTime; + + @ApiModelProperty("告警内容") + private String content; + + + @ApiModelProperty("告警类型") + private String type; + + @ApiModelProperty("告警次数") + private String num; + + @ApiModelProperty("初步分析原因") + @JSONField(name = "ORD") + private String reason; + + @ApiModelProperty("建议处置方式") + @JSONField(name = "INFO") + private String advise; + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunReportVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunReportVO.java new file mode 100644 index 0000000..9a92921 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunReportVO.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.report.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class RunReportVO implements Serializable { + private static final long serialVersionUID = -4198449565005940501L; + + private Integer index; + + @ApiModelProperty("人员ID") + private String userId; + @ApiModelProperty("姓名") + private String userName; + @ApiModelProperty("完成次数") + private Integer completeNum; + @ApiModelProperty("完成任务数量") + private List completeList; + @ApiModelProperty("未完成次数") + private Integer incompleteNum; + @ApiModelProperty("完成任务数量") + private List incompleteList; + @ApiModelProperty("备注") + private String remark; + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/StationRunReportAllVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/StationRunReportAllVO.java new file mode 100644 index 0000000..80697f7 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/StationRunReportAllVO.java @@ -0,0 +1,50 @@ +package com.hnac.hzims.operational.report.vo; + +import com.hnac.hzims.fdp.vo.StatisticStatusVO; +import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; +import com.hnac.hzinfo.inspect.task.vo.TaskReportVO; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +@Data +public class StationRunReportAllVO implements Serializable { + private static final long serialVersionUID = -3173423342834166988L; + + @ApiModelProperty("月报统计月份") + private String yearMonth; + + @ApiModelProperty("电站名称") + private String stationName; + + @ApiModelProperty("电站发电情况") + private List stationReportVOList; + + @ApiModelProperty("值班") + private List dutyReportVOList; + + @ApiModelProperty("日常维护") + private List maintenanceReportVOList; + + @ApiModelProperty("巡检") + private List inspectReportVOList; + + @ApiModelProperty("检修") + private List accessReportVOList; + + @ApiModelProperty("缺陷") + private List defectReportsVOList; + + @ApiModelProperty("两票") + private List ticketInfoStatisticVOList; + + @ApiModelProperty("智能诊断") + private List fdpRunReportVOList; + + @ApiModelProperty("建议") + private String suggestion; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/StationRunReportVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/StationRunReportVO.java new file mode 100644 index 0000000..11bb939 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/StationRunReportVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.operational.report.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class StationRunReportVO implements Serializable { + private static final long serialVersionUID = -8957498837980526029L; + @ApiModelProperty("序号") + private Integer index; + @ApiModelProperty(value = "电站名称") + private String stationName; + @ApiModelProperty(value = "月计划发电量") + private Double powerMonPlan; + @ApiModelProperty(value = "实发电量") + private String finishPowerMon; + @JsonSerialize(nullsUsing = NullSerializer.class) + @ApiModelProperty(value = "月度完成率") + private String powerMonRate; + @JsonSerialize(nullsUsing = NullSerializer.class) + @ApiModelProperty(value = "年度计划") + private Double powerYearPlan; + @JsonSerialize(nullsUsing = NullSerializer.class) + @ApiModelProperty(value = "已完成") + private String finishPowerYear; + @ApiModelProperty(value = "年度完成率") + private String powerYearRate; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java index ddfd1f9..c5afd70 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java @@ -127,6 +127,21 @@ public class TimeUtils { } return monthList; } + public static List getListByYearMon(Integer year,Integer mon) { + List monthList=new ArrayList<>(); + for (int i = 0; i getTicketReportStatistic(@RequestBody TicketStatisticDTO ticketStatisticDTO) { + List workTicketStatistic = new ArrayList<>(); String startDate = ticketStatisticDTO.getStartDate(); String endDate = ticketStatisticDTO.getEndDate(); String deptIds = ticketStatisticDTO.getDeptIds(); - Assert.isTrue(StringUtil.isNoneBlank(deptIds),()->{ + Assert.isTrue(StringUtil.isNoneBlank(deptIds), () -> { throw new ServiceException("站点统计月报工作票查询机构ID不能为空"); }); List deptIdList = Arrays.stream(deptIds.split(",")).map(Long::parseLong).collect(Collectors.toList()); // 统计工作票 - TicketInfoStatisticVO workTicketStatistic = firstWorkTicketService.workTicketReportStatistic(startDate, endDate, deptIdList); + workTicketStatistic = firstWorkTicketService.workTicketReportStatistic(startDate, endDate, deptIdList); // 统计操作票 - TicketInfoStatisticVO operateTicketStatistic = standardTicketInfoService.operateTicketReportStatistic(startDate,endDate,deptIdList); - //TODO 统计应急抢修单 - return Lists.newArrayList(workTicketStatistic,operateTicketStatistic); + List operateTicketStatistic = standardTicketInfoService.operateTicketReportStatistic(startDate, endDate, deptIdList); + if (CollectionUtil.isNotEmpty(operateTicketStatistic)) { + workTicketStatistic.addAll(operateTicketStatistic); + //TODO 统计应急抢修单 + } + if (CollectionUtil.isNotEmpty(workTicketStatistic)){ + AtomicInteger index = new AtomicInteger(1); + workTicketStatistic = workTicketStatistic.stream().map(s -> { + s.setIndex(index.get()); + index.getAndIncrement(); + return s; + }).collect(Collectors.toList()); + TicketInfoStatisticVO ticketInfoStatisticVO=new TicketInfoStatisticVO(); + ticketInfoStatisticVO.setTicketInfoType("合计"); + int sum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoNumber).sum(); + int CompleteNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoCompleteNum).sum(); + int InvalidatedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoInvalidatedNum).sum(); + int QualifiedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum(); + Double Proportion = new BigDecimal(QualifiedNum).divide(new BigDecimal(sum),2,BigDecimal.ROUND_UP).doubleValue(); + ticketInfoStatisticVO.setTicketInfoNumber(sum); + ticketInfoStatisticVO.setTicketInfoCompleteNum(CompleteNum); + ticketInfoStatisticVO.setTicketInfoInvalidatedNum(InvalidatedNum); + ticketInfoStatisticVO.setTicketInfoQualifiedNum(QualifiedNum); + ticketInfoStatisticVO.setTicketInfoProportion(Proportion); + workTicketStatistic.add(ticketInfoStatisticVO); + }else { + TicketInfoStatisticVO ticketInfoStatisticVO=new TicketInfoStatisticVO(); + ticketInfoStatisticVO.setTicketInfoType("合计"); + ticketInfoStatisticVO.setTicketInfoNumber(0); + ticketInfoStatisticVO.setTicketInfoCompleteNum(0); + ticketInfoStatisticVO.setTicketInfoInvalidatedNum(0); + ticketInfoStatisticVO.setTicketInfoQualifiedNum(0); + ticketInfoStatisticVO.setTicketInfoProportion(0.0); + workTicketStatistic.add(ticketInfoStatisticVO); + } + return workTicketStatistic; } @Override diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java index 52a9e55..f426add 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java @@ -94,7 +94,7 @@ public interface IStandardTicketInfoService extends BaseService deptIdList); + List operateTicketReportStatistic(String startDate, String endDate, List deptIdList); /** * 获取首页区域当月操作票/工作票 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java index 524c43c..6c08004 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java @@ -38,6 +38,7 @@ import com.hnac.hzims.ticket.utils.PdfUtils; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketReportStatisticVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -681,20 +682,33 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl deptIdList) { - TicketInfoStatisticVO result = new TicketInfoStatisticVO(); - result.setTicketInfoType("操作票"); + public List operateTicketReportStatistic(String startDate, String endDate, List deptIdList) { + List res = new ArrayList<>(); List operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList); + Map> operateTicket = operateTicketReportStatistic.stream().filter(o -> ObjectUtil.isNotEmpty(o.getTicketType())) + .collect(Collectors.groupingBy(OperateTicketStatisticVO::getTicketType)); if (CollectionUtil.isNotEmpty(operateTicketReportStatistic)) { - //已完成数量 - int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()).size(); - //合格数量 - int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); - //计算合格率 - double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue(); - result = TicketInfoStatisticVO.builder().ticketInfoType("操作票").ticketInfoNumber(operateTicketReportStatistic.size()).ticketInfoCompleteNum(ticketInfoCompleteNum).ticketInfoQualifiedNum(ticketInfoQualifiedNum).ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum).ticketInfoProportion(ticketInfoProportion).build(); - } - return result; + for (Map.Entry> typeOperateTicket : operateTicket.entrySet()) { + String type = TicketConstants.TicketTypeNameEnum.getTicketNameByType(typeOperateTicket.getKey()); + //已完成数量 + int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()).size(); + //合格数量 + int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); + //废票数量 + int ticketInfoInvalidatedNum = operateTicketReportStatistic.stream().filter(item -> "作废".equals(item.getFlowTaskName())).collect(Collectors.toList()).size(); + //计算合格率 + double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue(); + TicketInfoStatisticVO ticketInfoStatisticVO = TicketInfoStatisticVO.builder().ticketInfoType(type) + .ticketInfoNumber(operateTicketReportStatistic.size()) + .ticketInfoCompleteNum(ticketInfoCompleteNum) + .ticketInfoQualifiedNum(ticketInfoQualifiedNum) + .ticketInfoInvalidatedNum(ticketInfoInvalidatedNum) + .ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum) + .ticketInfoProportion(ticketInfoProportion).build(); + res.add(ticketInfoStatisticVO); + } + } + return res; } @@ -788,16 +802,17 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl operate(IPage page,OperateVo business) { + public IPage operate(IPage page, OperateVo business) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ge(Func.isNotEmpty(business.getStartTime()), "oper.create_time", business.getStartTime()); queryWrapper.le(Func.isNotEmpty(business.getEndTime()), "oper.create_time", business.getEndTime()); - queryWrapper.in(Func.isNotEmpty(business.getDeptIds()), "oper.create_dept",Func.toLongList(",",business.getDeptIds())); + queryWrapper.in(Func.isNotEmpty(business.getDeptIds()), "oper.create_dept", Func.toLongList(",", business.getDeptIds())); queryWrapper.like(Func.isNotEmpty(business.getCode()), "oper.code", business.getCode()); queryWrapper.eq(Func.isNotEmpty(business.getTicketType()), "oper.ticket_type", business.getTicketType()); queryWrapper.eq(Func.isNotEmpty(business.getStatus()), "eva.status", business.getStatus()); @@ -816,11 +831,11 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl standardTicketInfoEntities = super.baseMapper.selectList(queryWrapper); - List list=new ArrayList<>(); - if (CollectionUtils.isNotEmpty(standardTicketInfoEntities)){ - List standardTicketInfoVOS = standardTicketInfoEntities.parallelStream().map(standardTicketInfoEntity -> { - StandardTicketExportVO exportVO = new StandardTicketExportVO(); - try { + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(standardTicketInfoEntities)) { + List standardTicketInfoVOS = standardTicketInfoEntities.parallelStream().map(standardTicketInfoEntity -> { + StandardTicketExportVO exportVO = new StandardTicketExportVO(); + try { exportVO.setCompany(Optional.ofNullable(standardTicketInfoEntity.getCompany()).orElse(null)); exportVO.setTicketType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE, standardTicketInfoEntity.getTicketType())).orElse(null)); exportVO.setCode(Optional.ofNullable(standardTicketInfoEntity.getCode()).orElse(null)); @@ -853,22 +868,23 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl() {{ eq(TicketInfoEvaluateEntity::getTicketId, standardTicketInfoEntity.getId()); }}.last(" limit 1")); - if ( ObjectUtil.isNotEmpty(evaluateEntity)) { + if (ObjectUtil.isNotEmpty(evaluateEntity)) { exportVO.setIsEvaluate(evaluateEntity.getStatus() == 1 ? "合格" : "不合格"); } } - }}catch (Exception e){ - log.error("转换失败----》"+e.toString()+standardTicketInfoEntity.toString()); - System.out.println("转换失败----》"+e.toString()+standardTicketInfoEntity.toString()); } - return exportVO; - }).collect(Collectors.toList()); - return standardTicketInfoVOS; - }else { + } catch (Exception e) { + log.error("转换失败----》" + e.toString() + standardTicketInfoEntity.toString()); + System.out.println("转换失败----》" + e.toString() + standardTicketInfoEntity.toString()); + } + return exportVO; + }).collect(Collectors.toList()); + return standardTicketInfoVOS; + } else { return list; } } @@ -876,8 +892,8 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl params = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(detail); - params.put("measureMapList",this.convert(detail.getStandardTicketMeasureVOList())); + Map params = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(detail); + params.put("measureMapList", this.convert(detail.getStandardTicketMeasureVOList())); XWPFDocument xwpfDocument = null; String fileName = "template/电气操作票.docx"; try { @@ -885,15 +901,15 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl documents, String savePath) throws IOException { @@ -902,39 +918,35 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl convert (List list) { - if(CollectionUtil.isNotEmpty(list)) { + private List convert(List list) { + if (CollectionUtil.isNotEmpty(list)) { return IntStream.iterate(0, index -> index + 1).limit(list.size() > 25 ? list.size() : 25).mapToObj(index -> { - if(index <= list.size() - 1) { + if (index <= list.size() - 1) { Map result = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(list.get(index)); - result.put("index",index + 1); - result.put("status",TicketConstants.MATTER_FINISH_STATUS == result.get("status") ? "√" : null); + result.put("index", index + 1); + result.put("status", TicketConstants.MATTER_FINISH_STATUS == result.get("status") ? "√" : null); return result; - } - else { + } else { return new HashMap(); } }).collect(Collectors.toList()); } - return IntStream.iterate(0,index -> index + 1).limit(4).mapToObj(index -> new HashMap()).collect(Collectors.toList()); + return IntStream.iterate(0, index -> index + 1).limit(4).mapToObj(index -> new HashMap()).collect(Collectors.toList()); } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/IFirstWorkTicketService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/IFirstWorkTicketService.java index f6bc5ec..1ff11e5 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/IFirstWorkTicketService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/IFirstWorkTicketService.java @@ -133,5 +133,5 @@ public interface IFirstWorkTicketService extends ITwoTicketService deptIdList); + List workTicketReportStatistic(String startDate, String endDate, List deptIdList); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java index dff3284..47e620c 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java @@ -1073,38 +1073,57 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl deptIdList) { - TicketInfoStatisticVO workTicketStatistic = new TicketInfoStatisticVO(); - workTicketStatistic.setTicketInfoType("工作票"); + public List workTicketReportStatistic(String startDate, String endDate, List deptIdList) { + List res = new ArrayList<>(); // 统计工作票 List workTicketReportStatistic = this.baseMapper.getWorkTicketReportStatistic(startDate, endDate, deptIdList); + Map> workTicketMap = workTicketReportStatistic.stream().filter(o -> ObjectUtil.isNotEmpty(o.getType())) + .collect(Collectors.groupingBy(WorkTicketReportStatisticVO::getType)); if(CollectionUtil.isNotEmpty(workTicketReportStatistic)) { - // 工作票完成数量 - int ticketInfoCompleteNum = workTicketReportStatistic.stream().filter(item -> "结束".equals(item.getFlowTaskName())) - .collect(Collectors.toList()).size(); - // 工作票未完成数量 - int ticketInfoStartNum = workTicketReportStatistic.size() - ticketInfoCompleteNum; - // 延期数量统计 - int ticketInfoDelayNum = workTicketReportStatistic.stream().filter(item -> "延期".equals(item.getInput())) - .collect(Collectors.toList()).size(); - // 合格数量统计 - int ticketInfoQualifiedNum = workTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && ticket.getEvaluation().intValue() == 1) - .collect(Collectors.toList()).size(); - //计算合格率 - Double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) workTicketReportStatistic.size() *100) - .setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); - - workTicketStatistic = TicketInfoStatisticVO.builder() - .ticketInfoType("工作票") - .ticketInfoNumber(workTicketReportStatistic.size()) - .ticketInfoCompleteNum(ticketInfoCompleteNum) - .ticketInfoStartNum(ticketInfoStartNum) - .ticketInfoDelayNum(ticketInfoDelayNum) - .ticketInfoQualifiedNum(ticketInfoQualifiedNum) - .ticketInfoProportion(ticketInfoProportion) - .build(); + for (Map.Entry> typeWorkTicket : workTicketMap.entrySet()) { + String ticketInfoType=""; + switch (typeWorkTicket.getKey()){ + case "6": + ticketInfoType="第一种工作票"; + break; + case "7": + ticketInfoType="第二种工作票"; + break; + case "8": + ticketInfoType="机械工作票"; + break; + } + // 工作票完成数量 + int ticketInfoCompleteNum = typeWorkTicket.getValue().stream().filter(item -> "结束".equals(item.getFlowTaskName())) + .collect(Collectors.toList()).size(); + // 工作票未完成数量 + int ticketInfoStartNum = typeWorkTicket.getValue().size() - ticketInfoCompleteNum; + // 延期数量统计 + int ticketInfoDelayNum = typeWorkTicket.getValue().stream().filter(item -> "延期".equals(item.getInput())) + .collect(Collectors.toList()).size(); + // 废票数量统计 + int invalidatedNum = typeWorkTicket.getValue().stream().filter(item -> "废票".equals(item.getFlowTaskName())) + .collect(Collectors.toList()).size(); + // 合格数量统计 + int ticketInfoQualifiedNum = typeWorkTicket.getValue().stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && ticket.getEvaluation().intValue() == 1) + .collect(Collectors.toList()).size(); + //计算合格率 + Double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) workTicketReportStatistic.size() *100) + .setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); + TicketInfoStatisticVO workTicketStatistic = TicketInfoStatisticVO.builder() + .ticketInfoType(ticketInfoType) + .ticketInfoNumber(workTicketReportStatistic.size()) + .ticketInfoCompleteNum(ticketInfoCompleteNum) + .ticketInfoStartNum(ticketInfoStartNum) + .ticketInfoDelayNum(ticketInfoDelayNum) + .ticketInfoInvalidatedNum(invalidatedNum) + .ticketInfoQualifiedNum(ticketInfoQualifiedNum) + .ticketInfoProportion(ticketInfoProportion) + .build(); + res.add(workTicketStatistic); + } } - return workTicketStatistic; + return res; } /** diff --git a/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/TicketApplicationTest.java b/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/TicketApplicationTest.java index f103792..59a498a 100644 --- a/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/TicketApplicationTest.java +++ b/hzims-service/ticket/src/test/java/com/hnac/hzims/ticket/TicketApplicationTest.java @@ -81,8 +81,8 @@ public class TicketApplicationTest { String startDate = "2022-07-01"; String endDate = "2022-07-31"; List deptIdList = Lists.newArrayList(2000000109L); - TicketInfoStatisticVO ticketInfoStatisticVO = firstWorkTicketService.workTicketReportStatistic(startDate, endDate, deptIdList); - log.info("{}",JSON.toJSONString(ticketInfoStatisticVO)); +// TicketInfoStatisticVO ticketInfoStatisticVO = firstWorkTicketService.workTicketReportStatistic(startDate, endDate, deptIdList); +// log.info("{}",JSON.toJSONString(ticketInfoStatisticVO)); }