Explorar el Código

add 输注历史模块
fix 修复已知bug

A17404李放 hace 3 años
padre
commit
802fe378ad
Se han modificado 26 ficheros con 820 adiciones y 140 borrados
  1. 1 1
      coffee-admin/src/main/resources/logback.xml
  2. 14 2
      coffee-common/src/main/java/com/coffee/common/util/RedissonUtil.java
  3. 0 1
      coffee-framework/src/main/java/com/coffee/framework/config/SaTokenConfig.java
  4. 10 9
      coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/MybatisPlusConfig.java
  5. 30 4
      coffee-system/src/main/java/com/coffee/bus/controller/BusClinicController.java
  6. 1 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceHistoryController.java
  7. 17 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusInfusionHistoryController.java
  8. 18 18
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  9. 28 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/MonitorDetailVo.java
  10. 8 13
      coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalLogEntity.java
  11. 2 2
      coffee-system/src/main/java/com/coffee/bus/hospital/HospitalManager.java
  12. 1 0
      coffee-system/src/main/java/com/coffee/bus/hospital/config/AbstractHospitalConfigHandler.java
  13. 11 5
      coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalAutoUndoConfigHandler.java
  14. 25 16
      coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFinishMonitorConfigHandler.java
  15. 13 9
      coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFunctionExtraConfigHandler.java
  16. 2 0
      coffee-system/src/main/java/com/coffee/bus/hospital/his/HisScriptSession.java
  17. 13 11
      coffee-system/src/main/java/com/coffee/bus/hospital/his/strategy/all/MoreToLessHisStrategyHandler.java
  18. 14 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusInfusionHistoryMapper.java
  19. 8 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusInfusionHistoryService.java
  20. 5 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java
  21. 187 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/CombineQuery.java
  22. 103 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/CombineResult.java
  23. 1 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java
  24. 5 1
      coffee-system/src/main/java/com/coffee/bus/websocket/DefaultWebSocketMsgHandler.java
  25. 48 46
      coffee-system/src/main/resources/mapper/bus/BusClinicMapper.xml
  26. 255 0
      coffee-system/src/main/resources/mapper/bus/BusInfusionHistoryMapper.xml

+ 1 - 1
coffee-admin/src/main/resources/logback.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
-    <property name="log.path" value="./logs"/>
+    <!--<property name="log.path" value="./logs"/>-->
     <property name="console.log.pattern"
               value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
     <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>

+ 14 - 2
coffee-common/src/main/java/com/coffee/common/util/RedissonUtil.java

@@ -12,8 +12,10 @@ import org.redisson.client.codec.Codec;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
 import java.util.function.Consumer;
 
 /**
@@ -53,6 +55,7 @@ public class RedissonUtil {
 
     public void offerQueue(RDelayedQueue<AbstractMsgId> delayedQueue,AbstractMsgId msg,long delay, TimeUnit timeUnit){
         delayedQueue.offerAsync(msg,delay,timeUnit);
+        log.info("延迟队列【{}】,消息【{}】【{}】提交成功,延迟时间【{}秒】",delayedQueue.getName(),msg.getId(),msg,timeUnit.toSeconds(delay));
     }
 
     public void clearQueue(RQueue<AbstractMsgId> queue){
@@ -70,9 +73,18 @@ public class RedissonUtil {
                 blockingDequeMap.put(name,destinationQueue);
                 destinationQueue.subscribeOnElements(i->{
                     //开启新的线程消费,唯一线程消费,不可阻塞该异步线程
-                    eventLoopGroup.submit(() -> {
+                    CompletableFuture.runAsync(()->{
+                        log.info("延迟队列【{}】,开始消费数据,消息id【{}】,消息内容【{}】",destinationQueue.getName(),i.getId(),i);
                         consumer.accept(i);
-                    });
+                    })
+                            .whenComplete((__,t)->{
+                                if(t==null){
+                                    log.info("延迟队列【{}】,数据【{}】消费完成",destinationQueue.getName(),i.getId());
+                                }else {
+                                    log.error("延迟队列【{}】,消费数据【{}】失败,",destinationQueue.getName(),i,t);
+                                }
+                            });
+
                 });
             }
             return delayedQueueMap.get(name);

+ 0 - 1
coffee-framework/src/main/java/com/coffee/framework/config/SaTokenConfig.java

@@ -28,7 +28,6 @@ public class SaTokenConfig {
     @Bean
     public HandlerInterceptor handlerInterceptor(){
         return new SaRouteInterceptor((req, res, handler) -> {
-            log.info("访问路径:{}", req.getRequestPath());
             SaRouter.match("/**")
                     .notMatch(IGNORE_URL)
                     .check(StpUtil::checkLogin);

+ 10 - 9
coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/MybatisPlusConfig.java

@@ -12,11 +12,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
-import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.dialects.MySqlDialect;
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.common.bo.LoginUser;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.util.SecurityUtil;
@@ -29,14 +27,10 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
-
-import javax.sql.DataSource;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -69,7 +63,7 @@ public class MybatisPlusConfig {
             ignoreTableName =
                     tableClass
                             .stream()
-                            .filter(aClass -> aClass.getSuperclass() != TenantGenericEntity.class)
+                            .filter(aClass -> !ClassUtil.isAssignable(TenantGenericEntity.class,aClass) )
                             .map(aClass -> {
                                 TableName tableName = aClass.getAnnotation(TableName.class);
                                 return tableName.value();
@@ -92,8 +86,13 @@ public class MybatisPlusConfig {
         interceptor.addInnerInterceptor(dataPermissionInterceptor());
         //多租户插件
         interceptor.addInnerInterceptor(tenantLineInnerInterceptor());
+
         // 分页插件
         interceptor.addInnerInterceptor(paginationInnerInterceptor());
+
+        //禁止全表更新
+        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
+
         // 乐观锁插件
         interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
 
@@ -115,11 +114,13 @@ public class MybatisPlusConfig {
      */
     public PaginationInnerInterceptor paginationInnerInterceptor() {
         PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
+
         // 设置数据库类型为mysql
         paginationInnerInterceptor.setDbType(DbType.MYSQL);
         // 设置最大单页限制数量,默认 500 条,-1 不受限制
         paginationInnerInterceptor.setMaxLimit(-1L);
         paginationInnerInterceptor.setDialect(new MySqlDialect());
+
         return paginationInnerInterceptor;
     }
 

+ 30 - 4
coffee-system/src/main/java/com/coffee/bus/controller/BusClinicController.java

@@ -1,8 +1,10 @@
 package com.coffee.bus.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.stp.StpLogic;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.coffee.bus.controller.vo.ClinicStatsVo;
 import com.coffee.bus.controller.vo.ClinicEditVo;
@@ -10,11 +12,14 @@ import com.coffee.bus.entity.*;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.service.*;
 import com.coffee.bus.service.dto.*;
+import com.coffee.common.crud.BaseService;
+import com.coffee.common.crud.controller.BaseCrudController;
+import com.coffee.common.crud.controller.BaseSaveController;
+import com.coffee.common.entity.GenericEntity;
+import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.exception.CustomException;
 import com.coffee.common.result.R;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
