Browse Source

add 常量类

18339543638 3 years ago
parent
commit
6acb588688
40 changed files with 579 additions and 437 deletions
  1. 2 1
      coffee-admin/src/main/java/com/coffee/admin/AdminApplication.java
  2. 46 0
      coffee-admin/src/main/test/java/com/coffee/admin/BusDeviceRegisterTest.java
  3. 0 48
      coffee-admin/src/test/java/com/coffee/admin/BusTemplateAnalgesicTest.java
  4. 1 1
      coffee-common/src/main/java/com/coffee/common/crud/BaseService.java
  5. 4 2
      coffee-framework/src/main/java/com/coffee/framework/web/exception/GlobalExceptionHandler.java
  6. 16 0
      coffee-system/src/main/java/com/coffee/bus/constant/ClinicConstant.java
  7. 3 3
      coffee-system/src/main/java/com/coffee/bus/controller/BusConstantController.java
  8. 3 3
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceController.java
  9. 29 11
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRunningController.java
  10. 0 43
      coffee-system/src/main/java/com/coffee/bus/controller/BusDoctorController.java
  11. 0 42
      coffee-system/src/main/java/com/coffee/bus/controller/BusEvaluationTmpController.java
  12. 2 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/ManualUndoConfig.java
  13. 1 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusClinicEntity.java
  14. 40 0
      coffee-system/src/main/java/com/coffee/bus/entity/BusConAlarmEntity.java
  15. 42 0
      coffee-system/src/main/java/com/coffee/bus/entity/BusConDoctor.java
  16. 40 0
      coffee-system/src/main/java/com/coffee/bus/entity/BusConMixEntity.java
  17. 9 9
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceEntity.java
  18. 0 29
      coffee-system/src/main/java/com/coffee/bus/entity/BusDoctorEntity.java
  19. 0 54
      coffee-system/src/main/java/com/coffee/bus/entity/BusEvaluationTmpEntity.java
  20. 1 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusPatientEntity.java
  21. 3 15
      coffee-system/src/main/java/com/coffee/bus/enums/ConstantEnum.java
  22. 38 0
      coffee-system/src/main/java/com/coffee/bus/enums/ConstantMixEnum.java
  23. 18 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusConAlarmMapper.java
  24. 4 3
      coffee-system/src/main/java/com/coffee/bus/mapper/BusConDoctorMapper.java
  25. 5 3
      coffee-system/src/main/java/com/coffee/bus/mapper/BusConMixMapper.java
  26. 0 1
      coffee-system/src/main/java/com/coffee/bus/mapper/BusPatientMapper.java
  27. 23 0
      coffee-system/src/main/java/com/coffee/bus/registry/constant/PatientKeyConstant.java
  28. 0 16
      coffee-system/src/main/java/com/coffee/bus/registry/device/bean/DeviceCacheInfo.java
  29. 29 26
      coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientOperator.java
  30. 6 6
      coffee-system/src/main/java/com/coffee/bus/registry/patient/PatientOperator.java
  31. 26 3
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusClinicService.java
  32. 28 41
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java
  33. 0 33
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDoctorService.java
  34. 0 31
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusEvaluationTmpService.java
  35. 24 2
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusHospitalService.java
  36. 2 2
      coffee-system/src/main/java/com/coffee/bus/service/constant/AbstractConstantService.java
  37. 36 0
      coffee-system/src/main/java/com/coffee/bus/service/constant/LocalBusConAlarmService.java
  38. 37 0
      coffee-system/src/main/java/com/coffee/bus/service/constant/LocalBusConDoctorService.java
  39. 37 0
      coffee-system/src/main/java/com/coffee/bus/service/constant/LocalBusConMixService.java
  40. 24 7
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

+ 2 - 1
coffee-admin/src/main/java/com/coffee/admin/AdminApplication.java

@@ -7,8 +7,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.context.annotation.Import;
 import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.tio.websocket.starter.EnableTioWebSocketServer;
-//import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 /**
  * Admin启动类
@@ -20,6 +20,7 @@ import org.tio.websocket.starter.EnableTioWebSocketServer;
 @EnableTioWebSocketServer
 @EnableScheduling
 @EnableAsync
+@EnableTransactionManagement
 public class AdminApplication {
 
     public static void main(String[] args) {

+ 46 - 0
coffee-admin/src/main/test/java/com/coffee/admin/BusDeviceRegisterTest.java

@@ -0,0 +1,46 @@
+package com.coffee.admin;
+
+import com.coffee.bus.controller.BusDeviceRunningController;
+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;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusHospitalTest.java
+ * @Description TODO
+ * @createTime 2022年03月19日 10:27:00
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AdminApplication.class)
+public class BusDeviceRegisterTest {
+    @Autowired
+    private LocalBusDeviceService registeredService;
+
+    @Autowired
+    private BusDeviceRunningController netPumpController;
+    @Test
+    public void save(){
+        BusDeviceEntity registeredEntity = new BusDeviceEntity();
+        registeredEntity.setAlias("测试泵");
+        registeredEntity.setDeviceId("123");
+        registeredEntity.setEnable(true);
+        registeredService.save(registeredEntity);
+    }
+
+    @Test
+    public void query(){
+
+    }
+
+    @Test
+    public void Delete(){
+//        boolean b = busHospitalService.removeById(1505789328745721857L);
+//        System.out.println(b);
+    }
+}

+ 0 - 48
coffee-admin/src/test/java/com/coffee/admin/BusTemplateAnalgesicTest.java

@@ -1,48 +0,0 @@
-package com.coffee.admin;
-
-import com.coffee.bus.controller.BusEvaluationTmpController;
-import com.coffee.bus.entity.BusEvaluationTmpEntity;
-import com.coffee.bus.service.LocalBusEvaluationTmpService;
-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.Arrays;
-import java.util.List;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusHospitalTest.java
- * @Description TODO
- * @createTime 2022年03月19日 10:27:00
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = AdminApplication.class)
-public class BusTemplateAnalgesicTest {
-    @Autowired
-    private LocalBusEvaluationTmpService analgesicService;
-
-    @Autowired
-    private BusEvaluationTmpController analgesicController;
-    @Test
-    public void save(){
-//        StpUtil.login();
-        BusEvaluationTmpEntity analgesicEntity = new BusEvaluationTmpEntity();
-
-        analgesicController.add(analgesicEntity);
-    }
-
-    @Test
-    public void query(){
-        List<BusEvaluationTmpEntity> list = analgesicService.list();
-        System.out.println(list);
-    }
-
-    @Test
-    public void Delete(){
-
-    }
-}

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

@@ -257,7 +257,7 @@ public abstract class BaseService<M extends BaseMapper<E>, E,PK extends Serializ
 //        else {
 //            queryWrapper.orderByDesc("create_time");
 //        }
