diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java index e6721fb..b5f6d1b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java @@ -47,8 +47,8 @@ public class AbnormalAlarmController extends BladeController { @GetMapping("/queryByEntity") @ApiOperationSupport(order = 1) @ApiOperation(value = "统计通讯中断二级目录查询", notes = "传入imsDutyMainEntity") - public R> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { - IPage pages = service.queryByEntity(entity,query); + public R> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { + IPage pages = service.queryByEntity(entity,query); return R.data(pages); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java index 0682ecf..41fce42 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java @@ -25,7 +25,7 @@ public interface HistoryAbnormalAlarmService extends BaseService getAlarmTime(Query query, HistoryAbnormalAlarmEntity entity); - IPage queryByEntity(HistoryAbnormalAlarmEntity entity,Query query); + IPage queryByEntity(HistoryAbnormalAlarmEntity entity,Query query); // 智能告警数量: 时间范围当天 List alarmCount(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index 1773c0c..5c8b08b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -158,7 +158,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl getAlarmEntityQueryWrapper(HistoryAbnormalAlarmEntity entity) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (entity.getStationName() != null) { - queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getStationName, entity.getStationName()); + queryWrapper.lambda().like(HistoryAbnormalAlarmEntity::getStationName, entity.getStationName()); } if (entity.getType() != null) { queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getType, entity.getType()); @@ -173,10 +173,30 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { + public IPage queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { QueryWrapper alarmEntityQueryWrapper = getAlarmEntityQueryWrapper(entity); IPage historyAbnormalAlarmEntityIPage = this.baseMapper.selectPage(Condition.getPage(query), alarmEntityQueryWrapper); - return historyAbnormalAlarmEntityIPage; + List records = historyAbnormalAlarmEntityIPage.getRecords(); + List voList =new ArrayList<>(); + if (records.size()>0) { + List historyAbnormalAlarmVos = BeanUtil.copy(records, HistoryAbnormalAlarmVo.class); + //赋值空的endTime + if (ObjectUtils.isNotEmpty(entity.getEndTime())) { + historyAbnormalAlarmVos.stream().filter(s -> s.getEndTime() == null).forEach(s -> s.setEndTime(entity.getEndTime())); + } else { + historyAbnormalAlarmVos.stream().filter(s -> s.getEndTime() == null).forEach(s -> s.setEndTime(new Date())); + } + voList= historyAbnormalAlarmVos.parallelStream().map(s -> { + long duration = s.getEndTime().getTime() - s.getStartTime().getTime(); + double v = BigDecimal.valueOf(duration / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + s.setDuration(v); + return s; + }).collect(Collectors.toList()); + } + IPage page = Condition.getPage(query); + page.setTotal(historyAbnormalAlarmEntityIPage.getTotal()); + page.setRecords(voList); + return page; } /**