15638522405 3 vuotta sitten
vanhempi
commit
9c48c99cfe

+ 35 - 0
coffee-admin/src/test/java/com/coffee/admin/BusPatientTest.java

@@ -1,5 +1,11 @@
 package com.coffee.admin;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.coffee.bus.controller.vo.DeviceUse;
+import com.coffee.bus.entity.BusDeviceAlarmEntity;
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.mapper.BusDeviceAlarmMapper;
+import com.coffee.bus.service.LocalBusDeviceAlarmService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
 import org.junit.Test;
@@ -22,10 +28,39 @@ import java.util.List;
 public class BusPatientTest {
     @Autowired
     private LocalBusPatientService patientService;
+    @Autowired
+    private LocalBusDeviceAlarmService deviceAlarmService;
+    @Autowired
+    private BusDeviceAlarmMapper deviceAlarmMapper;
 
     @Test
     public  void test(){
         List<PatientDeviceRepeatResult> patientDeviceRepeatResults = patientService.repeatDevice();
         System.out.println(patientDeviceRepeatResults);
     }
+
+    @Test
+    public  void test1(){
+        List<DeviceUse> deviceUseList = deviceAlarmService.countAlarm();
+        for (DeviceUse d:
+             deviceUseList) {
+            System.out.println(d);
+        }
+    }
+    @Test
+    public  void test2(){
+
+        QueryWrapper<BusDeviceAlarmEntity> busDeviceAlarmEntityQueryWrapper = new QueryWrapper<>();
+        BusDeviceAlarmEntity busDeviceAlarmEntity = new BusDeviceAlarmEntity();
+
+        //busDeviceAlarmEntity.setTenantId("1");
+        busDeviceAlarmEntityQueryWrapper.setEntity(busDeviceAlarmEntity);
+        busDeviceAlarmEntity.setAlarm(DeviceAlarmEnum.LowBattery);
+
+        System.out.println(busDeviceAlarmEntityQueryWrapper.getEntity().getAlarm());
+        //System.out.println("----------------------------------------"+busDeviceAlarmEntityQueryWrapper.getEntity().getTenantId());
+        System.out.println("=================================="+deviceAlarmMapper.selectCount(busDeviceAlarmEntityQueryWrapper));
+    }
+
+
 }

+ 2 - 0
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceController.java

@@ -39,4 +39,6 @@ public class BusDeviceController extends BaseCrudController<BusDeviceEntity, Str
     public BaseService<? extends Mapper<BusDeviceEntity>, BusDeviceEntity, String> getService() {
         return deviceRegisteredService;
     }
+
+
 }

+ 1 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceAlarmMapper.java

@@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface BusDeviceAlarmMapper extends BaseMapper<BusDeviceAlarmEntity> {
 
+    void selectCount(BusDeviceAlarmEntity busDeviceAlarmEntity);
 }

+ 14 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceMapper.java

@@ -1,8 +1,11 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceEntity;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * @author lifang
@@ -14,4 +17,15 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface BusDeviceMapper extends BaseMapper<BusDeviceEntity> {
 
+    /**
+     * 获取病号最近一场手术信息
+     * @param hospitalId
+     * @param patientCode
+     * @return
+     */
+    @Select("select * from bus_clinic where tenant_id=#{hospitalId} and patient_code=#{patientCode} order by start_time DESC limit 0,1")
+    BusClinicEntity recentClinic(@Param("hospitalId") String hospitalId, @Param("patientCode") String patientCode);
+
+
+
 }

+ 48 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceAlarmService.java

@@ -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;
+
+    }
 }

+ 3 - 2
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java

@@ -37,8 +37,7 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
 
     @Override
     public void validateBeforeDelete(String id) {
-
-    }
+     }
 
     @Override
     public void postSave(BusDeviceEntity entity) {
@@ -65,4 +64,6 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
         BusDeviceEntity registeredEntity = this.getById(id);
         deviceRegistry.remove(registeredEntity.getDeviceId());
     }
+
+
 }