@@ -124,7 +129,7 @@ public class BusClinicController {
 
     @PostMapping("/edit")
     @SaCheckPermission("bus:clinic:edit")
-    @ApiOperation(value = "编辑病人信息",notes = "编辑病人临床信息,权限【bus:clinic:edit】")
+    @ApiOperation(value = "编辑病人(当前)信息",notes = "编辑病人临床信息,权限【bus:clinic:edit】")
     public R<Boolean> edit(@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId, @RequestBody @Validated ClinicEditVo entity){
         if(entity.getHaveDevice()){
             BusClinicEntity clinic = entity.getClinic();
@@ -151,4 +156,25 @@ public class BusClinicController {
         return R.success();
     }
 
+    @PostMapping("/view/{id}")
+    @SaCheckPermission("bus:clinic:query")
+    @ApiOperation(value = "根据ID查询",notes = "新增病人信息,权限【bus:clinic:query】")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id",value = "主键id",required = true)
+    })
+    public R<BusClinicEntity> getById(@PathVariable("id") String id) {
+        String key=String.valueOf(id);
+        if(StrUtil.isNullOrUndefined(key)){
+            return R.fail("查询结果不存在");
+        }
+        return R.success(clinicService.getById(key));
+    }
+
+    @PostMapping("/edit/any")
+    @SaCheckPermission("bus:clinic:edit")
+    @ApiOperation(value = "根据ID修改数据(所有临床数据)",notes = "新增病人信息,权限【bus:clinic:edit】")
+    public R update(@RequestBody @Validated(GenericEntity.Update.class)BusClinicEntity payload){
+        return clinicService.updateById(payload)?R.success(payload):R.fail("更新失败");
+    }
+
 }

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceHistoryController.java

