Quellcode durchsuchen

Merge branch 'dev' into zsl

# Conflicts:
#	coffee-admin/src/test/java/com/coffee/admin/BusPatientTest.java
#	coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceController.java
#	coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceMapper.java
#	coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java
15638522405 vor 3 Jahren
Ursprung
Commit
0b38aa7753
100 geänderte Dateien mit 2768 neuen und 1078 gelöschten Zeilen
  1. 1 1
      coffee-admin/Dockerfile
  2. 0 49
      coffee-admin/logs/sys-info.2022-04-06.log
  3. 5 4
      coffee-admin/src/main/resources/application.yml
  4. 51 0
      coffee-admin/src/test/java/com/coffee/admin/BusClinicTest.java
  5. 53 0
      coffee-admin/src/test/java/com/coffee/admin/BusDeviceTest.java
  6. 142 23
      coffee-admin/src/test/java/com/coffee/admin/BusPatientTest.java
  7. 13 1
      coffee-common/src/main/java/com/coffee/common/cache/ClusterConfigStorage.java
  8. 30 0
      coffee-common/src/main/java/com/coffee/common/cache/value/SimpleValue.java
  9. 1 2
      coffee-common/src/main/java/com/coffee/common/config/CorsConfig.java
  10. 0 48
      coffee-common/src/main/java/com/coffee/common/config/mybatis/WebConfig.java
  11. 16 0
      coffee-common/src/main/java/com/coffee/common/config/websocket/WebSocketConstant.java
  12. 9 6
      coffee-common/src/main/java/com/coffee/common/crud/BaseService.java
  13. 25 5
      coffee-common/src/main/java/com/coffee/common/entity/GenericEntity.java
  14. 1 0
      coffee-common/src/main/java/com/coffee/common/entity/TenantGenericEntity.java
  15. 1 0
      coffee-common/src/main/java/com/coffee/common/entity/param/Term.java
  16. 4 5
      coffee-common/src/main/java/com/coffee/common/enums/SexEnum.java
  17. 5 0
      coffee-framework/pom.xml
  18. 14 13
      coffee-framework/src/main/java/com/coffee/framework/config/SaTokenConfig.java
  19. 0 6
      coffee-framework/src/main/java/com/coffee/framework/config/WebAppMvcConfig.java
  20. 7 3
      coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/MybatisPlusConfig.java
  21. 97 98
      coffee-system/src/main/java/com/coffee/aliyun/AliyunConsumerGroupService.java
  22. 17 24
      coffee-system/src/main/java/com/coffee/aliyun/AliyunIotSubscribeClient.java
  23. 1 1
      coffee-system/src/main/java/com/coffee/aliyun/PlatformAccount.java
  24. 1 1
      coffee-system/src/main/java/com/coffee/aliyun/PlatformLog.java
  25. 27 23
      coffee-system/src/main/java/com/coffee/aliyun/sdk/AliyunIotSdk.java
  26. 16 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/Constants.java
  27. 37 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/DeviceAlarmUtils.java
  28. 28 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/DeviceRunStatusUtils.java
  29. 26 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/DeviceTypeUtils.java
  30. 30 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/EnumUtils.java
  31. 33 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/Items.java
  32. 46 0
      coffee-system/src/main/java/com/coffee/aliyun/utils/PumpParams.java
  33. 2 2
      coffee-system/src/main/java/com/coffee/bus/controller/BusAlarmController.java
  34. 10 6
      coffee-system/src/main/java/com/coffee/bus/controller/BusClinicController.java
  35. 0 2
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceController.java
  36. 61 0
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceManualController.java
  37. 14 12
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRunningController.java
  38. 71 30
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  39. 33 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/ClinicStatsVo.java
  40. 24 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/DeviceBindVo.java
  41. 23 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/DeviceManualVo.java
  42. 44 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/DeviceRunningMockVo.java
  43. 2 2
      coffee-system/src/main/java/com/coffee/bus/controller/vo/MonitorFinishedVo.java
  44. 2 2
      coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfigVo.java
  45. 6 8
      coffee-system/src/main/java/com/coffee/bus/entity/BusClinicEntity.java
  46. 2 0
      coffee-system/src/main/java/com/coffee/bus/entity/BusConMixEntity.java
  47. 0 4
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceAlarmEntity.java
  48. 40 12
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceEntity.java
  49. 9 136
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceHistoryEntity.java
  50. 87 0
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceManualEntity.java
  51. 46 142
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRunningEntity.java
  52. 1 12
      coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalConfigEntity.java
  53. 0 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java
  54. 46 138
      coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionHistoryEntity.java
  55. 35 138
      coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionModifyEntity.java
  56. 27 6
      coffee-system/src/main/java/com/coffee/bus/entity/BusPatientEntity.java
  57. 2 2
      coffee-system/src/main/java/com/coffee/bus/entity/PatientDeviceRepeatDomain.java
  58. 88 16
      coffee-system/src/main/java/com/coffee/bus/entity/PatientMonitorDomain.java
  59. 53 0
      coffee-system/src/main/java/com/coffee/bus/entity/common/CommonDeviceParam.java
  60. 149 0
      coffee-system/src/main/java/com/coffee/bus/entity/common/DeviceProperties.java
  61. 14 9
      coffee-system/src/main/java/com/coffee/bus/enums/DeviceAlarmEnum.java
  62. 26 0
      coffee-system/src/main/java/com/coffee/bus/enums/DeviceManualEnum.java
  63. 6 3
      coffee-system/src/main/java/com/coffee/bus/enums/DeviceStatusEnum.java
  64. 30 0
      coffee-system/src/main/java/com/coffee/bus/enums/DeviceStatusEnum2.java
  65. 6 4
      coffee-system/src/main/java/com/coffee/bus/enums/DeviceTypeEnum.java
  66. 42 0
      coffee-system/src/main/java/com/coffee/bus/enums/FlowStatusEnum.java
  67. 1 0
      coffee-system/src/main/java/com/coffee/bus/enums/PatientAlarmEnum.java
  68. 32 0
      coffee-system/src/main/java/com/coffee/bus/enums/WarnEnum.java
  69. 33 0
      coffee-system/src/main/java/com/coffee/bus/exception/BusinessException.java
  70. 80 0
      coffee-system/src/main/java/com/coffee/bus/exception/ErrorStatus.java
  71. 2 2
      coffee-system/src/main/java/com/coffee/bus/handler/CheckSignHandler.java
  72. 8 0
      coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceInfoEvent.java
  73. 21 0
      coffee-system/src/main/java/com/coffee/bus/listener/event/infusion/InfusionCreateEvent.java
  74. 21 0
      coffee-system/src/main/java/com/coffee/bus/listener/event/infusion/InfusionUpdateEvent.java
  75. 6 1
      coffee-system/src/main/java/com/coffee/bus/mapper/BusClinicMapper.java
  76. 26 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceManualMapper.java
  77. 9 8
      coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceMapper.java
  78. 1 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusInfusionHistoryMapper.java
  79. 2 0
      coffee-system/src/main/java/com/coffee/bus/registry/constant/DeviceKeyConstant.java
  80. 10 0
      coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java
  81. 2 0
      coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceRegistry.java
  82. 13 0
      coffee-system/src/main/java/com/coffee/bus/registry/device/DeviceOperator.java
  83. 32 11
      coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientRegistry.java
  84. 17 3
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusClinicService.java
  85. 61 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceManualService.java
  86. 40 31
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java
  87. 111 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java
  88. 97 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusInfusionHistoryService.java
  89. 70 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java
  90. 33 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicStatsQueryResult.java
  91. 71 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicStatsReturnResult.java
  92. 0 4
      coffee-system/src/main/java/com/coffee/bus/service/dto/DeviceShiftConfig.java
  93. 26 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/ManualMonitorQuery.java
  94. 55 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/ManualMonitorResult.java
  95. 4 1
      coffee-system/src/main/java/com/coffee/bus/service/dto/ManualUndoConfig.java
  96. 30 6
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceNoneResult.java
  97. 2 2
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceRepeatResult.java
  98. 55 7
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java
  99. 3 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorResult.java
  100. 56 0
      coffee-system/src/main/java/com/coffee/bus/utils/MockUtils.java

+ 1 - 1
coffee-admin/Dockerfile

@@ -1,6 +1,6 @@
 FROM docker.io/java:8
 
-COPY target/coffee-admin.jar /pump.jar
+ADD target/coffee-admin.jar /pump.jar
 RUN bash -c "touch /pump.jar"
 #ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/pump.jar"]
 ENTRYPOINT ["java", "-jar", "/pump.jar"]

+ 0 - 49
coffee-admin/logs/sys-info.2022-04-06.log

@@ -1,49 +0,0 @@
-2022-04-06 18:08:24 [main] INFO  com.coffee.admin.AliyunTest - Starting AliyunTest using Java 14.0.1 on DESKTOP-NLH890S with PID 38940 (started by Administrator in E:\git\java\NB_NetPump\coffee-admin)
-2022-04-06 18:08:24 [main] INFO  com.coffee.admin.AliyunTest - The following profiles are active: dev
-2022-04-06 18:08:24 [background-preinit] INFO  o.h.validator.internal.util.Version - HV000001: Hibernate Validator 6.2.0.Final
-2022-04-06 18:08:30 [main] INFO  c.c.a.AliyunConsumerGroupService - 订阅禁止
-2022-04-06 18:08:35 [Thread-2] INFO  o.t.w.s.TioWebSocketServerBootstrap - Initializing Tio WebSocket Server
-2022-04-06 18:08:35 [Thread-2] INFO  org.tio.server.TioServer - 
-|----------------------------------------------------------------------------------------|
-| t-io site         | https://www.t-io.org                                               |
-| t-io on gitee     | https://gitee.com/tywo45/t-io                                      |
-| t-io on github    | https://github.com/tywo45/t-io                                     |
-| t-io version      | 3.6.0.v20200315-RELEASE                                            |
-| ---------------------------------------------------------------------------------------|
-| TioConfig name    | tio-websocket-spring-boot-starter                                  |
-| Started at        | 2022-04-06 18:08:35                                                |
-| Listen on         | 0.0.0.0:9000                                                       |
-| Main Class        | java.lang.Thread                                                   |
-| Jvm start time    | 11980ms                                                            |
-| Tio start time    | 8ms                                                                |
-| Pid               | 38940                                                              |
-|----------------------------------------------------------------------------------------|
-
-2022-04-06 18:08:36 [main] INFO  com.coffee.admin.AliyunTest - Started AliyunTest in 12.056 seconds (JVM running for 13.306)
-2022-04-06 18:08:37 [main] INFO  c.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
-2022-04-06 18:08:40 [SpringApplicationShutdownHook] INFO  c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closing ...
-2022-04-06 18:08:40 [SpringApplicationShutdownHook] INFO  c.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed
-2022-04-06 18:10:48 [main] INFO  com.coffee.admin.AliyunTest - Starting AliyunTest using Java 14.0.1 on DESKTOP-NLH890S with PID 36056 (started by Administrator in E:\git\java\NB_NetPump\coffee-admin)
-2022-04-06 18:10:48 [main] INFO  com.coffee.admin.AliyunTest - The following profiles are active: dev
-2022-04-06 18:10:48 [background-preinit] INFO  o.h.validator.internal.util.Version - HV000001: Hibernate Validator 6.2.0.Final
-2022-04-06 18:10:53 [main] INFO  c.c.a.AliyunConsumerGroupService - 订阅禁止
-2022-04-06 18:10:58 [Thread-2] INFO  o.t.w.s.TioWebSocketServerBootstrap - Initializing Tio WebSocket Server
-2022-04-06 18:10:58 [Thread-2] INFO  org.tio.server.TioServer - 
-|----------------------------------------------------------------------------------------|
-| t-io site         | https://www.t-io.org                                               |
-| t-io on gitee     | https://gitee.com/tywo45/t-io                                      |
-| t-io on github    | https://github.com/tywo45/t-io                                     |
-| t-io version      | 3.6.0.v20200315-RELEASE                                            |
-| ---------------------------------------------------------------------------------------|
-| TioConfig name    | tio-websocket-spring-boot-starter                                  |
-| Started at        | 2022-04-06 18:10:58                                                |
-| Listen on         | 0.0.0.0:9000                                                       |
-| Main Class        | java.lang.Thread                                                   |
-| Jvm start time    | 11838ms                                                            |
-| Tio start time    | 8ms                                                                |
-| Pid               | 36056                                                              |
-|----------------------------------------------------------------------------------------|
-
-2022-04-06 18:10:59 [main] INFO  com.coffee.admin.AliyunTest - Started AliyunTest in 11.943 seconds (JVM running for 13.135)
-2022-04-06 18:11:00 [task-5] INFO  c.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
-2022-04-06 18:11:08 [tio-timer-checkheartbeat-1-Tio Websocket Server] INFO  org.tio.server.ServerTioConfig - tio-websocket-spring-boot-starter, 用户取消了框架层面的心跳检测,如果业务需要,请用户自己去完成心跳检测

+ 5 - 4
coffee-admin/src/main/resources/application.yml

@@ -64,12 +64,13 @@ mybatis-plus:
     dbConfig:
       idType: ASSIGN_ID
   configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
     default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
   type-aliases-package: com.coffee.bus.entity
 
 # 阿里云对接配置
 aliyun:
-  data-access:
-    enable: false  # 是否开启阿里云物联网订阅
-
+  server-subscription:
+    enable: false  # 是否开启阿里云物联网服务端订阅
+  product:
+    productKey: a1ALlsBa2ZK

+ 51 - 0
coffee-admin/src/test/java/com/coffee/admin/BusClinicTest.java

@@ -0,0 +1,51 @@
+package com.coffee.admin;
+
+import com.coffee.bus.controller.vo.ClinicStatsVo;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
+import com.coffee.bus.service.LocalBusClinicService;
+import com.coffee.bus.service.LocalBusInfusionHistoryService;
+import com.coffee.bus.service.dto.ClinicStatsReturnResult;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @Author longsanlang
+ * @Date 2022-04-06 17:55:44
+ * @Version 1.0
+ * @Description XXX
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AdminApplication.class)
+public class BusClinicTest {
+
+    @Autowired
+    private LocalBusClinicService clinicService;
+
+
+
+    @Test
+    public void stats(){
+        ClinicStatsVo clinicStatsVo = new ClinicStatsVo();
+        clinicStatsVo.setContinueDose(true);
+        clinicStatsVo.setInValidCount(true);
+        clinicStatsVo.setValidCount(true);
+        clinicStatsVo.setClinicId("1519516923748319234");
+        clinicStatsVo.setDeviceId("456");
+        ClinicStatsReturnResult stats = clinicService.stats(clinicStatsVo);
+        System.out.println(stats);
+    }
+
+
+    @Test
+    public void save(){
+
+    }
+
+
+}

+ 53 - 0
coffee-admin/src/test/java/com/coffee/admin/BusDeviceTest.java

@@ -0,0 +1,53 @@
+package com.coffee.admin;
+
+import com.coffee.bus.entity.BusDeviceEntity;
+import com.coffee.bus.service.LocalBusDeviceService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Author XX
+ * @Date 2022-04-25 19:00:10
+ * @Version 1.0
+ * @Description XXX
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AdminApplication.class)
+public class BusDeviceTest {
+
+    @Autowired
+    LocalBusDeviceService deviceService;
+
+    @Test
+    public void test001(){
+        BusDeviceEntity device = new BusDeviceEntity();
+        device.setDeviceId("12345678910");
+        device.setCreateBy("auto");
+        device.setCreateTime(new Date());
+        deviceService.saveByDeviceId(device);
+
+    }
+
+    @Test
+    public void addAlias(){
+        List<BusDeviceEntity> list = deviceService.list();
+        for (BusDeviceEntity device : list) {
+
+            device.setAlias(BusPatientTest.getName());
+        }
+        deviceService.updateBatchById(list);
+
+    }
+
+    @Test
+    public void test002(){
+        deviceService.removeByDeviceId("nbceshi001");
+    }
+
+}

+ 142 - 23
coffee-admin/src/test/java/com/coffee/admin/BusPatientTest.java

@@ -1,20 +1,30 @@
 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 cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.EnumUtil;
+import cn.hutool.core.util.RandomUtil;
+import com.coffee.bus.controller.BusDeviceManualController;
+import com.coffee.bus.controller.vo.DeviceManualVo;
+import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusDeviceManualEntity;
+import com.coffee.bus.entity.BusPatientEntity;
+import com.coffee.bus.enums.DeviceManualEnum;
+import com.coffee.bus.service.LocalBusClinicService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
+import com.coffee.common.enums.SexEnum;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
+import java.util.Random;
 
 /**
  * @author lifang
@@ -28,39 +38,148 @@ import java.util.List;
 public class BusPatientTest {
     @Autowired
     private LocalBusPatientService patientService;
+
     @Autowired
-    private LocalBusDeviceAlarmService deviceAlarmService;
-    @Autowired
-    private BusDeviceAlarmMapper deviceAlarmMapper;
+    private LocalBusClinicService clinicService;
 
+    @Autowired
+    private BusDeviceManualController manualController;
     @Test
     public  void test(){
         List<PatientDeviceRepeatResult> patientDeviceRepeatResults = patientService.repeatDevice();
+        System.out.println(getName());
         System.out.println(patientDeviceRepeatResults);
     }
 
+    public static List<String> clinicNames= Arrays.asList("阑尾手术","肛门手术","肝脏手术","感冒","发烧","肠其他手术","结肠造口术","回肠造口术","肠造口闭合术","肠固定术","肠的其他修补","阑尾切除术","腹腔镜下阑尾切除术","阑尾切除术","阑尾残端切除术");
+    public static List<String> anaTypes=Arrays.asList("局部麻醉","全麻");
+    public static List<String> analTypes=Arrays.asList("PCIA","PCEA","PCSA","PCNA");
+
     @Test
-    public  void test1(){
-        List<DeviceUse> deviceUseList = deviceAlarmService.countAlarm();
-        for (DeviceUse d:
-             deviceUseList) {
-            System.out.println(d);
+    public void save(){
+        for (int i = 0; i < 30; i++) {
+            BusClinicEntity clinic = new BusClinicEntity();
+            clinic.setStartTime(new Date());
+            clinic.setName(clinicNames.get(RandomUtil.randomInt(clinicNames.size()-1)));
+            clinic.setPatientName(getName());
+            clinic.setPatientGender(EnumUtil.likeValueOf(SexEnum.class,RandomUtil.randomInt(1,2)));
+            clinic.setBedNo(String.valueOf(RandomUtil.randomInt(10,100)));
+            clinic.setWard(String.valueOf(RandomUtil.randomInt(10,100)));
+            clinic.setWeight(String.valueOf(RandomUtil.randomInt(90,150)));
+            clinic.setWeight(String.valueOf(RandomUtil.randomInt(150,200)));
+            clinic.setAnaDoctor(getName());
+            clinic.setAnaType(anaTypes.get(RandomUtil.randomInt(anaTypes.size()-1)));
+            clinic.setAnalType(analTypes.get(RandomUtil.randomInt(analTypes.size()-1)));
+            clinic.setSurgeryDoctor(getName());
+            clinic.setConfigPerson(getName());
+            clinic.setPatientCode(String.valueOf(RandomUtil.randomInt(100000,300000)));
+            clinic.setMonitorType(true);
+            clinic.setTenantId("1");
+            BusPatientEntity patient = BusPatientEntity.of(clinic);
+//        patientService.save(patient);
+//        clinicService.save(clinic);
+            patientService.manualEdit(clinic);
         }
     }
+
     @Test
-    public  void test2(){
+    public void manualSave(){
+        for (int i = 0; i < 30; i++) {
+            DeviceManualVo deviceManualVo = new DeviceManualVo();
+            BusClinicEntity clinic = new BusClinicEntity();
+            clinic.setStartTime(new Date());
+            clinic.setName(clinicNames.get(RandomUtil.randomInt(clinicNames.size()-1)));
+            clinic.setPatientName(getName());
+            clinic.setPatientGender(EnumUtil.likeValueOf(SexEnum.class,RandomUtil.randomInt(1,2)));
+            clinic.setBedNo(String.valueOf(RandomUtil.randomInt(10,100)));
+            clinic.setWard(String.valueOf(RandomUtil.randomInt(10,100)));
+            clinic.setWeight(String.valueOf(RandomUtil.randomInt(90,150)));
+            clinic.setWeight(String.valueOf(RandomUtil.randomInt(150,200)));
+            clinic.setAnaDoctor(getName());
+            clinic.setAnaType(anaTypes.get(RandomUtil.randomInt(anaTypes.size()-1)));
+            clinic.setAnalType(analTypes.get(RandomUtil.randomInt(analTypes.size()-1)));
+            clinic.setSurgeryDoctor(getName());
+            clinic.setConfigPerson(getName());
+            clinic.setPatientCode(String.valueOf(RandomUtil.randomInt(100000,300000)));
+            clinic.setTenantId("1");
+
+            deviceManualVo.setClinic(clinic);
 
-        QueryWrapper<BusDeviceAlarmEntity> busDeviceAlarmEntityQueryWrapper = new QueryWrapper<>();
-        BusDeviceAlarmEntity busDeviceAlarmEntity = new BusDeviceAlarmEntity();
+            BusDeviceManualEntity manual = new BusDeviceManualEntity();
+            manual.setType(DeviceManualEnum.machine);
+            manual.setTotalDose(RandomUtil.randomInt(100));
+            manual.setContinueDose(RandomUtil.randomBigDecimal(BigDecimal.valueOf(10)));
+            manual.setSelfControlDose(RandomUtil.randomBigDecimal(BigDecimal.valueOf(10)));
+            manual.setSelfControlLockTime(RandomUtil.randomInt(100));
+            deviceManualVo.setManual(manual);
+            manualController.save(deviceManualVo);
 
-        //busDeviceAlarmEntity.setTenantId("1");
-        busDeviceAlarmEntityQueryWrapper.setEntity(busDeviceAlarmEntity);
-        busDeviceAlarmEntity.setAlarm(DeviceAlarmEnum.LowBattery);
+//        patientService.save(patient);
+//        clinicService.save(clinic);
+        }
+    }
 
-        System.out.println(busDeviceAlarmEntityQueryWrapper.getEntity().getAlarm());
-        //System.out.println("----------------------------------------"+busDeviceAlarmEntityQueryWrapper.getEntity().getTenantId());
-        System.out.println("=================================="+deviceAlarmMapper.selectCount(busDeviceAlarmEntityQueryWrapper));
+    public static void main(String[] args) {
+        System.out.println(getName());
     }
 
+    public static String getName(){
+        Random random=new Random(System.currentTimeMillis());
+        /* 598 百家姓 */
+        String[] Surname= {"赵","钱","孙","李","周","吴","郑","王","冯","陈","褚","卫","蒋","沈","韩","杨","朱","秦","尤","许",
+                "何","吕","施","张","孔","曹","严","华","金","魏","陶","姜","戚","谢","邹","喻","柏","水","窦","章","云","苏","潘","葛","奚","范","彭","郎",
+                "鲁","韦","昌","马","苗","凤","花","方","俞","任","袁","柳","酆","鲍","史","唐","费","廉","岑","薛","雷","贺","倪","汤","滕","殷",
+                "罗","毕","郝","邬","安","常","乐","于","时","傅","皮","卞","齐","康","伍","余","元","卜","顾","孟","平","黄","和",
+                "穆","萧","尹","姚","邵","湛","汪","祁","毛","禹","狄","米","贝","明","臧","计","伏","成","戴","谈","宋","茅","庞","熊","纪","舒",
+                "屈","项","祝","董","梁","杜","阮","蓝","闵","席","季","麻","强","贾","路","娄","危","江","童","颜","郭","梅","盛","林","刁","钟",
+                "徐","邱","骆","高","夏","蔡","田","樊","胡","凌","霍","虞","万","支","柯","昝","管","卢","莫","经","房","裘","缪","干","解","应",
+                "宗","丁","宣","贲","邓","郁","单","杭","洪","包","诸","左","石","崔","吉","钮","龚","程","嵇","邢","滑","裴","陆","荣","翁","荀",
+                "羊","于","惠","甄","曲","家","封","芮","羿","储","靳","汲","邴","糜","松","井","段","富","巫","乌","焦","巴","弓","牧","隗","山",
+                "谷","车","侯","宓","蓬","全","郗","班","仰","秋","仲","伊","宫","宁","仇","栾","暴","甘","钭","厉","戎","祖","武","符","刘","景",
+                "詹","束","龙","叶","幸","司","韶","郜","黎","蓟","溥","印","宿","白","怀","蒲","邰","从","鄂","索","咸","籍","赖","卓","蔺","屠",
+                "蒙","池","乔","阴","郁","胥","能","苍","双","闻","莘","党","翟","谭","贡","劳","逄","姬","申","扶","堵","冉","宰","郦","雍","却",
+                "璩","桑","桂","濮","牛","寿","通","边","扈","燕","冀","浦","尚","农","温","别","庄","晏","柴","瞿","阎","充","慕","连","茹","习",
+                "宦","艾","鱼","容","向","古","易","慎","戈","廖","庾","终","暨","居","衡","步","都","耿","满","弘","匡","国","文","寇","广","禄",
+                "阙","东","欧","殳","沃","利","蔚","越","夔","隆","师","巩","厍","聂","晁","勾","敖","融","冷","訾","辛","阚","那","简","饶","空",
+                "曾","毋","沙","乜","养","鞠","须","丰","巢","关","蒯","相","查","后","荆","红","游","郏","竺","权","逯","盖","益","桓","公","仉",
+                "督","岳","帅","缑","亢","况","郈","有","琴","归","海","晋","楚","闫","法","汝","鄢","涂","钦","商","牟","佘","佴","伯","赏","墨",
+                "哈","谯","篁","年","爱","阳","佟","言","福","南","火","铁","迟","漆","官","冼","真","展","繁","檀","祭","密","敬","揭","舜","楼",
+                "疏","冒","浑","挚","胶","随","高","皋","原","种","练","弥","仓","眭","蹇","覃","阿","门","恽","来","綦","召","仪","风","介","巨",
+                "木","京","狐","郇","虎","枚","抗","达","杞","苌","折","麦","庆","过","竹","端","鲜","皇","亓","老","是","秘","畅","邝","还","宾",
+                "闾","辜","纵","侴","万俟","司马","上官","欧阳","夏侯","诸葛","闻人","东方","赫连","皇甫","羊舌","尉迟","公羊","澹台","公冶","宗正",
+                "濮阳","淳于","单于","太叔","申屠","公孙","仲孙","轩辕","令狐","钟离","宇文","长孙","慕容","鲜于","闾丘","司徒","司空","兀官","司寇",
+                "南门","呼延","子车","颛孙","端木","巫马","公西","漆雕","车正","壤驷","公良","拓跋","夹谷","宰父","谷梁","段干","百里","东郭","微生",
+                "梁丘","左丘","东门","西门","南宫","第五","公仪","公乘","太史","仲长","叔孙","屈突","尔朱","东乡","相里","胡母","司城","张廖","雍门",
+                "毋丘","贺兰","綦毋","屋庐","独孤","南郭","北宫","王孙"};
 
