|
|
@@ -1,14 +1,24 @@
|
|
|
package com.coffee.bus.service;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.coffee.bus.controller.vo.DeviceUse;
|
|
|
import com.coffee.bus.entity.BusDeviceAlarmEntity;
|
|
|
+import com.coffee.bus.entity.BusHospitalEntity;
|
|
|
+import com.coffee.bus.enums.DeviceAlarmEnum;
|
|
|
import com.coffee.bus.mapper.BusDeviceAlarmMapper;
|
|
|
+import com.coffee.bus.mapper.BusHospitalMapper;
|
|
|
import com.coffee.common.crud.BaseService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* @author lifang
|
|
|
* @version 1.0.0
|
|
|
@@ -19,6 +29,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper, BusDeviceAlarmEntity,String> {
|
|
|
+ private final BusDeviceAlarmMapper deviceAlarmMapper;
|
|
|
+ private final BusHospitalMapper hospitalMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void validateBeforeSave(BusDeviceAlarmEntity entity) {
|
|
|
|
|
|
@@ -34,6 +47,7 @@ public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 添加报警原因
|
|
|
* @param id
|
|
|
@@ -50,4 +64,38 @@ public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper
|
|
|
}
|
|
|
this.update(new UpdateWrapper<BusDeviceAlarmEntity>().lambda().eq(BusDeviceAlarmEntity::getId,id).set(BusDeviceAlarmEntity::getCause,cause));
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看报警数量
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public List<DeviceUse> countAlarm(){
|
|
|
+ List<BusHospitalEntity> hospitalList = hospitalMapper.selectList(new QueryWrapper<>());
|
|
|
+ List<DeviceUse> deviceUseList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (BusHospitalEntity hospital:
|
|
|
+ hospitalList) {
|
|
|
+ DeviceUse deviceUse = new DeviceUse();
|
|
|
+ deviceUse.setName(hospital.getName());
|
|
|
+ deviceUse.setAddress(hospital.getAddress());
|
|
|
+ Map<DeviceAlarmEnum, Long> deviceAlarms = new HashMap<>();
|
|
|
+ deviceUse.setDeviceAlarms(deviceAlarms);
|
|
|
+
|
|
|
+ QueryWrapper<BusDeviceAlarmEntity> busDeviceAlarmEntityQueryWrapper = new QueryWrapper<>();
|
|
|
+ BusDeviceAlarmEntity busDeviceAlarmEntity = new BusDeviceAlarmEntity();
|
|
|
+ busDeviceAlarmEntityQueryWrapper.setEntity(busDeviceAlarmEntity);
|
|
|
+ busDeviceAlarmEntity.setTenantId(hospital.getId());
|
|
|
+ for (DeviceAlarmEnum alarmEnum:
|
|
|
+ DeviceAlarmEnum.values()) {
|
|
|
+ busDeviceAlarmEntity.setAlarm(alarmEnum);
|
|
|
+ deviceAlarms.put(alarmEnum,deviceAlarmMapper.selectCount(busDeviceAlarmEntityQueryWrapper));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ deviceUseList.add(deviceUse);
|
|
|
+
|
|
|
+ }
|
|
|
+ return deviceUseList;
|
|
|
+
|
|
|
+ }
|
|
|
}
|