@@ -57,7 +57,7 @@ public class BusDeviceHistoryController extends BaseCrudController<BusDeviceHist
     @SaCheckPermission("bus:device:use")
     @ApiOperation(value = "设备使用查询",notes = "权限:【bus:device:use】")
     public R<List<DeviceUse>> deviceUse(@RequestAttribute(value = "tenantId",required = false)@ApiParam(hidden = true) String tenantId, @RequestBody @Validated DeviceAlarmQuery query){
-        if(StrUtil.isNotEmpty(tenantId)){
+        if(StrUtil.isNullOrUndefined(tenantId)){
             query.setTenantId(tenantId);
         }
         return R.success(deviceAlarmService.selectCountAlarm(query));

+ 17 - 1
coffee-system/src/main/java/com/coffee/bus/controller/BusInfusionHistoryController.java

@@ -1,17 +1,25 @@
 package com.coffee.bus.controller;
 
 import cn.dev33.satoken.SaManager;
+import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.stp.StpLogic;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.service.LocalBusInfusionHistoryService;
+import com.coffee.bus.service.dto.CombineQuery;
+import com.coffee.bus.service.dto.CombineResult;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseQueryController;
+import com.coffee.common.result.R;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-
+import java.util.*;
 /**
  * @author lifang
  * @version 1.0.0
@@ -31,6 +39,14 @@ public class BusInfusionHistoryController implements BaseQueryController<BusInfu
         return infusionHistoryService;
     }
 
+    @PostMapping("/combine/page")
+    @SaCheckPermission("bus:infusion:query")
+    @ApiOperation(value = "输注历史查询(此查询中包括了所属的临床信息)",notes = "权限【bus:infusion:query】")
+    public R<IPage<CombineResult>> compQuery(@RequestBody CombineQuery query){
+        return R.success(infusionHistoryService.queryPage(query,query.getPage()));
+    }
+
+
     @Override
     public String getPermissionPrefix() {
         return "bus:infusion";

+ 18 - 18
coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.coffee.bus.controller.vo.GetPatientInfoVo;
+import com.coffee.bus.controller.vo.MonitorDetailVo;
 import com.coffee.bus.controller.vo.MonitorFinishedVo;
 import com.coffee.bus.entity.*;
 import com.coffee.bus.enums.DeviceStatusEnum;
@@ -28,6 +29,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.context.request.async.DeferredResult;
 
+import javax.validation.constraints.NotNull;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -225,32 +227,30 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
     }
 
 
-    @GetMapping("/monitor/{monitorType}/{clinicId}")
+    @PostMapping("/monitor")
     @SaCheckPermission("device:patient:query")
     @ApiOperation(value = "查看病人当前监控详情",notes = "查看病人当前监控详情,权限标识为【device:patient:query】")
-    public R<PatientMonitorDetailResult> monitor(@PathVariable("monitorType")@ApiParam(value = "是否为有泵监控",example = "0、无泵,1、有泵") Boolean haveDevice, @PathVariable("clinicId")@ApiParam(value = "临床id")String clinicId){
+    public R<PatientMonitorDetailResult> monitor(@RequestBody@Validated MonitorDetailVo vo){
         PatientMonitorDetailResult result = new PatientMonitorDetailResult();
-        BusClinicEntity clinic = clinicService.getById(clinicId);
-        result.setClinic(clinic);
-        if(clinic==null){
-            throw new CustomException("该临床信息不存在,请刷新后重试");
-        }
-        if(haveDevice){
-            BusInfusionHistoryEntity infusion =infusionService.currentInClinic(clinic.getId());
+        BusClinicEntity clinic =null;
+        Boolean monitorType = vo.getMonitorType();
+        if(Boolean.TRUE.equals(monitorType)){
+            String patientCode = vo.getPatientCode();
+            BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode, patientCode));
+            clinic = clinicService.getById(patient.getClinicId());
+            BusInfusionHistoryEntity infusion =infusionService.getById(patient.getInfusionId());
             result.setInfusion(infusion);
-            if(StrUtil.isBlank(clinic.getWard())){
-                clinic.setWard(infusion.getWard());
-            }
-            if(StrUtil.isBlank(clinic.getBedNo())){
-                clinic.setBedNo(infusion.getBedNo());
-            }
-            if(StrUtil.isNotEmpty(infusion.getClinicId())){
-                result.setClinic(clinic);
-            }
         }else {
+            String clinicId = vo.getClinicId();
+            clinic = clinicService.getById(clinicId);
+            result.setClinic(clinic);
             //无泵查看
             result.setDeviceManual( manualService.getOne(new QueryWrapper<BusDeviceManualEntity>().lambda().eq(BusDeviceManualEntity::getClinicId, clinic.getId())));
         }
+        if(clinic==null){
+            throw new CustomException("该临床信息不存在,请刷新后重试");
+        }
+        result.setClinic(clinic);
         return R.success(result);
     }
 

+ 28 - 0
coffee-system/src/main/java/com/coffee/bus/controller/vo/MonitorDetailVo.java

@@ -0,0 +1,28 @@
+package com.coffee.bus.controller.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName MonitorDetailVo.java
+ * @Description 监控详情查看
+ * @createTime 2022年06月01日 14:02:00
+ */
+@Data
+@ApiModel
+public class MonitorDetailVo {
+    @ApiModelProperty("监控类型 true、输注监控 false、其他监控")
+    @NotNull(message = "监控类型不能为空")
+    private Boolean monitorType;
+    @ApiModelProperty("临床id")
+    @NotNull(message = "临床id不能为空")
+    private String clinicId;
+    @ApiModelProperty("病号")
+    @NotNull(message = "病号不能为空")
+    private String patientCode;
+}

+ 8 - 13
coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalLogEntity.java

@@ -1,25 +1,21 @@
 package com.coffee.bus.entity;
 
-import cn.hutool.json.JSON;
-import cn.hutool.json.JSONArray;
-import cn.hutool.json.JSONUtil;
+
+import cn.hutool.json.JSONObject;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
-import com.coffee.bus.enums.HospitalLogEnum;
-import com.coffee.common.config.mybatis.DateToBigIntHandler;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.exception.ExecuteResult;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonIgnore;
+
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
-import org.apache.ibatis.type.EnumTypeHandler;
-import org.hibernate.validator.constraints.Length;
 
-import java.util.Date;
+import java.util.Optional;
+
 
 /**
  * @author lifang
@@ -43,8 +39,7 @@ public class BusHospitalLogEntity extends TenantGenericEntity<String,String> {
     private String input;
 
     @ApiModelProperty(value = "医院数据处理结果")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private Object result;
+    private String result;
 
     @ApiModelProperty("错误消息")
     private String message;
@@ -57,7 +52,7 @@ public class BusHospitalLogEntity extends TenantGenericEntity<String,String> {
         result.setTenantId(tenantId);
         result.setInput(source.getInput());
         result.setMessage(source.getMessage());
-        result.setResult(source.getResult());
+        result.setResult(Optional.ofNullable(source.getResult()).orElse(new JSONObject()).toString());
         result.setSuccess(source.isSuccess());
         result.setUseTime(source.getUseTime());
         result.setPatientCode(patientCode);

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/hospital/HospitalManager.java

@@ -87,8 +87,8 @@ public class HospitalManager {
         this.storage=configStorageManager.getStorage(hospitalId);
         this.alarmService=alarmService;
         this.hospitalLogService=hospitalLogService;
-        this.autoUndoConfigHandler=new HospitalAutoUndoConfigHandler(storage,hospitalId,redissonUtil,infusionHistoryService,deviceRegistry,wsPublishUtils);
-        this.finishMonitorConfigHandler=new HospitalFinishMonitorConfigHandler(storage,hospitalId,redissonUtil,infusionHistoryService,deviceRegistry,wsPublishUtils);
+        this.autoUndoConfigHandler=new HospitalAutoUndoConfigHandler(storage,hospitalId,redissonUtil,infusionHistoryService,deviceRegistry,wsPublishUtils,patientService);
+        this.finishMonitorConfigHandler=new HospitalFinishMonitorConfigHandler(storage,hospitalId,redissonUtil,infusionHistoryService,deviceRegistry,wsPublishUtils,patientService);
         this.analConfigHandler=new HospitalFunctionAnalConfigHandler(storage,hospitalId,redissonUtil,infusionHistoryService,deviceRegistry,wsPublishUtils,alarmService);
         this.extraConfigHandler=new HospitalFunctionExtraConfigHandler(storage,hospitalId,redissonUtil,infusionHistoryService,deviceRegistry,wsPublishUtils,finishMonitorConfigHandler,autoUndoConfigHandler,alarmService,patientService);
         init(configStorageManager);

+ 1 - 0
coffee-system/src/main/java/com/coffee/bus/hospital/config/AbstractHospitalConfigHandler.java

@@ -3,6 +3,7 @@ package com.coffee.bus.hospital.config;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.registry.patient.PatientRegistry;
 import com.coffee.bus.service.LocalBusInfusionHistoryService;
+import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.utils.WsPublishUtils;
 import com.coffee.common.cache.ConfigStorage;
 import com.coffee.common.cache.value.Value;

+ 11 - 5
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalAutoUndoConfigHandler.java

@@ -1,6 +1,8 @@
 package com.coffee.bus.hospital.config;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.hospital.config.bean.FunctionAutoUndoConfig;
 import com.coffee.bus.hospital.config.bean.FunctionFinishMonitorConfig;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
@@ -8,6 +10,7 @@ import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.hospital.enums.ConfigHandlerEnums;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.service.LocalBusInfusionHistoryService;
+import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.service.dto.ManualUndoConfig;
 import com.coffee.bus.service.dto.UndoDeviceConfig;
 import com.coffee.bus.utils.WsPublishUtils;
@@ -35,8 +38,10 @@ public class HospitalAutoUndoConfigHandler extends  AbstractHospitalConfigHandle
 
     private UndoEntity lastAutoUndo;
     private UndoEntity lastNoSignalUndo;
-    public HospitalAutoUndoConfigHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil, LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils) {
+    private   final LocalBusPatientService patientService;
+    public HospitalAutoUndoConfigHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil, LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils, LocalBusPatientService patientService) {
         super(configStorage, hospitalId, redissonUtil, infusionHistoryService, deviceRegistry, wsPublishUtils);
+        this.patientService=patientService;
     }
 
     @Override
@@ -94,7 +99,7 @@ public class HospitalAutoUndoConfigHandler extends  AbstractHospitalConfigHandle
                 .patientCode(patientCode)
                 .config(undoDeviceConfig)
                 .timeout(config.getNoSignalInterval())
-                .unit(TimeUnit.SECONDS)
+                .unit(TimeUnit.MINUTES)
                 .tenantId(tenantId)
                 .infusionId(infusionId)
                 .timestamp(new Date())
@@ -127,7 +132,7 @@ public class HospitalAutoUndoConfigHandler extends  AbstractHospitalConfigHandle
                     .clinicId(source.getClinicId())
                     .infusionId(source.getInfusionId())
                     .timeout(config.getShutDownInterval())
-                    .unit(TimeUnit.SECONDS)
+                    .unit(TimeUnit.MINUTES)
                     .tenantId(source.getTenantId())
                     .timestamp(new Date())
                     .build();
@@ -150,8 +155,9 @@ public class HospitalAutoUndoConfigHandler extends  AbstractHospitalConfigHandle
      */
     private void handleAutoUndo(UndoEntity source){
         String infusionId = source.getInfusionId();
-        BusInfusionHistoryEntity lastInfusion = infusionHistoryService.lastInfusion(source.getDeviceId());
-        if (lastInfusion.getId().equals(infusionId)) {
+        BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode, source.getPatientCode())
+                .eq(BusPatientEntity::getTenantId, source.getTenantId()));
+        if (!infusionId.equals(patient.getInfusionId())) {
             //只有副泵会自动撤泵
             ManualUndoConfig manualUndoConfig = new ManualUndoConfig();
             manualUndoConfig.setInfusionIds(Collections.singletonList(source.getInfusionId()));

+ 25 - 16
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFinishMonitorConfigHandler.java

@@ -1,12 +1,14 @@
 package com.coffee.bus.hospital.config;
 
 
+import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.hospital.config.bean.FunctionFinishMonitorConfig;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.hospital.enums.ConfigHandlerEnums;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.service.LocalBusInfusionHistoryService;
+import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.service.dto.ManualUndoConfig;
 import com.coffee.bus.service.dto.UndoDeviceConfig;
 import com.coffee.bus.utils.WsPublishUtils;
@@ -34,9 +36,11 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
 
 
     private FinishMonitorEntity lastShutDownFinish;
-    private FinishMonitorEntity lastNosignalFinish;
-    public HospitalFinishMonitorConfigHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil,LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils) {
+    private FinishMonitorEntity lastNoSignalFinish;
+    private LocalBusPatientService patientService;
+    public HospitalFinishMonitorConfigHandler(ConfigStorage configStorage, String hospitalId, RedissonUtil redissonUtil,LocalBusInfusionHistoryService infusionHistoryService, DeviceRegistry deviceRegistry, WsPublishUtils wsPublishUtils, LocalBusPatientService patientService) {
         super(configStorage, hospitalId, redissonUtil, infusionHistoryService, deviceRegistry, wsPublishUtils);
+        this.patientService=patientService;
     }
 
     @Override
@@ -58,13 +62,13 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
         }
         judgeShutdownAutoFinish(source,config);
 
-        if(lastNosignalFinish!=null){
+        if(lastNoSignalFinish !=null){
             RDelayedQueue<AbstractMsgId> noSignalFinishDelay = redissonUtil.getDelayedQueue(getId() +"-noSignalFinish", e -> {
                 if(e instanceof FinishMonitorEntity){
                     this.handleFinishMonitor((FinishMonitorEntity) e);
                 }
             });
-            noSignalFinishDelay.remove(lastNosignalFinish);
+            noSignalFinishDelay.remove(lastNoSignalFinish);
         }
     }
 
@@ -80,7 +84,7 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
         });
         UndoDeviceConfig undoDeviceConfig = new UndoDeviceConfig();
         undoDeviceConfig.setUndoBy(config.getUndoBy());
