Browse Source

#告警数据来源统计修改

zhongwei
yang_shj 12 months ago
parent
commit
9d139cf89f
  1. 4
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java
  2. 2
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java
  3. 13
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

4
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/controller/ShowAlarmController.java

@ -55,8 +55,8 @@ public class ShowAlarmController extends BladeController {
@PostMapping("/count")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "告警分类数量", notes = "不需要传入参数")
public R<List<AlarmCountVo>> counts() {
return R.data(alarmService.counts());
public R<List<AlarmCountVo>> counts(@RequestBody AlarmEntity alarm) {
return R.data(alarmService.counts(alarm));
}
}

2
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java

@ -14,7 +14,7 @@ public interface AlarmService extends BaseService<AlarmEntity> {
IPage<AlarmEntity> alarms(AlarmEntity alarm, IPage<AlarmEntity> page);
List<AlarmCountVo> counts();
List<AlarmCountVo> counts(AlarmEntity alarm);
List<AlarmEntity> broadcast(String startTime, String endTime);
}

13
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java

@ -98,7 +98,7 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
* @return
*/
@Override
public List<AlarmCountVo> counts() {
public List<AlarmCountVo> counts(AlarmEntity alarm) {
// 站点查询
List<StationEntity> stations = this.stations();
if(CollectionUtil.isEmpty(stations)){
@ -114,13 +114,22 @@ public class AlarmServiceImpl extends BaseServiceImpl<AlarmMapper, AlarmEntity>
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.eq("IS_RIGHT_TABULATION",0);
wrapper.in("STATION_ID",stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
if(!StringUtil.isEmpty(alarm.getStationId())){
wrapper.eq("STATION_ID",alarm.getStationId());
}
if(!StringUtil.isEmpty(alarm.getAlarmSource())){
wrapper.eq("ALARM_SOURCE",alarm.getAlarmSource());
}
if(!StringUtil.isEmpty(alarm.getAlarmType())){
wrapper.eq("ALARM_TYPE",alarm.getAlarmType());
}
// 查询告警数据
List<AlarmEntity> alarms = this.list(wrapper);
// 查询数量
return AlarmConstants.ALARAM_SOURCE.stream().map(source->{
AlarmCountVo count = new AlarmCountVo();
count.setType(source);
if(CollectionUtil.isNotEmpty(alarms)){
if(CollectionUtil.isEmpty(alarms)){
count.setCount(0L);
}else{
count.setCount(alarms.stream().filter(o->o.getAlarmSource().equals(source)).count());

Loading…
Cancel
Save