+        int index=random.nextInt(Surname.length-1);
+        String name = Surname[index]; //获得一个随机的姓氏
+
+        /* 从常用字中选取一个或两个字作为名 */
+        if(random.nextBoolean()){
+            name+=getChinese()+getChinese();
+        }else {
+            name+=getChinese();
+        }
+        return name;
+    }
+
+    public static String getChinese() {
+        String str = null;
+        int highPos, lowPos;
+        Random random = new Random();
+        highPos = (176 + Math.abs(random.nextInt(71)));//区码,0xA0打头,从第16区开始,即0xB0=11*16=176,16~55一级汉字,56~87二级汉字
+        random = new Random();
+        lowPos = 161 + Math.abs(random.nextInt(94));//位码,0xA0打头,范围第1~94列
+
+        byte[] bArr = new byte[2];
+        bArr[0] = (new Integer(highPos)).byteValue();
+        bArr[1] = (new Integer(lowPos)).byteValue();
+        try {
+            str = new String(bArr, "GB2312");    //区位码组合成汉字
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return str;
+    }
 }

+ 13 - 1
coffee-common/src/main/java/com/coffee/common/cache/ClusterConfigStorage.java

@@ -2,6 +2,7 @@ package com.coffee.common.cache;
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.annotation.IEnum;
 import com.coffee.common.cache.value.Value;
 import org.springframework.cache.Cache;
 import org.springframework.cache.CacheManager;
@@ -34,7 +35,15 @@ public class ClusterConfigStorage implements ConfigStorage {
         if (CollectionUtils.isEmpty(values)) {
             return true;
         }
-        boundHashOperations.putAll(values);
+        HashMap<String, Object> map = new HashMap<>();
+        values.forEach((k,v)->{
+            if(v instanceof IEnum){
+                map.put(k,((IEnum) v).getValue());
+            }else {
+                map.put(k,v);
+            }
+        });
+        boundHashOperations.putAll(map);
         return true;
     }
 
@@ -46,6 +55,9 @@ public class ClusterConfigStorage implements ConfigStorage {
         if(value==null){
             boundHashOperations.delete(key);
         }else {
+            if(value instanceof IEnum){
+                value=((IEnum) value).getValue();
+            }
             boundHashOperations.put(key,value);
         }
         return true;

+ 30 - 0
coffee-common/src/main/java/com/coffee/common/cache/value/SimpleValue.java

@@ -1,9 +1,15 @@
 package com.coffee.common.cache.value;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.EnumUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.annotation.IEnum;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.yaml.snakeyaml.util.EnumUtils;
+
 import java.lang.reflect.Array;
+import java.lang.reflect.Field;
 import java.util.*;
 
 @AllArgsConstructor(staticName = "of")
@@ -52,6 +58,30 @@ public class SimpleValue implements Value {
                 return (T) source;
             }
         }