-        lastNosignalFinish = FinishMonitorEntity.builder()
+        lastNoSignalFinish = FinishMonitorEntity.builder()
                 .deviceId(device)
                 .patientCode(patientCode)
                 .config(undoDeviceConfig)
@@ -92,7 +96,7 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
                 .timestamp(new Date())
                 .build();
 
-        redissonUtil.offerQueue(noSignalFinishDelay,lastNosignalFinish,lastNosignalFinish.getTimeout(),lastNosignalFinish.getUnit());
+        redissonUtil.offerQueue(noSignalFinishDelay, lastNoSignalFinish, lastNoSignalFinish.getTimeout(), lastNoSignalFinish.getUnit());
     }
 
     /**
@@ -138,17 +142,22 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
      * @return void
      */
     private void handleFinishMonitor(FinishMonitorEntity source){
+        log.info("延迟任务【{}】,结束临床管理【{}】",source.getId(),source);
+        //判断是否为主输注,只有主输注才可结束临床
         String patientCode = source.getPatientCode();
-        UndoDeviceConfig config = source.getConfig();
-        ManualUndoConfig manualUndoConfig = new ManualUndoConfig();
-        config.setUndoTime(new Date());
-        manualUndoConfig.setTenantId(source.getTenantId());
-        manualUndoConfig.setUndo(config);
-        manualUndoConfig.setMonitorType(true);
-        manualUndoConfig.setClinicId(source.getClinicId());
-        manualUndoConfig.setPatientCode(patientCode);
-        manualUndoConfig.setInfusionIds(Collections.singletonList(source.getInfusionId()));
-        infusionHistoryService.undo(manualUndoConfig,true);
+        BusPatientEntity patient = patientService.findByCode(patientCode, source.getTenantId());
+        if (source.getInfusionId().equals(patient.getInfusionId())) {
+            UndoDeviceConfig config = source.getConfig();
+            ManualUndoConfig manualUndoConfig = new ManualUndoConfig();
+            config.setUndoTime(new Date());
+            manualUndoConfig.setTenantId(source.getTenantId());
+            manualUndoConfig.setUndo(config);
+            manualUndoConfig.setMonitorType(true);
+            manualUndoConfig.setClinicId(patient.getClinicId());
+            manualUndoConfig.setPatientCode(patientCode);
+            manualUndoConfig.setInfusionIds(Collections.singletonList(source.getInfusionId()));
+            infusionHistoryService.undo(manualUndoConfig,true);
+        }
     }
 
     @Data

+ 13 - 9
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFunctionExtraConfigHandler.java

@@ -132,24 +132,28 @@ public class HospitalFunctionExtraConfigHandler  extends  AbstractHospitalConfig
         BusInfusionHistoryEntity infusionHistory = infusionHistoryService.getById(source.getInfusionId());
         if (Boolean.TRUE.equals(infusionHistory.getFinished())) {
             //输注已结束
+            log.debug("不在服务区消息【{}】由于输注已结束,不在继续处理该消息,消息【{}】",source.getId(),source);
             return;
         }
         //不在服务区报警信息保存
         Date uploadTime=new Date(source.getTimestamp().getTime()+source.getUnit().toMillis(source.getTimeout()));
         BusDeviceAlarmEntity alarm = BusDeviceAlarmEntity.noSignalOf(source.getDeviceId(),source.getInfusionId(),source.getHistoryId(),source.getTenantId(),uploadTime);
+        log.debug("消息【{}】处理,保存不在服务区报警",source);
         alarmService.save(alarm);
 
-        infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda().eq(BusInfusionHistoryEntity::getId, infusionHistory.getId())
+        boolean update = infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
+                .eq(BusInfusionHistoryEntity::getId, infusionHistory.getId())
+                .lt(BusInfusionHistoryEntity::getLastUploadTime, uploadTime)
                 .set(BusInfusionHistoryEntity::getRunState, DeviceStatusEnum.NoSignal));
         //报警/提醒缓存重置
-        deviceRegistry.getOperator(deviceId)
-                .setStatus(DeviceStatusEnum.NoSignal);
-
-        wsPublishUtils.publishPatientMonitor(infusionHistory.getPatientCode(), infusionHistory.getTenantId());
-
-        //不在服务区
-        monitorConfigHandler.judgeNoSignalAutoFinish(deviceId,source.getPatientCode(),source.getTenantId(),source.getInfusionId());
-        autoUndoConfigHandler.judgeNoSignalAutoUndo(deviceId,source.getPatientCode(),source.getTenantId(),source.getInfusionId());
+        if(update){
+            deviceRegistry.getOperator(deviceId)
+                    .setStatus(DeviceStatusEnum.NoSignal);
+            wsPublishUtils.publishPatientMonitor(infusionHistory.getPatientCode(), infusionHistory.getTenantId());
+            //不在服务区
+            monitorConfigHandler.judgeNoSignalAutoFinish(deviceId,source.getPatientCode(),source.getTenantId(),source.getInfusionId());
+            autoUndoConfigHandler.judgeNoSignalAutoUndo(deviceId,source.getPatientCode(),source.getTenantId(),source.getInfusionId());
+        }
     }
 
 

+ 2 - 0
coffee-system/src/main/java/com/coffee/bus/hospital/his/HisScriptSession.java

@@ -27,6 +27,7 @@ import com.coffee.common.cache.manager.ConfigStorageManager;
 import com.coffee.common.cache.value.Value;
 import com.coffee.common.exception.CustomException;
 import com.coffee.common.result.R;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.util.Assert;
