|
|
@@ -6,13 +6,16 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.nb.bus.entity.BusDeviceAlarmEntity;
|
|
|
import com.nb.bus.entity.BusHospitalEntity;
|
|
|
+import com.nb.bus.entity.BusInfusionHistoryEntity;
|
|
|
import com.nb.bus.enums.DeviceAlarmEnum;
|
|
|
+import com.nb.bus.enums.FlowStatusEnum;
|
|
|
import com.nb.bus.mapper.BusDeviceAlarmMapper;
|
|
|
-import com.nb.bus.mapper.BusHospitalMapper;
|
|
|
import com.nb.bus.service.dto.*;
|
|
|
import com.nb.common.crud.BaseService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -29,18 +32,61 @@ import java.util.Map;
|
|
|
* @createTime 2022年03月19日 09:27:00
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
@AllArgsConstructor
|
|
|
public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper, BusDeviceAlarmEntity,String> {
|
|
|
+
|
|
|
@Autowired
|
|
|
- private BusDeviceAlarmMapper busDeviceAlarmMapper;
|
|
|
+ @Lazy
|
|
|
+ private LocalBusHospitalService hospitalService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private BusHospitalMapper hospitalMapper;
|
|
|
+ @Lazy
|
|
|
+ private LocalBusInfusionHistoryService infusionHistoryService;
|
|
|
|
|
|
@Override
|
|
|
public void validateBeforeSave(BusDeviceAlarmEntity entity) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean save(BusDeviceAlarmEntity entity) {
|
|
|
+ BusInfusionHistoryEntity infusionHistoryEntity = infusionHistoryService.getById(entity.getInfusionId());
|
|
|
+ if(entity.getDeviceType()==null){
|
|
|
+ entity.setDeviceType(infusionHistoryEntity.getType());
|
|
|
+ }
|
|
|
+ if(entity.getAlarmState()==null){
|
|
|
+ entity.setAlarmState(DeviceAlarmEnum.None);
|
|
|
+ }
|
|
|
+ if(entity.getWarnAnalgesicPoor()==null){
|
|
|
+ entity.setWarnAnalgesicPoor(false);
|
|
|
+ }
|
|
|
+ if(entity.getWarnFlow()==null){
|
|
|
+ entity.setWarnFlow(FlowStatusEnum.None);
|
|
|
+ }
|
|
|
+ if(entity.getWarnWillFinished()==null){
|
|
|
+ entity.setWarnWillFinished(false);
|
|
|
+ }
|
|
|
+ if(entity.getWarnLowBattery()==null){
|
|
|
+ entity.setWarnLowBattery(false);
|
|
|
+ }
|
|
|
+ if(entity.getWarnAnalgesicPoor()==null){
|
|
|
+ entity.setWarnAnalgesicPoor(false);
|
|
|
+ }
|
|
|
+ if(!entity.alarmOrWarn()){
|
|
|
+ //无警报信息,存储失败
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ BusDeviceAlarmEntity existAlarm = BusDeviceAlarmEntity.parseRunning(infusionHistoryEntity);
|
|
|
+ if (entity.signParm().equalsIgnoreCase(existAlarm.signParm())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //再判断是否报警或提示是否发生重复
|
|
|
+ //满足以上条件进行保存
|
|
|
+ return super.save(entity);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void validateBeforeUpdate(BusDeviceAlarmEntity entity) {
|
|
|
|
|
|
@@ -86,12 +132,12 @@ public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper
|
|
|
if(query.getTenantId()!=null){
|
|
|
busHospitalEntityQueryWrapper.getEntity().setId(query.getTenantId());
|
|
|
}
|
|
|
- List<BusHospitalEntity> hospitalEntities = hospitalMapper.selectList(busHospitalEntityQueryWrapper);
|
|
|
+ List<BusHospitalEntity> hospitalEntities = hospitalService.getBaseMapper().selectList(busHospitalEntityQueryWrapper);
|
|
|
|
|
|
List<DeviceUse> deviceUseList = new ArrayList<>();
|
|
|
|
|
|
// 获取 报警所有信息数量
|
|
|
- List<DeviceAlarmCountResult> alarmResults = busDeviceAlarmMapper.selectAlarmCount(query);
|
|
|
+ List<DeviceAlarmCountResult> alarmResults = this.baseMapper.selectAlarmCount(query);
|
|
|
|
|
|
//处理报警信息
|
|
|
Map<String,Map<String,String>> alarmMap= new HashMap<>();
|
|
|
@@ -113,7 +159,7 @@ public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper
|
|
|
|
|
|
|
|
|
// 获取告警信息
|
|
|
- List<DeviceWarnCountResult> warnResults = busDeviceAlarmMapper.selectWarnCount(query);
|
|
|
+ List<DeviceWarnCountResult> warnResults = this.baseMapper.selectWarnCount(query);
|
|
|
//处理告警信息
|
|
|
for (DeviceWarnCountResult deviceWarnCountResult : warnResults
|
|
|
) {
|
|
|
@@ -166,7 +212,7 @@ public class LocalBusDeviceAlarmService extends BaseService<BusDeviceAlarmMapper
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public List<DeviceCountResult> selectUseDetail(BusDeviceAlarmEntity query){
|
|
|
|
|
|
- return busDeviceAlarmMapper.selectDeviceCount(query);
|
|
|
+ return this.baseMapper.selectDeviceCount(query);
|
|
|
|
|
|
}
|
|
|
|