|
|
@@ -1,17 +1,29 @@
|
|
|
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.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.coffee.bus.entity.BusClinicEntity;
|
|
|
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.bus.service.dto.AlarmQuery;
|
|
|
+import com.coffee.bus.service.dto.DeviceAlarmQuery;
|
|
|
+import com.coffee.bus.service.dto.DeviceUse;
|
|
|
import com.coffee.common.crud.BaseService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
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
|
|
|
@@ -22,6 +34,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper, BusDeviceAlarmEntity,String> {
|
|
|
+ @Autowired
|
|
|
+ private BusDeviceAlarmMapper busDeviceAlarmMapper;
|
|
|
+ @Autowired
|
|
|
+ BusHospitalMapper hospitalMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void validateBeforeSave(BusDeviceAlarmEntity entity) {
|
|
|
|
|
|
@@ -56,4 +73,54 @@ 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> selectCountAlarm(DeviceAlarmQuery query){
|
|
|
+ QueryWrapper<BusHospitalEntity> busHospitalEntityQueryWrapper = new QueryWrapper<>();
|
|
|
+ if(query.getHositalName()!=null){
|
|
|
+ busHospitalEntityQueryWrapper.getEntity().setName(query.getHositalName());
|
|
|
+ }
|
|
|
+ List<BusHospitalEntity> hospitalEntities = hospitalMapper.selectList(busHospitalEntityQueryWrapper);
|
|
|
+ List<DeviceUse> deviceUseList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (BusHospitalEntity hospital:
|
|
|
+ hospitalEntities) {
|
|
|
+ DeviceUse deviceUse = new DeviceUse();
|
|
|
+ Map<String, Integer> deviceAlarms = new HashMap<>();
|
|
|
+
|
|
|
+ deviceUse.setName(hospital.getName());
|
|
|
+ deviceUse.setAddress(hospital.getAddress());
|
|
|
+ deviceUse.setDeviceAlarms(deviceAlarms);
|
|
|
+
|
|
|
+
|
|
|
+ query.setTenantId(hospital.getId());
|
|
|
+
|
|
|
+ for (DeviceAlarmEnum alarmEnum:
|
|
|
+ DeviceAlarmEnum.values()) {
|
|
|
+ query.setAlarmState(alarmEnum.getValue());
|
|
|
+ deviceAlarms.put(alarmEnum.getText(),busDeviceAlarmMapper.selectAlarmCount(query));
|
|
|
+ }
|
|
|
+ query.setAlarmState(null);
|
|
|
+ /*输注即将结束提醒*/
|
|
|
+ query.setWarnWillFinished(1);
|
|
|
+ deviceAlarms.put("warnWillFinished",busDeviceAlarmMapper.selectAlarmCount(query));
|
|
|
+ query.setWarnWillFinished(null);
|
|
|
+ /*镇痛不足提醒*/
|
|
|
+ query.setWarnAnalgesicPoor(1);
|
|
|
+ deviceAlarms.put("warnAnalgesicPoor",busDeviceAlarmMapper.selectAlarmCount(query));
|
|
|
+ query.setWarnAnalgesicPoor(null);
|
|
|
+ /*电量偏低提醒*/
|
|
|
+ query.setWarnWillFinished(1);
|
|
|
+ deviceAlarms.put("warnLowBattery",busDeviceAlarmMapper.selectAlarmCount(query));
|
|
|
+ query.setWarnWillFinished(null);
|
|
|
+
|
|
|
+ deviceUseList.add(deviceUse);
|
|
|
+
|
|
|
+ }
|
|
|
+ return deviceUseList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|