@@ -57,6 +58,7 @@ public class HisScriptSession {
     private LocalBusHospitalService hospitalService;
     private LocalBusPatientService patientService;
     private LocalBusHospitalLogService hospitalLogService;
+    private ObjectMapper objectMapper;
     private Map<String,HisRequest> hisRequestMap=new ConcurrentHashMap<>();
 
     public HisScriptSession(String hospitalId, ScriptManager scriptManager, ConfigStorageManager configStorageManager, LocalBusClinicService clinicService, LocalBusHospitalService hospitalService, LocalBusHospitalLogService hospitalLogService,LocalBusPatientService patientService) {

+ 13 - 11
coffee-system/src/main/java/com/coffee/bus/hospital/his/strategy/all/MoreToLessHisStrategyHandler.java

@@ -60,24 +60,26 @@ public class MoreToLessHisStrategyHandler implements HisAllStrategyHandler {
             if(timeRefresh(compareSub,target)){
                 infusionHistoryService.resetClinicStartTime(CollectionUtil.getFirst(compareSub.iterator()).getTenantId(),CollectionUtil.getFirst(compareSub.iterator()).getPatientCode());
             }
-            //对比修改临床信息
+            insert.addAll(source.subList(0,subSize));
+            //新增临床信息
+            for (int i = 0; i < insert.size(); i++) {
+                if(i!=0){
+                    insert.get(i).setFinished(true);
+                }else {
+                    insert.get(i).setFinished(false);
+                }
+                insert.get(i).setMonitorType(true);
+            }
+            //先处理新增数据。在处理修改数据
+            insert.forEach(clinicService::insertFromHis);
+            //对比修改临床信息,按照时间顺序从大到小比对
             int start=0;
             for (; start < compareSub.size(); start++) {
                 BusClinicEntity targetClinic = target.get(start);
                 targetClinic.setFinished(true);
                 clinicService.compareFromHis(compareSub.get(start),targetClinic);
             }
-            insert.addAll(source.subList(0,subSize));}
-        //新增临床信息
-        for (int i = 0; i < insert.size(); i++) {
-            if(i!=0){
-                insert.get(i).setFinished(true);
-            }else {
-                insert.get(i).setFinished(false);
-            }
-            insert.get(i).setMonitorType(true);
         }
-        insert.forEach(clinicService::insertFromHis);
         BusClinicEntity currentClinic = CollectionUtil.getFirst(insert.iterator());
         clinicService.setCurrentClinicByHis(currentClinic);
         wsPublishUtils.publishMonitorTotalCount(currentClinic.getTenantId());

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

@@ -1,7 +1,11 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import com.coffee.bus.service.dto.CombineQuery;
+import com.coffee.bus.service.dto.CombineResult;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -24,4 +28,14 @@ public interface BusInfusionHistoryMapper extends BaseMapper<BusInfusionHistoryE
      * @return BusInfusionHistoryEntity
      */
     BusInfusionHistoryEntity currentInClinic(@Param("clinicId")String clinicId);
+
+    /**
+     * 描述: 联合查询出输注信息
+     * @author lifang
+     * @date 2022/6/2 14:56
+     * @param query
+     * @param page
+     * @return IPage<CombineResult>
+     */
+    IPage<CombineResult> queryPage(@Param("query") CombineQuery query, Page<CombineResult> page);
 }

+ 8 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusInfusionHistoryService.java

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.coffee.aliyun.utils.Constants;
 import com.coffee.aliyun.utils.Items;
 import com.coffee.aliyun.utils.PumpParams;
@@ -16,6 +18,8 @@ import com.coffee.bus.listener.event.infusion.InfusionUpdateEvent;
 import com.coffee.bus.mapper.BusInfusionHistoryMapper;
 import com.coffee.bus.registry.device.DeviceOperator;
 import com.coffee.bus.registry.device.DeviceRegistry;
+import com.coffee.bus.service.dto.CombineQuery;
+import com.coffee.bus.service.dto.CombineResult;
 import com.coffee.bus.service.dto.ManualUndoConfig;
 import com.coffee.bus.service.dto.UndoDeviceConfig;
 import com.coffee.common.crud.BaseService;
@@ -357,4 +361,8 @@ public class LocalBusInfusionHistoryService extends BaseService<BusInfusionHisto
                 .eq(BusInfusionHistoryEntity::getDeviceId,deviceId).eq(BusInfusionHistoryEntity::getClassification,classification)
                 .last("limit 1"));
     }
+
+    public IPage<CombineResult> queryPage(CombineQuery query, Page<CombineResult> page) {
+        return this.baseMapper.queryPage(query,page);
+    }
 }

+ 5 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java

@@ -385,4 +385,9 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
 
         patientOperator.setBindDeviceId(shiftConfig.getMasterDeviceId());
     }
+
+    public BusPatientEntity findByCode(String patientCode,String tenantId){
+        return this.getOne(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
+                .eq(BusPatientEntity::getTenantId,tenantId));
+    }
 }

+ 187 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/CombineQuery.java

@@ -0,0 +1,187 @@
+package com.coffee.bus.service.dto;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.coffee.bus.enums.WarnEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName CombineQuery.java
+ * @Description 综合查询参数
+ * @createTime 2022年06月01日 20:49:00
+ */
+@Data
+public class CombineQuery {
+    @ApiModelProperty("病号")
+    private String patientCode;
+
+    @ApiModelProperty("病人姓名")
+    private String patientName;
+
+    /**
+     * @see  com.coffee.common.enums.SexEnum
+     */
+    @ApiModelProperty("性别 1、男 2、女 3、未知")
+    private Integer patientGender;
+
+    @ApiModelProperty("年龄区间")
+    private List<Integer> ageRange;
+
+    @ApiModelProperty("体重区间")
+    private List<Integer> weightRange;
+
+    @ApiModelProperty("asa")
+    private String asa;
+
+    @ApiModelProperty("病区")
+    private String ward;
+
+    @ApiModelProperty("床号")
+    private String bedNo;
+
+    @ApiModelProperty("输注开始时间区间")
+    private List<Date> startTimeRange;
+
+    @ApiModelProperty("输注撤泵时间区间")
+    private List<Date>  undoTimeRange;
+
+    @ApiModelProperty(value = "麻醉医生")
+    private String anaDoctor;
+
+    @ApiModelProperty(value = "麻醉方式")
+    private String anaType;
+
+    @ApiModelProperty(value = "镇痛方式")
+    private String analType;
+
+    @ApiModelProperty(value = "药品名称")
+    private String drugName;
+
+    @ApiModelProperty(value = "手术医生")
+    private String surgeryDoctor;
+
+    @ApiModelProperty(value = "手术名称")
+    private String surgeryName;
+
+    /**
+     * @see  com.coffee.bus.enums.DeviceTypeEnum
+     */
+    @ApiModelProperty(value = "设备类型")
+    private Integer deviceType;
+
+    @ApiModelProperty(value = "设备id")
+    private String deviceId;
+
+    @ApiModelProperty(value = "有效自控次数区间",hidden = true)
+    @JsonIgnore
+    private List<Integer> validPcaCountRange;
+
+    @ApiModelProperty(value = "无效自控次数区间",hidden = true)
+    @JsonIgnore
+    private List<Integer> inValidPcaCountRange;
+
+    @ApiModelProperty(value = "自控次数总数区间",hidden = true)
+    @JsonIgnore
+    private List<Integer> totalPcaCountRange;
+
+    @ApiModelProperty(value = "自控次数,由前端传入,和自控类型进行组合判断")
+    private List<Integer> pcaCountRange;
+
+    @ApiModelProperty("自控类型 0、有效 1、无效 2、总数")
+    private Integer pcaType;
+
+
+    /**
+     * 根据此提醒进行解析
+     * @see  com.coffee.bus.enums.WarnEnum
+     */
+    @ApiModelProperty(value = "提醒【0、智能泵-正常; 1、智能泵-加档受限; 2、智能泵-流速已达上限; 3、智能泵-加档; 4、智能泵-减档; 5、智能泵-低输注状态; 6、输注即将结束;7、镇痛不足;8、低电量】 ")
+    private List<WarnEnum> warns;
+
+    @ApiModelProperty(value = "设备输注最后即将结束警告",hidden = true)
+    @JsonIgnore
+    private boolean warnWillFinished;
+
+    @ApiModelProperty(value = "设备输注最后镇痛不足警告",hidden = true)
+    @JsonIgnore
+    private boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "设备输注最后低电量警告",hidden = true)
+    @JsonIgnore
+    private boolean warnLowBattery;
+
+    @ApiModelProperty(value = "智能泵加减档警告",hidden = true)
+    @JsonIgnore
+    private List<Integer> warnFlow;
+
+    @ApiModelProperty("分页查询")
+    @NotNull(message = "分页参数不可为空")
+    private Page<CombineResult> page;
+
+    public void setPcaCountRange(List<Integer> pcaCountRange) {
+        this.pcaCountRange = pcaCountRange;
+        parsePca();
+    }
+
+    public void setPcaType(Integer pcaType) {
+        this.pcaType = pcaType;
+        parsePca();
+    }
+
+    /**
+     * 描述:对pca参数进行解析填充
+     * @author lifang
+     * @date 2022/6/2 15:44
+     * @param
+     * @return void
+     */
+    private void parsePca(){
+        if(pcaType!=null&& CollectionUtil.isNotEmpty(pcaCountRange)){
+            switch (pcaType){
+                case 0:
+                    this.validPcaCountRange=pcaCountRange;
+                    return;
+                case 1:
+                    this.inValidPcaCountRange=pcaCountRange;
+                    return;
+                case 2:
+                    this.totalPcaCountRange=pcaCountRange;
+                    return;
+                default: break;
+            }
+        }
+    }
+
+
+    /**
+     * 将前端的提醒查询做统一封装,做请求处理
+     * @param warns
+     */
+    public void setWarns(List<WarnEnum> warns) {
+        this.warns = warns;
+        if(CollectionUtil.isNotEmpty(warns)){
+            warns.forEach(warn->{
+                if(warn==WarnEnum.analPoor){
+                    this.warnAnalgesicPoor=true;
+                }else if(warn==WarnEnum.willFinished){
+                    this.warnWillFinished=true;
+                }else if(warn==WarnEnum.lowBattery){
+                    this.warnLowBattery=true;
+                }else {
+                    this.warnFlow= Optional.ofNullable(warnFlow).orElse(new ArrayList<>());
+                    this.warnFlow.add(warn.getValue());
+                }
+            });
+        }
+    }
+}

