Browse Source

fix:
修改了一些bug

18339543638 1 năm trước cách đây
mục cha
commit
dd4f5fb0e5

+ 9 - 2
nb-service/web-service/src/main/java/com/nb/web/service/bus/controller/BusPatientController.java

@@ -129,12 +129,19 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
         if(CollUtil.isEmpty(patients)){
             throw new CustomException("病号不存在,请刷新后重试");
         }
+        List<String> infusionIds = patients.stream()
+                .map(BusPatientEntity::getInfusionId)
+                .filter(StrUtil::isNotEmpty)
+                .collect(Collectors.toList());
+        if(CollectionUtil.isEmpty(infusionIds)){
+            return R.success(false);
+        }
         return R.success(infusionService.count(new QueryWrapper<BusInfusionHistoryEntity>()
                 .lambda()
                 .nested(i->i.ne(BusInfusionHistoryEntity::getRunState,DeviceStatusEnum.Shutdown)
                         .ne(BusInfusionHistoryEntity::getRunState,DeviceStatusEnum.NoSignal))
-                .in(BusInfusionHistoryEntity::getPatientId,patients.stream().map(BusPatientEntity::getId).collect(Collectors.toList()))
-                .eq(BusInfusionHistoryEntity::getFinished,false))!=0);
+                .in(BusInfusionHistoryEntity::getId,infusionIds)
+        )!=0);
     }
 
     @PostMapping("/do/{monitorType}/finished")

+ 19 - 2
nb-service/web-service/src/main/java/com/nb/web/service/bus/mapper/BusPatientMapper.java

@@ -9,6 +9,7 @@ import com.nb.web.service.bus.service.dto.PatientDeviceNoneResult;
 import com.nb.web.api.feign.query.PatientMonitorQuery;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.web.bind.annotation.PathVariable;
 
 import java.util.*;
 /**
@@ -20,19 +21,35 @@ import java.util.*;
  */
 @Mapper
 public interface BusPatientMapper extends BaseMapper<BusPatientEntity> {
+    /**
+     * 查询给定医院下所有同时挂载多个泵的病患信息
+     * @param
+     * @return
+     */
+    default List<PatientDeviceRepeatDomain> selectRepeatDevice(){
+        return selectRepeatDevice(null);
+    };
+    /**
+     * 查询给定医院下所有同时挂载多个泵的病患信息
+     * @param
+     * @return
+     */
+    List<PatientDeviceRepeatDomain> selectRepeatDevice(@Param("tenantId") String tenantId);
 
     /**
      * 查询给定医院下所有同时挂载多个泵的病患信息
      * @param
      * @return
      */
-    List<PatientDeviceRepeatDomain> selectRepeatDevice();
+    default List<PatientDeviceNoneResult> selectNoneDevice(){
+        return selectNoneDevice(null);
+    };
 
     /**
      * 查询当前医院下所有没有泵的病患信息
      * @return
      */
-    List<PatientDeviceNoneResult> selectNoneDevice();
+    List<PatientDeviceNoneResult> selectNoneDevice(@Param("tenantId") String tenantId);
 
     /**
      * 查询监控病患列表, 不分页

+ 5 - 2
nb-service/web-service/src/main/java/com/nb/web/service/bus/utils/WsPublishUtils.java

@@ -1,9 +1,11 @@
 package com.nb.web.service.bus.utils;
 
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.nb.web.api.enums.PatientAlarmEnum;
+import com.nb.web.service.bus.mapper.BusPatientMapper;
 import com.nb.web.service.bus.service.LocalBusPatientService;
 import com.nb.web.service.bus.service.dto.MonitorStatusStatsCountResult;
 import com.nb.web.api.feign.result.PatientMonitorResult;
@@ -31,6 +33,7 @@ import java.io.Serializable;
 @Slf4j
 public class WsPublishUtils implements Serializable{
     private final LocalBusPatientService patientService;
+    private final BusPatientMapper patientMapper;
     private final RedissonUtil redissonUtil;
 
     private void publish(String topic,TopicMessage msg){
@@ -106,7 +109,7 @@ public class WsPublishUtils implements Serializable{
 //    @Async
     public void publishDeviceRepeat(String tenantId){
         Assert.hasText(tenantId,"医院id不能为空");
-        JSONObject message = new JSONObject().putOpt("count", patientService.patientAlarmCount(tenantId,PatientAlarmEnum.DEVICE_REPEAT));
+        JSONObject message = new JSONObject().putOpt("count", CollectionUtil.size(patientMapper.selectRepeatDevice(tenantId)));
         this.publish(WebSocketConstant.getDeviceRepeat(tenantId).getTopic(),
                 TopicMessage.of(message,tenantId)
         );
@@ -122,7 +125,7 @@ public class WsPublishUtils implements Serializable{
 //    @Async
     public void publishDeviceNone(String tenantId){
         Assert.hasText(tenantId,"医院id不能为空");
-        JSONObject message = new JSONObject().putOpt("count",patientService.patientAlarmCount(tenantId,PatientAlarmEnum.DEVICE_NONE));
+        JSONObject message = new JSONObject().putOpt("count",CollectionUtil.size(patientMapper.selectNoneDevice(tenantId)));
         this.publish(WebSocketConstant.getDeviceNone(tenantId).getTopic(),
                 TopicMessage.of(message,tenantId)
         );