Browse Source

调整统计通讯中断时间接口

zhongwei
tyty 2 years ago
parent
commit
1c8d6a2f8d
  1. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java
  2. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java
  3. 26
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

4
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") @GetMapping("/queryByEntity")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "统计通讯中断二级目录查询", notes = "传入imsDutyMainEntity") @ApiOperation(value = "统计通讯中断二级目录查询", notes = "传入imsDutyMainEntity")
public R<IPage<HistoryAbnormalAlarmEntity>> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { public R<IPage<HistoryAbnormalAlarmVo>> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) {
IPage<HistoryAbnormalAlarmEntity> pages = service.queryByEntity(entity,query); IPage<HistoryAbnormalAlarmVo> pages = service.queryByEntity(entity,query);
return R.data(pages); return R.data(pages);
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java

@ -25,7 +25,7 @@ public interface HistoryAbnormalAlarmService extends BaseService<HistoryAbnormal
IPage<HistoryAbnormalAlarmVo> getAlarmTime(Query query, HistoryAbnormalAlarmEntity entity); IPage<HistoryAbnormalAlarmVo> getAlarmTime(Query query, HistoryAbnormalAlarmEntity entity);
IPage<HistoryAbnormalAlarmEntity> queryByEntity(HistoryAbnormalAlarmEntity entity,Query query); IPage<HistoryAbnormalAlarmVo> queryByEntity(HistoryAbnormalAlarmEntity entity,Query query);
// 智能告警数量: 时间范围当天 // 智能告警数量: 时间范围当天
List<IntelligentAlarmCountVo> alarmCount(); List<IntelligentAlarmCountVo> alarmCount();

26
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

@ -158,7 +158,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
private QueryWrapper<HistoryAbnormalAlarmEntity> getAlarmEntityQueryWrapper(HistoryAbnormalAlarmEntity entity) { private QueryWrapper<HistoryAbnormalAlarmEntity> getAlarmEntityQueryWrapper(HistoryAbnormalAlarmEntity entity) {
QueryWrapper<HistoryAbnormalAlarmEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<HistoryAbnormalAlarmEntity> queryWrapper = new QueryWrapper<>();
if (entity.getStationName() != null) { if (entity.getStationName() != null) {
queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getStationName, entity.getStationName()); queryWrapper.lambda().like(HistoryAbnormalAlarmEntity::getStationName, entity.getStationName());
} }
if (entity.getType() != null) { if (entity.getType() != null) {
queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getType, entity.getType()); queryWrapper.lambda().eq(HistoryAbnormalAlarmEntity::getType, entity.getType());
@ -173,10 +173,30 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
} }
@Override @Override
public IPage<HistoryAbnormalAlarmEntity> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { public IPage<HistoryAbnormalAlarmVo> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) {
QueryWrapper<HistoryAbnormalAlarmEntity> alarmEntityQueryWrapper = getAlarmEntityQueryWrapper(entity); QueryWrapper<HistoryAbnormalAlarmEntity> alarmEntityQueryWrapper = getAlarmEntityQueryWrapper(entity);
IPage<HistoryAbnormalAlarmEntity> historyAbnormalAlarmEntityIPage = this.baseMapper.selectPage(Condition.getPage(query), alarmEntityQueryWrapper); IPage<HistoryAbnormalAlarmEntity> historyAbnormalAlarmEntityIPage = this.baseMapper.selectPage(Condition.getPage(query), alarmEntityQueryWrapper);
return historyAbnormalAlarmEntityIPage; List<HistoryAbnormalAlarmEntity> records = historyAbnormalAlarmEntityIPage.getRecords();
List<HistoryAbnormalAlarmVo> voList =new ArrayList<>();
if (records.size()>0) {
List<HistoryAbnormalAlarmVo> 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<HistoryAbnormalAlarmVo> page = Condition.getPage(query);
page.setTotal(historyAbnormalAlarmEntityIPage.getTotal());
page.setRecords(voList);
return page;
} }
/** /**

Loading…
Cancel
Save