+        if(IEnum.class.isAssignableFrom(targetClass)){
+            if (targetClass.isEnum()) {
+                T[] enumConstants = targetClass.getEnumConstants();
+                for (T enumConstant : enumConstants) {
+                    try {
+                        Field value = enumConstant.getClass().getDeclaredField("value");
+                        value.setAccessible(true);
+                        try {
+                            if(ObjectUtil.equal(value.get(enumConstant),source)){
+                                return enumConstant;
+                            }
+                        } catch (IllegalAccessException e) {
+                            log.error("枚举类转换失败,[value]值无法获取,{}",targetClass.getName());
+                            return null;
+                        }
+                    } catch (NoSuchFieldException e) {
+                        log.error("枚举类转换失败,不存在[value]值,{}",targetClass.getName());
+                        return null;
+                    }
+                }
+            }else {
+                return null;
+            }
+        }
         if (Collection.class.isAssignableFrom(targetClass)) {
             Collection collection = newCollection(targetClass);
             Collection sourceCollection;

+ 1 - 2
coffee-common/src/main/java/com/coffee/common/config/CorsConfig.java

@@ -1,7 +1,6 @@
 package com.coffee.common.config;
 
 import org.springframework.context.annotation.Configuration;
-import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
@@ -12,7 +11,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  * @Description TODO
  * @createTime 2022年03月23日 14:49:00
  */
-//@Configuration
+@Configuration
 public class CorsConfig implements WebMvcConfigurer {
     @Override
     public void addCorsMappings(CorsRegistry registry) {

+ 0 - 48
coffee-common/src/main/java/com/coffee/common/config/mybatis/WebConfig.java

@@ -1,48 +0,0 @@
-package com.coffee.common.config.mybatis;
-
-import java.math.BigInteger;
-import java.nio.charset.Charset;
-import java.util.List;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-@Configuration
-@EnableWebMvc
-public class WebConfig implements WebMvcConfigurer {
-
-    @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-        registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
-    }
-    
-    /**
-     * * 针对Long丢失经度问题;发现后台返回前台的数据不会出现问题。前台请求的数据也是正常的
-     * * 只不过前台js获取到页面上会出现问题,针对以上情况,在前台js中,修改id的name值为id_
-     */
-    @Override
-    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-        MappingJackson2HttpMessageConverter jackson2HttpMessageConverter =
-                new MappingJackson2HttpMessageConverter();
-        
-        ObjectMapper objectMapper = new ObjectMapper();
-        SimpleModule simpleModule = new SimpleModule();
-        simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
-        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
-        simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
-        objectMapper.registerModule(simpleModule);
-        jackson2HttpMessageConverter.setObjectMapper(objectMapper);
-        converters.add(jackson2HttpMessageConverter);
-        converters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
-    }
-    
-
-}

+ 16 - 0
coffee-common/src/main/java/com/coffee/common/config/websocket/WebSocketConstant.java

@@ -16,6 +16,11 @@ public class WebSocketConstant {
     public static final String DEVICE_STATE_COUNT="device-state-count";
     public static final String CLINIC_INFO = "clinic-info";
     public static final String DEVICE_CONFLICT = "device-conflict";
+    /**
+     * 病人监控订阅
+     */
+    public static final String PATIENT_MONITOR="patient-monitor";
+
     /**
      * 主题格式为 device-info-detail:default:45789215623:医院id
      *             alarm-count:default:电量不足:医院id
@@ -86,4 +91,15 @@ public class WebSocketConstant {
     public static String getDeviceConflictTopic(String productName,String param,String tenantId){
         return getTopic(DEVICE_CONFLICT,productName,param,tenantId);
     }
+
+    /**
+     * 获取 病人监护变化主题
+     * @param productName
+     * @param param
+     * @param tenantId
+     * @return
+     */
+    public static String getPatientMonitor(String productName,String param,String tenantId){
+        return getTopic(PATIENT_MONITOR,productName,param,tenantId);
+    }
 }

+ 9 - 6
coffee-common/src/main/java/com/coffee/common/crud/BaseService.java

@@ -10,6 +10,7 @@ import cn.hutool.db.sql.Order;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.enums.SqlMethod;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
 import com.baomidou.mybatisplus.core.toolkit.Assert;
@@ -198,18 +199,20 @@ public abstract class BaseService<M extends BaseMapper<E>, E,PK extends Serializ
     @Override
     public boolean updateBatchById(Collection<E> entityList) {
         entityList.forEach(this::validateBeforeUpdate);
-        entityList.forEach(this::postUpdate);
+        if (super.updateBatchById(entityList)) {
+            entityList.forEach(this::postUpdate);
+            return  true;
+        }
         return false;
     }
 
-    public Page<E> list(QueryParamEntity<E> param) {
+    public IPage<E> list(QueryParamEntity<E> param) {
         //是否为分页查询
         if(ObjectUtil.isNotNull(param.getPage())){
-//            param.getPage().setSearchCount(false);
             QueryWrapper<E> wrapper = build(param);
-            return this.page(param.getPage(),wrapper);
-//            page.setTotal(this.count(wrapper));
-//            return this.page(param.getPage(),build(param));
+            Page<E> page = param.getPage();
+//            page.setCurrent(page.getCurrent()>0?page.getCurrent()-1:0);
+            return this.page(page,wrapper);
         }else {
             try {
                 List<E> list = list(build(param));

+ 25 - 5
coffee-common/src/main/java/com/coffee/common/entity/GenericEntity.java

@@ -1,18 +1,38 @@
 package com.coffee.common.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.Data;
+import org.springframework.validation.annotation.Validated;
 
 
-public abstract class  GenericEntity<PK> implements Entity {
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+@Data
+public abstract class  GenericEntity<PK> implements Entity,RecordModifierEntity,RecordCreationEntity {
     private static final long serialVersionUID = 1L;
 
     @TableId(type = IdType.ASSIGN_ID)
     @ApiModelProperty(value = "id")
-    @Getter
-    @Setter
+    @JsonSerialize(using = ToStringSerializer.class)
     private PK id;
+
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
+
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private String updateBy;
+
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
 }

+ 1 - 0
coffee-common/src/main/java/com/coffee/common/entity/TenantGenericEntity.java

@@ -25,6 +25,7 @@ public abstract class TenantGenericEntity<PK,TN> extends GenericEntity<PK> {
     @Getter
     @TableField(value = "tenant_id",fill = FieldFill.INSERT)
     @Setter
+    @JsonSerialize(using = ToStringSerializer.class)
     private TN tenantId;
 
     @Getter

+ 1 - 0
coffee-common/src/main/java/com/coffee/common/entity/param/Term.java

@@ -53,6 +53,7 @@ public class Term implements Cloneable, Serializable {
             @Override
             public void build(QueryWrapper<?> queryWrapper,Term term){
                 term.getTermType().build(queryWrapper,StrUtil.toUnderlineCase(term.getColumn()),term.getValue());
+                term.getTermType().buildCollection(queryWrapper,StrUtil.toUnderlineCase(term.getColumn()),term.getValues());
             };
         };
 

+ 4 - 5
coffee-common/src/main/java/com/coffee/common/enums/SexEnum.java

@@ -19,18 +19,17 @@ public enum SexEnum  implements IEnum<Integer> {
     /**
      * 男
      */
-    MAN(1,"1", "男"),
+    MAN(1,"男"),
     /**
      * 女
      */
-    WOMAN(2,"2", "女"),
+    WOMAN(2, "女"),
     /**
      * 未知
      */
-    UNKNOW(3,"3", "未知");
+    UNKNOW(3, "未知");
 
     private Integer value;
-    private String code;
-    private String desc;
+    private String text;
 
 }

+ 5 - 0
coffee-framework/pom.xml

@@ -37,6 +37,11 @@
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>provided</scope>
+        </dependency>
         <!-- 系统模块 -->
         <dependency>
             <groupId>com.coffee</groupId>

+ 14 - 13
coffee-framework/src/main/java/com/coffee/framework/config/SaTokenConfig.java

@@ -6,10 +6,14 @@ import cn.dev33.satoken.router.SaRouter;
 import cn.dev33.satoken.stp.StpUtil;
 import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.HandlerInterceptor;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -19,8 +23,17 @@ import java.util.List;
  */
 @Slf4j
 @Configuration
-public class SaTokenConfig implements WebMvcConfigurer {
+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);
+        });
+    }
     private static final List<String> IGNORE_URL = Lists.newArrayList();
 
     static {
@@ -41,16 +54,4 @@ public class SaTokenConfig implements WebMvcConfigurer {
         IGNORE_URL.add("/system/sysDept/**");
     }
 
-    @Override
-    public void addInterceptors(InterceptorRegistry registry) {
-         // 注册路由拦截器,自定义认证规则
-        registry.addInterceptor(new SaRouteInterceptor((req, res, handler) -> {
-            log.info("访问路径:{}", req.getRequestPath());
-            SaRouter.match("/**")
-                    .notMatch(IGNORE_URL)
-                    .check(StpUtil::checkLogin);
-        }));
-        registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
-    }
-
 }

+ 0 - 6
coffee-framework/src/main/java/com/coffee/framework/config/WebAppMvcConfig.java

@@ -34,12 +34,6 @@ public class WebAppMvcConfig implements WebMvcConfigurer {
     public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
         MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
         ObjectMapper objectMapper = converter.getObjectMapper();
-        // 生成JSON时,将所有Long转换成String
-//        SimpleModule dateSimpleModule = new SimpleModule();
-//        dateSimpleModule.addSerializer(Long.class, ToStringSerializer.instance);
-//        dateSimpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
-//
-//        objectMapper.registerModule(dateSimpleModule);
         // 时间格式化
         objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

+ 7 - 3
coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/MybatisPlusConfig.java

@@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionIntercepto
 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.pagination.dialects.MySqlDialect;
 import com.coffee.common.Constants;
 import com.coffee.common.bo.LoginUser;
 import com.coffee.common.entity.TenantGenericEntity;
@@ -29,6 +30,7 @@ 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.mock.web.MockHttpServletRequest;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
@@ -85,12 +87,13 @@ public class MybatisPlusConfig {
         MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
         // 数据权限插件
         interceptor.addInnerInterceptor(dataPermissionInterceptor());
+        //多租户插件
+        interceptor.addInnerInterceptor(tenantLineInnerInterceptor());
         // 分页插件
         interceptor.addInnerInterceptor(paginationInnerInterceptor());
         // 乐观锁插件
         interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
-        //多租户插件
-        interceptor.addInnerInterceptor(tenantLineInnerInterceptor());
+
         return interceptor;
     }
 
@@ -113,6 +116,7 @@ public class MybatisPlusConfig {
         paginationInnerInterceptor.setDbType(DbType.MYSQL);
         // 设置最大单页限制数量,默认 500 条,-1 不受限制
         paginationInnerInterceptor.setMaxLimit(-1L);
+        paginationInnerInterceptor.setDialect(new MySqlDialect());
         return paginationInnerInterceptor;
     }
 
@@ -138,7 +142,7 @@ public class MybatisPlusConfig {
             public boolean ignoreTable(String tableName) {
                 ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
                 //非用户请求,即来自程序自身,则忽略
-                if(request==null){
+                if(request==null||request.getRequest() instanceof MockHttpServletRequest){
                     return true;
                 }
                 StringBuffer url = request.getRequest().getRequestURL();

+ 97 - 98
coffee-system/src/main/java/com/coffee/aliyun/AliyunConsumerGroupService.java

@@ -1,23 +1,31 @@
 package com.coffee.aliyun;
 
+import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.coffee.aliyun.utils.Constants;
+import com.coffee.aliyun.utils.EnumUtils;
+import com.coffee.aliyun.utils.Items;
+import com.coffee.bus.bean.AliIotConfig;
+import com.coffee.bus.entity.BusDeviceEntity;
+import com.coffee.bus.entity.BusDeviceHistoryEntity;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
-import lombok.AllArgsConstructor;
+import com.coffee.bus.service.LocalBusDeviceHistoryService;
+import com.coffee.bus.service.LocalBusDeviceService;
+import com.coffee.bus.service.LocalBusInfusionHistoryService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.PostConstruct;
 import javax.jms.Message;
 import javax.jms.MessageListener;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutorService;
@@ -26,7 +34,7 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
 /**
-* @Author longsanlang
+* @Author 龙三郎
 * @Date 2022-4-06 16:22:13
 * @Version 1.0
 * @Description 阿里云物联网平台服务端订阅
@@ -34,19 +42,21 @@ import java.util.concurrent.TimeUnit;
 @Service
 @Slf4j
 public class AliyunConsumerGroupService {
-
-    private final ApplicationContext applicationContext;
-
-    // 初始化订阅客户端
-    // 阿里云账号信息
-    private final AliyunIotSubscribeClient client;
-
-    public AliyunConsumerGroupService(ApplicationContext applicationContext, AliyunIotSubscribeClient client) {
-        this.applicationContext = applicationContext;
-        this.client = client;
-    }
-
-    @Value("${aliyun.data-access.enable:false}")
+    @Autowired
+    @Lazy
+    private AliyunIotSubscribeClient client;
+    @Autowired
+    @Lazy
+    private LocalBusDeviceService deviceService;
+    @Autowired
+    @Lazy
+    private LocalBusInfusionHistoryService infusionHistoryService;
+
+    @Autowired
+    @Lazy
+    private LocalBusDeviceHistoryService deviceHistoryService;
+
+    @Value("${aliyun.server-subscription.enable:false}")
     private boolean isEnable;
 
     // 开启服务端订阅
@@ -94,113 +104,102 @@ public class AliyunConsumerGroupService {
      */
     private static final String IOTID = "iotId";
     private static final String PRODUCTKEY = "productKey";
+    private static final String DEVICENAME = "deviceName";
     private static final String TOPIC = "topic";
     private static final String MESSAGEID = "messageId";
     private static final String ITEMS = "items";
     private static final String VALUE = "value";
     private static final String STATUS = "status";
+    private static final String CONTENT = "content";
 
-    private synchronized void processMessage(Message message) {
+    private void processMessage(Message message) {
 
-        PlatformDataLog dataLog = new PlatformDataLog();
+        PlatformLog platformLog = new PlatformLog();
         Map<String, Object> platformData = new HashMap<>();
         try {
-            byte[] body = message.getBody(byte[].class);
-            String contentString = new String(body);
+            // 获取主题,消息id和内容
             String topic = message.getStringProperty(TOPIC);
             String messageId = message.getStringProperty(MESSAGEID);
+            JSONObject content = JSON.parseObject(new String(message.getBody(byte[].class)));
+            // 平台数据
             platformData.put(TOPIC,topic);
             platformData.put(MESSAGEID,messageId);
-            platformData.put("content",contentString);
-
+            platformData.put(CONTENT,content);
             log.info("阿里云物联网发送的数据:"+JSON.toJSONString(platformData));
 
-            /**
-             * platformData:
-             * {
-             * "topic":"/a1M7k1TAECc/ceshi001/thing/event/property/post",
-             * "messageId":"1496410088574460416",
-             * "content":"{\"deviceType\":\"CustomCategory\",
-             * \"iotId\":\"0syOzMqwkGebZBGKa08d000000\",
-             * \"requestId\":\"254\",\"checkFailedData\":{},
-             * \"productKey\":\"a1M7k1TAECc\",\"gmtCreate\":1645606941721,
-             * \"deviceName\":\"ceshi001\",
-             * \"items\":{
-             * \"total\":{\"value\":100,\"time\":1645606941717},
-             * \"pumpCode\":{\"value\":\"5719512336330299\",\"time\":1645606941717},
-             * \"dataNumber\":{\"value\":254,\"time\":1645606941717},
-             * \"PCAInvalid\":{\"value\":0,\"time\":1645606941717},
-             * \"alarm\":{\"value\":0,\"time\":1645606941717},
-             * \"flowRate\":{\"value\":2,\"time\":1645606941717},
-             * \"PCAValid\":{\"value\":0,\"time\":1645606941717},
-             * \"forecast\":{\"value\":0,\"time\":1645606941717},
-             * \"finished\":{\"value\":17,\"time\":1645606941717},
-             * \"battery\":{\"value\":65,\"time\":1645606941717},
-             * \"runStatus\":{\"value\":2,\"time\":1645606941717},
-             * \"patientCode\":{\"value\":111110000,\"time\":1645606941717}}}"
-             * }
-             */
-            // 日志编号
-            dataLog.setCode(messageId);
-            // 平台数据
-            dataLog.setPlatformData(JSON.toJSONString(platformData));
-            // 将内容转换成对象
-            JSONObject content = JSON.parseObject(contentString);
-            // 设备编号
-            String deviceCode = content.getString(IOTID);
-            String productKey = content.getString(PRODUCTKEY);
-            // 设置平台和设备
-            dataLog.setPlatformCode(PlatformType.ALIYUN);
-            dataLog.setDeviceCode(deviceCode);
-            dataLog.setPlatformProductCode(productKey);
+            // 设备名称
+            String deviceName = content.getString(DEVICENAME);
+            // 创建设备对象
+            Date now = new Date();
             // 根据topic判断数据类型
             if (topic.matches("^/as/mqtt/status/[\\w\\/]*")){//设备上下线状态
+                BusDeviceEntity device = new BusDeviceEntity();
+                device.setDeviceId(deviceName);
                 String status = content.getString(STATUS);
+                device.setStatus(EnumUtils.getDeviceStatusEnum2(status));
                 if (status.equals("online")){
-                    log.info(deviceCode+"设备上线");
+                    log.info(deviceName+"设备上线");
                 }else if (status.equals("offline")){
-                    log.info(deviceCode+"设备下线");
+                    log.info(deviceName+"设备下线");
                 }else {
-                    log.info(deviceCode+"设备未激活");
+                    log.info(deviceName+"设备未激活");
                 }
+                // 更新设备状态
+                deviceService.updateByDeviceId(device);
             }else if (topic.matches("[\\w\\/]*event/property/post$")){//设备属性上报
-                // 设备属性上报
-
-
-                // 发布设备信息事件
-                DeviceInfoEvent deviceInfoEvent = new DeviceInfoEvent(this,new BusDeviceRunningEntity(),"123456");
-                applicationContext.publishEvent(deviceInfoEvent);
-
-            }else if(topic.matches("[\\w\\/]+thing/liftcycle$")){// 设备生命周期
-
-                /**
-                 * 生命周期,删除设备
-                 * {"topic":"/a1M7k1TAECc/456789/thing/lifecycle",
-                 * "messageId":"1511903665358296576",
-                 * "content":"{\"iotId\":\"hGMEfTMBv9O6gyvpMSvi000000\",\"action\":\"delete\",
-                 * \"messageCreateTime\":1649300898278,\"productKey\":\"a1M7k1TAECc\",
-                 * \"deviceName\":\"456789\"}"}
-                 *
-                 * 生命周期,添加设备
-                 * {"topic":"/a1M7k1TAECc/ceshidevice007/thing/lifecycle",
-                 * "messageId":"1511904535630241792",
-                 * "content":"{\"iotId\":\"KsCWSsSf86fjD6ux16sC000000\",
-                 * \"deviceSecret\":\"989561a8d3bd939bfb8321bafc61b64c\",
-                 * \"action\":\"create\",\"messageCreateTime\":1649301105776,
-                 * \"productKey\":\"a1M7k1TAECc\",\"deviceName\":\"ceshidevice007\"}"}
-                 *
-                 */
-
+                // 设备属性集合
+                Items items = new Items(content.getJSONObject("items"));
+                BusDeviceRunningEntity deviceRunning = new BusDeviceRunningEntity();
+                deviceRunning.setFiledsByItems(deviceName,items);
+                // 发布事件
+                SpringUtil.publishEvent(new DeviceInfoEvent(this,deviceRunning,deviceName));
+
+
+//                BusInfusionHistoryEntity infusionHistory = infusionHistoryService.saveInfusion(deviceName,items);
+//                // 保存到device_history表中
+//                BusDeviceHistoryEntity deviceHistory = new BusDeviceHistoryEntity();
+//                // 将infusionHistory对象的值,复制到deviceHistory对象
+//                BeanUtils.copyProperties(infusionHistory,deviceHistory);
+//                deviceHistory.setId(null);
+//                deviceHistory.setInfusionId(infusionHistory.getId());
+//                // 保存设备的历史数据
+//                deviceHistoryService.save(deviceHistory);
+
+            }else if(topic.matches("[\\w\\/]+thing/lifecycle$")){// 设备生命周期
+                // 获取生命周期类型
+                String action = content.getString("action");
+                if ("create".equals(action)){
+                    // 创建设备
+                    BusDeviceEntity device = new BusDeviceEntity();
+                    device.setDeviceId(deviceName);
+                    device.setCreateBy(Constants.DefaultCreateBy);
+                    device.setUpdateBy(Constants.DefaultUpdateBy);
+                    device.setUpdateTime(now);
+                    device.setTenantId(Constants.DefaultHospital);
+
+                    // 配置信息
+                    AliIotConfig config = new AliIotConfig();
+                    config.setDeviceName(deviceName);
+                    config.setDeviceSecret(content.getString("deviceSecret"));
+                    config.setIotId(content.getString("iotId"));
+                    config.setProductKey(content.getString("productKey"));
+
+                    // 设置配置信息
+                    device.setConfig(config);
+                    deviceService.saveByDeviceId(device);
+                }else if ("delete".equals(action)){
+                    // 删除设备
+                    deviceService.removeByDeviceId(deviceName);
+                }
 
             }else {
-                log.info("未知的topic:"+topic);
+                log.error("未知的topic:"+topic);
             }
 
         } catch (Exception e) {
-//            e.printStackTrace();
             // 错误标志
-            dataLog.setIsError("1");
-            dataLog.setErrorLog(e.getMessage());
+            platformLog.setIsError("1");
+            platformLog.setErrorLog(e.getMessage());
             log.error("数据处理失败 ", e);
         }
         // 存储日志

+ 17 - 24
coffee-system/src/main/java/com/coffee/aliyun/AliyunIotSubscribeClient.java

@@ -1,5 +1,6 @@
 package com.coffee.aliyun;
 
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Base64;
@@ -23,7 +24,7 @@ import java.util.Hashtable;
 import java.util.List;
 
 /**
- * @Author XX
+ * @Author 龙三郎
  * @Date 2021-06-17 10:53:30
  * @Version 1.0
  * @Description XXX
@@ -43,11 +44,13 @@ public class AliyunIotSubscribeClient {
         this.consumerGroupId = platformAccount.getConsumerGroupId();
         this.aliyunUid = platformAccount.getAliyunUid();
         this.iotInstanceId = platformAccount.getIotInstanceId();
-        //
-//        setClientIdAndHost();
+
+        this.host = aliyunUid+".iot-amqp."+ regionId +".aliyuncs.com";
+        // 设置客户端id
+        setClientIdAndHost();
     }
 
-    // 设置客户端id和host
+    // 设置客户端id
     private void setClientIdAndHost(){
         // 获取ip地址
         InetAddress addr = null;
@@ -56,32 +59,29 @@ public class AliyunIotSubscribeClient {
         } catch (UnknownHostException e) {
             e.printStackTrace();
         }
-        String ip = addr.getHostAddress();
-
-        this.clientId = consumerGroupId + ip;
-        this.host = aliyunUid+".iot-amqp."+ regionId +".aliyuncs.com";
+        this.clientId = IdWorker.getIdStr();
     }
 
-    private String accessKey = "LTAI4FhB19MgQuviGxwA3aod";
-    private String accessSecret = "cQQVkATR0yv2G9CEtfjAhEGBepPDRs";
-    private String consumerGroupId = "DEFAULT_GROUP";
-    private String aliyunUid = "1177450762772738";
-    private String regionId = "cn-shanghai";
+    private String accessKey;
+    private String accessSecret;
+    private String consumerGroupId;
+    private String aliyunUid;
+    private String regionId;
 
     //iotInstanceId:企业版实例请填写实例ID,公共实例请填空字符串""。
-    private String iotInstanceId = "";
+    private String iotInstanceId;
 
     //控制台服务端订阅中消费组状态页客户端ID一栏将显示clientId参数。
     //建议使用机器UUID、MAC地址、IP等唯一标识等作为clientId。便于您区分识别不同的客户端。
-    private String clientId = "123456789";
+    private String clientId;
 
     //${YourHost}为接入域名,请参见AMQP客户端接入说明文档。
-    private String host = "1177450762772738.iot-amqp.cn-shanghai.aliyuncs.com";
+    private String host;
 
     // 指定单个进程启动的连接数
     // 单个连接消费速率有限,请参考使用限制,最大64个连接
     // 连接数和消费速率及rebalance相关,建议每500QPS增加一个连接
-    private static int connectionCount = 4;
+    private static int connectionCount = 1;
 
     @Getter
     private List<Connection> connections = null;
@@ -155,7 +155,6 @@ public class AliyunIotSubscribeClient {
         public void onConnectionEstablished(URI remoteURI) {
             log.info("连接成功, remoteUri:{}", remoteURI);
         }
-
         /**
          * 尝试过最大重试次数之后,最终连接失败。
          */
@@ -163,7 +162,6 @@ public class AliyunIotSubscribeClient {
         public void onConnectionFailure(Throwable error) {
             log.error("连接失败, {}", error.getMessage());
         }
-
         /**
          * 连接中断。
          */
@@ -171,7 +169,6 @@ public class AliyunIotSubscribeClient {
         public void onConnectionInterrupted(URI remoteURI) {
             log.info("连接中断, remoteUri:{}", remoteURI);
         }
-
         /**
          * 连接中断后又自动重连上。
          */
@@ -179,16 +176,12 @@ public class AliyunIotSubscribeClient {
         public void onConnectionRestored(URI remoteURI) {
             log.info("自动重连, remoteUri:{}", remoteURI);
         }
-
         @Override
         public void onInboundMessage(JmsInboundMessageDispatch envelope) {}
-
         @Override
         public void onSessionClosed(Session session, Throwable cause) {}
-
         @Override
         public void onConsumerClosed(MessageConsumer consumer, Throwable cause) {}
-
         @Override
         public void onProducerClosed(MessageProducer producer, Throwable cause) {}
     };

+ 1 - 1
coffee-system/src/main/java/com/coffee/aliyun/PlatformAccount.java

@@ -23,7 +23,7 @@ import org.springframework.context.annotation.Configuration;
 public class PlatformAccount {
     private String accessKey = "LTAI4FhB19MgQuviGxwA3aod";
     private String accessSecret = "cQQVkATR0yv2G9CEtfjAhEGBepPDRs";
-    private String consumerGroupId = "DEFAULT_GROUP";
+    private String consumerGroupId = "nalavzBm4RuVJc0BUij7000100";
     private String aliyunUid = "1177450762772738";
     private String regionId = "cn-shanghai";
     //iotInstanceId:企业版实例请填写实例ID,公共实例请填空字符串""。

+ 1 - 1
coffee-system/src/main/java/com/coffee/aliyun/PlatformDataLog.java → coffee-system/src/main/java/com/coffee/aliyun/PlatformLog.java

@@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
-public class PlatformDataLog {
+public class PlatformLog {
     @TableId(value = "id",type = IdType.AUTO)
     private Long id;
     private String code;

+ 27 - 23
coffee-system/src/main/java/com/coffee/aliyun/AliyunIotSdk.java → coffee-system/src/main/java/com/coffee/aliyun/sdk/AliyunIotSdk.java

@@ -1,4 +1,4 @@
-package com.coffee.aliyun;
+package com.coffee.aliyun.sdk;
 
 import com.alibaba.fastjson.JSON;
 import com.aliyuncs.DefaultAcsClient;
@@ -6,7 +6,12 @@ import com.aliyuncs.exceptions.ClientException;
 import com.aliyuncs.iot.model.v20180120.*;
 import com.aliyuncs.profile.DefaultProfile;
 import com.aliyuncs.profile.IClientProfile;
+import com.coffee.aliyun.PlatformAccount;
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -16,29 +21,26 @@ import java.util.Map;
 //import com.tuoren.common.utils.StringUtils;
 
 /**
- * @Author XX
+ * @Author 龙三郎
  * @Date 2021-06-11 08:10:58
  * @Version 1.0
  * @Description XXX
  */
-@Data
+@Configuration
+@EnableConfigurationProperties(PlatformAccount.class)
+@Slf4j
 public class AliyunIotSdk {
-    private static final String ACCESSKEY = "accessKey";
-    private static final String ACCESSSECRET = "accessSecret";
-    private static final String REFIONID = "regionId";
+
+
+    @Value("${aliyun.product.productKey:a1ALlsBa2ZK}")
+    private String productKey;
 
     private String accessKey;
     private String accessSecret;
     private String regionId;
     // client
     private DefaultAcsClient client;
-    public AliyunIotSdk(String accessKey, String accessSecret, String regionId) {
-        this.accessKey = accessKey;
-        this.accessSecret = accessSecret;
-        this.regionId = regionId;
-    }
-
-    public AliyunIotSdk(PlatformAccount platformAccount) {
+    public AliyunIotSdk(PlatformAccount platformAccount){
         this.accessKey = platformAccount.getAccessKey();
         this.accessSecret = platformAccount.getAccessSecret();
         this.regionId = platformAccount.getRegionId();
@@ -105,6 +107,9 @@ public class AliyunIotSdk {
 
         // 获取阿里云SDK客户端
         DefaultAcsClient client = this.getAliyuniotClient();
+        List<QueryDeviceResponse.DeviceInfo> list = new ArrayList<>();
+        Integer pageSize = 100,currentPage = 1;
+
         RegisterDeviceRequest request = new RegisterDeviceRequest();
         // 产品key,必需
         request.setProductKey(productKey);
@@ -113,7 +118,7 @@ public class AliyunIotSdk {
         try {
             RegisterDeviceResponse response = client.getAcsResponse(request);
             System.out.println(response.getSuccess());
-            // 获取失败直接跳出
+            // 获取失败直接跳出循环
             if (!response.getSuccess()){
                 return null;
             }
@@ -151,10 +156,9 @@ public class AliyunIotSdk {
 
     /**
      * 获取设备
-     * @param productKey
      * @return
      */
-    public List<QueryDeviceResponse.DeviceInfo> queryDevice(String productKey){
+    public List<QueryDeviceResponse.DeviceInfo> queryDevice(){
 
         // 获取阿里云SDK客户端
         DefaultAcsClient client = this.getAliyuniotClient();
@@ -292,23 +296,23 @@ public class AliyunIotSdk {
 
     /**
      * 获取设备的详细信息
-     * @param iotId
+     * @param deviceName
      */
-    public QueryDeviceDetailResponse.Data queryDeviceDetail(String iotId){
+    public QueryDeviceDetailResponse queryDeviceDetail(String deviceName){
         // 获取阿里云SDK客户端
         DefaultAcsClient client = this.getAliyuniotClient();
 
         QueryDeviceDetailRequest _request = new QueryDeviceDetailRequest();
-        _request.setIotId(iotId);
+        _request.setProductKey(productKey);
+        _request.setDeviceName(deviceName);
 
-        QueryDeviceDetailResponse.Data data = null;
+        QueryDeviceDetailResponse acsResponse = null;
         try {
-            QueryDeviceDetailResponse acsResponse = client.getAcsResponse(_request);
-            data = acsResponse.getData();
+            acsResponse = client.getAcsResponse(_request);
         } catch (ClientException e) {
             e.printStackTrace();
         }
-        return data;
+        return acsResponse;
     }
 
 

+ 16 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/Constants.java

@@ -0,0 +1,16 @@
+package com.coffee.aliyun.utils;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-26 13:44:36
+ * @Version 1.0
+ * @Description XXX
+ */
+public class Constants {
+    // 默认医院
+    public static final String DefaultHospital = "1";
+    // 默认创建人
+    public static final String DefaultCreateBy = "1";
+    // 默认更新人
+    public static final String DefaultUpdateBy = "1";
+}

+ 37 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/DeviceAlarmUtils.java

@@ -0,0 +1,37 @@
+package com.coffee.aliyun.utils;
+
+import com.coffee.bus.enums.DeviceAlarmEnum;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-29 11:04:04
+ * @Version 1.0
+ * @Description 根据阿里云发送的报警标识,获取报警枚举对象。阿里云发送的报警是0-9的整数。
+ */
+public class DeviceAlarmUtils {
+    public static DeviceAlarmEnum getAlarm(Integer i){
+        if (i == 0){
+            return DeviceAlarmEnum.None;
+        }else if (i == 1){
+            return DeviceAlarmEnum.Bubble;
+        }else if (i == 2){
+            return DeviceAlarmEnum.Jam;
+        }else if (i == 3){
+            return DeviceAlarmEnum.NotBox;
+        }else if (i == 4){
+            return DeviceAlarmEnum.InfusionMax;
+        }else if (i == 5){
+            return DeviceAlarmEnum.Limit;
+        }else if (i == 6){
+            return DeviceAlarmEnum.Finished;
+        }else if (i == 7){
+            return DeviceAlarmEnum.LowBattery;
+        }else if (i == 8){
+            return DeviceAlarmEnum.OutOfControl;
+        }else if (i == 9){
+            return DeviceAlarmEnum.Machine;
+        }else {
+            return DeviceAlarmEnum.Finished;
+        }
+    }
+}

+ 28 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/DeviceRunStatusUtils.java

@@ -0,0 +1,28 @@
+package com.coffee.aliyun.utils;
+
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-29 11:36:03
+ * @Version 1.0
+ * @Description 根据阿里云发送的运行标识,获取运行枚举对象。阿里云发送的运行是0-4的整数。
+ */
+public class DeviceRunStatusUtils {
+    public static DeviceStatusEnum getRunStatus(Integer i){
+        if (i == 0){
+            return DeviceStatusEnum.Shutdown;
+        }else if (i == 1){
+            return DeviceStatusEnum.StartUp;
+        }else if (i == 2){
+            return DeviceStatusEnum.Running;
+        }else if (i == 3){
+            return DeviceStatusEnum.Pause;
+        }else if (i == 4){
+            return DeviceStatusEnum.Waiting;
+        }else {
+            return DeviceStatusEnum.Shutdown;
+        }
+    }
+}

+ 26 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/DeviceTypeUtils.java

@@ -0,0 +1,26 @@
+package com.coffee.aliyun.utils;
+
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-29 11:52:36
+ * @Version 1.0
+ * @Description XXX
+ */
+public class DeviceTypeUtils {
+    public static DeviceTypeEnum getDeviceType(Integer i){
+        if (i == 0){
+            return DeviceTypeEnum.no;
+        }else if (i == 1){
+            return DeviceTypeEnum.continuous;
+        }else if (i == 2){
+            return DeviceTypeEnum.pulse;
+        }else if (i == 3){
+            return DeviceTypeEnum.intelligent;
+        }else {
+            return DeviceTypeEnum.other;
+        }
+    }
+}

+ 30 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/EnumUtils.java

@@ -0,0 +1,30 @@
+package com.coffee.aliyun.utils;
+
+import cn.hutool.core.util.StrUtil;
+import com.coffee.bus.enums.DeviceStatusEnum2;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-05-06 15:03:48
+ * @Version 1.0
+ * @Description XXX
+ */
+public class EnumUtils {
+    /**
+     * @author 龙三郎
+     * 根据阿里云返回的状态获取枚举
+     * @param status
+     * @return
+     */
+    public static DeviceStatusEnum2 getDeviceStatusEnum2(String status){
+        status = status.toLowerCase();
+        if ("online".equals(status)){
+            return DeviceStatusEnum2.ONLINE;
+        }else if ("offline".equals(status)){
+            return DeviceStatusEnum2.OFFLINE;
+        }else{
+            return DeviceStatusEnum2.NOACTIVE;
+        }
+    }
+
+}

+ 33 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/Items.java

@@ -0,0 +1,33 @@
+package com.coffee.aliyun.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-26 10:18:08
+ * @Version 1.0
+ * @Description 方便获取阿里云数据中的items中的属性的value
+ */
+@AllArgsConstructor
+public class Items {
+    public static final String VALUE = "value";
+
+    private JSONObject items;
+
+    public String getString(PumpParams param){
+        return items.getJSONObject(param.getParam()).getString(VALUE);
+    }
+
+    public Integer getInteger(PumpParams param){
+        return items.getJSONObject(param.getParam()).getInteger(VALUE);
+    }
+
+    public BigDecimal getBigDecimal(PumpParams param){
+        return items.getJSONObject(param.getParam()).getBigDecimal(VALUE);
+    }
+
+}

+ 46 - 0
coffee-system/src/main/java/com/coffee/aliyun/utils/PumpParams.java

@@ -0,0 +1,46 @@
+package com.coffee.aliyun.utils;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-26 10:37:47
+ * @Version 1.0
+ * @Description 设备上传的数据参数
+ */
+@AllArgsConstructor
+public enum PumpParams {
+    protocolHeader("protocolHeader","协议头"),
+    dataLength("dataLength","数据长度"),
+    pumpType("pumpType","泵类型"),
+    classification("classification","分类标识"),
+    dataNumber("dataNumber","数据编号"),
+    patientCodeLength("patientCodeLength","住院号长度"),
+    patientCode("patientCode","住院号"),
+    ward("ward","病区"),
+    bedNo("bedNo","床号"),
+    totalDose("totalDose","总量"),
+    maxDose("maxDose","极限量"),
+    singleDosis("singleDose","追加量"),
+    lockTime("lockTime","锁时时间"),
+    flow("flow","持续量"),
+    finishedDose("finishedDose","已输入量"),
+    firstDosis("firstDose","首次量"),
+    pcaValid("pcaValid","PCA有效次数"),
+    pcaInvalid("pcaInvalid","PCA无效次数"),
+    electricQuantity("electricQuantity","电池电量"),
+    runStatus("runStatus","运行状态"),
+    alarmStatus("alarmStatus","报警"),
+    warnWillFinished("warnWillFinished","输液将结束预报"),
+    warnAnalgesicPoor("warnAnalgesicPoor","镇痛不足预报"),
+    warnLowBattery("warnLowBattery","电量偏低预报"),
+    CRC("CRC","CRC");
+
+    @Getter
+    private String param;
+    @Getter
+    private String info;
+
+}

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

@@ -3,7 +3,7 @@ package com.coffee.bus.controller;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.coffee.bus.entity.BusDeviceAlarmEntity;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.service.LocalBusDeviceAlarmService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
@@ -48,7 +48,7 @@ public class BusAlarmController extends BaseCrudController<BusDeviceAlarmEntity,
     }
 
     public static void main(String[] args) {
-        set(DeviceEnum.continuous);
+        set(DeviceTypeEnum.continuous);
     }
 
 

+ 10 - 6
coffee-system/src/main/java/com/coffee/bus/controller/BusClinicController.java

@@ -1,18 +1,17 @@
 package com.coffee.bus.controller;
 
 import com.baomidou.mybatisplus.core.mapper.Mapper;
+import com.coffee.bus.controller.vo.ClinicStatsVo;
 import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.service.LocalBusClinicService;
-import com.coffee.bus.service.LocalBusPatientService;
+import com.coffee.bus.service.dto.ClinicStatsReturnResult;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
+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.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
+import org.springframework.web.bind.annotation.*;
 /**
  * @author lifang
  * @version 1.0.0
@@ -28,6 +27,11 @@ public class BusClinicController extends BaseCrudController<BusClinicEntity, Str
     private final LocalBusClinicService clinicService;
 
 
+    @PostMapping("/stats")
+    @ApiOperation("临床过程中的数据记录")
+    public R<ClinicStatsReturnResult> list(@RequestBody ClinicStatsVo statsVo) {
+        return R.success(clinicService.stats(statsVo));
+    }
     /**
      * 权限控制前缀
      * @return

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

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

+ 61 - 0
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceManualController.java

@@ -0,0 +1,61 @@
+package com.coffee.bus.controller;
+
+import cn.dev33.satoken.SaManager;
+import cn.dev33.satoken.stp.StpLogic;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.mapper.Mapper;
+import com.coffee.bus.controller.vo.DeviceManualVo;
+import com.coffee.bus.entity.BusDeviceManualEntity;
+import com.coffee.bus.entity.BusDrugEntity;
+import com.coffee.bus.service.LocalBusDeviceManualService;
+import com.coffee.bus.service.LocalBusDrugService;
+import com.coffee.bus.service.dto.ManualMonitorQuery;
+import com.coffee.bus.service.dto.ManualMonitorResult;
+import com.coffee.common.crud.BaseService;
+import com.coffee.common.crud.controller.BaseCrudController;
+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.List;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusDrugController.java
+ * @Description TODO
+ * @createTime 2022年04月08日 10:18:00
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/device/manual")
+@Api(tags = "其他监控(即手动添加设备管理)")
+public class BusDeviceManualController {
+    private final LocalBusDeviceManualService deviceManualService;
+
+    @PostMapping("/edit")
+    @ApiOperation(value = "编辑病人信息",notes = "编辑病人信息,权限【device:manual:edit】")
+    public R edit(@RequestBody DeviceManualVo entity){
+//        deviceManualService.update(entity.getManual(),entity.getClinic());
+        return R.success();
+    }
+
+    @PostMapping("/save")
+    @ApiOperation(value = "新增病人信息",notes = "新增病人信息,权限【device:manual:save】")
+    public R save(@RequestBody DeviceManualVo entity){
+        deviceManualService.save(entity.getManual(),entity.getClinic());
+        return R.success();
+    }
+
+    @PostMapping("/no_page")
+    @ApiOperation(value = "查询其他监控输注列表,不分页",notes = "新增病人信息,权限【device:manual:query】")
+    public R<List<ManualMonitorResult>> list(@RequestBody ManualMonitorQuery query){
+        return R.success(deviceManualService.selectMonitor(query));
+    }
+}

+ 14 - 12
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRunningController.java

@@ -3,16 +3,17 @@ package com.coffee.bus.controller;
 import cn.dev33.satoken.SaManager;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.stp.StpLogic;
-import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.service.dto.DeviceShiftConfig;
-import com.coffee.bus.service.dto.ManualUndoConfig;
-import com.coffee.bus.controller.vo.NoPumpConfig;
+import com.coffee.bus.controller.vo.DeviceRunningMockVo;
+import com.coffee.bus.controller.vo.NoPumpConfigVo;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.enums.DeviceAlarmEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
 import com.coffee.bus.service.LocalBusDeviceRunningService;
+import com.coffee.bus.utils.MockUtils;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseQueryController;
 import com.coffee.common.result.R;
@@ -21,6 +22,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springframework.boot.SpringApplication;
 import org.springframework.web.bind.annotation.*;
 
 /**
@@ -52,7 +54,7 @@ public class BusDeviceRunningController implements BaseQueryController<BusDevice
     @PostMapping("/nopump")
     @SaCheckPermission("device:running:add")
     @ApiOperation(value = "新增无泵数据,权限为device:running:add")
-    public R saveNoPump(@RequestBody NoPumpConfig noPump){
+    public R saveNoPump(@RequestBody NoPumpConfigVo noPump){
         return R.success();
     }
 
@@ -69,13 +71,13 @@ public class BusDeviceRunningController implements BaseQueryController<BusDevice
                 .eq(BusDeviceRunningEntity::getClinicId,clinic)));
     }
 
-//    @PostMapping("/undo")
-//    @SaCheckPermission("device:running:undo")
-//    @ApiOperation(value = "进行病患下临床的撤泵操作",notes = "在进行撤泵操作之前[{/count/clinic}],即【查询临床下泵的数量】接口,当出现泵重复状态时,提醒用户处理,权限标识为【device:running:undo】")
-//    public R undo(@RequestBody ManualUndoConfig manualUndoConfig){
-//        netPumpService.undo(manualUndoConfig);
-//        return R.success();
-//    }
+    @PostMapping("/mock")
+    @ApiOperation(value = "模拟设备运行数据",notes = "在进行数据模拟前,请确保该泵存在于bus_device表中,若不存在,请添加后再模拟数据,当出现泵重复状态时,权限标识为【无】")
+    public R<BusDeviceRunningEntity> mock(@RequestBody DeviceRunningMockVo mockVo){
+        BusDeviceRunningEntity mock = MockUtils.mock(mockVo.getDeviceId(), mockVo.getPatientCode(), mockVo.getClassification(), mockVo.getType());
+        SpringUtil.publishEvent(new DeviceInfoEvent(this,mockVo,mockVo.getDeviceId()));
+        return R.success(mock);
+    }
 
 
 

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

@@ -2,23 +2,19 @@ package com.coffee.bus.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.controller.vo.MonitorFinished;
-import com.coffee.bus.entity.BusDeviceRunningEntity;
-import com.coffee.bus.entity.BusPatientEntity;
-import com.coffee.bus.entity.PatientMonitorDomain;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.coffee.bus.controller.vo.MonitorFinishedVo;
+import com.coffee.bus.entity.*;
 import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.PatientAlarmEnum;
 import com.coffee.bus.registry.patient.PatientOperator;
 import com.coffee.bus.registry.patient.PatientRegistry;
 import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
-import com.coffee.bus.service.LocalBusClinicService;
-import com.coffee.bus.service.LocalBusDeviceRunningService;
-import com.coffee.bus.service.LocalBusPatientService;
+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.exception.CustomException;
 import com.coffee.common.result.R;
 import com.coffee.common.result.ResultCode;
@@ -50,21 +46,24 @@ public class BusPatientController  {
 
     private final PatientRegistry patientRegistry;
 
+    private final LocalBusInfusionHistoryService infusionService;
+
+    private final LocalBusDeviceManualService manualService;
     @PostMapping("/no_page")
     @SaCheckPermission("bus:patient:query")
-    @ApiOperation(value = "病人监控管理列表",notes = "病人监控管理列表,权限【bus:patient:query】")
+    @ApiOperation(value = "输注监控列表",notes = "病人监控管理列表,权限【bus:patient:query】")
     public R<List<PatientMonitorDomain>> selectPage(@RequestBody PatientMonitorQuery query){
         return R.success(patientService.selectAll(query));
     }
 
     @GetMapping("/repeat/device")
-    @ApiOperation(value = "获取当前医院绑定设备重复的所有病患信息",notes = "当出现病患同一时间绑定了多个泵时,调用该接口查询出所有设备重复报警数据,权限【无】")
+    @ApiOperation(value = "设备重复提示列表",notes = "当出现病患同一时间绑定了多个泵时,调用该接口查询出所有设备重复报警数据,权限【无】")
     public R<List<PatientDeviceRepeatResult>> repeatDevice(){
         return R.success(patientService.repeatDevice());
     }
 
     @GetMapping("/none/device")
-    @ApiOperation(value = "获取当前医院没有绑定泵的所有病患临床信息",notes = "当出现病患同一时间没有泵时,调用该接口查询出所有没有泵信息的病患临床数据,权限【无】")
+    @ApiOperation(value = "临床无泵列表",notes = "当出现病患同一时间没有泵时,调用该接口查询出所有没有泵信息的病患临床数据,权限【无】")
     public R<List<PatientDeviceNoneResult>> noneDevice(){
         return R.success(patientService.noneDevice());
     }
@@ -72,11 +71,10 @@ public class BusPatientController  {
     @PostMapping("/judge/repeat")
     @ApiOperation(value = "判断所给病号中是否出现了绑定设备重复",notes = "当结束管理时,调用改接口判断所结束病号是否出现了设备重复异常,权限【无】")
     @ApiResponses({
-            @ApiResponse(code = 200,message = "true 设备中未出现重复"),
-            @ApiResponse(code = 200,message = "false 设备中出现重复")
+            @ApiResponse(code = 200,message = "0 病人中未出现重复,非0 病人中出现重复"),
     })
-    public R<Boolean> judgeRepeat(@RequestBody List<String> patientCode){
-        return R.success(patientService.count(new QueryWrapper<BusPatientEntity>().lambda().in(BusPatientEntity::getCode,patientCode))==0);
+    public R<Long> judgeRepeat(@RequestBody List<String> patientCode){
+        return R.success(patientService.count(new QueryWrapper<BusPatientEntity>().lambda().in(BusPatientEntity::getCode,patientCode).eq(BusPatientEntity::getAlarm,PatientAlarmEnum.DEVICE_REPEAT)));
     }
 
     @PostMapping("/judge/finished")
@@ -102,9 +100,9 @@ public class BusPatientController  {
     @PostMapping("/do/finished")
     @SaCheckPermission("bus:patient:finished")
     @ApiResponse(code = 4001,message = "病号当前绑定了多个设备,不可结束管理")
-    @ApiOperation(value = "结束对于病号的当前监控,即结束管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
-    public R finished(@RequestBody MonitorFinished monitorFinished, @RequestAttribute("tenantId")String tenantId){
-        List<String> patientCodes = monitorFinished.getPatientCodes();
+    @ApiOperation(value = "即结束管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
+    public R finished(@RequestBody MonitorFinishedVo monitorFinishedVo, @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
+        List<String> patientCodes = monitorFinishedVo.getPatientCodes();
         if(CollectionUtil.isEmpty(patientCodes)){
             throw new CustomException("请选择一个病患");
         }
@@ -124,18 +122,30 @@ public class BusPatientController  {
         }
         //组装撤泵信息
         List<ManualUndoConfig> undoConfigs = patientOperators.stream().map(operator ->
-                ManualUndoConfig.of(Collections.singletonList(operator.getBindDeviceId()), operator.getCode(), tenantId,true, monitorFinished.getUndo())
+                ManualUndoConfig.of(Collections.singletonList(operator.getBindDeviceId()), operator.getCode(), tenantId,true, monitorFinishedVo.getUndo())
         )
-                .filter(undoConfig -> undoConfig.getDeviceIds() != null && undoConfig.getDeviceIds().size() > 0)
+//                .filter(undoConfig -> undoConfig.getDeviceIds() != null && undoConfig.getDeviceIds().size() > 0)
                 .collect(Collectors.toList());
         //病患绑定的有设备,对设备进行撤泵操作,且结束临床
         deviceRunningService.batchUndo(undoConfigs,true);
         return R.success();
     }
 
+
+    @PostMapping("/monitor/reset/{patientCode}")
+    @SaCheckPermission("device:patient:edit")
+    @ApiOperation(value = "病人当前监控时间重启",notes = "当结束临床后有新的输注信息产生,那么病人监控会重新显示,此时监控时间不会重新计算,需先调用该接口,权限标识为【device:patient:edit】")
+    public R reset(@PathVariable("patientCode")String patientCode){
+        return R.success(patientService.update(new UpdateWrapper<BusPatientEntity>()
+                .lambda()
+                .eq(BusPatientEntity::getCode,patientCode)
+                .set(BusPatientEntity::getTmpFinished,false)));
+    }
+
+
     @PostMapping("/shift")
     @SaCheckPermission("device:patient:shift")
-    @ApiOperation(value = "病人进行主泵切换的操作,只切换,不结束",notes = "当出现泵重复状态时,若用户想要进行主泵的切换,调用该接口进行操作,主泵切换完成后,会将副泵自动撤泵,权限标识为【device:patient:shift】")
+    @ApiOperation(value = "主泵切换的操作,只切换,不结束",notes = "当出现泵重复状态时,若用户想要进行主泵的切换,调用该接口进行操作,主泵切换完成后,会将副泵自动撤泵,权限标识为【device:patient:shift】")
     public R shift(@RequestBody DeviceShiftConfig shiftConfig){
         deviceRunningService.shift(shiftConfig);
         return R.success();
@@ -143,18 +153,38 @@ public class BusPatientController  {
 
     @PostMapping("/undo")
     @SaCheckPermission("device:patient:undo")
-    @ApiOperation(value = "病人多余的副泵撤掉,只撤泵,不切换",notes = "当出现泵重复状态时,若用户想要取消对其他副泵的监控,则调用此接口进行撤泵操作,权限标识为【device:patient:undo】")
+    @ApiOperation(value = "批量撤泵,只撤泵,不切换",notes = "当出现泵重复状态时,若用户想要取消对其他副泵的监控,则调用此接口进行撤泵操作,权限标识为【device:patient:undo】")
     public R shift(@RequestBody ManualUndoConfig undoConfig){
+        //泵切换完成后,对病号报警解除
         deviceRunningService.undo(undoConfig,false);
+        //判断当前病号下是否还存在副泵
+        long count = deviceRunningService.count(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getPatientCode, undoConfig.getPatientCode())
+                .eq(BusDeviceRunningEntity::getTenantId, undoConfig.getTenantId())
+                .eq(BusDeviceRunningEntity::getMaster, false)
+                .eq(BusDeviceRunningEntity::getIsUndo, false));
+        //处理缓存信息
+        PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(undoConfig.getTenantId(), undoConfig.getPatientCode());
+        String bindDeviceId = operator.getBindDeviceId();
+        Set<DeviceTimeSmallInfo> allDevice = operator.getAllDevice();
+        Optional<DeviceTimeSmallInfo> first = allDevice.stream().filter(device -> device.getDeviceId().equals(bindDeviceId)).findFirst();
+        operator.setAllDevice(Collections.singleton(first.get()));
+        if(count>0){
+            //仅撤泵,病号报警不解除
+            return R.success();
+        }
+        patientService.update(new UpdateWrapper<BusPatientEntity>().lambda()
+                .eq(BusPatientEntity::getCode,undoConfig.getPatientCode())
+                .eq(BusPatientEntity::getTenantId,undoConfig.getTenantId())
+                .set(BusPatientEntity::getAlarm, PatientAlarmEnum.NONE));
         return R.success();
     }
 
 
-    //todo
     @PostMapping("/edit")
     @SaCheckPermission("device:patient:edit")
-    @ApiOperation(value = "编辑病人信息及病人当前手术信息",notes = "编辑病人信息及病人当前手术信息,权限标识为【device:patient:edit】")
-    public R edit(){
+    @ApiOperation(value = "编辑病人当前手术信息",notes = "编辑病人信息及病人当前手术信息,权限标识为【device:patient:edit】")
+    public R edit(@RequestBody BusClinicEntity clinic){
+        patientService.manualEdit(clinic);
         return R.success();
     }
 
@@ -165,10 +195,21 @@ public class BusPatientController  {
     public R<PatientMonitorResult> monitor(@PathVariable("monitorType")@ApiParam(value = "是否为有泵监控",example = "0、无泵,1、有泵") Boolean haveDevice,@PathVariable("patientCode")@ApiParam(value = "病号") String patientCode){
         PatientMonitorResult result = new PatientMonitorResult();
         if(haveDevice){
-            patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda()
-                    .eq(BusPatientEntity::getCode,patientCode).last("limit 1"));
+            BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda()
+                    .eq(BusPatientEntity::getCode, patientCode).last("limit 1"));
+            BusInfusionHistoryEntity infusion = infusionService.getById(patient.getInfusionId());
+            result.setPatient(patient);
+            result.setInfusion(infusion);
+            if(StrUtil.isNotEmpty(infusion.getClinicId())){
+                result.setClinic(clinicService.getById(infusion.getClinicId()));
+            }
         }else {
-
+            //无泵查看
+            BusClinicEntity clinic = clinicService.getOne(new QueryWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getPatientCode, patientCode).eq(BusClinicEntity::getMonitorType, false).orderByDesc(BusClinicEntity::getStartTime).last("limit 1"));
+            if(clinic!=null){
+                result.setClinic(clinic);
+                result.setDeviceManual( manualService.getOne(new QueryWrapper<BusDeviceManualEntity>().lambda().eq(BusDeviceManualEntity::getClinicId, clinic.getId())));
+            }
         }
         return R.success(result);
     }

+ 33 - 0
coffee-system/src/main/java/com/coffee/bus/controller/vo/ClinicStatsVo.java

@@ -0,0 +1,33 @@
+package com.coffee.bus.controller.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ClinicStatsVo.java
+ * @Description TODO
+ * @createTime 2022年04月27日 15:46:00
+ */
+@ApiModel("临床数据统计")
+@Data
+public class ClinicStatsVo {
+    @ApiModelProperty("临床id")
+    private String clinicId;
+    @ApiModelProperty("设备id")
+    private String deviceId;
+    @ApiModelProperty("输注id")
+    private String infusionId;
+    @ApiModelProperty("是否统计流速")
+    private boolean continueDose;
+    @ApiModelProperty("是否统计追加量")
+    private boolean appendDose;
+    @ApiModelProperty("是否统计已输注量")
+    private boolean inputDose;
+    @ApiModelProperty("是否统计有效次数")
+    private boolean validCount;
+    @ApiModelProperty("是否统计无效次数")
+    private boolean inValidCount;
+}

+ 24 - 0
coffee-system/src/main/java/com/coffee/bus/controller/vo/DeviceBindVo.java

@@ -0,0 +1,24 @@
+package com.coffee.bus.controller.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.*;
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DeviceShiftBindVO.java
+ * @Description 设备切换绑定
+ * @createTime 2022年05月05日 22:32:00
+ */
+@Data
+@ApiModel("设备绑定视图")
+public class DeviceBindVo {
+    @ApiModelProperty("需要绑定的医院")
+    private String bindTenantId;
+    @ApiModelProperty("换绑设备id(设备唯一标识)")
+    @NotNull(message = "请选择设备")
+    private List<String> deviceIds;
+}

+ 23 - 0
coffee-system/src/main/java/com/coffee/bus/controller/vo/DeviceManualVo.java

@@ -0,0 +1,23 @@
+package com.coffee.bus.controller.vo;
+
+import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusDeviceManualEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DeviceManualVo.java
+ * @Description TODO
+ * @createTime 2022年05月06日 09:29:00
+ */
+@ApiModel("手动添加其他监控视图")
+@Data
+public class DeviceManualVo {
+    @ApiModelProperty("设备信息")
+    private BusDeviceManualEntity manual;
+    @ApiModelProperty("手术信息")
+    private BusClinicEntity clinic;
+}

+ 44 - 0
coffee-system/src/main/java/com/coffee/bus/controller/vo/DeviceRunningMockVo.java

@@ -0,0 +1,44 @@
+package com.coffee.bus.controller.vo;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.ibatis.type.EnumTypeHandler;
+
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DeviceRunningMockVo.java
+ * @Description TODO
+ * @createTime 2022年04月28日 11:52:00
+ */
+@ApiModel("Mock设备运行数据")
+@Data
+public class DeviceRunningMockVo {
+    @ApiModelProperty(value = "网络泵id",readOnly = true)
+    private String deviceId;
+
+    @ApiModelProperty(value = "病号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "分包标记位",readOnly = true)
+    @JsonIgnoreProperties(allowSetters = true)
+    private String classification;
+
+    @ApiModelProperty(value = "泵类型",readOnly = true)
+    @TableField(javaType = true,updateStrategy = FieldStrategy.NEVER)
+    private DeviceTypeEnum type;
+}

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/controller/vo/MonitorFinished.java → coffee-system/src/main/java/com/coffee/bus/controller/vo/MonitorFinishedVo.java

@@ -11,13 +11,13 @@ import java.util.List;
 /**
  * @author lifang
  * @version 1.0.0
- * @ClassName MonitorFinished.java
+ * @ClassName MonitorFinishedVo.java
  * @Description TODO
  * @createTime 2022年04月20日 20:34:00
  */
 @ApiModel("监控结束")
 @Data
-public class MonitorFinished {
+public class MonitorFinishedVo {
     @ApiModelProperty("结束监控的病号")
     private List<String> patientCodes;
 

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfig.java → coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfigVo.java

@@ -9,13 +9,13 @@ import lombok.Data;
 /**
  * @author lifang
  * @version 1.0.0
- * @ClassName NoPumpConfig.java
+ * @ClassName NoPumpConfigVo.java
  * @Description 无泵监护配置
  * @createTime 2022年03月31日 20:58:00
  */
 @Data
 @ApiModel("新增无泵监护配置")
-public class NoPumpConfig {
+public class NoPumpConfigVo {
     @ApiModelProperty("泵数据")
     private BusDeviceRunningEntity pump;
     @ApiModelProperty("手术信息")

+ 6 - 8
coffee-system/src/main/java/com/coffee/bus/entity/BusClinicEntity.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import com.coffee.bus.bean.HisInfo;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.enums.SexEnum;
@@ -85,21 +86,18 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
     @Length(max = 255,message = "手术医生不得超过255个字节")
     private String surgeryDoctor;
 
-    @ApiModelProperty(value = "手术名称")
-    @Length(max = 255,message = "手术名称不得超过255个字节")
-    private String surgeryName;
-
     @ApiModelProperty(value = "配置人员")
     private String configPerson;
 
     @ApiModelProperty(value = "配方")
-    private String formula;
+    @TableField(typeHandler = FastjsonTypeHandler.class,javaType = true)
+    private List<FormulaDrugDomain> formula;
 
     @ApiModelProperty(value = "临床是否结束,0、未结束 1、结束 ")
     private Boolean finished;
 
     @ApiModelProperty(value = "临床使用过的设备号")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
+    @TableField(typeHandler = FastjsonTypeHandler.class,javaType = true)
     private Set<String> deviceCodes;
 
     @TableField(fill = FieldFill.INSERT)
@@ -108,7 +106,7 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
 
     //todo
     @ApiModelProperty(value = "监护类型,1、有泵监护 0、无泵监护")
-    @JsonIgnoreProperties
+    @JsonIgnoreProperties(allowGetters = true)
     private Boolean monitorType;
 
     public static BusClinicEntity of(HisInfo hisInfo){
@@ -128,7 +126,7 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
         clinic.setStartTime(hisInfo.getOperationTime());
         //asa分级 todo
         //easymode todo
-        clinic.setFormula(hisInfo.getFormula());
+//        clinic.setFormula(hisInfo.getFormula());
         clinic.setConfigPerson(hisInfo.getConfigPerson());
         return clinic;
     }

+ 2 - 0
coffee-system/src/main/java/com/coffee/bus/entity/BusConMixEntity.java

@@ -36,4 +36,6 @@ public class BusConMixEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "混合常量类型",example = "ward,surgery,asa,anaesthesia,anal,drugCate,entrust")
     private ConstantMixEnum type;
+
+    private String code;
 }

+ 0 - 4
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceAlarmEntity.java

@@ -53,9 +53,6 @@ public class BusDeviceAlarmEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "输注记录")
     private String infusionId;
 
-    @ApiModelProperty(value = "临床id",readOnly = true)
-    private String clinicId;
-
 
     @ApiModelProperty(value = "设备标识",readOnly = true,hidden = true)
     @JsonIgnoreProperties(allowSetters = true)
@@ -68,7 +65,6 @@ public class BusDeviceAlarmEntity extends TenantGenericEntity<String,String> {
         entity.setAlarmTime(history.getUploadTime());
         entity.setHistoryId(history.getId());
         entity.setInfusionId(history.getInfusionId());
-        entity.setClinicId(history.getClinicId());
         entity.setClassification(history.getClassification());
         entity.setTenantId(history.getTenantId());
         return entity;

+ 40 - 12
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceEntity.java

@@ -1,10 +1,14 @@
 package com.coffee.bus.entity;
 
+import com.aliyuncs.iot.model.v20180120.QueryDeviceDetailResponse;
+import com.aliyuncs.iot.model.v20180120.QueryDeviceResponse;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.coffee.aliyun.utils.EnumUtils;
 import com.coffee.bus.bean.AliIotConfig;
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceStatusEnum2;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.common.entity.RecordCreationEntity;
 import com.coffee.common.entity.RecordModifierEntity;
@@ -30,7 +34,7 @@ import java.util.Date;
 @TableName(value = "bus_device",autoResultMap = true)
 @ApiModel(value="设备经销商管理", description="设备与医院关系管理")
 @ToString
-public class BusDeviceEntity extends TenantGenericEntity<String,String> implements RecordCreationEntity, RecordModifierEntity {
+public class BusDeviceEntity extends TenantGenericEntity<String,String> {
 
 
     @ApiModelProperty(value = "设备唯一id")
@@ -42,7 +46,7 @@ public class BusDeviceEntity extends TenantGenericEntity<String,String> implemen
 
     @ApiModelProperty(value = "设备类型")
     @Length(max = 255,message = "设备类型不得超过255个字符")
-    private DeviceEnum type;
+    private DeviceTypeEnum type;
 
     @ApiModelProperty(value = "运行状态",readOnly = true)
     @TableField(javaType = true,updateStrategy = FieldStrategy.IGNORED)
@@ -53,21 +57,45 @@ public class BusDeviceEntity extends TenantGenericEntity<String,String> implemen
     private DeviceAlarmEnum alarm;
 
     @ApiModelProperty(value = "第三方平台返回配置")
-    @TableField(typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.NEVER)
+    @TableField(typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.DEFAULT)
     private AliIotConfig config;
 
     @ApiModelProperty(value = "是否启用,0、不启用 1、启用 ")
     private Boolean enable;
 
-    @TableField(fill = FieldFill.INSERT_UPDATE)
-    private Date createTime;
 
-    @TableField(fill = FieldFill.INSERT_UPDATE)
-    private String createBy;
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic(value = "0",delval = "1")
+    private Integer isDelete;
 
-    @TableField(fill = FieldFill.UPDATE)
-    private String updateBy;
+    @ApiModelProperty(value = "设备在线状态,0未激活,1在线,2离线",readOnly = true)
+    private DeviceStatusEnum2 status;
 
-    @TableField(fill = FieldFill.UPDATE)
-    private Date updateTime;
+    /**
+     * @author 龙三郎
+     * 根据阿里云返回的数据更新设备对象
+     * @param data 由queryDeviceDetail接口返回的数据
+     */
+    public void setFields(QueryDeviceDetailResponse.Data data) {
+        this.deviceId = data.getDeviceName();
+        this.config.setProductKey(data.getProductKey());
+        this.config.setIotId(data.getIotId());
+        this.config.setDeviceSecret(data.getDeviceSecret());
+        this.config.setDeviceName(data.getDeviceName());
+        this.setStatus(EnumUtils.getDeviceStatusEnum2(data.getStatus()));
+    }
+
+    /**
+     * @author 龙三郎
+     * 根据设备查询接口返回的数据,更新设备对象
+     * @param item
+     */
+    public void setFields(QueryDeviceResponse.DeviceInfo item) {
+        this.deviceId = item.getDeviceName();
+        this.config.setProductKey(item.getProductKey());
+        this.config.setIotId(item.getIotId());
+        this.config.setDeviceSecret(item.getDeviceSecret());
+        this.config.setDeviceName(item.getDeviceName());
+        this.setStatus(EnumUtils.getDeviceStatusEnum2(item.getDeviceStatus()));
+    }
 }

+ 9 - 136
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceHistoryEntity.java

@@ -3,8 +3,9 @@ package com.coffee.bus.entity;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.coffee.bus.entity.common.CommonDeviceParam;
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -33,138 +34,18 @@ import java.util.Date;
 @Accessors(chain = true)
 @TableName(value = "bus_device_history",autoResultMap = true)
 @ApiModel(value="设备历史运行数据", description="设备历史运行数据记录")
-public class BusDeviceHistoryEntity extends TenantGenericEntity<String,String> {
+public class BusDeviceHistoryEntity extends CommonDeviceParam<String,String> {
 
-    @ApiModelProperty(value = "网络泵id")
-    @JsonIgnoreProperties
-    private String deviceId;
-
-    @ApiModelProperty(value = "临床id")
-    @JsonIgnoreProperties
-    private String clinicId;
+    @ApiModelProperty(value = "患者编号")
+    private String patientId;
 
     @ApiModelProperty(value = "输注记录id")
     @JsonIgnoreProperties
     private String infusionId;
 
-
-    @ApiModelProperty(value = "总量",readOnly = true)
-    @Max(value = 999,message = "总量最大值不得超过999")
-    @Min(value = 0,message ="总量最小值不得超过0" )
-    private Integer totalDose;
-
-    @ApiModelProperty(value = "公共参数-首次量",readOnly = true)
-    @Max(value = 50,message = "首次量最大值不得超过50")
-    @Min(value = 0,message ="首次量最小值不得超过0" )
-    private Integer firstDose;
-
-
-    @ApiModelProperty(value = "公共参数-剩余量",readOnly = true)
-    private BigDecimal remainDose;
-
-    @ApiModelProperty(value = "公共参数-已输入量",readOnly = true)
-    private BigDecimal inputDose;
-
-    @ApiModelProperty(value = "公共参数-追加量",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendDose;
-
-    @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true)
-    @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendLockTime;
-
-    @ApiModelProperty(value = "公共参数-极限量",readOnly = true)
-    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal maxDose;
-
-    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
-    private BigDecimal selfControlLockTime;
-
-    @ApiModelProperty(value = "公共参数-自控次数",readOnly = true)
-    private BigDecimal selfControlCount;
-
-    @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true)
-    private Integer pcaValidCount;
-
-    @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true)
-    private Integer pcaInvalidCount;
-
-    @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true)
-    private Integer pcaTotalCount;
-
-    @ApiModelProperty(value = "持续泵参数-持续量",readOnly = true)
-    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
-    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
-    private BigDecimal continueDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true)
-    @Max(value = 20,message = "脉冲量最大值不得超过20")
-    @Min(value = 0,message ="脉冲量最小值不得超过0" )
-    private Integer pulseDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true)
-    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
-    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
-    private Integer pulseLockTime;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true)
-    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
-    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
-    private Integer pulseFirstLockTime;
-
-    @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "加档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" )
-    private BigDecimal flowUpCycle;
-
-    @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "减档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" )
-    private BigDecimal flowDownCycle;
-
-    @ApiModelProperty(value = "智能泵参数-计次",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" )
-    private BigDecimal flowCount;
-
-    @ApiModelProperty(value = "智能泵参数-上限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90")
-    @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" )
-    private BigDecimal flowUpLimit;
-
-    @ApiModelProperty(value = "智能泵参数-下限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50")
-    @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" )
-    private BigDecimal flowDownLimit;
-
-    @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true)
-    @DecimalMax(value = "95",message = "自调比例不得超过95")
-    @DecimalMin(value = "0",message ="自调比例最小值不得超过0" )
-    private BigDecimal flowAdjustRate;
-
-
-    @ApiModelProperty(value = "泵运行状态",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
-    private DeviceStatusEnum runState;
-
-    @ApiModelProperty(value = "报警信息",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
-    private DeviceAlarmEnum alarm;
-
-    @ApiModelProperty(value = "报警原因")
-    private String alarmCause;
-
-    @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
-    private Boolean warnWillFinished;
-
-    @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
-    private Boolean warnAnalgesicPoor;
-
-    @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
-    private Boolean warnLowBattery;
+    @ApiModelProperty(value = "输注修改记录id")
+    @JsonIgnoreProperties
+    private String infusionModifyId;
 
     @ApiModelProperty(value = "是否已撤泵,0、未撤泵1、已撤泵")
     @JsonIgnoreProperties
@@ -174,14 +55,6 @@ public class BusDeviceHistoryEntity extends TenantGenericEntity<String,String> {
     @JsonIgnoreProperties
     private Boolean master;
 
-    @ApiModelProperty(value = "分包标记位",readOnly = true)
-    @JsonIgnoreProperties(allowSetters = true)
-    private String classification;
-
-    @ApiModelProperty(value = "泵类型",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.NEVER)
-    private DeviceEnum type;
-
     @ApiModelProperty(value = "数据上传时间",readOnly = true,hidden = true)
     @JsonIgnoreProperties(allowSetters = true)
     private Date uploadTime;
@@ -190,11 +63,11 @@ public class BusDeviceHistoryEntity extends TenantGenericEntity<String,String> {
     public static BusDeviceHistoryEntity parseRunningInfo(BusDeviceRunningEntity running){
         BusDeviceHistoryEntity entity = new BusDeviceHistoryEntity();
         entity.setDeviceId(running.getDeviceId());
-        entity.setClinicId(running.getClinicId());
         entity.setType(running.getType());
         entity.setClassification(running.getClassification());
         entity.setTenantId(running.getTenantId());
         entity.setInfusionId(running.getInfusionId());
+        entity.setInfusionModifyId(running.getInfusionModifyId());
 
         entity.setTotalDose(running.getTotalDose());
         entity.setFirstDose(running.getFirstDose());

+ 87 - 0
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceManualEntity.java

@@ -0,0 +1,87 @@
+package com.coffee.bus.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.coffee.bus.enums.DeviceManualEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
+import com.coffee.common.entity.GenericEntity;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.validation.constraints.*;
+import java.math.BigDecimal;
+import java.util.Map;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusDocEntity.java
+ * @Description TODO
+ * @createTime 2022年04月09日 16:12:00
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName(value = "bus_device_manual",autoResultMap = true)
+@ApiModel(value="手动输录设备管理", description="手动输录设备管理")
+@ToString
+public class BusDeviceManualEntity extends GenericEntity<String> {
+    @ApiModelProperty("设备类型")
+    private DeviceManualEnum type;
+
+    @ApiModelProperty("当设备类型为【其他】时,用户自定义输入(key,value)【(参数名称,参数值)】即可")
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private Map<String,Object> config;
+
+    @ApiModelProperty(value = "公共参数-总量",readOnly = true)
+    @Max(value = 999,message = "总量最大值不得超过999")
+    @Min(value = 0,message ="总量最小值不得超过0" )
+    private Integer totalDose;
+
+    @ApiModelProperty(value = "临床id",hidden = true)
+    @JsonIgnore
+    private String clinicId;
+
+    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
+    private Integer selfControlLockTime;
+
+    @ApiModelProperty(value = "公共参数-自控量",readOnly = true)
+    private BigDecimal selfControlDose;
+
+    @ApiModelProperty(value = "机械泵、电子脉冲泵-持续量",readOnly = true)
+    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
+    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
+    private BigDecimal continueDose;
+
+
+    @ApiModelProperty(value = "电子泵、电子脉冲泵-首次量",readOnly = true)
+    @Max(value = 50,message = "首次量最大值不得超过50")
+    @Min(value = 0,message ="首次量最小值不得超过0" )
+    private Integer firstDose;
+
+
+    @ApiModelProperty(value = "电子脉冲泵-脉冲首次锁时",readOnly = true)
+    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
+    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
+    private Integer firstLockTime;
+
+    @ApiModelProperty(value = "电子脉冲泵-脉冲量",readOnly = true)
+    @Max(value = 20,message = "脉冲量最大值不得超过20")
+    @Min(value = 0,message ="脉冲量最小值不得超过0" )
+    private Integer pulseDose;
+
+    @ApiModelProperty(value = "电子脉冲泵-脉冲锁时",readOnly = true)
+    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
+    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
+    private Integer pulseLockTime;
+
+    @ApiModelProperty(value = "电子脉冲泵、电子泵-极限量",readOnly = true)
+    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
+    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal maxDose;
+
+}

+ 46 - 142
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRunningEntity.java

@@ -4,9 +4,11 @@ package com.coffee.bus.entity;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.coffee.aliyun.utils.*;
+import com.coffee.bus.entity.common.CommonDeviceParam;
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.enums.SexEnum;
 import com.fasterxml.jackson.annotation.*;
@@ -16,13 +18,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.experimental.Accessors;
-import org.apache.ibatis.type.EnumTypeHandler;
-import org.apache.ibatis.type.EnumTypeHandler;
 
-import javax.validation.constraints.DecimalMax;
-import javax.validation.constraints.DecimalMin;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -35,21 +31,15 @@ import java.util.Date;
  **/
 @ToString
 @Data
-@EqualsAndHashCode(callSuper = false)
+@EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @TableName(value = "bus_device_running",autoResultMap = true)
 @ApiModel(value="设备运行状态", description="设备运行状态")
-public class BusDeviceRunningEntity extends TenantGenericEntity<String,String> {
-
-    @ApiModelProperty(value = "网络泵id",readOnly = true)
-    private String deviceId;
+public class BusDeviceRunningEntity extends CommonDeviceParam<String,String> {
 
     @ApiModelProperty(value = "输注记录")
     private String infusionId;
 
-    @ApiModelProperty(value = "病号")
-    private String patientCode;
-
     @ApiModelProperty(value = "临床号")
     private String clinicId;
 
@@ -60,131 +50,11 @@ public class BusDeviceRunningEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "病人性别")
     private SexEnum patientSex;
 
-    @ApiModelProperty(value = "病区")
-    private String ward;
-
-    @ApiModelProperty(value = "床号")
-    private String bedNo;
     /***************临床固定数据*****************/
 
     @ApiModelProperty(value = "设备别名")
     private String alias;
 
-    @ApiModelProperty(value = "总量",readOnly = true)
-    @Max(value = 999,message = "总量最大值不得超过999")
-    @Min(value = 0,message ="总量最小值不得超过0" )
-    private Integer totalDose;
-
-    @ApiModelProperty(value = "公共参数-首次量",readOnly = true)
-    @Max(value = 50,message = "首次量最大值不得超过50")
-    @Min(value = 0,message ="首次量最小值不得超过0" )
-    private Integer firstDose;
-
-
-    @ApiModelProperty(value = "公共参数-剩余量",readOnly = true)
-    private BigDecimal remainDose;
-
-    @ApiModelProperty(value = "公共参数-已输入量",readOnly = true)
-    private BigDecimal inputDose;
-
-    @ApiModelProperty(value = "公共参数-追加量",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendDose;
-
-    @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true)
-    @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendLockTime;
-
-    @ApiModelProperty(value = "公共参数-极限量",readOnly = true)
-    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal maxDose;
-
-    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
-    private BigDecimal selfControlLockTime;
-
-    @ApiModelProperty(value = "公共参数-自控次数",readOnly = true)
-    private BigDecimal selfControlCount;
-
-    @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true)
-    private Integer pcaValidCount;
-
-    @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true)
-    private Integer pcaInvalidCount;
-
-    @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true)
-    private Integer pcaTotalCount;
-
-    @ApiModelProperty(value = "公共参数-持续量(流速)",readOnly = true)
-    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
-    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
-    private BigDecimal continueDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true)
-    @Max(value = 20,message = "脉冲量最大值不得超过20")
-    @Min(value = 0,message ="脉冲量最小值不得超过0" )
-    private Integer pulseDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true)
-    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
-    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
-    private Integer pulseLockTime;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true)
-    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
-    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
-    private Integer pulseFirstLockTime;
-
-    @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "加档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" )
-    private BigDecimal flowUpCycle;
-
-    @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "减档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" )
-    private BigDecimal flowDownCycle;
-
-    @ApiModelProperty(value = "智能泵参数-计次",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" )
-    private BigDecimal flowCount;
-
-    @ApiModelProperty(value = "智能泵参数-上限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90")
-    @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" )
-    private BigDecimal flowUpLimit;
-
-    @ApiModelProperty(value = "智能泵参数-下限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50")
-    @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" )
-    private BigDecimal flowDownLimit;
-
-    @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true)
-    @DecimalMax(value = "95",message = "自调比例不得超过95")
-    @DecimalMin(value = "0",message ="自调比例最小值不得超过0" )
-    private BigDecimal flowAdjustRate;
-
-
-    @ApiModelProperty(value = "泵运行状态",readOnly = true)
-    @TableField(typeHandler = EnumTypeHandler.class,javaType = true,updateStrategy = FieldStrategy.IGNORED)
-    private DeviceStatusEnum runState;
-
-    @ApiModelProperty(value = "报警信息",readOnly = true)
-    @TableField(typeHandler = EnumTypeHandler.class,javaType = true,updateStrategy = FieldStrategy.IGNORED)
-    private DeviceAlarmEnum alarm;
-
-    @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
-    private Boolean warnWillFinished;
-
-    @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
-    private Boolean warnAnalgesicPoor;
-
-    @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
-    private Boolean warnLowBattery;
-
     @ApiModelProperty(value = "输注开始时间,即本次运行开机时间",readOnly = true)
     private Date startTime;
 
@@ -203,15 +73,49 @@ public class BusDeviceRunningEntity extends TenantGenericEntity<String,String> {
     @JsonIgnoreProperties(allowSetters = true)
     private Boolean master;
 
-    @ApiModelProperty(value = "分包标记位",readOnly = true)
-    @JsonIgnoreProperties(allowSetters = true)
-    private String classification;
-
-    @ApiModelProperty(value = "泵类型",readOnly = true)
-    @TableField(typeHandler = EnumTypeHandler.class,javaType = true,updateStrategy = FieldStrategy.NEVER)
-    private DeviceEnum type;
 
     @ApiModelProperty(value = "数据上传时间",readOnly = true,hidden = true)
     @JsonIgnoreProperties(allowSetters = true)
     private Date uploadTime;
+
+    /**
+     * 当前运行状态所绑定的输注修改记录id,只在设备上传解析过程中使用,其他地方无用处
+     */
+    @TableField(exist = false)
+    @JsonIgnoreProperties
+    private String infusionModifyId;
+
+    /**
+     * @author 龙三郎
+     * 根据阿里云传回数据的items,设置输注的属性
+     * @param deviceName
+     * @param items
+     */
+    public void setFiledsByItems(String deviceName, Items items) {
+        this.setDeviceId(deviceName)  ;
+        this.setClassification( items.getString(PumpParams.classification));
+        this.setDataNumber(items.getInteger(PumpParams.dataNumber));
+        this.setPatientCode( items.getString(PumpParams.patientCode));
+        this.setWard(items.getString(PumpParams.ward));
+        this.setBedNo(items.getString(PumpParams.bedNo));
+        this.setTotalDose( items.getInteger(PumpParams.totalDose));
+        this.setInputDose(items.getBigDecimal(PumpParams.finishedDose));
+        this.setRemainDose(BigDecimal.valueOf(this.getTotalDose()).subtract(this.getInputDose()));
+        this.setFirstDose( items.getInteger(PumpParams.firstDosis));
+        this.setMaxDose(items.getBigDecimal(PumpParams.maxDose));
+        this.setAppendDose(items.getBigDecimal(PumpParams.singleDosis));
+        this.setAppendLockTime(items.getBigDecimal(PumpParams.lockTime));
+        this.setContinueDose(items.getBigDecimal(PumpParams.flow));
+        this.setType( DeviceTypeUtils.getDeviceType(items.getInteger(PumpParams.pumpType)));
+        this.setPcaValidCount(items.getInteger(PumpParams.pcaValid));
+        this.setPcaInvalidCount(items.getInteger(PumpParams.pcaInvalid));
+        this.setPcaTotalCount(this.getPcaInvalidCount()+this.getPcaValidCount());
+        this.setElectricQuantity(items.getInteger(PumpParams.electricQuantity));
+        this.setRunState(DeviceRunStatusUtils.getRunStatus(items.getInteger(PumpParams.runStatus)));
+        this.setAlarm(DeviceAlarmUtils.getAlarm(items.getInteger(PumpParams.alarmStatus)));
+        // 预报
+
+    }
+
+
 }

+ 1 - 12
coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalConfigEntity.java

@@ -27,7 +27,7 @@ import java.util.Map;
 @Data
 @TableName(value = "bus_hospital_config",autoResultMap = true)
 @ApiModel(value="医院配置", description="配置医院的全局参数,如撤泵配置、评价配置等")
-public class BusHospitalConfigEntity extends TenantGenericEntity<String,String> implements RecordModifierEntity, RecordCreationEntity {
+public class BusHospitalConfigEntity extends TenantGenericEntity<String,String>  {
 
 
     @ApiModelProperty(value = "配置类型",example = "eval:评价配置,other:其他设置,undo:撤泵配置",allowableValues = "eval:评价配置,other:其他设置,undo:撤泵配置")
@@ -37,15 +37,4 @@ public class BusHospitalConfigEntity extends TenantGenericEntity<String,String>
     @ApiModelProperty(value = "配置类型", example= "详情请查看apiModel中:评价配置,其他设置,撤泵配置")
     private Map<String,Object> config;
 
-    @TableField(fill = FieldFill.INSERT)
-    private String createBy;
-
-    @TableField(fill = FieldFill.INSERT_UPDATE)
-    private String updateBy;
-
-    @TableField(fill = FieldFill.INSERT)
-    private Date createTime;
-
-    @TableField(fill = FieldFill.UPDATE)
-    private Date updateTime;
 }

+ 0 - 1
coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java

@@ -3,7 +3,6 @@ package com.coffee.bus.entity;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.coffee.bus.bean.Script;
-import com.coffee.common.config.mybatis.DateToBigIntHandler;
 import com.coffee.common.entity.RecordCreationEntity;
 import com.coffee.common.entity.RecordModifierEntity;
 import io.swagger.annotations.ApiModel;

+ 46 - 138
coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionHistoryEntity.java

@@ -1,10 +1,16 @@
 package com.coffee.bus.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.coffee.aliyun.utils.*;
+import com.coffee.bus.entity.common.CommonDeviceParam;
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.FlowStatusEnum;
+import com.coffee.common.entity.RecordCreationEntity;
+import com.coffee.common.entity.RecordModifierEntity;
 import com.coffee.common.entity.TenantGenericEntity;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -12,6 +18,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.experimental.Accessors;
+
 import javax.validation.constraints.DecimalMax;
 import javax.validation.constraints.DecimalMin;
 import javax.validation.constraints.Max;
@@ -32,157 +39,24 @@ import java.util.Date;
 @Accessors(chain = true)
 @TableName(value = "bus_infusion_history",autoResultMap = true)
 @ApiModel(value="设备输注历史信息记录", description="设备的classification标识每改变一次,就算一次新的输注记录")
-public class BusInfusionHistoryEntity extends TenantGenericEntity<String,String> {
-    @ApiModelProperty(value = "网络泵id",readOnly = true)
-    private String deviceId;
-
-    @ApiModelProperty(value = "病号")
-    private String patientCode;
+public class BusInfusionHistoryEntity extends CommonDeviceParam<String,String> {
 
     @ApiModelProperty(value = "临床号")
     private String clinicId;
 
-    /***************临床固定数据*****************/
-    @ApiModelProperty(value = "病区")
-    private String ward;
-
-    @ApiModelProperty(value = "床号")
-    private String bedNo;
-    /***************临床固定数据*****************/
-
-    @ApiModelProperty(value = "总量",readOnly = true)
-    @Max(value = 999,message = "总量最大值不得超过999")
-    @Min(value = 0,message ="总量最小值不得超过0" )
-    private Integer totalDose;
-
-    @ApiModelProperty(value = "公共参数-首次量",readOnly = true)
-    @Max(value = 50,message = "首次量最大值不得超过50")
-    @Min(value = 0,message ="首次量最小值不得超过0" )
-    private Integer firstDose;
-
-
-    @ApiModelProperty(value = "公共参数-剩余量",readOnly = true)
-    private BigDecimal remainDose;
-
-    @ApiModelProperty(value = "公共参数-已输入量",readOnly = true)
-    private BigDecimal inputDose;
-
-    @ApiModelProperty(value = "公共参数-追加量",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendDose;
-
-    @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true)
-    @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendLockTime;
-
-    @ApiModelProperty(value = "公共参数-极限量",readOnly = true)
-    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal maxDose;
-
-    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
-    private BigDecimal selfControlLockTime;
-
-    @ApiModelProperty(value = "公共参数-自控次数",readOnly = true)
-    private BigDecimal selfControlCount;
-
-    @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true)
-    private Integer pcaValidCount;
-
-    @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true)
-    private Integer pcaInvalidCount;
-
-    @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true)
-    private Integer pcaTotalCount;
-
-    @ApiModelProperty(value = "持续泵参数-持续量",readOnly = true)
-    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
-    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
-    private BigDecimal continueDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true)
-    @Max(value = 20,message = "脉冲量最大值不得超过20")
-    @Min(value = 0,message ="脉冲量最小值不得超过0" )
-    private Integer pulseDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true)
-    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
-    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
-    private Integer pulseLockTime;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true)
-    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
-    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
-    private Integer pulseFirstLockTime;
-
-    @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "加档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" )
-    private BigDecimal flowUpCycle;
-
-    @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "减档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" )
-    private BigDecimal flowDownCycle;
-
-    @ApiModelProperty(value = "智能泵参数-计次",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" )
-    private BigDecimal flowCount;
-
-    @ApiModelProperty(value = "智能泵参数-上限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90")
-    @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" )
-    private BigDecimal flowUpLimit;
-
-    @ApiModelProperty(value = "智能泵参数-下限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50")
-    @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" )
-    private BigDecimal flowDownLimit;
-
-    @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true)
-    @DecimalMax(value = "95",message = "自调比例不得超过95")
-    @DecimalMin(value = "0",message ="自调比例最小值不得超过0" )
-    private BigDecimal flowAdjustRate;
-
-
-    @ApiModelProperty(value = "泵运行状态",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
-    private DeviceStatusEnum runState;
-
-    @ApiModelProperty(value = "报警信息",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
-    private DeviceAlarmEnum alarm;
-
-    @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
-    private Boolean warnWillFinished;
-
-    @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
-    private Boolean warnAnalgesicPoor;
-
-    @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
-    private Boolean warnLowBattery;
+    @ApiModelProperty(value = "患者编号")
+    private String patientId;
 
     @ApiModelProperty(value = "输注开始时间,即本次运行开机时间",readOnly = true)
     private Date startTime;
 
     @ApiModelProperty(value = "是否已撤泵,0、未撤泵1、已撤泵")
-    @JsonIgnoreProperties(allowSetters = true)
+    @JsonIgnore
     private Boolean isUndo;
 
     @ApiModelProperty(value = "备注")
     private String remark;
 
-    @ApiModelProperty(value = "分包标记位",readOnly = true)
-    @JsonIgnoreProperties(allowSetters = true)
-    private String classification;
-
-    @ApiModelProperty(value = "泵类型",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.NEVER)
-    private DeviceEnum type;
-
     @ApiModelProperty(value = "当前输注记录数据最后上传时间",readOnly = true,hidden = true)
     @JsonIgnoreProperties(allowSetters = true)
     private Date lastUploadTime;
@@ -205,6 +79,10 @@ public class BusInfusionHistoryEntity extends TenantGenericEntity<String,String>
     @ApiModelProperty(value = "该次输注是否已结束")
     private Boolean finished;
 
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic(value = "0",delval = "1")
+    private Integer isDelete;
+
     public static BusInfusionHistoryEntity parseRunningInfo(BusDeviceRunningEntity running){
         BusInfusionHistoryEntity entity = new BusInfusionHistoryEntity();
         entity.setDeviceId(running.getDeviceId());
@@ -258,4 +136,34 @@ public class BusInfusionHistoryEntity extends TenantGenericEntity<String,String>
         entity.setClinicStartTime(new Date(31510861L));
         return entity;
     }
+
+    /**
+     * @author 龙三郎
+     * 根据阿里云传回数据的items,设置输注的属性
+     * @param items
+     */
+    public void setFiledsByItems(Items items) {
+        this.setClassification( items.getString(PumpParams.classification));
+        this.setDataNumber(items.getInteger(PumpParams.dataNumber));
+        this.setPatientCode( items.getString(PumpParams.patientCode));
+        this.setWard(items.getString(PumpParams.ward));
+        this.setBedNo(items.getString(PumpParams.bedNo));
+        this.setTotalDose( items.getInteger(PumpParams.totalDose));
+        this.setInputDose(items.getBigDecimal(PumpParams.finishedDose));
+        this.setFirstDose( items.getInteger(PumpParams.firstDosis));
+        this.setMaxDose(items.getBigDecimal(PumpParams.maxDose));
+        this.setAppendLockTime(items.getBigDecimal(PumpParams.lockTime));
+        this.setContinueDose(items.getBigDecimal(PumpParams.flow));
+        this.setType( DeviceTypeUtils.getDeviceType(items.getInteger(PumpParams.pumpType)));
+        this.setAppendDose(items.getBigDecimal(PumpParams.singleDosis));
+        this.setPcaValidCount(items.getInteger(PumpParams.pcaValid));
+        this.setPcaInvalidCount(items.getInteger(PumpParams.pcaInvalid));
+        this.setPcaTotalCount(this.getPcaInvalidCount()+this.getPcaValidCount());
+        this.setElectricQuantity(items.getInteger(PumpParams.electricQuantity));
+        this.setRunState(DeviceRunStatusUtils.getRunStatus(items.getInteger(PumpParams.runStatus)));
+        this.setAlarm(DeviceAlarmUtils.getAlarm(items.getInteger(PumpParams.alarmStatus)));
+        // 预报
+
+    }
+
 }

+ 35 - 138
coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionModifyEntity.java

@@ -5,15 +5,17 @@ import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.entity.common.CommonDeviceParam;
+import com.coffee.bus.entity.common.DeviceProperties;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.entity.TenantGenericEntity;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.experimental.Accessors;
-import org.springframework.web.context.request.async.DeferredResult;
 
 import javax.validation.constraints.DecimalMax;
 import javax.validation.constraints.DecimalMin;
@@ -31,136 +33,27 @@ import java.util.Date;
  */
 @ToString
 @Data
-@EqualsAndHashCode(callSuper = false)
+@EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @TableName(value = "bus_infusion_modify",autoResultMap = true)
 @ApiModel(value="设备输注参数修改记录", description="当输注参数发生修改时,在此表中进行记录")
-public class BusInfusionModifyEntity extends TenantGenericEntity<String,String> {
-    @ApiModelProperty(value = "网络泵id",readOnly = true)
-    private String deviceId;
+public class BusInfusionModifyEntity extends DeviceProperties<String,String> {
 
     @ApiModelProperty(value = "输注记录")
     private String infusionId;
 
-    @ApiModelProperty(value = "临床号")
-    private String clinicId;
-
-    @ApiModelProperty(value = "泵类型",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.NEVER)
-    private DeviceEnum type;
-
-    @ApiModelProperty(value = "总量",readOnly = true)
-    @Max(value = 999,message = "总量最大值不得超过999")
-    @Min(value = 0,message ="总量最小值不得超过0" )
-    private Integer totalDose;
-
-    @ApiModelProperty(value = "公共参数-首次量",readOnly = true)
-    @Max(value = 50,message = "首次量最大值不得超过50")
-    @Min(value = 0,message ="首次量最小值不得超过0" )
-    private Integer firstDose;
-
-    @ApiModelProperty(value = "公共参数-剩余量",readOnly = true)
-    private BigDecimal remainDose;
-
-    @ApiModelProperty(value = "公共参数-已输入量",readOnly = true)
-    private BigDecimal inputDose;
-
-    @ApiModelProperty(value = "公共参数-追加量",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendDose;
-
-    @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true)
-    @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal appendLockTime;
-
-    @ApiModelProperty(value = "公共参数-极限量",readOnly = true)
-    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
-    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
-    private BigDecimal maxDose;
-
-    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
-    private BigDecimal selfControlLockTime;
-
-    @ApiModelProperty(value = "公共参数-自控次数",readOnly = true)
-    private BigDecimal selfControlCount;
-
-    @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true)
-    private Integer pcaValidCount;
-
-    @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true)
-    private Integer pcaInvalidCount;
-
-    @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true)
-    private Integer pcaTotalCount;
-
-    @ApiModelProperty(value = "持续泵参数-持续量",readOnly = true)
-    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
-    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
-    private BigDecimal continueDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true)
-    @Max(value = 20,message = "脉冲量最大值不得超过20")
-    @Min(value = 0,message ="脉冲量最小值不得超过0" )
-    private Integer pulseDose;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true)
-    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
-    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
-    private Integer pulseLockTime;
-
-    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true)
-    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
-    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
-    private Integer pulseFirstLockTime;
-
-    @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "加档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" )
-    private BigDecimal flowUpCycle;
-
-    @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true)
-    @DecimalMax(value = "10",message = "减档周期最大值不得超过10")
-    @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" )
-    private BigDecimal flowDownCycle;
-
-    @ApiModelProperty(value = "智能泵参数-计次",readOnly = true)
-    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
-    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" )
-    private BigDecimal flowCount;
-
-    @ApiModelProperty(value = "智能泵参数-上限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90")
-    @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" )
-    private BigDecimal flowUpLimit;
-
-    @ApiModelProperty(value = "智能泵参数-下限",readOnly = true)
-    @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50")
-    @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" )
-    private BigDecimal flowDownLimit;
-
-    @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true)
-    @DecimalMax(value = "95",message = "自调比例不得超过95")
-    @DecimalMin(value = "0",message ="自调比例最小值不得超过0" )
-    private BigDecimal flowAdjustRate;
-
     @ApiModelProperty(value = "参数修改时间")
     private Date modifyTime;
 
-    //todo
-    @ApiModelProperty(value = "监控当前病患临床开始时间")
-    @TableField(exist = false)
-    private Date clinicStartTime;
 
     public static BusInfusionModifyEntity parseRunningInfo(BusDeviceRunningEntity running){
         BusInfusionModifyEntity entity = new BusInfusionModifyEntity();
         entity.setDeviceId(running.getDeviceId());
-        entity.setClinicId(running.getClinicId());
         entity.setTenantId(running.getTenantId());
         entity.setInfusionId(running.getInfusionId());
         entity.setType(running.getType());
 
+        entity.setClassification(running.getClassification());
         entity.setTotalDose(running.getTotalDose());
         entity.setFirstDose(running.getFirstDose());
         entity.setRemainDose(running.getRemainDose());
@@ -198,36 +91,40 @@ public class BusInfusionModifyEntity extends TenantGenericEntity<String,String>
         //保证参数有序
         JSONObject param = new JSONObject(true);
 
+        //加密过程中,加入分包标识,保证新的输注的输注参数必定发生改变
         switch (this.getType()){
             case continuous:
-                param.putOpt("continueDose",this.continueDose);
-                param.putOpt("firstDose",this.firstDose);
-                param.putOpt("appendDose",this.appendDose);
-                param.putOpt("appendLockTime",this.appendLockTime);
-                param.putOpt("maxDose",this.maxDose);
+                param.putOpt("continueDose",this.getContinueDose());
+                param.putOpt("firstDose",this.getFirstDose());
+                param.putOpt("appendDose",this.getAppendDose());
+                param.putOpt("appendLockTime",this.getAppendLockTime());
+                param.putOpt("maxDose",this.getMaxDose());
+                param.putOpt("classification",this.getClassification());
                 break;
             case pulse:
-                param.putOpt("firstDose",this.firstDose);
-                param.putOpt("firstLockTime",this.pulseFirstLockTime);
-                param.putOpt("continueDose",this.continueDose);
-                param.putOpt("pulseDose",this.pulseDose);
-                param.putOpt("lockTime",this.pulseLockTime);
-                param.putOpt("appendDose",this.appendDose);
-                param.putOpt("appendLockTime",this.appendLockTime);
-                param.putOpt("maxDose",this.maxDose);
+                param.putOpt("firstDose",this.getFirstDose());
+                param.putOpt("firstLockTime",this.getPulseFirstLockTime());
+                param.putOpt("continueDose",this.getContinueDose());
+                param.putOpt("pulseDose",this.getPulseDose());
+                param.putOpt("lockTime",this.getPulseLockTime());
+                param.putOpt("appendDose",this.getAppendDose());
+                param.putOpt("appendLockTime",this.getAppendLockTime());
+                param.putOpt("maxDose",this.getMaxDose());
+                param.putOpt("classification",this.getClassification());
                 break;
             case intelligent:
-                param.putOpt("firstDose",this.firstDose);
-                param.putOpt("appendDose",this.appendDose);
-                param.putOpt("appendLockTime",this.appendLockTime);
-                param.putOpt("flowUpCycle",this.flowUpCycle);
-                param.putOpt("flowCount",this.flowCount);
-                param.putOpt("flowDownCycle",this.flowDownCycle);
-                param.putOpt("flowAdjustRate",this.flowAdjustRate);
-                param.putOpt("flowUpLimit",this.flowUpLimit);
-                param.putOpt("flowDownLimit",this.flowDownLimit);
-                param.putOpt("continueDose",this.continueDose);
-                param.putOpt("maxDose",this.maxDose);
+                param.putOpt("firstDose",this.getFirstDose());
+                param.putOpt("appendDose",this.getAppendDose());
+                param.putOpt("appendLockTime",this.getAppendLockTime());
+                param.putOpt("flowUpCycle",this.getFlowUpCycle());
+                param.putOpt("flowCount",this.getFlowCount());
+                param.putOpt("flowDownCycle",this.getFlowDownCycle());
+                param.putOpt("flowAdjustRate",this.getFlowAdjustRate());
+                param.putOpt("flowUpLimit",this.getFlowUpLimit());
+                param.putOpt("flowDownLimit",this.getFlowDownLimit());
+                param.putOpt("continueDose",this.getContinueDose());
+                param.putOpt("maxDose",this.getMaxDose());
+                param.putOpt("classification",this.getClassification());
                 break;
             default:break;
         }

+ 27 - 6
coffee-system/src/main/java/com/coffee/bus/entity/BusPatientEntity.java

@@ -1,8 +1,6 @@
 package com.coffee.bus.entity;
 
-import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.coffee.bus.bean.HisInfo;
 import com.coffee.bus.enums.PatientAlarmEnum;
@@ -15,6 +13,8 @@ import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import org.hibernate.validator.constraints.Length;
 
+import java.util.Date;
+
 /**
  * @author lifang
  * @version 1.0.0
@@ -43,13 +43,23 @@ public class BusPatientEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty("病号最新的输注记录")
     private String infusionId;
 
+    @TableField
+    @ApiModelProperty("病人此次监护开始时间")
+    private Date monitorStartTime;
+
+    @TableField
+    @ApiModelProperty("此次监护医生是否已手动结束,以此表示来计算监护时长")
+    private Boolean tmpFinished;
+
+    @TableField
+    @ApiModelProperty("病人最后一次手动监护结束时间")
+    private Date monitorEndTime;
+
+    @TableField
     @ApiModelProperty("病人最后的手术id,若病人手术信息暂不存在,则先置为-1")
     private String clinicId;
 
-    @TableField(fill = FieldFill.INSERT)
-    @TableLogic(value = "0",delval = "1")
-    private Integer isDelete;
-
+    @TableField
     @ApiModelProperty(value = "病人报警信息",example = "泵重复,无泵")
     private PatientAlarmEnum alarm;
 
@@ -61,4 +71,15 @@ public class BusPatientEntity extends TenantGenericEntity<String,String> {
         patient.setTenantId(hisInfo.getHospitalId());
         return patient;
     }
+
+    public static BusPatientEntity of(BusClinicEntity clinic){
+        BusPatientEntity patient = new BusPatientEntity();
+        patient.setCode(clinic.getPatientCode());
+        patient.setName(clinic.getPatientName());
+        patient.setGender(clinic.getPatientGender());
+        patient.setClinicId(clinic.getId());
+        patient.setTmpFinished(clinic.getFinished());
+        patient.setTenantId(clinic.getTenantId());
+        return patient;
+    }
 }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/entity/PatientDeviceRepeatDomain.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.entity;
 
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.enums.SexEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -40,7 +40,7 @@ public class PatientDeviceRepeatDomain {
     @ApiModelProperty("设备别名")
     private String deviceAlias;
     @ApiModelProperty("设备运行状态")
-    private DeviceEnum deviceRunState;
+    private DeviceTypeEnum deviceRunState;
     @ApiModelProperty("设备报警信息")
     private DeviceAlarmEnum deviceAlarm;
     @ApiModelProperty("输注开始时间")

+ 88 - 16
coffee-system/src/main/java/com/coffee/bus/entity/PatientMonitorDomain.java

@@ -1,14 +1,12 @@
 package com.coffee.bus.entity;
 
-import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
-import com.coffee.bus.enums.DeviceStatusEnum;
-import com.coffee.bus.enums.PatientAlarmEnum;
+import cn.hutool.core.util.StrUtil;
+import com.coffee.bus.enums.*;
 import com.coffee.common.enums.SexEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import org.hibernate.validator.constraints.Length;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -38,6 +36,8 @@ public class PatientMonitorDomain {
     @ApiModelProperty(value = "设备id")
     private String deviceId;
 
+    @ApiModelProperty(value = "泵别名")
+    private String deviceAlias;
 
     @ApiModelProperty(value = "临床号")
     private String clinicId;
@@ -48,13 +48,14 @@ public class PatientMonitorDomain {
     @ApiModelProperty(value = "床号")
     private String bedNo;
 
-
     @ApiModelProperty(value = "总量")
     private Integer totalDose;
 
     @ApiModelProperty(value = "公共参数-首次量")
     private Integer firstDose;
 
+    @ApiModelProperty(value = "公共参数-电量",readOnly = true)
+    private Integer electricQuantity;
 
     @ApiModelProperty(value = "公共参数-剩余量")
     private BigDecimal remainDose;
@@ -123,15 +124,6 @@ public class PatientMonitorDomain {
     @ApiModelProperty(value = "报警信息")
     private DeviceAlarmEnum deviceAlarm;
 
-    @ApiModelProperty(value = "输注即将结束提醒")
-    private Boolean warnWillFinished;
-
-    @ApiModelProperty(value = "镇痛不足提醒")
-    private Boolean warnAnalgesicPoor;
-
-    @ApiModelProperty(value = "电量偏低提醒")
-    private Boolean warnLowBattery;
-
     @ApiModelProperty(value = "输注开始时间,即本次运行开机时间")
     private Date infusionStartTime;
 
@@ -139,7 +131,7 @@ public class PatientMonitorDomain {
     private String remark;
 
     @ApiModelProperty(value = "泵类型")
-    private DeviceEnum deviceType;
+    private DeviceTypeEnum deviceType;
 
     @ApiModelProperty(value = "麻醉医生")
     private String anaDoctor;
@@ -155,4 +147,84 @@ public class PatientMonitorDomain {
 
     @ApiModelProperty(value = "手术名称")
     private String surgeryName;
+
+    @ApiModelProperty(value = "当前病人是否已结束临床,根据此参数+监护开始时间计算总监护时间",
+            notes = "false:监护时长=当前时间-监护开始时间 ,true:监护时长=监护结束时间-监护开始时间")
+    private Boolean clinicFinished;
+
+    @ApiModelProperty("当前病人监护结束时间")
+    private Date monitorEndTime;
+
+    @ApiModelProperty("当前病人监护开始时间")
+    private Date monitorStartTime;
+
+    @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 = "加减档提示",readOnly = true)
+    @JsonIgnore
+    private FlowStatusEnum warnFlow;
+
+    @ApiModelProperty("提醒字段")
+    private String warns;
+
+    private void judgeWarnWillFinished() {
+        if(!Boolean.TRUE.equals(this.warnWillFinished)){
+           return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="输注即将结束;";
+        }else {
+            this.warns=this.warns+"输注即将结束;";
+        }
+    }
+
+    private void judgeWarnAnalgesicPoor() {
+        if(!Boolean.TRUE.equals(this.warnAnalgesicPoor)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="镇痛不足;";
+        }else {
+            this.warns=this.warns+"镇痛不足;";
+        }
+    }
+
+    private void judgeWarnLowBattery() {
+        if(!Boolean.TRUE.equals(this.warnLowBattery)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="电量偏低;";
+        }else {
+            this.warns=this.warns+"电量偏低;";
+        }
+    }
+
+    private void judgeWarnFlow() {
+        if(this.warnFlow==null){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns=warnFlow.getText()+";";
+        }else {
+            this.warns=this.warns+warnFlow.getText()+";";
+        }
+    }
+
+    public void handleWarn(){
+        judgeWarnAnalgesicPoor();
+        judgeWarnFlow();
+        judgeWarnLowBattery();
+        judgeWarnWillFinished();
+    }
 }

+ 53 - 0
coffee-system/src/main/java/com/coffee/bus/entity/common/CommonDeviceParam.java

@@ -0,0 +1,53 @@
+package com.coffee.bus.entity.common;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
+import com.coffee.bus.enums.FlowStatusEnum;
+import com.coffee.common.entity.TenantGenericEntity;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BaseDeviceParam.java
+ * @Description 设备公共参数信息
+ * @createTime 2022年05月05日 20:51:00
+ */
+@Accessors(chain = true)
+@Data
+public class CommonDeviceParam<PK,TN>  extends DeviceProperties<PK,TN>  {
+
+    @ApiModelProperty(value = "泵运行状态",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private DeviceStatusEnum runState;
+
+    @ApiModelProperty(value = "报警信息",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private DeviceAlarmEnum alarm;
+
+    @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
+    private Boolean warnWillFinished;
+
+    @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
+    private Boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
+    private Boolean warnLowBattery;
+
+    @ApiModelProperty(value = "加减档提示",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.DEFAULT)
+    private FlowStatusEnum warnFlow;
+
+}

+ 149 - 0
coffee-system/src/main/java/com/coffee/bus/entity/common/DeviceProperties.java

@@ -0,0 +1,149 @@
+package com.coffee.bus.entity.common;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.coffee.bus.enums.DeviceTypeEnum;
+import com.coffee.common.entity.TenantGenericEntity;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DeviceProperties.java
+ * @Description 设备上传属性(不包含报警、提醒字段)
+ * @createTime 2022年05月06日 09:06:00
+ */
+@Data
+public class DeviceProperties<PK,TN>  extends TenantGenericEntity<PK,TN> {
+    @ApiModelProperty(value = "网络泵id",readOnly = true)
+    private String deviceId;
+
+    @ApiModelProperty(value = "数据分类号,标识某些数据属于同一个输注",readOnly = true)
+    @JsonIgnoreProperties(allowSetters = true)
+    private String classification;
+
+    @ApiModelProperty(value = "数据编号",readOnly = true)
+    @JsonIgnoreProperties(allowSetters = true)
+    private Integer dataNumber;
+
+    @ApiModelProperty(value = "泵类型",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.NEVER)
+    private DeviceTypeEnum type;
+
+    @ApiModelProperty(value = "住院号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "病区")
+    private String ward;
+
+    @ApiModelProperty(value = "床号")
+    private String bedNo;
+
+    @ApiModelProperty(value = "总量",readOnly = true)
+    @Max(value = 999,message = "总量最大值不得超过999")
+    @Min(value = 0,message ="总量最小值不得超过0" )
+    private Integer totalDose;
+
+    @ApiModelProperty(value = "公共参数-首次量",readOnly = true)
+    @Max(value = 50,message = "首次量最大值不得超过50")
+    @Min(value = 0,message ="首次量最小值不得超过0" )
+    private Integer firstDose;
+
+
+    @ApiModelProperty(value = "公共参数-剩余量",readOnly = true)
+    private BigDecimal remainDose;
+
+    @ApiModelProperty(value = "公共参数-已输入量",readOnly = true)
+    private BigDecimal inputDose;
+
+    @ApiModelProperty(value = "公共参数-追加量",readOnly = true)
+    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
+    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal appendDose;
+
+    @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true)
+    @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99")
+    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal appendLockTime;
+
+    @ApiModelProperty(value = "公共参数-极限量",readOnly = true)
+    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
+    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal maxDose;
+
+    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
+    private Integer selfControlLockTime;
+
+    @ApiModelProperty(value = "公共参数-自控次数",readOnly = true)
+    private Integer selfControlCount;
+
+    @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true)
+    private Integer pcaValidCount;
+
+    @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true)
+    private Integer pcaInvalidCount;
+
+    @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true)
+    private Integer pcaTotalCount;
+
+    @ApiModelProperty(value = "持续泵参数-持续量",readOnly = true)
+    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
+    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
+    private BigDecimal continueDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true)
+    @Max(value = 20,message = "脉冲量最大值不得超过20")
+    @Min(value = 0,message ="脉冲量最小值不得超过0" )
+    private Integer pulseDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true)
+    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
+    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
+    private Integer pulseLockTime;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true)
+    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
+    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
+    private Integer pulseFirstLockTime;
+
+    @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true)
+    @DecimalMax(value = "10",message = "加档周期最大值不得超过10")
+    @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" )
+    private BigDecimal flowUpCycle;
+
+    @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true)
+    @DecimalMax(value = "10",message = "减档周期最大值不得超过10")
+    @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" )
+    private BigDecimal flowDownCycle;
+
+    @ApiModelProperty(value = "智能泵参数-计次",readOnly = true)
+    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
+    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" )
+    private BigDecimal flowCount;
+
+    @ApiModelProperty(value = "智能泵参数-上限",readOnly = true)
+    @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90")
+    @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" )
+    private BigDecimal flowUpLimit;
+
+    @ApiModelProperty(value = "智能泵参数-下限",readOnly = true)
+    @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50")
+    @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" )
+    private BigDecimal flowDownLimit;
+
+    @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true)
+    @DecimalMax(value = "95",message = "自调比例不得超过95")
+    @DecimalMin(value = "0",message ="自调比例最小值不得超过0" )
+    private BigDecimal flowAdjustRate;
+
+    @ApiModelProperty(value = "公共参数-电量",readOnly = true)
+    private Integer electricQuantity;
+}

+ 14 - 9
coffee-system/src/main/java/com/coffee/bus/enums/DeviceAlarmEnum.java

@@ -22,16 +22,21 @@ public enum DeviceAlarmEnum  implements IEnum<Integer> {
      * 切记不可删除!!!!!!!!!!!!
      */
     //    以下为报警信息状态
-    Finished(0,"输液结束"),
-    LowBattery(1,"低电量报警"),
+    None(0,"无报警"),
+    Bubble(1,"气泡报警"),
     Jam(2,"堵塞报警"),
-    Bubble(3,"气泡报警"),
-    NoSignal(4,"不在服务区"),
-    Machine(5,"机械故障"),
-    NotFastened(6,"未扣合故障"),
-    NotBox(7,"未装药盒报警"),
-    Limit(8,"极限报警"),
-    OutOfControl(9,"电机失控报警");
+    NotBox(3,"未装药盒报警"),
+    InfusionMax(4,"输入总量报警"),
+    Limit(5,"极限报警"),
+    Finished(6,"输液结束"),
+    LowBattery(7,"电量耗尽报警"),
+    OutOfControl(8,"电机失控报警"),
+    Machine(9,"机械故障"),
+    NoSignal(10,"不在服务区"),
+
+
+
+    ;
 
 
     @Getter

+ 26 - 0
coffee-system/src/main/java/com/coffee/bus/enums/DeviceManualEnum.java

@@ -0,0 +1,26 @@
+package com.coffee.bus.enums;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DeviceManualEnum.java
+ * @Description TODO
+ * @createTime 2022年05月07日 09:40:00
+ */
+@Getter
+@AllArgsConstructor
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+public enum DeviceManualEnum implements IEnum<Integer> {
+    machine(0,"机械泵"),
+    electronPulse(1,"电子脉冲泵"),
+    electron(2,"电子泵"),
+    other(3,"其他泵");
+
+    private Integer value;
+    private String text;
+}

+ 6 - 3
coffee-system/src/main/java/com/coffee/bus/enums/DeviceStatusEnum.java

@@ -23,9 +23,12 @@ public enum DeviceStatusEnum  implements IEnum<Integer> {
      * 如若新增,请在最后尾部新增
      * 切记不可删除!!!!!!!!!!!!
      */
-    Running(0,"正在运行"),
-    Waiting(1,"待机中"),
-    Shutdown(2,"关机");
+    Shutdown(0,"关机"),
+    StartUp(1,"开机"),
+    Running(2,"运行"),
+    Pause(3,"暂停"),
+    Waiting(4,"待机")
+    ;
 
 
     /**

+ 30 - 0
coffee-system/src/main/java/com/coffee/bus/enums/DeviceStatusEnum2.java

@@ -0,0 +1,30 @@
+package com.coffee.bus.enums;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-05-06 14:54:04
+ * @Version 1.0
+ * @Description 设备网络状态
+ */
+@AllArgsConstructor
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+public enum DeviceStatusEnum2 implements IEnum<Integer> {
+
+    NOACTIVE(0,"未激活"),
+    ONLINE(1,"在线"),
+    OFFLINE(2,"离线");
+
+
+    @Getter
+    @ApiModelProperty("状态编码")
+    private Integer value;
+    @Getter
+    @ApiModelProperty("状态内容")
+    private String text;
+}

+ 6 - 4
coffee-system/src/main/java/com/coffee/bus/enums/DeviceEnum.java → coffee-system/src/main/java/com/coffee/bus/enums/DeviceTypeEnum.java

@@ -15,10 +15,12 @@ import lombok.Getter;
  */
 @AllArgsConstructor
 @JsonFormat(shape = JsonFormat.Shape.OBJECT)
-public enum  DeviceEnum implements IEnum<Integer> {
-    continuous(0,"持续型网络泵"),
-    intelligent(1,"智能泵"),
-    pulse(2,"脉冲泵");
+public enum DeviceTypeEnum implements IEnum<Integer> {
+    no(0,"无泵"),
+    continuous(1,"网络泵"),
+    intelligent(2,"智能泵"),
+    pulse(3,"脉冲泵"),
+    other(4,"其他泵");
 
     @Getter
     @ApiModelProperty("设备编码")

+ 42 - 0
coffee-system/src/main/java/com/coffee/bus/enums/FlowStatusEnum.java

@@ -0,0 +1,42 @@
+package com.coffee.bus.enums;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-26 09:28:34
+ * @Version 1.0
+ * @Description 智能泵提示
+ */
+@AllArgsConstructor
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+public enum FlowStatusEnum implements IEnum<Integer> {
+    /**
+     * 0 --- 正常(默认值)
+     * 1 --- 加档受限
+     * 2 --- 流速已达上限
+     * 3 --- 加档
+     * 4 --- 减档
+     * 5 --- 低输注状态
+     */
+    None(0,"正常"),
+    Limited(1,"加档受限"),
+    MaxFlow(2,"流速已达上限"),
+    Up(3,"加档"),
+    Down(4,"减档"),
+    Lowest(5,"低输注状态");
+
+    /**
+     * 与枚举ordinal保持一致
+     */
+    @Getter
+    @ApiModelProperty("状态编码")
+    private Integer value;
+    @Getter
+    @ApiModelProperty("状态内容")
+    private String text;
+}

+ 1 - 0
coffee-system/src/main/java/com/coffee/bus/enums/PatientAlarmEnum.java

@@ -16,6 +16,7 @@ import lombok.Getter;
 @JsonFormat(shape = JsonFormat.Shape.OBJECT)
 @Getter
 public enum PatientAlarmEnum implements IEnum<Integer> {
+    NONE(0,"无报警信息"),
     DEVICE_REPEAT(1,"病人绑定多个设备"),
     DEVICE_NONE(2,"病人未绑定设备");
 

+ 32 - 0
coffee-system/src/main/java/com/coffee/bus/enums/WarnEnum.java

@@ -0,0 +1,32 @@
+package com.coffee.bus.enums;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName WarnEnum.java
+ * @Description TODO
+ * @createTime 2022年05月06日 16:53:00
+ */
+@Getter
+@AllArgsConstructor
+public enum  WarnEnum  implements IEnum<Integer> {
+    /**
+     * @see FlowStatusEnum 与该类保持一致
+     */
+    flowNone(0),
+    flowLimited(1),
+    flowMax(2),
+    flowUp(3),
+    flowDown(4),
+    flowLowest(5),
+
+    willFinished(6),
+    analPoor(7),
+    lowBattery(8),;
+
+    private Integer value;
+}

+ 33 - 0
coffee-system/src/main/java/com/coffee/bus/exception/BusinessException.java

@@ -0,0 +1,33 @@
+package com.coffee.bus.exception;
+
+import lombok.Data;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-05-06 10:03:58
+ * @Version 1.0
+ * @Description 业务异常
+ */
+@Data
+public class BusinessException extends RuntimeException {
+    static final long serialVersionUID = -7034897190745766940L;
+
+    private Integer code;
+
+    public BusinessException(ErrorStatus errorStatus){
+        super(errorStatus.getMessage());
+        this.code = errorStatus.getCode();
+    }
+
+    public BusinessException(Integer code, String message){
+        super(message);
+        this.code = code;
+    }
+
+    public BusinessException(ErrorStatus errorStatus, String message){
+        super(message);
+        this.code = errorStatus.getCode();
+    }
+
+
+}

+ 80 - 0
coffee-system/src/main/java/com/coffee/bus/exception/ErrorStatus.java

@@ -0,0 +1,80 @@
+package com.coffee.bus.exception;
+
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-05-06 10:17:13
+ * @Version 1.0
+ * @Description 错误状态码
+ */
+public enum ErrorStatus {
+    DEVICE_NOT_EXISTS(100,"设备不存在"),
+    DEVICEID_IS_EMPTY(101,"设备ID不能为空"),
+    DEVICE_NOT_MAPPING_HOSPITAL(102,"设备没有映射医院"),
+    DEVICE_NOT_MAPPING_PRODUCT(103,"设备没有映射产品"),
+    RAWPATIENTCODE_IS_EMPTY(104,"住院号不能为空"),
+    PATIENT_NOT_EXISTS(105,"患者不存在"),
+    AUTO_CREATE_CLINIC_FAILURE(106,"自动创建临床失败"),
+    CLASSIFICATION_NOT_EMPTY(107,"数据分类标识不能为空"),
+    DATANUMBER_NOT_EMPTY(108,"数据编号不能为空"),
+    AUTO_CREATE_DEVICEUSE_FAILURE(109,"自动创建设备使用失败"),
+    STATUS_NOT_EMPTY(110,"状态不能为空"),
+    DATATYPE_NOT_EMPTY(111,"数据类型不能为空"),
+    PLATFORMCODE_IS_EMPTY(112,"平台编号不能为空"),
+    PLATFORM_NOT_EXISTS(113,"平台不存在"),
+    PRODUCTCODE_IS_EMPTY(114,"产品编号不能为空"),
+    PRODUCTNAME_IS_EMPTY(115,"产品名称不能为空"),
+    PRODUCT_HAD_EXISTS(116,"产品已经存在"),
+    PRODUCT_NOT_EXISTS(117,"产品不存在"),
+    OBJECT_CHANGE_EXCEPTION(118,"对象转换异常"),
+    CLINIC_HAD_EXISTS(119,"患者正在治疗中"),
+    DEVICENAME_IS_EMPTY(120,"设备名称不能为空"),
+    HOSPITALCODE_IS_EMPTY(121,"医院编号不能为空"),
+    DEVICE_HAD_EXISTS(122,"设备已经存在"),
+    HOSPITAL_NOT_EXISTS(123,"医院不存在"),
+    PATIENT_HAD_EXISTS(124,"患者已经存在"),
+    USERNAME_IS_EMPTY(125,"用户名不能为空"),
+    ROLE_NOT_EXISTS(126,"角色不存在"),
+    REPASSWORD_NOT_EQUALS(127,"两次密码不一致"),
+    PLATFORMPRODUCTCODE_IS_EMPTY(128,"平台产品编号不能为空"),
+    PLATFORMPRODUCT_NOT_EXISTS(129,"平台产品不存在"),
+    AUTO_CREATE_PATIENT_FAILURE(130,"自动创建患者失败"),
+    RAWDATA_IS_EMPTY(131,"原始数据不能为空"),
+    DATA_CHANGE_FAILURE(132,"数据转换失败"),
+    PATIENTCODE_IS_EMPTY(133,"患者编号不能为空"),
+    MENU_IS_EXISTS(134,"菜单已经存在,或菜单编号重复"),
+    PARENTMENU_NOT_EXISTS(135,"上级菜单不存在"),
+    MENUCODE_IS_EMPTY(136,"菜单编号不能为空"),
+    MENUNAME_IS_EMPTY(137,"菜单名称不能为空"),
+    PATIENTCODEANDRAWPATIENTCODE_IS_EMPTY_TOGETHER(138,"患者编号和住院号不能同时为空"),
+    PLATFORM_ACCOUNT_NOT_EXISTS(139,"平台账号不存在"),
+    DEVICE_REGISTER_FAILURE(140,"向平台注册设备失败"),
+    DEVICE_AMOUNT_NOT_NULL(141,"设备数量不能为空"),
+    TUORENPLATDATA_ANALY_ERROR(142,"驼人平台数据解析错误"),
+    CLINICCODE_NOT_EMPTY(143,"临床编号不能为空"),
+    CLINIC_NOT_EMPTY(144,"临床不存在"),
+
+    NONE(1000,"没有错误");
+
+    private Integer code;
+    private String message;
+
+    public Integer getCode() {
+        return code;
+    }
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+    public String getMessage() {
+        return message;
+    }
+    public void setMessage(String message) {
+        this.message = message;
+    }
+    ErrorStatus(Integer code, String message){
+        this.code = code;
+        this.message = message;
+    }
+
+
+}

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/handler/CheckSignHandler.java

@@ -23,8 +23,8 @@ import java.nio.charset.Charset;
  * @Description TODO
  * @createTime 2022年04月22日 10:47:00
  */
-@Configuration
-@Profile("dev")
+//@Configuration
+//@Profile("dev")
 public class CheckSignHandler implements HandlerInterceptor {
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {

+ 8 - 0
coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceInfoEvent.java

@@ -1,5 +1,7 @@
 package com.coffee.bus.listener.event.bean;
 
+import cn.hutool.json.JSONUtil;
+import com.coffee.bus.controller.vo.DeviceRunningMockVo;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import lombok.Getter;
 import org.springframework.context.ApplicationEvent;
@@ -36,6 +38,12 @@ public class DeviceInfoEvent extends ApplicationEvent {
         this.deviceId=deviceId;
     }
 
+    public DeviceInfoEvent(Object source, @NotNull DeviceRunningMockVo content, @NotNull String deviceId) {
+        super(source);
+        this.content= JSONUtil.toBean(JSONUtil.toJsonStr(content),BusDeviceRunningEntity.class);
+        this.deviceId=deviceId;
+    }
+
     public DeviceInfoEvent(Object source, Clock clock, @NotNull BusDeviceRunningEntity content, @NotNull String deviceId) {
         super(source, clock);
         this.content=content;

+ 21 - 0
coffee-system/src/main/java/com/coffee/bus/listener/event/infusion/InfusionCreateEvent.java

@@ -0,0 +1,21 @@
+package com.coffee.bus.listener.event.infusion;
+
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import lombok.Getter;
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-26 14:42:27
+ * @Version 1.0
+ * @Description 输注开始事件,当泵刚开机时,会创建一个新的输注,此时会发布该事件。用途,临床管理模块可以监听该事件,去为该输注,获取临床数据
+ */
+@Getter
+public class InfusionCreateEvent extends ApplicationEvent {
+    private BusInfusionHistoryEntity infusion;
+
+    public InfusionCreateEvent(Object source,BusInfusionHistoryEntity infusion) {
+        super(source);
+        this.infusion = infusion;
+    }
+}

+ 21 - 0
coffee-system/src/main/java/com/coffee/bus/listener/event/infusion/InfusionUpdateEvent.java

@@ -0,0 +1,21 @@
+package com.coffee.bus.listener.event.infusion;
+
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import lombok.Getter;
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * @Author 龙三郎
+ * @Date 2022-04-26 14:42:27
+ * @Version 1.0
+ * @Description 网络泵发送数据的时候,输注管理模块会将最新的输注信息发布。输注监护模块可以订阅该事件,将数据推送到界面。
+ */
+@Getter
+public class InfusionUpdateEvent extends ApplicationEvent {
+    private BusInfusionHistoryEntity infusion;
+
+    public InfusionUpdateEvent(Object source, BusInfusionHistoryEntity infusion) {
+        super(source);
+        this.infusion = infusion;
+    }
+}

+ 6 - 1
coffee-system/src/main/java/com/coffee/bus/mapper/BusClinicMapper.java

@@ -1,8 +1,10 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.coffee.bus.controller.vo.ClinicStatsVo;
 import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusPatientEntity;
+import java.util.*;
+import com.coffee.bus.service.dto.ClinicStatsQueryResult;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -25,4 +27,7 @@ public interface BusClinicMapper extends BaseMapper<BusClinicEntity> {
      */
     @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);
+
+
+    List<ClinicStatsQueryResult> stats(@Param("query") ClinicStatsVo query);
 }

+ 26 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceManualMapper.java

@@ -0,0 +1,26 @@
+package com.coffee.bus.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.coffee.bus.entity.BusDeviceManualEntity;
+import com.coffee.bus.service.dto.ManualMonitorQuery;
+import com.coffee.bus.service.dto.ManualMonitorResult;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.*;
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusDeviceManualMapper.java
+ * @Description
+ * @createTime 2022年03月19日 09:15:00
+ */
+@Mapper
+public interface BusDeviceManualMapper extends BaseMapper<BusDeviceManualEntity> {
+
+    /**
+     * 查询其他监控信息列表
+     * @return
+     */
+    List<ManualMonitorResult> selectMonitor(@Param("query") ManualMonitorQuery query);
+}

+ 9 - 8
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceMapper.java

@@ -1,10 +1,8 @@
 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;
 
 /**
@@ -18,14 +16,17 @@ import org.apache.ibatis.annotations.Select;
 public interface BusDeviceMapper extends BaseMapper<BusDeviceEntity> {
 
     /**
-     * 获取病号最近一场手术信息
-     * @param hospitalId
-     * @param patientCode
+     * 获取设备,无视逻辑删除
+     * @param deviceId
      * @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);
-
+    BusDeviceEntity selectOneByDeviceId(String deviceId);
 
+    /**
+     * 去掉逻辑删除标志
+     * @param deviceId
+     * @return
+     */
+    Integer notDelete(String deviceId);
 
 }

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

@@ -3,6 +3,7 @@ package com.coffee.bus.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 /**
  * @author 龙三郎

+ 2 - 0
coffee-system/src/main/java/com/coffee/bus/registry/constant/DeviceKeyConstant.java

@@ -35,4 +35,6 @@ public class DeviceKeyConstant {
     public static final String INFUSION_PARAM="infusion_param";
 
     public static final String UNDO="undo";
+
+    public static final String UPLOAD_TIME="upload_time";
 }

+ 10 - 0
coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java

@@ -258,6 +258,16 @@ public class ClusterDeviceOperator implements DeviceOperator<DeviceCacheInfo> {
         configStorage.setConfig(DeviceKeyConstant.UNDO,undo);
     }
 
+    @Override
+    public Date getUploadTime() {
+        return getValue(DeviceKeyConstant.UPLOAD_TIME).asDate();
+    }
+
+    @Override
+    public void setUploadTime(Date uploadTime) {
+        configStorage.setConfig(DeviceKeyConstant.UPLOAD_TIME,uploadTime);
+    }
+
     @Override
     public void clear() {
         configStorage.clear();

+ 2 - 0
coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceRegistry.java

@@ -46,12 +46,14 @@ public class ClusterDeviceRegistry implements DeviceRegistry {
                 //设备不存在,即缓存操作不存在
                 return null;
             }
+            //设备注册信息
             deviceOperator.setEnable(device.getEnable());
             deviceOperator.setDeviceId(deviceId);
             deviceOperator.setTenantId(device.getTenantId());
             if(runningInfo==null){
                 deviceOperator.setAlias(device.getAlias());
             }else {
+                //设备运行信息
                 deviceOperator.setUsingId(runningInfo.getId());
                 deviceOperator.setClassification(runningInfo.getClassification());
                 deviceOperator.setAlarm(runningInfo.getAlarm());

+ 13 - 0
coffee-system/src/main/java/com/coffee/bus/registry/device/DeviceOperator.java

@@ -186,5 +186,18 @@ public interface DeviceOperator<T> extends Operator<T> {
      */
     void setUndo(Boolean undo);
 
+    /**
+     * 获取设备最新上传数据时间
+     * @return
+     */
+    Date getUploadTime();
+
+
+    /**
+     * 设置设备最新上传数据时间
+     * @param uploadTime
+     */
+    void setUploadTime(Date uploadTime);
+
     void clear();
 }

+ 32 - 11
coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientRegistry.java

@@ -1,20 +1,18 @@
 package com.coffee.bus.registry.patient;
 
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.registry.RegistryConstant;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.service.LocalBusClinicService;
+import com.coffee.bus.service.LocalBusInfusionHistoryService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.common.cache.manager.ClusterConfigStorageManager;
-import com.coffee.common.cache.value.Value;
-import com.coffee.common.redis.RedisUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.python.antlr.ast.Str;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -35,6 +33,7 @@ public class ClusterPatientRegistry implements PatientRegistry {
     private final LocalBusPatientService patientService;
     private final ClusterConfigStorageManager configStorageManager;
     private final LocalBusClinicService clinicService;
+    private final LocalBusInfusionHistoryService infusionService;
     @Override
     @Transactional(rollbackFor = Exception.class)
     public PatientOperator<PatientCacheInfo> getOperator(String hospitalId, String patientCode) {
@@ -50,31 +49,53 @@ public class ClusterPatientRegistry implements PatientRegistry {
             patient = patientService.getOne(new QueryWrapper<BusPatientEntity>()
                     .lambda().eq(BusPatientEntity::getCode, patientCode)
                     .eq(BusPatientEntity::getTenantId, hospitalId));
+            boolean insert=false;
             if(patient==null){
+                insert=true;
                 patient=new BusPatientEntity();
                 patient.setCode(patientCode);
+                //默认为空字符串
+                patient.setClinicId("");
                 patient.setTenantId(hospitalId);
-                try {
-                    log.info("医院[{}]新增病号数据[{}]",hospitalId,patientCode);
-                    patientService.save(patient);
-                }catch (DuplicateKeyException e){
-                    log.warn("病号重复插入,医院id:[{}],病号:[{}]",hospitalId,patientCode);
-                }
             }
             patientOperator.setCode(patientCode);
             patientOperator.setTenantId(hospitalId);
             patientOperator.setName(patient.getName());
             patientOperator.setGender(patient.getGender());
+
             BusClinicEntity clinic = clinicService.recentClinicByPatientCode(hospitalId, patientCode);
             //不存在临床或临床已结束
             if(clinic==null||Boolean.TRUE.equals(clinic.getFinished())){
                 clinicService.asyncFromHis(hospitalId,patientCode);
+                patient.setClinicId("-1");
+                patientOperator.setClinicId("-1");
             }else {
+                //填充临床信息
+                patient.setName(clinic.getName());
+                patient.setTmpFinished(clinic.getFinished());
+                patient.setClinicId(clinic.getId());
+                patient.setTmpFinished(clinic.getFinished());
+
                 patientOperator.setWard(clinic.getWard());
                 patientOperator.setBedNo(clinic.getBedNo());
                 patientOperator.setClinicId(clinic.getId());
+                patientOperator.setFinished(clinic.getFinished());
+            }
+            //填充输注信息
+            BusInfusionHistoryEntity infusion = infusionService.recentInfusionByPatientCode(hospitalId, patientCode);
+            if(infusion!=null){
+                patient.setInfusionId(infusion.getId());
+                patient.setMonitorStartTime(infusion.getStartTime());
+                patient.setMonitorEndTime(infusion.getUndoTime());
+            }
+            if(insert){
+                try {
+                    log.info("医院[{}]新增病号数据[{}]",hospitalId,patientCode);
+                    patientService.save(patient);
+                }catch (DuplicateKeyException e){
+                    log.warn("病号重复插入,医院id:[{}],病号:[{}]",hospitalId,patientCode);
+                }
             }
-            //将临床数据拉入缓存,获取最新的临床信息 todo
         }
         return patientOperator;
     }

+ 17 - 3
coffee-system/src/main/java/com/coffee/bus/service/LocalBusClinicService.java

@@ -1,11 +1,14 @@
 package com.coffee.bus.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.coffee.bus.controller.vo.ClinicStatsVo;
 import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.mapper.BusClinicMapper;
-import com.coffee.bus.registry.patient.PatientOperator;
 import com.coffee.bus.registry.patient.PatientRegistry;
-import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
+import com.coffee.bus.service.dto.ClinicStatsQueryResult;
+import com.coffee.bus.service.dto.ClinicStatsReturnResult;
 import com.coffee.common.crud.BaseService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +28,9 @@ import java.util.*;
 @Service
 @Slf4j
 public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClinicEntity,String> {
-
+    @Autowired
+    @Lazy
+    private LocalBusPatientService patientService;
     @Autowired
     @Lazy
     private PatientRegistry patientRegistry;
@@ -70,6 +75,11 @@ public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClini
                 .eq(BusClinicEntity::getFinished,false)
                 .set(BusClinicEntity::getFinished,true)
                 .set(BusClinicEntity::getEndTime,finishTime));
+
+        patientService.update(new UpdateWrapper<BusPatientEntity>().lambda()
+                .in(BusPatientEntity::getCode,patientCodes)
+                .set(BusPatientEntity::getTmpFinished,true)
+                .set(BusPatientEntity::getMonitorEndTime,finishTime));
         //更新病人缓存
         patientCodes.stream().map(code->patientRegistry.getOperator(tenantId,code)).forEach(operator->operator.setFinished(true));
     }
@@ -92,4 +102,8 @@ public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClini
     public void asyncFromHis(String hospitalId, String patientCode) {
 
     }
+
+    public ClinicStatsReturnResult stats(ClinicStatsVo statsVo) {
+        return ClinicStatsReturnResult.of(this.baseMapper.stats(statsVo));
+    }
 }

+ 61 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceManualService.java

@@ -0,0 +1,61 @@
+package com.coffee.bus.service;
+
+import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusDeviceManualEntity;
+import com.coffee.bus.mapper.BusDeviceManualMapper;
+import com.coffee.bus.service.dto.ManualMonitorQuery;
+import com.coffee.bus.service.dto.ManualMonitorResult;
+import com.coffee.common.crud.BaseService;
+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;
+import java.util.*;
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName LocalBusHospitalService.java
+ * @Description 设备注册
+ * @createTime 2022年03月19日 09:27:00
+ */
+@Service
+@Slf4j
+public class LocalBusDeviceManualService extends BaseService<BusDeviceManualMapper, BusDeviceManualEntity,String> {
+
+    @Autowired
+    @Lazy
+    private LocalBusClinicService clinicService;
+    @Override
+    public void validateBeforeSave(BusDeviceManualEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeUpdate(BusDeviceManualEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeDelete(String id) {
+
+    }
+
+    /**
+     * 新增其他监控信息
+     * @param manual
+     * @param clinic
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void save(BusDeviceManualEntity manual, BusClinicEntity clinic) {
+        //将临床设置为无泵监控临床
+        clinic.setMonitorType(false);
+        clinicService.save(clinic);
+        manual.setClinicId(clinic.getId());
+        this.save(manual);
+    }
+
+    public List<ManualMonitorResult> selectMonitor(ManualMonitorQuery query){
+        return this.baseMapper.selectMonitor(query);
+    }
+}

+ 40 - 31
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java

@@ -36,10 +36,18 @@ import java.util.stream.Collectors;
  */
 @Service
 public class LocalBusDeviceRunningService extends BaseService<BusDeviceRunningMapper, BusDeviceRunningEntity,String> {
-    private final LocalBusInfusionHistoryService infusionHistoryService;
-    private final PatientRegistry patientRegistry;
-    private final LocalBusPatientService patientService;
-    private final LocalBusClinicService clinicService;
+    @Autowired
+    @Lazy
+    private LocalBusInfusionHistoryService infusionHistoryService;
+    @Autowired
+    @Lazy
+    private PatientRegistry patientRegistry;
+    @Autowired
+    @Lazy
+    private LocalBusPatientService patientService;
+    @Autowired
+    @Lazy
+    private LocalBusClinicService clinicService;
     @Autowired
     @Lazy
     private DeviceRegistry deviceRegistry;
@@ -90,33 +98,34 @@ public class LocalBusDeviceRunningService extends BaseService<BusDeviceRunningMa
     @Transactional(rollbackFor = Exception.class)
     public void undo(ManualUndoConfig manualUndoConfig,boolean finishClinic) {
         List<String> deviceIds = manualUndoConfig.getDeviceIds();
-        if(CollectionUtil.isEmpty(deviceIds)){
-            return;
-        }
-        /****************将撤泵记录存入到泵的使用历史记录中***************/
-        List<BusDeviceRunningEntity> devices = this.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().in(BusDeviceRunningEntity::getDeviceId,deviceIds));
-        if(CollectionUtil.isEmpty(devices)){
-            return;
-        }
-        if (devices.stream().anyMatch(BusDeviceRunningEntity::getMaster)) {
-            throw new CustomException("主泵不可撤除,请在【结束管理】处操作");
-        }
-        //对所有运行中的泵进行撤泵操作
-        this.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().in(BusDeviceRunningEntity::getDeviceId,deviceIds).set(BusDeviceRunningEntity::getIsUndo,true));
-        //无泵监护,不需要监护输注数据
-        if(!Boolean.TRUE.equals(manualUndoConfig.getMonitorType())){
-            //输注结束,更新撤泵信息
-            Set<String> infusionIds = devices.stream().map(BusDeviceRunningEntity::getInfusionId).collect(Collectors.toSet());
-            UndoDeviceConfig undo = manualUndoConfig.getUndo();
-            infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
-                    .in(BusInfusionHistoryEntity::getId,infusionIds)
-                    .set(BusInfusionHistoryEntity::getUndoBy,undo.getUndoBy())
-                    .set(BusInfusionHistoryEntity::getUndoTime,undo.getUndoTime())
-                    .set(BusInfusionHistoryEntity::getDestroyer,undo.getDestroyer())
-                    .set(BusInfusionHistoryEntity::getWitnesses,undo.getWitnesses()));
-            //将缓存设置为已撤泵状态
-            deviceIds.stream().map(deviceRegistry::getOperator)
-                    .forEach(operator->operator.setUndo(true));
+        if(CollectionUtil.isNotEmpty(deviceIds)){
+            /****************将撤泵记录存入到泵的使用历史记录中***************/
+            List<BusDeviceRunningEntity> devices = this.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().in(BusDeviceRunningEntity::getDeviceId,deviceIds));
+            if(CollectionUtil.isEmpty(devices)){
+                return;
+            }
+//            //主泵撤除且没有结束临床
+//            if (devices.stream().anyMatch(BusDeviceRunningEntity::getMaster)&&!finishClinic) {
+//                throw new CustomException("主泵不可撤除,请在【结束管理】处操作");
+//            }
+            //对所有运行中的泵进行撤泵操作
+            this.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().in(BusDeviceRunningEntity::getDeviceId,deviceIds).set(BusDeviceRunningEntity::getIsUndo,true));
+            //无泵监护,不需要监护输注数据
+            if(Boolean.TRUE.equals(manualUndoConfig.getMonitorType())){
+                //输注结束,更新撤泵信息
+                Set<String> infusionIds = devices.stream().map(BusDeviceRunningEntity::getInfusionId).collect(Collectors.toSet());
+                UndoDeviceConfig undo = manualUndoConfig.getUndo();
+                infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
+                        .in(BusInfusionHistoryEntity::getId,infusionIds)
+                        .set(BusInfusionHistoryEntity::getIsUndo,true)
+                        .set(BusInfusionHistoryEntity::getUndoBy,undo.getUndoBy())
+                        .set(BusInfusionHistoryEntity::getUndoTime,undo.getUndoTime())
+                        .set(BusInfusionHistoryEntity::getDestroyer,undo.getDestroyer())
+                        .set(BusInfusionHistoryEntity::getWitnesses,undo.getWitnesses()));
+                //将缓存设置为已撤泵状态
+                deviceIds.stream().map(deviceRegistry::getOperator)
+                        .forEach(operator->operator.setUndo(true));
+            }
         }
         //结束临床
         if(finishClinic){

+ 111 - 1
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java

@@ -1,6 +1,10 @@
 package com.coffee.bus.service;
 
 import cn.hutool.core.util.StrUtil;
+import com.aliyuncs.iot.model.v20180120.QueryDeviceDetailResponse;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.coffee.aliyun.sdk.AliyunIotSdk;
+import com.coffee.bus.bean.AliIotConfig;
 import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.mapper.BusDeviceMapper;
@@ -11,6 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
+
 /**
  * @author lifang
  * @version 1.0.0
@@ -25,6 +32,13 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
     @Autowired
     @Lazy
     private DeviceRegistry deviceRegistry;
+
+    @Autowired
+    private BusDeviceMapper deviceMapper;
+
+    @Autowired
+    private AliyunIotSdk aliyunIotSdk;
+
     @Override
     public void validateBeforeSave(BusDeviceEntity entity) {
 
@@ -37,7 +51,8 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
 
     @Override
     public void validateBeforeDelete(String id) {
-     }
+
+    }
 
     @Override
     public void postSave(BusDeviceEntity entity) {
@@ -57,6 +72,9 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
         if(entity.getEnable()!=null){
             deviceOperator.setEnable(entity.getEnable());
         }
+        if(StrUtil.isNotEmpty(entity.getTenantId())){
+            deviceOperator.setTenantId(entity.getTenantId());
+        }
     }
 
     @Override
@@ -65,5 +83,97 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
         deviceRegistry.remove(registeredEntity.getDeviceId());
     }
 
+    /**
+     * @author 龙三郎
+     * 根据deviceId删除设备
+     * @param deviceId
+     */
+    public void removeByDeviceId(String deviceId){
+        this.remove(new QueryWrapper<BusDeviceEntity>().lambda()
+                .eq(BusDeviceEntity::getDeviceId,deviceId));
+    }
+
+    /**
+     * @author 龙三郎
+     * 根据deviceId更新设备在线状态
+     * @param device
+     */
+    public boolean updateByDeviceId(BusDeviceEntity device){
+        return this.update(device,new QueryWrapper<BusDeviceEntity>().lambda()
+                .eq(BusDeviceEntity::getDeviceId,device.getDeviceId()));
+    }
+
+    /**
+     * @author 龙三郎
+     * 添加设备
+     * @param entity
+     */
+    public boolean saveByDeviceId(BusDeviceEntity entity) {
+        // 查询设备是否存在,无视逻辑删除
+        BusDeviceEntity old = deviceMapper.selectOneByDeviceId(entity.getDeviceId());
+        // 设备存在,且处于删除状态,首先去掉逻辑删除标志 ?? 逻辑删除后设备数据是否不再接收
+        if (Objects.nonNull(old) && old.getIsDelete() == 1){
+            deviceMapper.notDelete(entity.getDeviceId());
+        }
+        // 设备存在
+        if (Objects.nonNull(old)){
+            // 更新设备
+            return this.updateByDeviceId(entity);
+        }else {
+            // 添加设备
+            return this.save(entity);
+        }
+    }
 
+    /**
+     * @author 龙三郎
+     * 根据deviceId获取设备
+     * @param deviceId
+     * @return
+     */
+    public BusDeviceEntity getByDeviceId(String deviceId) {
+        BusDeviceEntity device = getOne(new QueryWrapper<BusDeviceEntity>().lambda()
+                .eq(BusDeviceEntity::getDeviceId,deviceId));
+        return device;
+    }
+
+    /**
+     * @author 龙三郎
+     * 该方法用于从阿里云同步设备,系统暂时不允许创建非阿里云物联网平台设备。意思是系统中的设备必须存在于阿里云物联网平台。
+     * 通过deviceId从阿里云查询设备,如果设备在阿里云平台不存在,则创建失败,如果存在,则获取设备数据,插入或更新设备数据,表示创建成功。
+     * @param deviceId
+     * @return
+     */
+    public BusDeviceEntity add(String deviceId) {
+        BusDeviceEntity device = new BusDeviceEntity();
+        device.setConfig(new AliIotConfig());
+        // 从阿里云物联网查询设备
+        QueryDeviceDetailResponse response = aliyunIotSdk.queryDeviceDetail(deviceId);
+        // 设备存在
+        if (response.getSuccess()){
+            device.setFields(response.getData());
+            // 存储设备
+            this.saveByDeviceId(device);
+            return device;
+        }
+        // 不存在返回null
+        return null;
+    }
+
+    /**
+     * @author 龙三郎
+     * 从阿里云平台获取全部的设备,同步到系统数据库
+     * @return
+     */
+    public int syncDevice() {
+        AtomicReference<Integer> n = new AtomicReference<>(0);
+        aliyunIotSdk.queryDevice().forEach(item ->{
+            BusDeviceEntity device = new BusDeviceEntity();
+            device.setConfig(new AliIotConfig());
+            // 更新设备属性
+            device.setFields(item);
+            n.updateAndGet(v -> v + (this.saveByDeviceId(device)?1:0));
+        });
+        return n.get();
+    }
 }

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

@@ -1,10 +1,23 @@
 package com.coffee.bus.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import cn.hutool.extra.spring.SpringUtil;
+import com.coffee.aliyun.utils.Constants;
+import com.coffee.aliyun.utils.Items;
+import com.coffee.aliyun.utils.PumpParams;
+import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
+import com.coffee.bus.entity.BusPatientEntity;
+import com.coffee.bus.listener.event.infusion.InfusionCreateEvent;
+import com.coffee.bus.listener.event.infusion.InfusionUpdateEvent;
 import com.coffee.bus.mapper.BusInfusionHistoryMapper;
 import com.coffee.common.crud.BaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
+import java.util.Objects;
+
 /**
  * @author 龙三郎
  * @version 1.0.0
@@ -14,6 +27,14 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class LocalBusInfusionHistoryService extends BaseService<BusInfusionHistoryMapper, BusInfusionHistoryEntity,String> {
+
+    @Autowired
+    @Lazy
+    private LocalBusDeviceService deviceService;
+    @Autowired
+    @Lazy
+    private LocalBusPatientService patientService;
+
     @Override
     public void validateBeforeSave(BusInfusionHistoryEntity entity) {
 
@@ -28,4 +49,80 @@ public class LocalBusInfusionHistoryService extends BaseService<BusInfusionHisto
     public void validateBeforeDelete(String id) {
 
     }
+
+    /**
+     * @author 龙三郎
+     * 保存输注
+     * 处理输注数据
+     * @param deviceId
+     * @param items
+     * @return
+     */
+    public BusInfusionHistoryEntity saveInfusion(String deviceId, Items items) {
+
+        // 第一步:判断设备是否存在
+        BusDeviceEntity device = deviceService.getByDeviceId(deviceId);
+        if (Objects.isNull(device)){
+            // 设备不存在,抛个异常
+            throw new RuntimeException("设备不存在");
+        }
+        // 第二步:判断输注是否存在,处理输注
+        // 根据deviceId和分类标识查询输注
+        String classification = items.getString(PumpParams.classification);
+        BusInfusionHistoryEntity infusion = getOneByDeviceIdAndClassification(deviceId,classification);
+        // 输注是否存在
+        boolean infusionIsExists = Objects.nonNull(infusion);
+        if (!infusionIsExists){
+            // 输注不存在
+            infusion = new BusInfusionHistoryEntity();
+            infusion.setDeviceId(deviceId);
+            infusion.setCreateBy(Constants.DefaultCreateBy);
+            infusion.setUpdateBy(Constants.DefaultUpdateBy);
+            // 给输注设置租户id
+            infusion.setTenantId(device.getTenantId());
+            // 根据阿里云发送的数据更新输注对象。
+            infusion.setFiledsByItems(items);
+            // 根据住院号和医院获取一个患者
+            BusPatientEntity patient = patientService.getOneByHospitalAndPatientCode(device.getTenantId(),items.getString(PumpParams.patientCode));
+            infusion.setPatientId(patient.getId());
+            // 添加一个输注
+            this.save(infusion);
+        }else {
+            // 更新输注数据。
+            infusion.setFiledsByItems(items);
+            this.updateById(infusion);
+        }
+
+
+        // 输注不存在,创建新的输注的时候,需要去请求临床数据
+        if (!infusionIsExists){
+            // 发布输注创建事件,临床管理模块需要订阅该事件,去获取临床数据
+            // 输注监护功能订阅该事件
+            SpringUtil.publishEvent(new InfusionCreateEvent(this,infusion));
+        }else {
+            // 输注数据更新事件
+            SpringUtil.publishEvent(new InfusionUpdateEvent(this,infusion));
+        }
+        return infusion;
+    }
+
+    /**
+     * @author 龙三郎
+     * 根据分类标识和设备号获取输注
+     * @param deviceId
+     * @param classification
+     * @return
+     */
+    private BusInfusionHistoryEntity getOneByDeviceIdAndClassification(String deviceId,String classification){
+        return this.getOne(new QueryWrapper<BusInfusionHistoryEntity>().lambda()
+                .eq(BusInfusionHistoryEntity::getDeviceId,deviceId)
+                .eq(BusInfusionHistoryEntity::getClassification,classification));
+    }
+
+    public BusInfusionHistoryEntity recentInfusionByPatientCode(String hospitalId, String patientCode) {
+        return this
+                .getOne(new QueryWrapper<BusInfusionHistoryEntity>()
+                .lambda()
+                .eq(BusInfusionHistoryEntity::getTenantId,hospitalId).eq(BusInfusionHistoryEntity::getPatientCode,patientCode).last("limit 1"));
+    }
 }

+ 70 - 1
coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java

@@ -1,20 +1,33 @@
 package com.coffee.bus.service;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.entity.PatientDeviceRepeatDomain;
 import com.coffee.bus.entity.PatientMonitorDomain;
+import com.coffee.bus.mapper.BusClinicMapper;
 import com.coffee.bus.mapper.BusPatientMapper;
+import com.coffee.bus.registry.patient.PatientOperator;
+import com.coffee.bus.registry.patient.PatientRegistry;
+import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.service.dto.PatientDeviceNoneResult;
 import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
 import com.coffee.bus.service.dto.PatientMonitorQuery;
 import com.coffee.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.data.domain.PageRequest;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 
@@ -26,9 +39,15 @@ import java.util.*;
  * @createTime 2022年03月19日 09:27:00
  */
 @Service
-@AllArgsConstructor
 @Slf4j
 public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPatientEntity,String> {
+    @Autowired
+    @Lazy
+    private LocalBusClinicService clinicService;
+    @Autowired
+    @Lazy
+    private PatientRegistry patientRegistry;
+
     @Override
     public void validateBeforeSave(BusPatientEntity entity) {
 
@@ -101,6 +120,56 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     public List<PatientMonitorDomain> selectAll(PatientMonitorQuery query) {
         Page<PatientMonitorDomain> page = new Page<>(0, 500, false);
         IPage<PatientMonitorDomain> result = this.baseMapper.selectMonitor(page,query);
+        if(CollectionUtil.isNotEmpty(result.getRecords())){
+            result.getRecords().forEach(PatientMonitorDomain::handleWarn);
+        }
         return result.getRecords();
     }
+
+    /**
+     * 根据医院和住院号获取一个患者
+     * @param tenantId
+     * @param patientCode
+     * @return
+     */
+    public BusPatientEntity getOneByHospitalAndPatientCode(String tenantId, String patientCode) {
+        BusPatientEntity patient = this.getOne(new QueryWrapper<BusPatientEntity>().lambda()
+                .eq(BusPatientEntity::getTenantId,tenantId)
+                .eq(BusPatientEntity::getCode,patientCode));
+        // 如果患者不存在则新增一个患者
+        if (Objects.isNull(patient)){
+            patient = new BusPatientEntity();
+            patient.setTenantId(tenantId);
+            patient.setCode(patientCode);
+            this.save(patient);
+        }
+        return patient;
+    }
+
+    /**
+     *
+     * 病人手动更新当前监控的临床信息 todo
+     * @param clinic
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void manualEdit(BusClinicEntity clinic) {
+        //先更新手术信息 todo
+        clinicService.saveOrUpdate(clinic);
+        //后更新病人信息
+        BusPatientEntity patient = BusPatientEntity.of(clinic);
+        PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(patient.getTenantId(), patient.getCode());
+        if (StrUtil.isEmpty(patientOperator.getCode())) {
+            this.save(patient);
+            patientOperator.setCode(patient.getCode());
+            patientOperator.setTenantId(patient.getTenantId());
+        }else {
+            BusPatientEntity existPatient = this.getOne(new QueryWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode, patient.getCode()).last("limit 1"));
+            patient.setId(existPatient.getId());
+            this.updateById(patient);
+        }
+        patientOperator.setClinicId(patient.getClinicId());
+        patientOperator.setName(patient.getName());
+        patientOperator.setBedNo(clinic.getBedNo());
+        patientOperator.setWard(clinic.getWard());
+    }
 }

+ 33 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicStatsQueryResult.java

@@ -0,0 +1,33 @@
+package com.coffee.bus.service.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ClinicStatsQueryResult.java
+ * @Description TODO
+ * @createTime 2022年04月27日 16:55:00
+ */
+@ApiModel("统计查询数据库结果")
+@Data
+public class ClinicStatsQueryResult implements Serializable {
+    @ApiModelProperty(value = "流速",hidden = true)
+    private BigDecimal continueDose;
+    @ApiModelProperty(value = "追加量",hidden = true)
+    private BigDecimal appendDose;
+    @ApiModelProperty(value = "已输注量",hidden = true)
+    private BigDecimal inputDose;
+    @ApiModelProperty(value = "无效次数",hidden = true)
+    private Integer validCount;
+    @ApiModelProperty(value = "有效次数",hidden = true)
+    private Integer inValidCount;
+    @ApiModelProperty(value = "数据上传时间",hidden = true)
+    private Date uploadTime;
+}

+ 71 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicStatsReturnResult.java

@@ -0,0 +1,71 @@
+package com.coffee.bus.service.dto;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.python.antlr.ast.Str;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.*;
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ClinicStatsResult.java
+ * @Description TODO
+ * @createTime 2022年04月27日 16:16:00
+ */
+@Data
+@ApiModel("统计返回前端数据")
+public class ClinicStatsReturnResult implements Serializable {
+    @ApiModelProperty("流速数据集")
+    private List<List<Object>> continueDose;
+    @ApiModelProperty("追加量数据集")
+    private List<List<Object>> appendDose;
+    @ApiModelProperty("已输注量数据集")
+    private List<List<Object>> inputDose;
+    @ApiModelProperty("有效次数数据集")
+    private List<List<Object>> validCount;
+    @ApiModelProperty("无效次数数据集")
+    private List<List<Object>> inValidCount;
+
+    public static ClinicStatsReturnResult of(List<ClinicStatsQueryResult> queryResults){
+        ClinicStatsReturnResult result = new ClinicStatsReturnResult();
+        if(CollectionUtil.isEmpty(queryResults)){
+            return result;
+        }
+        queryResults.forEach(queryResult -> {
+            String uploadTime = DateUtil.format(queryResult.getUploadTime(), DatePattern.NORM_DATETIME_PATTERN);
+            List<List<Object>> continueDoses = Optional.ofNullable(result.getContinueDose()).orElse(new ArrayList<>());
+            List<List<Object>> appendDoses = Optional.ofNullable(result.getAppendDose()).orElse(new ArrayList<>());
+            List<List<Object>> inputDoses = Optional.ofNullable(result.getInputDose()).orElse(new ArrayList<>());
+            List<List<Object>> validCounts = Optional.ofNullable(result.getValidCount()).orElse(new ArrayList<>());
+            List<List<Object>> inValidCounts = Optional.ofNullable(result.getInValidCount()).orElse(new ArrayList<>());
+
+            if( queryResult.getContinueDose()!=null){
+                continueDoses.add(Arrays.asList(uploadTime, queryResult.getContinueDose()));
+            }
+            if(queryResult.getAppendDose()!=null){
+                appendDoses.add(Arrays.asList(uploadTime,queryResult.getAppendDose()));
+            }
+            if( queryResult.getInputDose()!=null){
+                inputDoses.add(Arrays.asList(uploadTime, queryResult.getInputDose()));
+            }
+            if(queryResult.getValidCount()!=null){
+                validCounts.add(Arrays.asList(uploadTime,queryResult.getValidCount()));
+            }
+            if(queryResult.getInValidCount()!=null){
+                inValidCounts.add(Arrays.asList(uploadTime,queryResult.getInValidCount()));
+            }
+
+            result.setContinueDose(continueDoses);
+            result.setAppendDose(appendDoses);
+            result.setInputDose(inputDoses);
+            result.setValidCount(validCounts);
+            result.setInValidCount(inValidCounts);
+        });
+        return result;
+    }
+}

+ 0 - 4
coffee-system/src/main/java/com/coffee/bus/service/dto/DeviceShiftConfig.java

@@ -25,10 +25,6 @@ public class DeviceShiftConfig {
     @NotNull(message = "请选择一个泵作为此临床信息的主泵进行监控")
     private String masterDeviceId;
 
-    @ApiModelProperty("主泵的开始时间")
-    @NotNull(message = "主泵的开始时间不能为空")
-    private Date startTime;
-
     @ApiModelProperty("病号")
     @NotNull(message = "病号不能为空")
     private String patientCode;

+ 26 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/ManualMonitorQuery.java

@@ -0,0 +1,26 @@
+package com.coffee.bus.service.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.*;
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ManualMonitorQuery.java
+ * @Description TODO
+ * @createTime 2022年05月07日 10:18:00
+ */
+@Data
+@ApiModel("其他监控查询参数")
+public class ManualMonitorQuery {
+    @ApiModelProperty("模糊查询,病区、床号、姓名、住院号")
+    private String blurry;
+
+    /**
+     * @see  com.coffee.bus.enums.DeviceManualEnum
+     */
+    @ApiModelProperty("设备类型;0、机械泵;1、电子脉冲泵;2、电子泵;3、其他泵")
+    private List<Integer> types;
+}

+ 55 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/ManualMonitorResult.java

@@ -0,0 +1,55 @@
+package com.coffee.bus.service.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.coffee.bus.entity.FormulaDrugDomain;
+import com.coffee.bus.enums.DeviceManualEnum;
+import com.coffee.common.enums.SexEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ManualMonitorResult.java
+ * @Description 其他监护(即无泵监护)
+ * @createTime 2022年05月07日 10:08:00
+ */
+@Data
+@ApiModel("其他监护查询返回结果")
+public class ManualMonitorResult {
+    @ApiModelProperty(value = "临床手术名称")
+    private String surgeryName;
+
+    @ApiModelProperty(value = "病号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "手术开始时间")
+    private Date startTime;
+
+    @ApiModelProperty(value = "患者姓名")
+    private String patientName;
+
+    @ApiModelProperty(value = "患者性别")
+    private SexEnum patientGender;
+
+    @ApiModelProperty(value = "患者年龄")
+    private Integer patientAge;
+
+    @ApiModelProperty(value = "病区")
+    private String ward;
+
+    @ApiModelProperty(value = "病床号")
+    private String bedNo;
+
+    @ApiModelProperty(value = "麻醉医生")
+    private String anaDoctor;
+
+    @ApiModelProperty("设备类型")
+    private DeviceManualEnum deviceType;
+}

+ 4 - 1
coffee-system/src/main/java/com/coffee/bus/service/dto/ManualUndoConfig.java

@@ -5,8 +5,10 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 import java.util.*;
 /**
  * @author lifang
@@ -18,7 +20,8 @@ import java.util.*;
 @Data
 @ApiModel("手动撤泵配置")
 @AllArgsConstructor(staticName = "of")
-public class ManualUndoConfig {
+@NoArgsConstructor
+public class ManualUndoConfig implements Serializable {
     @ApiModelProperty("进行撤泵的所有运行数据id")
     private List<String> deviceIds;
 

+ 30 - 6
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceNoneResult.java

@@ -1,16 +1,12 @@
 package com.coffee.bus.service.dto;
 
-import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler;
 import com.coffee.common.enums.SexEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import lombok.AllArgsConstructor;
 import lombok.Data;
 
-import java.util.Date;
-import java.util.List;
-
 /**
  * @author lifang
  * @version 1.0.0
@@ -25,6 +21,7 @@ public class PatientDeviceNoneResult {
     private String name;
 
     @ApiModelProperty("病患性别")
+    @TableField(typeHandler = MybatisEnumTypeHandler.class)
     private SexEnum gender;
 
     @ApiModelProperty("病号")
@@ -44,4 +41,31 @@ public class PatientDeviceNoneResult {
 
     @ApiModelProperty("麻醉医生")
     private String anaDoctor;
+
+    @ApiModelProperty("体重")
+    private String weight;
+
+    @ApiModelProperty("身高")
+    private String height;
+
+    @ApiModelProperty("麻醉方式")
+    private String anaType;
+
+    @ApiModelProperty("镇痛方式")
+    private String analType;
+
+    @ApiModelProperty("手术医生")
+    private String surgeryDoctor;
+
+    @ApiModelProperty("手术名称")
+    private String surgeryName;
+
+    @ApiModelProperty("配方")
+    private String formula;
+
+    @ApiModelProperty("临床是否结束")
+    private Boolean finished;
+
+    @ApiModelProperty("配置人员")
+    private String configPerson;
 }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceRepeatResult.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.service.dto;
 
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.enums.SexEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -56,7 +56,7 @@ public class PatientDeviceRepeatResult {
         @ApiModelProperty("设备别名")
         private String deviceAlias;
         @ApiModelProperty("设备运行状态")
-        private DeviceEnum deviceRunState;
+        private DeviceTypeEnum deviceRunState;
         @ApiModelProperty("设备报警信息")
         private DeviceAlarmEnum deviceAlarm;
         @ApiModelProperty("输注开始时间")

+ 55 - 7
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java

@@ -1,11 +1,16 @@
 package com.coffee.bus.service.dto;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.WarnEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
 import java.util.*;
 /**
  * @author lifang
@@ -23,21 +28,64 @@ public class PatientMonitorQuery {
     @ApiModelProperty("病区查询集合")
     private List<String> wards;
 
+    /**
+     * @see  DeviceTypeEnum #value
+     */
     @ApiModelProperty("设备类型查询,网络泵、脉冲泵、智能泵")
-    private List<DeviceEnum> types;
+    private List<Integer> types;
 
+    /**
+     * @see  DeviceStatusEnum #value
+     */
     @ApiModelProperty("设备输注最后运行状态查询")
-    private List<DeviceStatusEnum> deviceStatus;
+    private List<Integer> deviceStatus;
 
+    /**
+     * @see  DeviceAlarmEnum #value
+     */
     @ApiModelProperty("设备输注最后报警状态")
-    private List<DeviceAlarmEnum> deviceAlarms;
+    private List<Integer> deviceAlarms;
 
-    @ApiModelProperty("设备输注最后即将结束警告")
+    @ApiModelProperty(value = "设备输注最后即将结束警告",hidden = true)
+    @JsonIgnore
     private boolean warnWillFinished;
 
-    @ApiModelProperty("设备输注最后镇痛不足警告")
+    @ApiModelProperty(value = "设备输注最后镇痛不足警告",hidden = true)
+    @JsonIgnore
     private boolean warnAnalgesicPoor;
 
-    @ApiModelProperty("设备输注最后低电量警告")
+    @ApiModelProperty(value = "设备输注最后低电量警告",hidden = true)
+    @JsonIgnore
     private boolean warnLowBattery;
+
+    @ApiModelProperty(value = "智能泵加减档警告",hidden = true)
+    private List<Integer> warnFlow;
+
+    /**
+     * 根据此提醒进行解析
+     * @see  com.coffee.bus.enums.WarnEnum
+     */
+    @ApiModelProperty(value = "提醒【0、智能泵-正常; 1、智能泵-加档受限; 2、智能泵-流速已达上限; 3、智能泵-加档; 4、智能泵-减档; 5、智能泵-低输注状态; 6、输注即将结束;7、镇痛不足;8、低电量】 ")
+    private List<WarnEnum> warns;
+
+    @ApiModelProperty("查询时间区间")
+    private List<Date> timeRange;
+
+    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());
+                }
+            });
+        }
+    }
 }

+ 3 - 0
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorResult.java

@@ -1,6 +1,7 @@
 package com.coffee.bus.service.dto;
 
 import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusDeviceManualEntity;
 import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import io.swagger.annotations.ApiModel;
@@ -23,4 +24,6 @@ public class PatientMonitorResult {
     private BusInfusionHistoryEntity infusion;
     @ApiModelProperty("手术信息")
     private BusClinicEntity clinic;
+    @ApiModelProperty("无泵时查看")
+    private BusDeviceManualEntity deviceManual;
 }

+ 56 - 0
coffee-system/src/main/java/com/coffee/bus/utils/MockUtils.java

@@ -0,0 +1,56 @@
+package com.coffee.bus.utils;
+
+import cn.hutool.core.util.RandomUtil;
+import com.coffee.bus.entity.BusDeviceRunningEntity;
+import com.coffee.bus.enums.DeviceTypeEnum;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName MockUtils.java
+ * @Description TODO
+ * @createTime 2022年05月05日 14:29:00
+ */
+public class MockUtils {
+    public static BusDeviceRunningEntity mock(String deviceId,String patientCode,String classify,DeviceTypeEnum type){
+        BusDeviceRunningEntity pump = new BusDeviceRunningEntity();
+        pump.setType(type);
+        pump.setClassification(classify);
+        pump.setDeviceId(deviceId);
+        pump.setPatientCode(patientCode);
+        pump.setTotalDose(RandomUtil.randomInt(100));
+        pump.setFirstDose(RandomUtil.randomInt(100));
+        pump.setRemainDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setInputDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setAppendDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setAppendLockTime(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setMaxDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setSelfControlCount(RandomUtil.randomInt(100));
+        pump.setSelfControlLockTime(RandomUtil.randomInt(100));
+        pump.setFirstDose(RandomUtil.randomInt(100));
+        pump.setRemainDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setContinueDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setSelfControlLockTime(RandomUtil.randomInt(100));
+        pump.setPcaValidCount(RandomUtil.randomInt(100));
+        pump.setPcaInvalidCount(RandomUtil.randomInt(100));
+        pump.setPcaTotalCount(pump.getPcaInvalidCount()+pump.getPcaValidCount());
+        pump.setContinueDose(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+
+        pump.setPulseDose(RandomUtil.randomInt(100));
+        pump.setPulseLockTime(RandomUtil.randomInt(100));
+        pump.setPulseFirstLockTime(RandomUtil.randomInt(100));
+        pump.setFlowAdjustRate(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setFlowCount(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setFlowDownCycle(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setFlowDownLimit(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setFlowUpCycle(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+        pump.setFlowUpLimit(BigDecimal.valueOf(RandomUtil.randomInt(100)));
+
+        pump.setUploadTime(new Date());
+
+        return pump;
+    }
+}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.