-        if(!StrUtil.isNullOrUndefined(param.getTenantId())){
+        if(!StrUtil.isNotEmpty(param.getTenantId())&&!StrUtil.isNullOrUndefined(param.getTenantId())){
             LoginUser loginUser = (LoginUser) StpUtil.getTokenSession().get(com.coffee.common.Constants.LOGIN_USER_KEY);
             //是否为系统用户
             if(loginUser!=null&&loginUser.getIsSys()!=null&&loginUser.getIsSys()){

+ 4 - 2
coffee-framework/src/main/java/com/coffee/framework/web/exception/GlobalExceptionHandler.java

@@ -57,13 +57,15 @@ public class GlobalExceptionHandler {
     @ExceptionHandler(RuntimeException.class)
     public R handleRuntimeException(RuntimeException e) {
         log.error(e.getMessage(), e);
-        return R.result(ResultCode.INTERNAL_SERVER_ERROR);
+//        return R.result(ResultCode.INTERNAL_SERVER_ERROR);
+        return R.fail(e.getLocalizedMessage());
     }
 
     @ExceptionHandler(Exception.class)
     public R handleException(Exception e) {
         log.error(e.getMessage(), e);
-        return R.result(ResultCode.INTERNAL_SERVER_ERROR);
+//        return R.result(ResultCode.INTERNAL_SERVER_ERROR);
+        return R.fail(e.getLocalizedMessage());
     }
 
     /**

+ 16 - 0
coffee-system/src/main/java/com/coffee/bus/constant/ClinicConstant.java

@@ -0,0 +1,16 @@
+package com.coffee.bus.constant;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ClinicConstant.java
+ * @Description 临床常量
+ * @createTime 2022年04月13日 15:07:00
+ */
+public class ClinicConstant {
+
+    /**
+     * 当临床不存在时,采用该常量作为临时的临床id,当临床信息从his更新后,在进行替换
+     */
+    public static final String TEMP_ID="-1";
+}

+ 3 - 3
coffee-system/src/main/java/com/coffee/bus/controller/BusConstantController.java

@@ -40,7 +40,7 @@ public class BusConstantController {
 
     @PostMapping("/{type}/page")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class),
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "mix,doctor,alarm",allowMultiple = true,dataTypeClass = ConstantEnum.class),
             @ApiImplicitParam(name = "query",value = "查询参数",required = true)
     })
     @ApiOperation(value = "使用POST方式分页动态查询")
@@ -55,7 +55,7 @@ public class BusConstantController {
     @PostMapping("/{type}/remove")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id",value = "主键id",required = true),
-            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class)
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "mix,doctor,alarm",allowMultiple = true,dataTypeClass = ConstantEnum.class)
     })
     @ApiOperation(value = "根据ID删除")
     public R delete(@PathVariable("type") ConstantEnum type,@RequestParam("id") Serializable id) {
@@ -74,7 +74,7 @@ public class BusConstantController {
     @PostMapping("/_batch")
     @ApiOperation(value = "批量新增数据")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarmCause,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class)
+            @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "ward,doctor,surgery,asa,anaesthesia,anal,alarm,drugCate,entrust",allowMultiple = true,dataTypeClass = ConstantEnum.class)
     })
     public R add(@PathVariable("type") ConstantEnum type,@RequestBody List<?> payload) {
         AbstractConstantService constantService = constantHashMap.get(type);

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

@@ -19,8 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @AllArgsConstructor
-@RequestMapping("/bus/device/reg")
-@Api(tags = "经销商设备注册",description = "统一权限前缀(device:reg),device:reg:add")
+@RequestMapping("/bus/device/info")
+@Api(tags = "设备管理",description = "统一权限前缀(device:info),device:info:add")
 public class BusDeviceController extends BaseCrudController<BusDeviceEntity, String> {
     private final LocalBusDeviceService deviceRegisteredService;
 
@@ -31,7 +31,7 @@ public class BusDeviceController extends BaseCrudController<BusDeviceEntity, Str
      */
     @Override
     public String getPermissionPrefix() {
-        return "device:reg";
+        return "device:info";
     }
 
 

+ 29 - 11
coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRunningController.java

@@ -3,6 +3,8 @@ 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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.coffee.bus.controller.vo.ManualUndoConfig;
 import com.coffee.bus.controller.vo.NoPumpConfig;
@@ -13,6 +15,8 @@ import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseQueryController;
 import com.coffee.common.result.R;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
@@ -26,8 +30,8 @@ import org.springframework.web.bind.annotation.*;
  */
 @RestController
 @AllArgsConstructor
-@RequestMapping({"/bus/netpump","/bus/device/using"})
-@Api(tags = "设备运行状态管理",description = "统一权限前缀(bus:device),例如新增bus:device:add")
+@RequestMapping("/bus/device/running")
+@Api(tags = "设备运行状态管理",description = "统一权限前缀(device:running),例如新增device:running:add")
 public class BusDeviceRunningController implements BaseQueryController<BusDeviceRunningEntity, String> {
     private final LocalBusDeviceRunningService netPumpService;
 
@@ -38,19 +42,33 @@ public class BusDeviceRunningController implements BaseQueryController<BusDevice
         return R.success(DeviceStatusEnum.values());
     }
 
-    @PostMapping("/undo")
-    @SaCheckPermission("bus:device:undo")
-    @ApiOperation(value = "进行撤泵操作,权限为bus:pump:undo")
-    public R undo(@RequestBody ManualUndoConfig manualUndoConfig){
-        netPumpService.undo(manualUndoConfig);
+    @PostMapping("/nopump")
+    @SaCheckPermission("device:running:add")
+    @ApiOperation(value = "新增无泵数据,权限为device:running:add")
+    public R saveNoPump(@RequestBody NoPumpConfig noPump){
         return R.success();
     }
 
-    @PostMapping("/nopump")
-    @SaCheckPermission("bus:device:add")
-    @ApiOperation(value = "新增无泵数据,权限为bus:pump:add")
-    public R saveNoPump(@RequestBody NoPumpConfig noPump){
+    @PostMapping("/count/clinic")
+    @ApiOperation(value = "查询临床下泵的数量",notes = "根据病号+临床id+医院id 查询一个病人下是否绑定了多个泵,以此来作为泵重复的依据,权限标识为【空】")
+    @ApiImplicitParams({
+            @ApiImplicitParam(value = "code",name = "病号"),
+            @ApiImplicitParam(value = "clinicId",name = "临床id"),
+            @ApiImplicitParam(value = "tenantId",name = "医院id",required = false,example = "当为系统用户时,此参数必传,平台用户时,此参数可忽略"),
+    })
+    public R repeatCount(@RequestParam("code") String patientCode,@RequestParam("clinicId") String clinic,@RequestParam(required = false) String tenantId){
+        return R.success(netPumpService.count(new QueryWrapper<BusDeviceRunningEntity>()
+                .lambda()
+                .eq(BusDeviceRunningEntity::getPatientCode,patientCode)
+                .eq(BusDeviceRunningEntity::getClinicId,clinic)
+                .eq(StrUtil.isNotEmpty(tenantId),BusDeviceRunningEntity::getTenantId,tenantId)));
+    }
 
+    @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();
     }
 

+ 0 - 43
coffee-system/src/main/java/com/coffee/bus/controller/BusDoctorController.java

@@ -1,43 +0,0 @@
-package com.coffee.bus.controller;
-
-import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.entity.BusDoctorEntity;
-import com.coffee.bus.entity.BusHospitalEntity;
-import com.coffee.bus.service.LocalBusDoctorService;
-import com.coffee.bus.service.LocalBusHospitalService;
-import com.coffee.common.crud.BaseService;
-import com.coffee.common.crud.controller.BaseCrudController;
-import io.swagger.annotations.Api;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusHospitalController.java
- * @Description TODO
- * @createTime 2022年03月19日 09:28:00
- */
-@RestController
-@AllArgsConstructor
-@RequestMapping("/bus/doctor")
-@Api(tags = "医院医生管理",description = "统一权限前缀(bus:doctor),例如新增bus:doctor:add")
-public class BusDoctorController extends BaseCrudController<BusDoctorEntity, String> {
-    private final LocalBusDoctorService doctorService;
-
-
-    /**
-     * 权限控制前缀
-     * @return
-     */
-    @Override
-    public String getPermissionPrefix() {
-        return "bus:doctor";
-    }
-
-    @Override
-    public BaseService<? extends Mapper<BusDoctorEntity>, BusDoctorEntity, String> getService() {
-        return doctorService;
-    }
-}

+ 0 - 42
coffee-system/src/main/java/com/coffee/bus/controller/BusEvaluationTmpController.java

@@ -1,42 +0,0 @@
-package com.coffee.bus.controller;
-
-import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.entity.BusEvaluationTmpEntity;
-import com.coffee.bus.service.LocalBusEvaluationTmpService;
-import com.coffee.common.crud.BaseService;
-import com.coffee.common.crud.controller.BaseCrudController;
-import io.swagger.annotations.Api;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusHospitalController.java
- * @Description TODO
- * @createTime 2022年03月19日 09:28:00
- */
-@RestController
-@AllArgsConstructor
-@RequestMapping("/eval/temp")
-@Api(tags = "评价模板管理",description = "统一权限前缀(eval:temp),eval:temp:add")
-@Deprecated
-public class BusEvaluationTmpController extends BaseCrudController<BusEvaluationTmpEntity, String> {
-    private final LocalBusEvaluationTmpService evalTmpService;
-
-
-    /**
-     * 权限控制前缀
-     * @return
-     */
-    @Override
-    public String getPermissionPrefix() {
-        return "eval:temp";
-    }
-
-    @Override
-    public BaseService<? extends Mapper<BusEvaluationTmpEntity>, BusEvaluationTmpEntity, String> getService() {
-        return evalTmpService;
-    }
-}

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

@@ -14,7 +14,9 @@ import java.util.*;
 @Data
 @ApiModel("手动撤泵配置")
 public class ManualUndoConfig {
+    @ApiModelProperty("进行撤泵的所有运行数据id")
     private List<String> ids;
+
     @ApiModelProperty("撤泵人")
     private String undoBy;
 

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

@@ -22,7 +22,7 @@ import java.util.*;
 /**
  * @author lifang
  * @version 1.0.0
- * @ClassName BusDoctorEntity.java
+ * @ClassName BusClinicEntity.java
  * @Description TODO
  * @createTime 2022年03月21日 11:17:00
  */

+ 40 - 0
coffee-system/src/main/java/com/coffee/bus/entity/BusConAlarmEntity.java

@@ -0,0 +1,40 @@
+package com.coffee.bus.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.common.entity.TenantGenericEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.apache.ibatis.type.EnumOrdinalTypeHandler;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusConAlarmEntity.java
+ * @Description TODO
+ * @createTime 2022年04月14日 10:09:00
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName(value = "bus_con_alarm",autoResultMap = true)
+@ApiModel(value="常量设置的混合类", description="包括:病区、手术、ASA、镇痛、麻醉、药品分类、医嘱")
+@ToString
+public class BusConAlarmEntity extends TenantGenericEntity<String,String> {
+
+    @ApiModelProperty(value = "报警原因")
+    @Length(max = 255,message = "报警原因长度不得超过255个字节")
+    private String cause;
+
+    @ApiModelProperty(value = "备注")
+    @Length(max = 255,message = "备注长度不得超过255个字节")
+    private String remark;
+
+    @ApiModelProperty(value = "报警类型",example = "ward,surgery,asa,anaesthesia,anal,drugCate,entrust")
+    @TableField(javaType = true,typeHandler = EnumOrdinalTypeHandler.class)
+    private DeviceAlarmEnum type;
+}

+ 42 - 0
coffee-system/src/main/java/com/coffee/bus/entity/BusConDoctor.java

@@ -0,0 +1,42 @@
+package com.coffee.bus.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.coffee.common.entity.TenantGenericEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusConDoctor.java
+ * @Description TODO
+ * @createTime 2022年04月14日 10:54:00
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName(value = "bus_con_doctor",autoResultMap = true)
+@ApiModel(value="常量人员", description="包括:病区、手术、ASA、镇痛、麻醉、药品分类、医嘱")
+@ToString
+public class BusConDoctor extends TenantGenericEntity<String,String> {
+
+    @ApiModelProperty(value = "医生名称")
+    @Length(max = 255,message = "名称长度不得超过255个字节")
+    private String name;
+
+    @ApiModelProperty(value = "备注")
+    @Length(max = 255,message = "备注长度不得超过255个字节")
+    private String remark;
+
+    @ApiModelProperty(value = "是否为手术医生")
+    private Boolean surgeon;
+
+    @ApiModelProperty(value = "是否为麻醉医生")
+    private Boolean anesthetists;
+
+    @ApiModelProperty(value = "是否为配置、撤泵、评价人员")
+    private Boolean reviewer;
+}

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

@@ -0,0 +1,40 @@
+package com.coffee.bus.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.coffee.bus.enums.ConstantMixEnum;
+import com.coffee.common.entity.TenantGenericEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.apache.ibatis.type.EnumOrdinalTypeHandler;
+import org.hibernate.validator.constraints.Length;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusConMixEntity.java
+ * @Description TODO
+ * @createTime 2022年04月14日 10:09:00
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName(value = "bus_con_mix",autoResultMap = true)
+@ApiModel(value="常量设置的混合类", description="包括:病区、手术、ASA、镇痛、麻醉、药品分类、医嘱")
+@ToString
+public class BusConMixEntity extends TenantGenericEntity<String,String> {
+
+    @ApiModelProperty(value = "常量名称")
+    @Length(max = 255,message = "名称长度不得超过255个字节")
+    private String name;
+
+    @ApiModelProperty(value = "备注")
+    @Length(max = 255,message = "备注长度不得超过255个字节")
+    private String remark;
+
+    @ApiModelProperty(value = "混合常量类型",example = "ward,surgery,asa,anaesthesia,anal,drugCate,entrust")
+    @TableField(javaType = true,typeHandler = EnumOrdinalTypeHandler.class)
+    private ConstantMixEnum type;
+}

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

@@ -3,6 +3,7 @@ package com.coffee.bus.entity;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.coffee.bus.bean.AliIotConfig;
+import com.coffee.bus.enums.DeviceAlarmEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.common.entity.TenantGenericEntity;
 import io.swagger.annotations.ApiModel;
@@ -10,12 +11,13 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
+import org.apache.ibatis.type.EnumOrdinalTypeHandler;
 import org.hibernate.validator.constraints.Length;
 
 /**
  * @author lifang
  * @version 1.0.0
- * @ClassName BusDoctorEntity.java
+ * @ClassName BusDeviceEntity.java
  * @Description TODO
  * @createTime 2022年03月21日 11:17:00
  */
@@ -38,11 +40,13 @@ public class BusDeviceEntity extends TenantGenericEntity<String,String> {
     @Length(max = 255,message = "设备类型不得超过255个字符")
     private String type;
 
-    @ApiModelProperty(value = "运行状态")
-    private DeviceStatusEnum status;
+    @ApiModelProperty(value = "运行状态",readOnly = true)
+    @TableField(typeHandler = EnumOrdinalTypeHandler.class,javaType = true,updateStrategy = FieldStrategy.IGNORED)
+    private DeviceStatusEnum runState;
 
-    @ApiModelProperty(value = "是否已注册完成,0、未注册 1、注册")
-    private Integer register;
+    @ApiModelProperty(value = "报警信息",readOnly = true)
+    @TableField(typeHandler = EnumOrdinalTypeHandler.class,javaType = true,updateStrategy = FieldStrategy.IGNORED)
+    private DeviceAlarmEnum alarm;
 
     @ApiModelProperty(value = "第三方平台返回配置")
     @TableField(typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.NEVER)
@@ -50,8 +54,4 @@ public class BusDeviceEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "是否启用,0、不启用 1、启用 ")
     private Boolean enable;
-
-    @TableField(fill = FieldFill.INSERT)
-    @TableLogic(value = "0",delval = "1")
-    private Integer isDelete;
 }

+ 0 - 29
coffee-system/src/main/java/com/coffee/bus/entity/BusDoctorEntity.java

@@ -1,29 +0,0 @@
-package com.coffee.bus.entity;
-
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.coffee.common.entity.TenantGenericEntity;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import org.hibernate.validator.constraints.Length;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusDoctorEntity.java
- * @Description TODO
- * @createTime 2022年03月21日 11:17:00
- */
-@EqualsAndHashCode(callSuper = true)
-@Data
-@TableName(value = "bus_doctor",autoResultMap = true)
-@ApiModel(value="医院医生", description="医院医生实体类")
-public class BusDoctorEntity  extends TenantGenericEntity<String,String> {
-    @ApiModelProperty(value = "医生名称")
-    @Length(max = 255,message = "医生名称长度不得超过255个字节")
-    private String name;
-    @ApiModelProperty(value = "医生岗位")
-    @Length(max = 255,message = "医生岗位长度不得超过255个字节")
-    private String job;
-}

+ 0 - 54
coffee-system/src/main/java/com/coffee/bus/entity/BusEvaluationTmpEntity.java

@@ -1,54 +0,0 @@
-package com.coffee.bus.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
-import com.coffee.common.config.mybatis.DateToBigIntHandler;
-import com.coffee.common.entity.TenantGenericEntity;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.util.*;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusEvaluationTmpEntity.java
- * @Description TODO
- * @createTime 2022年03月21日 14:18:00
- */
-@EqualsAndHashCode(callSuper = true)
-@Data
-@TableName(value = "bus_evaluation_temp",autoResultMap = true)
-@ApiModel(value="评价模板", description="评价模板")
-public class BusEvaluationTmpEntity extends TenantGenericEntity<String,String> {
-
-    @ApiModelProperty(value = "需要评价的字段,如calm、leftArm等")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
-    private List<String> includeConfig;
-
-//    @ApiModelProperty(value = "提醒时间间隔")
-//    private Integer remindInterval;
-//
-//    @ApiModelProperty(value = "提醒时间")
-//    private Integer remindTime;
-
-    @TableField(fill = FieldFill.INSERT)
-    private String createBy;
-
-    @TableField(fill = FieldFill.INSERT_UPDATE)
-    private String updateBy;
-
-    @TableField(typeHandler = DateToBigIntHandler.class,fill = FieldFill.INSERT)
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date createTime;
-
-    @TableField(typeHandler = DateToBigIntHandler.class,fill = FieldFill.UPDATE)
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date updateTime;
-
-}

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

@@ -18,7 +18,7 @@ import org.hibernate.validator.constraints.Length;
 /**
  * @author lifang
  * @version 1.0.0
- * @ClassName BusDoctorEntity.java
+ * @ClassName BusPatientEntity.java
  * @Description TODO
  * @createTime 2022年03月21日 11:17:00
  */

+ 3 - 15
coffee-system/src/main/java/com/coffee/bus/enums/ConstantEnum.java

@@ -16,22 +16,10 @@ import lombok.AllArgsConstructor;
 @ApiModel("常量类型")
 @AllArgsConstructor
 public enum  ConstantEnum {
-    @ApiModelProperty("病区")
-    ward,
+    @ApiModelProperty("混合常量")
+    mix,
     @ApiModelProperty("医护人员")
     doctor,
-    @ApiModelProperty("手术名称")
-    surgery,
-    @ApiModelProperty("asa")
-    asa,
-    @ApiModelProperty("麻醉手术")
-    anaesthesia,
-    @ApiModelProperty("镇痛手术")
-    anal,
     @ApiModelProperty("报警原因")
-    alarmCause,
-    @ApiModelProperty("药品分类")
-    drugCate,
-    @ApiModelProperty("医嘱")
-    entrust;
+    alarm
 }

+ 38 - 0
coffee-system/src/main/java/com/coffee/bus/enums/ConstantMixEnum.java

@@ -0,0 +1,38 @@
+package com.coffee.bus.enums;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ConstantEnum.java
+ * @Description TODO
+ * @createTime 2022年04月09日 10:42:00
+ */
+@JsonFormat(shape = JsonFormat.Shape.OBJECT)
+@ApiModel("混合常量类型")
+@AllArgsConstructor
+@Getter
+public enum ConstantMixEnum {
+    @ApiModelProperty("病区")
+    ward(0,"病区"),
+    @ApiModelProperty("手术名称")
+    surgery(1,"手术名称"),
+    @ApiModelProperty("asa")
+    asa(2,"asa"),
+    @ApiModelProperty("麻醉手术")
+    anaesthesia(3,"麻醉手术"),
+    @ApiModelProperty("镇痛手术")
+    anal(4,"镇痛手术"),
+    @ApiModelProperty("药品分类")
+    drugCate(5,"药品分类"),
+    @ApiModelProperty("医嘱")
+    entrust(6,"医嘱");
+
+    private Integer code;
+    private String text;
+}

+ 18 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusConAlarmMapper.java

@@ -0,0 +1,18 @@
+package com.coffee.bus.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.coffee.bus.entity.BusConAlarmEntity;
+import com.coffee.bus.entity.BusConMixEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusConAlarmMapper.java
+ * @Description 常量-报警原因
+ * @createTime 2022年03月19日 09:15:00
+ */
+@Mapper
+public interface BusConAlarmMapper extends BaseMapper<BusConAlarmEntity> {
+
+}

+ 4 - 3
coffee-system/src/main/java/com/coffee/bus/mapper/BusDoctorMapper.java → coffee-system/src/main/java/com/coffee/bus/mapper/BusConDoctorMapper.java

@@ -1,16 +1,17 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusDoctorEntity;
+import com.coffee.bus.entity.BusConDoctor;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
  * @author lifang
  * @version 1.0.0
  * @ClassName BusHospitalMapper.java
- * @Description TODO
+ * @Description 常量-人员
  * @createTime 2022年03月19日 09:15:00
  */
 @Mapper
-public interface BusDoctorMapper extends BaseMapper<BusDoctorEntity> {
+public interface BusConDoctorMapper extends BaseMapper<BusConDoctor> {
+
 }

+ 5 - 3
coffee-system/src/main/java/com/coffee/bus/mapper/BusEvalutaionTmpMapper.java → coffee-system/src/main/java/com/coffee/bus/mapper/BusConMixMapper.java

@@ -1,16 +1,18 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusEvaluationTmpEntity;
+import com.coffee.bus.entity.BusConDoctor;
+import com.coffee.bus.entity.BusConMixEntity;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
  * @author lifang
  * @version 1.0.0
  * @ClassName BusHospitalMapper.java
- * @Description TODO
+ * @Description 常量-混合
  * @createTime 2022年03月19日 09:15:00
  */
 @Mapper
-public interface BusEvalutaionTmpMapper extends BaseMapper<BusEvaluationTmpEntity> {
+public interface BusConMixMapper extends BaseMapper<BusConMixEntity> {
+
 }

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

@@ -1,7 +1,6 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusDoctorEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import org.apache.ibatis.annotations.Mapper;
 

+ 23 - 0
coffee-system/src/main/java/com/coffee/bus/registry/constant/PatientKeyConstant.java

@@ -0,0 +1,23 @@
+package com.coffee.bus.registry.constant;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName PatientKeyConstant.java
+ * @Description TODO
+ * @createTime 2022年04月13日 15:45:00
+ */
+public class PatientKeyConstant {
+    public static final String CODE="code";
+
+    public static final String GENDER="gender";
+
+    public static final String NAME="name";
+
+    public static final String TENANT_ID="tenantId";
+    public static final String CLINIC_ID="clinicId";
+    public static final String START_TIME="startTime";
+    public static final String FINISHED="finished";
+    public static final String BIND_DEVICE_ID="bindDeviceId";
+    public static final String DEVICES="devices";
+}

+ 0 - 16
coffee-system/src/main/java/com/coffee/bus/registry/device/bean/DeviceCacheInfo.java

@@ -71,20 +71,4 @@ public class DeviceCacheInfo implements CacheInfo {
      */
     private Boolean master;
     /**********泵正在运行状态**********/
-
-    private DeviceCacheInfo() {
-    }
-
-    private DeviceCacheInfo(String deviceId, String alias, Boolean enable, String tenantId, String usingId, Date startTime, DeviceStatusEnum status, String patientCode, String classification, Boolean master) {
-        this.deviceId = deviceId;
-        this.alias = alias;
-        this.enable = enable;
-        this.tenantId = tenantId;
-        this.usingId = usingId;
-        this.startTime = startTime;
-        this.status = status;
-        this.patientCode = patientCode;
-        this.classification = classification;
-        this.master = master;
-    }
 }

+ 29 - 26
coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientOperator.java

@@ -2,6 +2,7 @@ package com.coffee.bus.registry.patient;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
+import com.coffee.bus.registry.constant.PatientKeyConstant;
 import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.common.cache.ConfigStorage;
@@ -107,102 +108,104 @@ public class ClusterPatientOperator implements PatientOperator<PatientCacheInfo>
 
     @Override
     public void setCode(String code) {
-        configStorage.setConfig("code",code);
+        configStorage.setConfig(PatientKeyConstant.CODE,code);
     }
 
     @Override
     public String getCode() {
-        return getValue("code").as(String.class);
+        return getValue(PatientKeyConstant.CODE).as(String.class);
     }
 
     @Override
     public void setGender(SexEnum gender) {
         if(gender==null){
-            return;
+            configStorage.setConfig(PatientKeyConstant.GENDER,null);
+        }else {
+            configStorage.setConfig(PatientKeyConstant.GENDER,gender.ordinal());
         }
-        configStorage.setConfig("gender",gender.ordinal());
     }
 
     @Override
     public SexEnum getGender() {
-        return getValue("gender").as(SexEnum.class);
+        return getValue(PatientKeyConstant.GENDER).as(SexEnum.class);
     }
 
     @Override
     public void setName(String name) {
-        configStorage.setConfig("name",name);
+        configStorage.setConfig(PatientKeyConstant.NAME,name);
     }
 
     @Override
     public String getName() {
-        return getValue("name").as(String.class);
+        return getValue(PatientKeyConstant.NAME).as(String.class);
     }
 
     @Override
     public void setTenantId(String tenantId) {
-        configStorage.setConfig("tenantId",tenantId);
+        configStorage.setConfig(PatientKeyConstant.TENANT_ID,tenantId);
     }
 
     @Override
     public String getTenantId() {
-        return getValue("tenantId").as(String.class);
+        return getValue(PatientKeyConstant.TENANT_ID).as(String.class);
     }
 
     @Override
     public void setClinicId(String clinicId) {
-        configStorage.setConfig("clinicId",clinicId);
+        configStorage.setConfig(PatientKeyConstant.CLINIC_ID,clinicId);
     }
 
     @Override
-    public Boolean getFinished() {
-        return getValue("finished").as(Boolean.class);
+    public String getClinicId() {
+        return getValue(PatientKeyConstant.CLINIC_ID).as(String.class);
     }
 
     @Override
-    public void setFinished(Boolean finished) {
-        configStorage.setConfig("finished",finished);
+    public Boolean getFinished() {
+        return getValue(PatientKeyConstant.FINISHED).as(Boolean.class);
     }
 
     @Override
-    public String getClinicId() {
-        return getValue("clinicId").as(String.class);
+    public void setFinished(Boolean finished) {
+        configStorage.setConfig(PatientKeyConstant.FINISHED,finished);
     }
 
+
     @Override
     public void setStartTime(Date startTime) {
-        configStorage.setConfig("startTime",startTime);
+        configStorage.setConfig(PatientKeyConstant.START_TIME,startTime);
     }
 
     @Override
     public Date getStartTime() {
-        return getValue("startTime").as(Date.class);
+        return getValue(PatientKeyConstant.START_TIME).as(Date.class);
     }
 
     @Override
     public void setBindDeviceId(String deviceId) {
-        configStorage.setConfig("bindDeviceId",deviceId);
+        configStorage.setConfig(PatientKeyConstant.BIND_DEVICE_ID,deviceId);
     }
 
     @Override
     public String getBindDeviceId() {
-        return getValue("bindDeviceId").asString();
+        return getValue(PatientKeyConstant.BIND_DEVICE_ID).asString();
     }
 
     @Override
     public Set<DeviceTimeSmallInfo> getAllDevice() {
-        return getValue("devices").as(HashSet.class);
+        return getValue(PatientKeyConstant.DEVICES).as(HashSet.class);
     }
 
     @Override
     public void setAllDevice(Collection<DeviceTimeSmallInfo> devices) {
-        configStorage.setConfig("devices",devices);
+        configStorage.setConfig(PatientKeyConstant.DEVICES,devices);
     }
 
     @Override
     public void add(Collection<DeviceTimeSmallInfo> devices) {
-        Set<DeviceTimeSmallInfo> deviceList = getValue("devices").as(HashSet.class);
+        Set<DeviceTimeSmallInfo> deviceList = getValue(PatientKeyConstant.DEVICES).as(HashSet.class);
         deviceList.addAll(devices);
-        configStorage.setConfig("devices",deviceList);
+        configStorage.setConfig(PatientKeyConstant.DEVICES,deviceList);
     }
 
     @Override
@@ -212,12 +215,12 @@ public class ClusterPatientOperator implements PatientOperator<PatientCacheInfo>
 
     @Override
     public void clearClinic() {
-        configStorage.remove(Arrays.asList("clinicId","startTime","finished"));
+        configStorage.remove(Arrays.asList(PatientKeyConstant.CLINIC_ID,PatientKeyConstant.START_TIME,PatientKeyConstant.FINISHED));
     }
 
     @Override
     public void clearDevice() {
-        configStorage.remove(Arrays.asList("bindDeviceId","devices"));
+        configStorage.remove(Arrays.asList(PatientKeyConstant.BIND_DEVICE_ID,PatientKeyConstant.DEVICES));
     }
 
     @Override

+ 6 - 6
coffee-system/src/main/java/com/coffee/bus/registry/patient/PatientOperator.java

@@ -69,6 +69,12 @@ public interface PatientOperator<T> extends Operator<T> {
      */
     void setClinicId(String clinicId);
 
+    /**
+     * 获取当前临床信息id
+     * @return
+     */
+    String getClinicId();
+
     /**
      * 判断当前临床是否结束
      * @return
@@ -80,12 +86,6 @@ public interface PatientOperator<T> extends Operator<T> {
      */
     void setFinished(Boolean finished);
 
-    /**
-     * 获取当前临床信息id
-     * @return
-     */
-    String getClinicId();
-
     /**
      * 设置临床开始时间
      * @param startTime

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

@@ -1,13 +1,19 @@
 package com.coffee.bus.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.coffee.bus.entity.BusClinicEntity;
 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.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.Date;
 
 /**
  * @author lifang
@@ -19,9 +25,9 @@ import org.springframework.stereotype.Service;
 @Service
 @Slf4j
 public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClinicEntity,String> {
+
     @Autowired
-    @Lazy
-    private LocalBusDeviceRunningService netPumpService;
+    private PatientRegistry patientRegistry;
     @Override
     public void validateBeforeSave(BusClinicEntity entity) {
 
@@ -64,4 +70,21 @@ public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClini
     public boolean save(BusClinicEntity entity) {
         return super.save(entity);
     }
+
+    /**
+     * 结束当前医院病号的临床数据
+     * @param patientCode 病号
+     * @param tenantId 医院id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void finish(String patientCode, String tenantId) {
+        this.update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getPatientCode,patientCode)
+        .eq(BusClinicEntity::getTenantId,tenantId)
+        .eq(BusClinicEntity::getFinished,false)
+        .set(BusClinicEntity::getFinished,true)
+        .set(BusClinicEntity::getEndTime,new Date()));
+        //更新病人缓存 todo
+        PatientOperator<PatientCacheInfo> patient = patientRegistry.getPatient(tenantId, patientCode);
+        patient.setFinished(true);
+    }
 }

+ 28 - 41
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRunningService.java

@@ -2,15 +2,18 @@ package com.coffee.bus.service;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.coffee.bus.controller.vo.ManualUndoConfig;
 import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceRunningEntity;
 import com.coffee.bus.entity.BusDeviceHistoryEntity;
+import com.coffee.bus.entity.BusInfusionHistoryEntity;
 import com.coffee.bus.mapper.BusDeviceRunningMapper;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.util.Date;
 import java.util.List;
@@ -29,7 +32,7 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class LocalBusDeviceRunningService extends BaseService<BusDeviceRunningMapper, BusDeviceRunningEntity,String> {
     private final LocalBusClinicService clinicService;
-    private final LocalBusDeviceHistoryService historyService;
+    private final LocalBusInfusionHistoryService infusionHistoryService;
     @Override
     public void validateBeforeSave(BusDeviceRunningEntity entity) {
 
@@ -53,51 +56,35 @@ public class LocalBusDeviceRunningService extends BaseService<BusDeviceRunningMa
     public BusDeviceRunningEntity getByDeviceId(String deviceId){
         return this.getOne(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId,deviceId));
     }
+
     /**
      * 撤泵操作
      * @param manualUndoConfig
      */
     @Transactional(rollbackFor = Exception.class)
     public void undo(ManualUndoConfig manualUndoConfig) {
-//        List<String> ids = manualUndoConfig.getIds();
-//        if(CollectionUtil.isEmpty(ids)){
-//            return;
-//        }
-//        /****************将撤泵记录存入到泵的使用历史记录中***************/
-//        List<BusDeviceRunningEntity> pumps = this.listByIds(ids);
-//        //获取有泵监护的临床信息
-//        Set<String> clinicIds = pumps.stream().map(BusDeviceRunningEntity::getClinicId).collect(Collectors.toSet());
-//        List<BusClinicEntity> clinics = clinicService.listByIds(clinicIds);
-//        Map<String, List<BusClinicEntity>> clinicMap = clinics.stream().collect(Collectors.groupingBy(BusClinicEntity::getId));
-//        //泵的撤泵数据插入到历史数据中
-//        List<BusDeviceHistoryEntity> pumpHistories = pumps.stream().map(pump -> {
-//            BusDeviceHistoryEntity history = BusDeviceHistoryEntity.of(pump, clinicMap.get(pump.getClinicId()).get(0));
-//            history.setUndoBy(manualUndoConfig.getUndoBy());
-//            history.setUndoTime(manualUndoConfig.getUndoTime());
-//            history.setDestroyer(manualUndoConfig.getDestroyer());
-//            history.setWitnesses(manualUndoConfig.getWitnesses());
-//            history.setIsUndo(1);
-//            return history;
-//        }).collect(Collectors.toList());
-//        historyService.saveBatch(pumpHistories);
-//        /****************将撤泵记录存入到泵的使用历史记录中***************/
-//
-//        /****************将泵改为撤泵状态***************/
-//        this.updateBatchById(ids.stream().map(id->{
-//            BusDeviceRunningEntity pump = new BusDeviceRunningEntity();
-//            pump.setId(id);
-//            pump.setIsUndo(true);
-//            return pump;
-//        }).collect(Collectors.toList()));
-//        /****************将泵改为撤泵状态***************/
-//
-//
-//        /****************对临床时间进行记录***************/
-//        clinics.forEach(clinic->{
-//            clinic.setEndTime(new Date());
-//            clinic.setFinished(1);
-//        });
-//        clinicService.updateBatchById(clinics);
-//        /****************对临床时间进行记录***************/
+        List<String> ids = manualUndoConfig.getIds();
+        if(CollectionUtil.isEmpty(ids)){
+            return;
+        }
+        /****************将撤泵记录存入到泵的使用历史记录中***************/
+        List<BusDeviceRunningEntity> devices = this.listByIds(ids);
+        if(CollectionUtil.isEmpty(devices)){
+            return;
+        }
+        //对所有运行中的泵进行撤泵操作
+        this.update(new UpdateWrapper<BusDeviceRunningEntity>().lambda().in(BusDeviceRunningEntity::getId,ids).set(BusDeviceRunningEntity::getIsUndo,true));
+
+        //输注结束,更新撤泵信息
+        Set<String> infusionIds = devices.stream().map(BusDeviceRunningEntity::getInfusionId).collect(Collectors.toSet());
+        infusionHistoryService.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda()
+                .in(BusInfusionHistoryEntity::getId,infusionIds)
+                .set(BusInfusionHistoryEntity::getUndoBy,manualUndoConfig.getUndoBy())
+                .set(BusInfusionHistoryEntity::getUndoTime,manualUndoConfig.getUndoTime())
+                .set(BusInfusionHistoryEntity::getDestroyer,manualUndoConfig.getDestroyer())
+                .set(BusInfusionHistoryEntity::getWitnesses,manualUndoConfig.getWitnesses()));
+
+        //结束撤泵设备所绑定的临床数据
+        devices.forEach(device->{ clinicService.finish(device.getPatientCode(),device.getTenantId()); });
     }
 }

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

@@ -1,33 +0,0 @@
-package com.coffee.bus.service;
-
-import com.coffee.bus.entity.BusDoctorEntity;
-import com.coffee.bus.entity.BusHospitalEntity;
-import com.coffee.bus.mapper.BusDoctorMapper;
-import com.coffee.bus.mapper.BusHospitalMapper;
-import com.coffee.common.crud.BaseService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName LocalBusHospitalService.java
- * @Description TODO
- * @createTime 2022年03月19日 09:27:00
- */
-@Service
-public class LocalBusDoctorService extends BaseService<BusDoctorMapper, BusDoctorEntity,String> {
-    @Override
-    public void validateBeforeSave(BusDoctorEntity entity) {
-
-    }
-
-    @Override
-    public void validateBeforeUpdate(BusDoctorEntity entity) {
-
-    }
-
-    @Override
-    public void validateBeforeDelete(String id) {
-
-    }
-}

+ 0 - 31
coffee-system/src/main/java/com/coffee/bus/service/LocalBusEvaluationTmpService.java

@@ -1,31 +0,0 @@
-package com.coffee.bus.service;
-
-import com.coffee.bus.entity.BusEvaluationTmpEntity;
-import com.coffee.bus.mapper.BusEvalutaionTmpMapper;
-import com.coffee.common.crud.BaseService;
-import org.springframework.stereotype.Service;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName LocalBusHospitalService.java
- * @Description TODO
- * @createTime 2022年03月19日 09:27:00
- */
-@Service
-public class LocalBusEvaluationTmpService extends BaseService<BusEvalutaionTmpMapper, BusEvaluationTmpEntity,String> {
-    @Override
-    public void validateBeforeSave(BusEvaluationTmpEntity entity) {
-
-    }
-
-    @Override
-    public void validateBeforeUpdate(BusEvaluationTmpEntity entity) {
-
-    }
-
-    @Override
-    public void validateBeforeDelete(String id) {
-
-    }
-}

+ 24 - 2
coffee-system/src/main/java/com/coffee/bus/service/LocalBusHospitalService.java

@@ -6,6 +6,7 @@ import com.coffee.bus.entity.BusHospitalEntity;
 import com.coffee.bus.mapper.BusHospitalMapper;
 import com.coffee.common.config.mybatis.GetNameInterface;
 import com.coffee.common.crud.BaseService;
+import com.coffee.common.exception.CustomException;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Service;
 
@@ -31,12 +32,16 @@ public class LocalBusHospitalService extends BaseService<BusHospitalMapper, BusH
 
     @Override
     public void validateBeforeUpdate(BusHospitalEntity entity) {
-
+        if("1".equals(entity.getId())){
+            throw new CustomException("系统级医院,不可修改");
+        }
     }
 
     @Override
     public void validateBeforeDelete(String id) {
-
+        if("1".equals(id)){
+            throw new CustomException("系统级医院,不可删除");
+        }
     }
 
     @Override
@@ -56,6 +61,7 @@ public class LocalBusHospitalService extends BaseService<BusHospitalMapper, BusH
 
     @Override
     public void run(String... args) {
+        saveDefaultHospital();
         List<BusHospitalEntity> hospitalList = this.list();
         if(CollectionUtil.isNotEmpty(hospitalList)){
             Map<String, List<BusHospitalEntity>> collect = hospitalList.stream().collect(Collectors.groupingBy(BusHospitalEntity::getId));
@@ -71,4 +77,20 @@ public class LocalBusHospitalService extends BaseService<BusHospitalMapper, BusH
         }
         return hospitalMap.get(id);
     }
+
+    private void saveDefaultHospital(){
+        BusHospitalEntity hospital = new BusHospitalEntity();
+        hospital.setId("1");
+        hospital.setName("驼人医疗器械有限公司");
+        hospital.setRemark("系统级医院,不可删除、修改");
+        BusHospitalEntity.GeoPoint geoPoint = new BusHospitalEntity.GeoPoint();
+        geoPoint.setLon("35.135106");
+        geoPoint.setLat("114.658855");
+        hospital.setCoordinate(geoPoint);
+        try {
+            this.save(hospital);
+        }catch (Exception e){
+
+        }
+    }
 }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/service/constant/AbstractConstantService.java

@@ -13,10 +13,10 @@ import java.io.Serializable;
  * @Description 常量继承类
  * @createTime 2022年04月09日 10:19:00
  */
-public abstract class AbstractConstantService<M extends BaseMapper<E>, E,PK extends Serializable>  extends BaseService {
+public abstract class AbstractConstantService<M extends BaseMapper<E>, E,PK extends Serializable> extends BaseService<M,E,PK>{
     /**
      * 获取常量名称
      * @return
      */
-    public abstract ConstantEnum getName();
+   public abstract ConstantEnum getName();
 }

+ 36 - 0
coffee-system/src/main/java/com/coffee/bus/service/constant/LocalBusConAlarmService.java

@@ -0,0 +1,36 @@
+package com.coffee.bus.service.constant;
+
+import com.coffee.bus.entity.BusConAlarmEntity;
+import com.coffee.bus.enums.ConstantEnum;
+import com.coffee.bus.mapper.BusConAlarmMapper;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName LocalBusConDoctorService.java
+ * @Description TODO
+ * @createTime 2022年03月19日 09:27:00
+ */
+@Service
+public class LocalBusConAlarmService extends AbstractConstantService<BusConAlarmMapper, BusConAlarmEntity,String>{
+    @Override
+    public void validateBeforeSave(BusConAlarmEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeUpdate(BusConAlarmEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeDelete(String id) {
+
+    }
+
+    @Override
+    public ConstantEnum getName() {
+        return ConstantEnum.alarm;
+    }
+}

+ 37 - 0
coffee-system/src/main/java/com/coffee/bus/service/constant/LocalBusConDoctorService.java

@@ -0,0 +1,37 @@
+package com.coffee.bus.service.constant;
+
+import com.coffee.bus.entity.BusConDoctor;
+import com.coffee.bus.enums.ConstantEnum;
+import com.coffee.bus.mapper.BusConDoctorMapper;
+import com.coffee.common.crud.BaseService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName LocalBusConDoctorService.java
+ * @Description TODO
+ * @createTime 2022年03月19日 09:27:00
+ */
+@Service
+public class LocalBusConDoctorService extends AbstractConstantService<BusConDoctorMapper, BusConDoctor,String> {
+    @Override
+    public void validateBeforeSave(BusConDoctor entity) {
+
+    }
+
+    @Override
+    public void validateBeforeUpdate(BusConDoctor entity) {
+
+    }
+
+    @Override
+    public void validateBeforeDelete(String id) {
+
+    }
+
+    @Override
+    public ConstantEnum getName() {
+        return ConstantEnum.doctor;
+    }
+}

+ 37 - 0
coffee-system/src/main/java/com/coffee/bus/service/constant/LocalBusConMixService.java

@@ -0,0 +1,37 @@
+package com.coffee.bus.service.constant;
+
+import com.coffee.bus.entity.BusConMixEntity;
+import com.coffee.bus.enums.ConstantEnum;
+import com.coffee.bus.mapper.BusConMixMapper;
+import com.coffee.common.crud.BaseService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName LocalBusConMixService.java
+ * @Description TODO
+ * @createTime 2022年03月19日 09:27:00
+ */
+@Service
+public class LocalBusConMixService extends AbstractConstantService<BusConMixMapper, BusConMixEntity,String> {
+    @Override
+    public void validateBeforeSave(BusConMixEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeUpdate(BusConMixEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeDelete(String id) {
+
+    }
+
+    @Override
+    public ConstantEnum getName() {
+        return ConstantEnum.mix;
+    }
+}

+ 24 - 7
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -1,6 +1,7 @@
 package com.coffee.bus.websocket.listener;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.swing.RobotUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.crypto.SignUtil;
@@ -32,8 +33,10 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.awt.*;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
@@ -90,10 +93,15 @@ public class DeviceInfoListener {
             device.setUploadTime(device.getUploadTime()==null?new Date():device.getUploadTime());
             log.info("接收到设备数据:[{}]",infoEvent.getContent().toString());
             AtomicBoolean newInfusion=new AtomicBoolean(false);
+            AtomicBoolean valid = new AtomicBoolean(true);
             //缓存操作
             List<Supplier<?>> cacheOperation=new ArrayList<>();
             //处理设备运行数据
-            boolean first = handleRunningInfo(device, deviceOperator,newInfusion,cacheOperation);
+            boolean first = handleRunningInfo(device, deviceOperator,newInfusion,valid,cacheOperation);
+            if(!valid.get()){
+                log.error("设备[{}]所绑定临床已结束且未关机,将数据[{}]丢弃",device.getDeviceId(),device.toString());
+                return;
+            }
             //处理病患数据,解决泵重复,无泵等问题
             handlePatient(device,cacheOperation);
             //todo 绑定当前临床信息
@@ -105,6 +113,7 @@ public class DeviceInfoListener {
             BusDeviceHistoryEntity history=handleRunningHistory(device);
             //处理报警信息
             handleAlarm(history,deviceOperator,cacheOperation);
+            //todo 流速图
             if(first){
                 deviceUsingService.save(device);
             }else {
@@ -129,10 +138,11 @@ public class DeviceInfoListener {
      * 设备运行数据处理,返回是否为第一次接受数据消息
      * @param device 接收到的设备信息
      * @param deviceOperator 设备缓存信息操作符
+     * @param valid 设备数据是否有效
      * @param newInfusion 是否为新的输注
      * @return 是否为第一次接收数据消息
      */
-    private boolean handleRunningInfo( BusDeviceRunningEntity device,DeviceOperator<DeviceCacheInfo> deviceOperator,AtomicBoolean newInfusion,List<Supplier<?>> suppliers){
+    private boolean handleRunningInfo( BusDeviceRunningEntity device,DeviceOperator<DeviceCacheInfo> deviceOperator,AtomicBoolean newInfusion,AtomicBoolean valid,List<Supplier<?>> suppliers){
         //判断此条数据的分包标识是否发生了改变,若改变则
         String originClassify = deviceOperator.getClassification();
         String classification = device.getClassification();
@@ -144,16 +154,23 @@ public class DeviceInfoListener {
             classification="-1";
             throw new RuntimeException("设备数据中分包标识不能为空");
         }
+        String usingId = deviceOperator.getUsingId();
+        //todo 这部分操作交由上游处理
+        device.setTenantId(deviceOperator.getTenantId());
+        device.setMonitorType(true);
         if(!classification.equals(originClassify)){
             newInfusion.set(true);
             //分包标识发生了改变,设备开机时间重新计算
             device.setStartTime(new Date());
-        }
+        }else {
 
-        String usingId = deviceOperator.getUsingId();
-        //todo 这部分操作交由上游处理
-        device.setTenantId(deviceOperator.getTenantId());
-        device.setMonitorType(true);
+            PatientOperator<PatientCacheInfo> patient = patientRegistry.getPatient(device.getTenantId(), device.getPatientCode());
+            Boolean finished = patient.getFinished();
+            if(Boolean.TRUE.equals(finished)){
+                //分包标识未改变且临床已结束 ,则此次数据无效
+                valid.set(false);
+            }
+        }
         boolean first=false;
         if(StrUtil.isNullOrUndefined(usingId)){
             //设备首次运行,记录开机时间