|
|
|
@ -158,7 +158,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl<HistoryAbno
|
|
|
|
|
private QueryWrapper<HistoryAbnormalAlarmEntity> getAlarmEntityQueryWrapper(HistoryAbnormalAlarmEntity entity) { |
|
|
|
|
QueryWrapper<HistoryAbnormalAlarmEntity> 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<HistoryAbno
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<HistoryAbnormalAlarmEntity> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { |
|
|
|
|
public IPage<HistoryAbnormalAlarmVo> queryByEntity(HistoryAbnormalAlarmEntity entity, Query query) { |
|
|
|
|
QueryWrapper<HistoryAbnormalAlarmEntity> alarmEntityQueryWrapper = getAlarmEntityQueryWrapper(entity); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|