+ 103 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/CombineResult.java

@@ -0,0 +1,103 @@
+package com.coffee.bus.service.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.coffee.bus.entity.common.CommonDeviceParam;
+import com.coffee.common.enums.SexEnum;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName InfusionResult.java
+ * @Description 综合
+ * @createTime 2022年06月02日 13:41:00
+ */
+@ApiModel("输注、临床综合结果")
+@Data
+public class CombineResult extends CommonDeviceParam<String,String> {
+
+    @ApiModelProperty(value = "输注开始时间,即本次运行开机时间",readOnly = true)
+    private Date infusionStartTime;
+
+    @ApiModelProperty("临床id")
+    private String clinicId;
+
+    @ApiModelProperty(value = "是否已撤泵,0、未撤泵1、已撤泵")
+    private Boolean isUndo;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "当前输注记录数据最后上传时间",readOnly = true,hidden = true)
+    private Date lastUploadTime;
+
+    @ApiModelProperty(value = "撤泵人")
+    private String undoBy;
+
+    @ApiModelProperty(value = "销毁人")
+    private String destroyer;
+
+    @ApiModelProperty(value = "见证人")
+    private String witnesses;
+
+    @ApiModelProperty(value = "撤泵时间")
+    private Date undoTime;
+
+    @ApiModelProperty(value = "该次输注是否已结束")
+    private Boolean infusionFinished;
+
+
+    @ApiModelProperty(value = "临床手术名称")
+    @Length(max = 255,message = "临床手术名称长度不得超过255个字节")
+    private String surgeryName;
+
+
+    @ApiModelProperty(value = "手术开始时间")
+    private Date surgeryStartTime;
+
+    @ApiModelProperty(value = "asa")
+    private String asa;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientName;
+
+    @ApiModelProperty(value = "患者性别")
+    private SexEnum patientGender;
+
+    @ApiModelProperty(value = "患者年龄")
+    private Integer patientAge;
+
+    @ApiModelProperty(value = "体重")
+    private String weight;
+
+    @ApiModelProperty(value = "身高")
+    private String height;
+
+    @ApiModelProperty(value = "麻醉医生")
+    private String anaDoctor;
+
+    @ApiModelProperty(value = "麻醉方式")
+    private String anaType;
+
+    @ApiModelProperty(value = "镇痛方式")
+    private String analType;
+
+    @ApiModelProperty(value = "手术医生")
+    private String surgeryDoctor;
+
+    @ApiModelProperty(value = "配置人员")
+    private String configPerson;
+
+    @ApiModelProperty(value = "配方")
+    private FormulaDrugDomain formula;
+
+    @ApiModelProperty(value = "医嘱")
+    private String entrust;
+}

+ 1 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java

