Parcourir la source

添加查询缓存

18339543638 il y a 1 an
Parent
commit
7a2df1b527

+ 31 - 0
nb-service-api/web-service-api/src/main/java/com/nb/web/api/feign/query/PatientMonitorQuery.java

@@ -1,6 +1,8 @@
 package com.nb.web.api.feign.query;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.nb.web.api.enums.DeviceAlarmEnum;
 import com.nb.web.api.enums.DeviceTypeEnum;
 import com.nb.web.api.enums.DeviceStatusEnum;
@@ -147,4 +149,33 @@ public class PatientMonitorQuery  implements Serializable {
         this.setDeviceAlias(blurry);
         this.setProductNo(blurry);
     }
+
+    /**
+     * 是否查询全部
+     * @return
+     */
+    public Boolean selectAll(){
+        return StrUtil.isEmpty(blurry)
+                &&CollectionUtil.isEmpty(wards)
+                &&StrUtil.isEmpty(bedNo)
+                &&StrUtil.isEmpty(name)
+                &&StrUtil.isEmpty(code)
+                &&StrUtil.isEmpty(deviceId)
+                &&StrUtil.isEmpty(deviceAlias)
+                &&StrUtil.isEmpty(productNo)
+                &&StrUtil.isEmpty(anaDoctor)
+                &&StrUtil.isEmpty(surgeName)
+                && ObjectUtil.isNull(gender)
+                &&StrUtil.isEmpty(anaType)
+                &&CollectionUtil.isEmpty(types)
+                &&CollectionUtil.isEmpty(deviceStatus)
+                &&CollectionUtil.isEmpty(deviceAlarms)
+                &&CollectionUtil.isEmpty(warnFlow)
+                &&CollectionUtil.isEmpty(warns)
+                &&CollectionUtil.isEmpty(timeRange)
+                &&ObjectUtil.isNull(infusionFinished)
+                &&ObjectUtil.isNull(manageType)
+                ;
+
+    }
 }

+ 2 - 1
nb-service/app-doctor/src/main/java/com/nb/app/doctor/controller/PatientMonitorController.java

@@ -56,8 +56,9 @@ public class PatientMonitorController {
     @PostMapping("/monitor/{consult}/no_page")
     @Log(title = "医生端获取病人输注列表")
     @ApiOperation(value = "输注监控列表")
-    public R<List<PatientMonitorResult>> selectPagePatient(@PathVariable("consult")@ApiParam("是否为咨询模式") boolean consult, @RequestBody PatientMonitorQuery query) {
+    public R<List<PatientMonitorResult>> selectPagePatient( @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId,@PathVariable("consult")@ApiParam("是否为咨询模式") boolean consult, @RequestBody PatientMonitorQuery query) {
         log.info("医生查看输注监控列表,【{}】", JSONUtil.toJsonStr(query));
+        query.setTenantId(tenantId);
 //        List<PatientMonitorConsultResult> results = BeanUtil.copyToList(patientClient.selectAll(query), PatientMonitorConsultResult.class);
         return R.success(patientClient.selectAll(query));
 //        if(consult){

+ 6 - 1
nb-service/web-service/src/main/java/com/nb/web/service/bus/controller/BusPatientController.java

@@ -71,8 +71,9 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
     @Log(title = "输注监控列表查询")
     @SaCheckPermission("device:patient:query")
     @ApiOperation(value = "输注监控列表",notes = "病人监控管理列表,权限【device:patient:query】")
-    public R<List<PatientMonitorResult>> selectPage(@RequestBody PatientMonitorQuery query){
+    public R<List<PatientMonitorResult>> selectPage(  @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId,@RequestBody PatientMonitorQuery query){
         log.info("输注监控列表,【{}】",JSONUtil.toJsonStr(query));
+        query.setTenantId(tenantId);
         return R.success(patientService.selectAll(query));
     }
 
@@ -158,6 +159,7 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
                 throw new CustomException("未选择住院号");
             }
             R<Boolean> result = monitorFinished(monitorFinishedVo, tenantId);
+            patientService.deleteAllCache(tenantId);
             CompletableFuture.runAsync(()->wsPublishUtils.publishMonitorTotalCount(tenantId))
                     .thenRunAsync(()->wsPublishUtils.publishDeviceNone(tenantId))
                     .thenRunAsync(()->wsPublishUtils.publishMonitorStateCount(tenantId));
@@ -227,6 +229,7 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
         R<Boolean> result = R.success(clinicService.update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId, clinicId)
                 .set(BusClinicEntity::getEndTime, null)));
         BusClinicEntity clinic = clinicService.getById(clinicId);
+        patientService.deleteAllCache(clinic.getTenantId());
         wsPublishUtils.publishPatientMonitor(clinic.getPatientId(),clinic.getTenantId());
         return result;
     }