@@ -81,6 +81,7 @@ public class PatientMonitorQuery  implements Serializable {
     private boolean warnLowBattery;
 
     @ApiModelProperty(value = "智能泵加减档警告",hidden = true)
+    @JsonIgnore
     private List<Integer> warnFlow;
 
     /**

+ 5 - 1
coffee-system/src/main/java/com/coffee/bus/websocket/DefaultWebSocketMsgHandler.java

@@ -179,7 +179,11 @@ public class DefaultWebSocketMsgHandler implements IWsMsgHandler {
             //医院响应
             HisResponse hisResponse = JSONUtil.toBean(message, HisResponse.class);
             CompletableFuture
-                    .runAsync(()-> scriptSessionManager.get(hospitalId).response(hisResponse));
+                    .runAsync(()-> scriptSessionManager.get(hospitalId).response(hisResponse))
+            .exceptionally(t->{
+                log.error("医院【{}】响应处理失败,响应消息【{}】,",hospitalId,message,t);
+                return null;
+            });
         }
     }
 }

+ 48 - 46
coffee-system/src/main/resources/mapper/bus/BusClinicMapper.xml

@@ -51,6 +51,8 @@
         FROM
         (select id from bus_infusion_history
         <where>
+            --         不统计开机数据
+            run_state!=1
             <if test="query.clinicId!=null">
                 and clinic_id = #{query.clinicId}
             </if>
@@ -77,52 +79,52 @@
 
     <select id="pageQuery" resultMap="queryResult" parameterType="com.coffee.bus.service.dto.ClinicQuery">
         select
-            c.id as clinic_id,
-            c.patient_code as patient_code,
-            c.patient_name as patient_name,
-            c.ward as ward,
-            c.bed_no as bed_no,
-            c.`surgery_name` as surgery_name,
-            c.surgery_doctor as surgery_doctor,
-            c.ana_doctor as ana_doctor,
-            c.monitor_type as monitor_type,
-            c.finished as finished,
-            c.start_time as clinic_start_time,
-            c.monitor_start_time as monitor_start_time,
-            c.end_time as monitor_end_time,
-            i.infusion_count as infusion_count,
-            eval.eval_count as eval_count
-            from (select * from bus_clinic
-            <where>
-                <if test="query.monitorType!=null">
-                    and monitor_type=#{query.monitorType}
-                </if>
-                <if test="query.surgeryName!=null">
-                    and surgery_name like concat('%',#{query.surgeryName},'%')
-                </if>
-                <if test="query.patientName!=null">
-                    and patient_name like concat('%',#{query.patientName},'%')
-                </if>
-                <if test="query.patientCode!=null">
-                    and patient_code like concat('%',#{query.patientCode},'%')
-                </if>
-                <if test="query.ward != null and query.ward.size > 0">
-                    and ward in
-                    <foreach item="w" index="index" collection="query.ward" open="(" separator="," close=")">
-                        #{w, jdbcType=VARCHAR}
-                    </foreach>
-                </if>
-                <if test="query.bedNo!=null">
-                    and bed_no like concat('%',#{query.bedNo},'%')
-                </if>
-                <if test="query.timeRange != null and query.timeRange.size >0">
-                    and monitor_start_time &gt; #{query.timeRange[0]} and  monitor_start_time &lt; #{query.timeRange[1]}
-                </if>
-            </where>
+        c.id as clinic_id,
+        c.patient_code as patient_code,
+        c.patient_name as patient_name,
+        c.ward as ward,
+        c.bed_no as bed_no,
+        c.`surgery_name` as surgery_name,
+        c.surgery_doctor as surgery_doctor,
+        c.ana_doctor as ana_doctor,
+        c.monitor_type as monitor_type,
+        c.finished as finished,
+        c.start_time as clinic_start_time,
+        c.monitor_start_time as monitor_start_time,
+        c.end_time as monitor_end_time,
+        i.infusion_count as infusion_count,
+        eval.eval_count as eval_count
+        from (select * from bus_clinic
+        <where>
+            <if test="query.monitorType!=null">
+                and monitor_type=#{query.monitorType}
+            </if>
+            <if test="query.surgeryName!=null">
+                and surgery_name like concat('%',#{query.surgeryName},'%')
+            </if>
+            <if test="query.patientName!=null">
+                and patient_name like concat('%',#{query.patientName},'%')
+            </if>
+            <if test="query.patientCode!=null">
+                and patient_code like concat('%',#{query.patientCode},'%')
+            </if>
+            <if test="query.ward != null and query.ward.size > 0">
+                and ward in
+                <foreach item="w" index="index" collection="query.ward" open="(" separator="," close=")">
+                    #{w, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+            <if test="query.bedNo!=null">
+                and bed_no like concat('%',#{query.bedNo},'%')
+            </if>
+            <if test="query.timeRange != null and query.timeRange.size >0">
+                and monitor_start_time &gt; #{query.timeRange[0]} and  monitor_start_time &lt; #{query.timeRange[1]}
+            </if>
+        </where>
 
-            ) as c
-            left join  (select clinic_id,count(1) as infusion_count from bus_infusion_history GROUP BY clinic_id) as i on i.clinic_id=c.id
-            left join (select clinic_id,count(1) as eval_count from bus_evaluation  GROUP BY clinic_id) as eval on eval.clinic_id=c.id
-            order by c.monitor_start_time desc
+        ) as c
+        left join  (select clinic_id,count(1) as infusion_count from bus_infusion_history GROUP BY clinic_id) as i on i.clinic_id=c.id
+        left join (select clinic_id,count(1) as eval_count from bus_evaluation  GROUP BY clinic_id) as eval on eval.clinic_id=c.id
+        order by c.monitor_start_time desc
     </select>
 </mapper>

+ 255 - 0
coffee-system/src/main/resources/mapper/bus/BusInfusionHistoryMapper.xml

@@ -2,6 +2,70 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.coffee.bus.mapper.BusInfusionHistoryMapper">
 
+    <resultMap id="combineResult" type="com.coffee.bus.service.dto.CombineResult">
+        <result column="infusion_id" property="id"/>
+        <result column="device_id" property="deviceId"/>
+        <result column="classification" property="classification"/>
+        <result column="data_num" property="dataNumber"/>
+        <result column="clinic_id" property="clinicId"/>
+        <result column="device_type" property="type"/>
+        <result column="patient_code" property="patientCode"/>
+        <result column="ward" property="ward"/>
+        <result column="bed_no" property="bedNo"/>
+        <result column="total_dose" property="totalDose"/>
+        <result column="first_dose" property="firstDose"/>
+        <result column="remain_dose" property="remainDose"/>
+        <result column="input_dose" property="inputDose"/>
+        <result column="append_dose" property="appendDose"/>
+        <result column="append_lock_time" property="appendLockTime"/>
+        <result column="max_dose" property="maxDose"/>
+        <result column="self_control_count" property="selfControlCount"/>
+        <result column="self_control_lock_time" property="selfControlLockTime"/>
+        <result column="pca_valid_count" property="pcaValidCount"/>
+        <result column="pca_invalid_count" property="pcaInvalidCount"/>
+        <result column="pca_total_count" property="pcaTotalCount"/>
+        <result column="continue_dose" property="continueDose"/>
+        <result column="pulse_dose" property="pulseDose"/>
+        <result column="pulse_first_lock_time" property="pulseFirstLockTime"/>
+        <result column="pulse_lock_time" property="pulseLockTime"/>
+        <result column="flow_up_cycle" property="flowUpCycle"/>
+        <result column="flow_down_cycle" property="flowDownCycle"/>
+        <result column="flow_count" property="flowCount"/>
+        <result column="flow_up_limit" property="flowUpLimit"/>
+        <result column="flow_down_limit" property="flowDownLimit"/>
+        <result column="flow_adjust_rate" property="flowAdjustRate"/>
+        <result column="electric_quantity" property="electricQuantity"/>
+        <result column="run_state" property="runState"/>
+        <result column="device_alarm" property="alarm"/>
+        <result column="warn_flow" property="warnFlow"/>
+        <result column="warn_analgesic_poor" property="warnAnalgesicPoor"/>
+        <result column="warn_low_battery" property="warnLowBattery"/>
+        <result column="warn_will_finished" property="warnWillFinished"/>
+        <result column="infusion_start_time" property="infusionStartTime"/>
+        <result column="patient_name" property="patientName"/>
+        <result column="infusion_start_time" property="infusionStartTime"/>
+        <result column="infusion_finished" property="infusionFinished"/>
+        <result column="is_undo" property="isUndo"/>
+        <result column="last_upload_time" property="lastUploadTime"/>
+        <result column="undo_by" property="undoBy"/>
+        <result column="destroyer" property="destroyer"/>
+        <result column="witnesses" property="witnesses"/>
+        <result column="undo_time" property="undoTime"/>
+        <result column="surgery_name" property="surgeryName"/>
+        <result column="asa" property="asa"/>
+        <result column="patient_gender" property="patientGender"/>
+        <result column="patient_name" property="patientName"/>
+        <result column="patient_age" property="patientAge"/>
+        <result column="weight" property="weight"/>
+        <result column="height" property="height"/>
+        <result column="ana_doctor" property="anaDoctor"/>
+        <result column="ana_type" property="anaType"/>
+        <result column="anal_type" property="analType"/>
+        <result column="surgery_doctor" property="surgeryDoctor"/>
+        <result column="surgery_name" property="surgeryName"/>
+        <result column="formula" property="formula" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="entrust" property="entrust"/>
+    </resultMap>
 
     <select id="currentInClinic" resultType="com.coffee.bus.entity.BusInfusionHistoryEntity">
         select d.alias,i.* from
@@ -12,5 +76,196 @@
 
 
 
+    <select id="queryPage" resultMap="combineResult">
+        select
+        i.id as infusion_id,
+        i.device_id as device_id,
+        i.classification as classification,
+        i.data_number as data_number,
+        i.clinic_id as clinic_id,
+        i.type as device_type,
+        i.patient_code as patient_code,
+        c.ward as ward,
+        c.bed_no as bed_no,
+        i.total_dose as total_dose,
+        i.first_dose as first_dose,
+        i.remain_dose as remain_dose,
+        i.input_dose as input_dose,
+        i.append_dose as append_dose,
+        i.append_lock_time as append_lock_time,
+        i.max_dose as max_dose,
+        i.self_control_count as self_control_count,
+        i.self_control_lock_time as self_control_lock_time,
+        i.pca_valid_count as pca_valid_count,
+        i.pca_invalid_count as pca_invalid_count,
+        i.pca_total_count as pca_total_count,
+        i.continue_dose as continue_dose,
+        i.pulse_dose as pulse_dose,
+        i.pulse_lock_time as pulse_lock_time,
+        i.pulse_first_lock_time as pulse_first_lock_time,
+        i.flow_up_cycle as flow_up_cycle,
+        i.flow_down_cycle as flow_down_cycle,
+        i.flow_count as flow_count,
+        i.flow_up_limit as flow_up_limit,
+        i.flow_down_limit as flow_down_limit,
+        i.flow_adjust_rate as flow_adjust_rate,
+        i.electric_quantity as electric_quantity,
+        i.run_state as run_state,
+        i.alarm as alarm,
+        i.warn_will_finished as warn_will_finished,
+        i.warn_analgesic_poor as warn_analgesic_poor,
+        i.warn_low_battery as warn_low_battery,
+        i.start_time as infusion_start_time,
+        i.warn_flow as warn_flow,
+        i.finished as infusion_finished,
+        i.is_undo as is_undo,
+        i.last_upload_time as last_upload_time,
+        i.undo_by as undo_by,
+        i.destroyer as destroyer,
+        i.witnesses as witnesses,
+        i.undo_time as undo_time,
+        c.surgery_name as surgery_name,
+        c.asa as asa,
+        c.patient_gender as patient_gender,
+        c.`patient_name` as patient_name,
+        c.`patient_age` as patient_age,
+        c.weight as weight,
+        c.`height` as height,
+        c.ana_doctor as ana_doctor,
+        c.patient_age as patient_age,
+        c.ana_type as ana_type,
+        c.anal_type as anal_type,
+        c.surgery_doctor as surgery_doctor,
+        c.formula as formula,
+        c.entrust as entrust
+        from (select * from bus_infusion_history
+        <where>
+            <if test="query.startTimeRange != null and query.startTimeRange.size > 0">
+                and start_time &gt;  #{query.startTimeRange[0]}
+                <if test="query.startTimeRange.size >1 ">
+                    and start_time &lt;  #{query.startTimeRange[1]}
+                </if>
+            </if>
+
+            <if test="query.undoTimeRange != null and query.undoTimeRange.size > 0">
+                and undo_time &gt;  #{query.undoTimeRange[0]}
+                <if test="query.startTimeRange.size >1 ">
+                    and undo_time &lt;  #{query.undoTimeRange[1]}
+                </if>
+            </if>
+
+            <if test="query.deviceType != null">
+                and device_type =  #{query.deviceType}
+            </if>
+
+            <if test="query.deviceId != null">
+                and device_id like concat('%',#{query.deviceId},'%')
+            </if>
+
+            <if test="query.validPcaCountRange != null and query.validPcaCountRange.size > 0">
+                and pca_valid_count &gt;  #{query.validPcaCountRange[0]}
+                <if test="query.validPcaCountRange.size >1 ">
+                    and pca_valid_count &lt;  #{query.validPcaCountRange[1]}
+                </if>
+            </if>
+
+            <if test="query.inValidPcaCountRange != null and query.inValidPcaCountRange.size > 0">
+                and pca_invalid_count &gt;  #{query.inValidPcaCountRange[0]}
+                <if test="query.inValidPcaCountRange.size >1 ">
+                    and pca_invalid_count &lt;  #{query.inValidPcaCountRange[1]}
+                </if>
+            </if>
+
+            <choose>
+                <when test="query.warnWillFinished != false or query.warnAnalgesicPoor != false or  query.warnLowBattery != false">
+                    and (
+                    <choose>
+                        <when test="query.warnWillFinished != false">warn_will_finished=1</when>
+                        <otherwise>warn_will_finished!=1</otherwise>
+                    </choose>
+                    <if test="query.warnAnalgesicPoor != false">or warn_analgesic_poor=1 </if>
+                    <if test="query.warnLowBattery != false"> or warn_low_battery=1 </if>
+                    <if test="query.warnFlow !=null">
+                        or warn_flow= #{query.warnFlow}
+                    </if>
+                    )
+                </when>
+                <otherwise>
+                    <if test="query.warnFlow !=null">
+                        and warn_flow= #{query.warnFlow}
+                    </if>
+                </otherwise>
+            </choose>
+
+        </where>
+        ) as i
+        JOIN (select * from bus_clinic
+        <where>
+            <if test="query.patientCode != null">
+                and patient_code like concat('%',#{query.patientCode},'%')
+            </if>
+
+            <if test="query.patientName != null">
+                and patient_name like concat('%',#{query.patientName},'%')
+            </if>
+
+            <if test="query.patientGender != null">
+                and patient_gender =#{query.patientGender}
+            </if>
+
+            <if test="query.ageRange != null and query.ageRange.size > 0">
+                and patient_age &gt;  #{query.ageRange[0]}
+                <if test="query.ageRange.size >1 ">
+                    and patient_age &lt;  #{query.ageRange[1]}
+                </if>
+            </if>
+
+            <if test="query.weightRange != null and query.weightRange.size > 0">
+                and weight &gt;  #{query.weightRange[0]}
+                <if test="query.weightRange.size >1 ">
+                    and weight &lt;  #{query.weightRange[1]}
+                </if>
+            </if>
+
+            <if test="query.asa != null">
+                and asa like concat('%',#{query.asa},'%')
+            </if>
+
+            <if test="query.ward != null">
+                and ward like concat('%',#{query.ward},'%')
+            </if>
+
+            <if test="query.bedNo != null">
+                and bed_no like concat('%',#{query.bedNo},'%')
+            </if>
+
+            <if test="query.anaDoctor != null">
+                and ana_doctor like concat('%',#{query.anaDoctor},'%')
+            </if>
+
+
+            <if test="query.anaType != null">
+                and ana_type like concat('%',#{query.anaType},'%')
+            </if>
+
+            <if test="query.analType != null">
+                and anal_type like concat('%',#{query.analType},'%')
+            </if>
+
+            <if test="query.drugName != null">
+                and formula like concat('%',#{query.drugName},'%')
+            </if>
+
+            <if test="query.surgeryDoctor != null">
+                and surgery_doctor like concat('%',#{query.surgeryDoctor},'%')
+            </if>
+
+            <if test="query.surgeryName != null">
+                and surgery_name like concat('%',#{query.surgeryName},'%')
+            </if>
+        </where>
+        ) as c
+        on i.clinic_id=c.id
+    </select>
 
 </mapper>