@@ -255,6 +258,7 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
     public R shift(@RequestBody@Validated DeviceShiftConfig shiftConfig){
         log.info("主泵切换的操作,【{}】",JSONUtil.toJsonStr(shiftConfig));
         patientService.shift(shiftConfig);
+        patientService.deleteAllCache(shiftConfig.getTenantId());
         wsPublishUtils.publishPatientMonitor(shiftConfig.getPatientId(),shiftConfig.getTenantId());
         return R.success();
     }
@@ -272,6 +276,7 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
         }
         //泵切换完成后,对病号报警解除
         infusionService.undo(undoConfig,false);
+        patientService.deleteAllCache(undoConfig.getTenantId());
         wsPublishUtils.publishPatientMonitor(patient.getId(),undoConfig.getTenantId());
         return R.success();
     }

+ 1 - 0
nb-service/web-service/src/main/java/com/nb/web/service/bus/listener/DeviceInfoListener.java

@@ -164,6 +164,7 @@ public class DeviceInfoListener implements IIotMsgHandler {
             }
 
             cacheOperation.add(()->{
+                patientService.deleteAllCache(device.getTenantId());
                 deviceOperator.setUploadTime(device.getUploadTime());
                 wsPublishUtils.publishPatientMonitor(device.getPatientId(),device.getTenantId());
                 //非测试数据再进行处理

+ 1 - 0
nb-service/web-service/src/main/java/com/nb/web/service/bus/listener/HisInfoListener.java

@@ -69,6 +69,7 @@ public class HisInfoListener {
                     //找到第一个匹配的处理器进行处理
                     .findFirst()
                     .ifPresent(handler-> handler.handle(sources,target));
+            patientService.deleteAllCache(hospitalId);
         } catch (Exception e){
             log.error("解析his数据时出错,解析后数据:{},错误原因,{}",JSONUtil.toJsonStr(infoEvent),e.getLocalizedMessage());
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

+ 3 - 2
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusDeviceService.java

@@ -413,8 +413,9 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
                 .forEach(deviceOperator -> {
                     deviceOperator.getCache().clear();
                 });
-
-        List<PatientMonitorResult> results = patientService.selectAll(new PatientMonitorQuery());
+        PatientMonitorQuery query = new PatientMonitorQuery();
+        query.setTenantId(originTenantId);
+        List<PatientMonitorResult> results = patientService.selectAll(query);
         if(CollectionUtil.isEmpty(results)){
             return;
         }

+ 23 - 3
nb-service/web-service/src/main/java/com/nb/web/service/bus/service/LocalBusPatientService.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.nb.auth.utils.SecurityUtil;
 import com.nb.web.api.entity.BusClinicEntity;
 import com.nb.web.api.entity.BusDeviceEntity;
 import com.nb.web.api.entity.BusInfusionHistoryEntity;
@@ -40,6 +41,8 @@ import com.nb.core.result.R;
 import com.nb.core.utils.ExceptionUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -115,12 +118,10 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
 
     @Override
     public void validateBeforeUpdate(BusPatientEntity entity) {
-
     }
 
     @Override
     public void validateBeforeDelete(String id) {
-
     }
 
     @Override
@@ -228,6 +229,9 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
 
     @Override
     public List<PatientMonitorResult> selectAll(PatientMonitorQuery query) {
+        if(Boolean.TRUE.equals(query.selectAll())){
+            return patientService.selectAll(query.getTenantId());
+        }
         Page<PatientMonitorResult> page = new Page<>(0, 9999, false);
         IPage<PatientMonitorResult> result = this.baseMapper.selectMonitor(page, query);
         if (CollectionUtil.isNotEmpty(result.getRecords())) {
@@ -236,6 +240,21 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
         return result.getRecords();
     }
 
+    @Cacheable(value = "patientList",key = "#tenantId")
+    public  List<PatientMonitorResult> selectAll(String tenantId){
+        PatientMonitorQuery query = new PatientMonitorQuery();
+        Page<PatientMonitorResult> page = new Page<>(0, 9999, false);
+        IPage<PatientMonitorResult> result = this.baseMapper.selectMonitor(page, query);
+        if (CollectionUtil.isNotEmpty(result.getRecords())) {
+            result.getRecords().forEach(PatientMonitorResult::handleWarn);
+        }
+        return result.getRecords();
+    }
+
+    @CacheEvict(value = "patientList",key = "#tenantId")
+    public  void deleteAllCache(String tenantId){
+
+    }
     /**
      *
      * 根据医院和住院号获取一个患者
@@ -313,6 +332,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
         this.updateById(patient);
         patientOperator.setClinicId(patient.getClinicId());
         wsPublishUtils.publishPatientMonitor(originPatientInfo.getId(), patient.getTenantId());
+        patientService.deleteAllCache(patient.getTenantId());
     }
 
     /**
@@ -559,7 +579,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
             CompletableFuture.runAsync(()-> wsPublishUtils.publishPatientMonitor(clinic.getPatientId(),clinic.getTenantId()));
             SpringUtil.publishEvent(new ClinicManageEvent(this,clinic.getTenantId(),clinic.getPatientId(),manageEnum));
         }
-
+        patientService.deleteAllCache(clinic.getTenantId());
         return result;
     }