18339543638 3 年之前
父节点
当前提交
7173db7647
共有 20 个文件被更改,包括 393 次插入29 次删除
  1. 5 5
      coffee-admin/Dockerfile
  2. 27 0
      coffee-admin/pom.xml
  3. 10 1
      coffee-common/src/main/java/com/coffee/common/crud/BaseService.java
  4. 2 0
      coffee-common/src/main/java/com/coffee/common/entity/QueryParamEntity.java
  5. 17 0
      coffee-system/src/main/java/com/coffee/bus/bean/AliIotConfig.java
  6. 42 0
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceRegisteredController.java
  7. 27 0
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  8. 18 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusPumpController.java
  9. 26 0
      coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfig.java
  10. 66 0
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRegisteredEntity.java
  11. 1 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusEvaluationEntity.java
  12. 9 6
      coffee-system/src/main/java/com/coffee/bus/entity/BusPumpEntity.java
  13. 15 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusPumpHistoryEntity.java
  14. 17 0
      coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceRegisteredMapper.java
  15. 7 3
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusClinicService.java
  16. 34 0
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRegisteredService.java
  17. 1 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusPumpService.java
  18. 15 5
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  19. 53 5
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/HistoryInfoListener.java
  20. 1 0
      pom.xml

+ 5 - 5
coffee-admin/Dockerfile

@@ -1,7 +1,7 @@
-FROM anapsix/alpine-java:8_server-jre_unlimited
+FROM docker.io/java:8
 
+COPY 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"]
 EXPOSE 9090
-
-ADD ./target/coffee-admin.jar ./app.jar
-
-ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

+ 27 - 0
coffee-admin/pom.xml

@@ -27,6 +27,7 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
         </dependency>
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
@@ -42,4 +43,30 @@
         </plugins>
     </build>
 
+    <!--<build>-->
+        <!--<plugins>-->
+            <!--<plugin>-->
+                <!--<groupId>org.springframework.boot</groupId>-->
+                <!--<artifactId>spring-boot-maven-plugin</artifactId>-->
+                <!--<configuration>-->
+                    <!--<mainClass>com.coffee.admin.AdminApplication</mainClass>-->
+                <!--</configuration>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<goals>-->
+                            <!--<goal>repackage</goal>-->
+                        <!--</goals>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+            <!--</plugin>-->
+            <!--&lt;!&ndash; 跳过单元测试 &ndash;&gt;-->
+            <!--<plugin>-->
+                <!--<groupId>org.apache.maven.plugins</groupId>-->
+                <!--<artifactId>maven-surefire-plugin</artifactId>-->
+                <!--<configuration>-->
+                    <!--<skipTests>true</skipTests>-->
+                <!--</configuration>-->
+            <!--</plugin>-->
+        <!--</plugins>-->
+    <!--</build>-->
 </project>

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

@@ -1,5 +1,7 @@
 package com.coffee.common.crud;
 
+import cn.dev33.satoken.session.SaSession;
+import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
@@ -17,6 +19,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
+import com.coffee.common.bo.LoginUser;
 import com.coffee.common.entity.QueryParamEntity;
 import com.coffee.common.entity.param.Term;
 import com.coffee.common.exception.CustomException;
@@ -253,7 +256,13 @@ public abstract class BaseService<M extends BaseMapper<E>, E,PK extends Serializ
         }else {
             queryWrapper.orderByDesc("id");
         }
-
+        if(!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()==1){
+                queryWrapper.eq("tenant_id",param.getTenantId());
+            }
+        }
         return queryWrapper;
     }
 

+ 2 - 0
coffee-common/src/main/java/com/coffee/common/entity/QueryParamEntity.java

@@ -37,4 +37,6 @@ public class QueryParamEntity<T> {
     @Schema(description = "排序规则,field传入字段名,Direction 传输ASC、DESC")
     private Set<Order> orders;
 
+    private String tenantId;
+
 }

+ 17 - 0
coffee-system/src/main/java/com/coffee/bus/bean/AliIotConfig.java

@@ -0,0 +1,17 @@
+package com.coffee.bus.bean;
+
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName AliIotConfig.java
+ * @Description 阿里云物联网注册设备返回配置结果
+ * @createTime 2022年04月01日 15:43:00
+ */
+@Data
+public class AliIotConfig {
+    private String deviceName;
+    private String deviceSecret;
+    private String productKey;
+}

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

@@ -0,0 +1,42 @@
+package com.coffee.bus.controller;
+
+import com.baomidou.mybatisplus.core.mapper.Mapper;
+import com.coffee.bus.entity.BusDeviceRegisteredEntity;
+import com.coffee.bus.service.LocalBusDeviceRegisteredService;
+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/device/reg")
+@Api(tags = "经销商设备注册",description = "统一权限前缀(device:reg),device:reg:add")
+public class BusDeviceRegisteredController extends BaseCrudController<BusDeviceRegisteredEntity, String> {
+    private final LocalBusDeviceRegisteredService deviceRegisteredService;
+
+
+    /**
+     * 权限控制前缀
+     * @return
+     */
+    @Override
+    public String getPermissionPrefix() {
+        return "device:reg";
+    }
+
+
+    @Override
+    public BaseService<? extends Mapper<BusDeviceRegisteredEntity>, BusDeviceRegisteredEntity, String> getService() {
+        return deviceRegisteredService;
+    }
+}

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

@@ -7,10 +7,16 @@ import com.coffee.bus.service.LocalBusDoctorService;
 import com.coffee.bus.service.LocalBusPatientService;
 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.v3.oas.annotations.Operation;
 import lombok.AllArgsConstructor;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.async.DeferredResult;
 
 /**
  * @author lifang
@@ -40,4 +46,25 @@ public class BusPatientController extends BaseCrudController<BusPatientEntity, S
     public BaseService<? extends Mapper<BusPatientEntity>, BusPatientEntity, String> getService() {
         return patientService;
     }
+
+    //todo 使用
+    @PostMapping("/syn/{hospitalId}/{patientCode}")
+    @Operation(summary = "同步更新患者信息,即等待更新完成后返回更新结果")
+    public DeferredResult<R> syn(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
+        DeferredResult<R> result = new DeferredResult<>();
+        result.onCompletion(()->{
+
+        });
+        result.onTimeout(()->{
+            R.fail("响应超时");
+        });
+        return result;
+    }
+
+    //todo
+    @PostMapping("/async/{hospitalId}/{patientCode}")
+    @Operation(summary = "异步更新患者信息,即立刻返回更新结果")
+    public R async(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
+        return R.success();
+    }
 }

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

@@ -1,7 +1,10 @@
 package com.coffee.bus.controller;
 
+import cn.dev33.satoken.SaManager;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.stp.StpLogic;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
+import com.coffee.bus.controller.vo.NoPumpConfig;
 import com.coffee.bus.controller.vo.UndoConfig;
 import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.enums.NetPumpWarnEnum;
@@ -9,6 +12,7 @@ import com.coffee.bus.enums.NetPumpStatusEnum;
 import com.coffee.bus.service.LocalBusPumpService;
 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.v3.oas.annotations.Operation;
@@ -26,7 +30,7 @@ import org.springframework.web.bind.annotation.*;
 @AllArgsConstructor
 @RequestMapping("/bus/netpump")
 @Api(tags = "网络泵管理",description = "统一权限前缀(bus:pump),例如新增bus:pump:add")
-public class BusPumpController extends BaseCrudController<BusPumpEntity, String> {
+public class BusPumpController implements BaseQueryController<BusPumpEntity, String> {
     private final LocalBusPumpService netPumpService;
 
     @GetMapping("/warn/dict")
@@ -50,6 +54,14 @@ public class BusPumpController extends BaseCrudController<BusPumpEntity, String>
         return R.success();
     }
 
+    @PostMapping("/nopump")
+    @SaCheckPermission("bus:pump:add")
+    @Operation(summary = "新增无泵数据,权限为bus:pump:add")
+    public R saveNoPump(@RequestBody NoPumpConfig noPump){
+
+        return R.success();
+    }
+
     /**
      * 权限控制前缀
      * @return
@@ -59,6 +71,11 @@ public class BusPumpController extends BaseCrudController<BusPumpEntity, String>
         return "bus:pump";
     }
 
+    @Override
+    public StpLogic getStpLogin() {
+        return SaManager.getStpLogic("");
+    }
+
     @Override
     public BaseService<? extends Mapper<BusPumpEntity>, BusPumpEntity, String> getService() {
         return netPumpService;

+ 26 - 0
coffee-system/src/main/java/com/coffee/bus/controller/vo/NoPumpConfig.java

@@ -0,0 +1,26 @@
+package com.coffee.bus.controller.vo;
+
+import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusPumpEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName NoPumpConfig.java
+ * @Description 无泵监护配置
+ * @createTime 2022年03月31日 20:58:00
+ */
+@Data
+@ApiModel("新增无泵监护配置")
+public class NoPumpConfig {
+    @ApiModelProperty("泵数据")
+    private BusPumpEntity pump;
+    @ApiModelProperty("手术信息")
+    private BusClinicEntity clinic;
+    @ApiModelProperty("医院号")
+    private String tenantId;
+
+}

+ 66 - 0
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRegisteredEntity.java

@@ -0,0 +1,66 @@
+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.bean.HisInfo;
+import com.coffee.bus.enums.NetPumpStatusEnum;
+import com.coffee.common.config.mybatis.DateToBigIntHandler;
+import com.coffee.common.entity.TenantGenericEntity;
+import com.coffee.common.enums.SexEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @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_device_registered",autoResultMap = true)
+@ApiModel(value="设备注册管理", description="设备注册管理实体类")
+@ToString
+public class BusDeviceRegisteredEntity extends TenantGenericEntity<String,String> {
+
+
+    @ApiModelProperty(value = "设备唯一id")
+    private String deviceId;
+
+    @ApiModelProperty(value = "设备别名")
+    @Length(max = 255,message = "设备别名不得超过255个字符")
+    private String alias;
+
+    @ApiModelProperty(value = "设备类型")
+    @Length(max = 255,message = "设备类型不得超过255个字符")
+    private String type;
+
+    @ApiModelProperty(value = "运行状态")
+    private NetPumpStatusEnum status;
+
+    @ApiModelProperty(value = "是否已注册完成,0、未注册 1、注册")
+    private Integer register;
+
+    @ApiModelProperty(value = "第三方平台返回配置")
+    @TableField(typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.NEVER)
+    private AliIotConfig config;
+
+    @ApiModelProperty(value = "是否启用,0、不启用 1、启用 ")
+    private Integer enable;
+
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic(value = "0",delval = "1")
+    private Integer isDelete;
+}

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

@@ -41,7 +41,7 @@ public class BusEvaluationEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "病号")
     @Length(max = 255,message = "病号长度不得超过255个字节")
-    public String patientId;
+    public String patientCode;
 
     @ApiModelProperty(value = "临床号")
     @Length(max = 255,message = "临床号长度不得超过255个字节")

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

@@ -28,7 +28,7 @@ import java.util.Date;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@TableName(value = "bus_netpump",autoResultMap = true)
+@TableName(value = "bus_pump",autoResultMap = true)
 @ApiModel(value="网络泵", description="")
 public class BusPumpEntity extends TenantGenericEntity<String,String> {
 
@@ -38,6 +38,10 @@ public class BusPumpEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "病号")
     private String patientCode;
 
+    @ApiModelProperty(value = "临床号")
+    private String clinicId;
+
+    /***************临床固定数据*****************/
     @ApiModelProperty(value = "病人名称")
     private String patientName;
 
@@ -45,15 +49,12 @@ public class BusPumpEntity extends TenantGenericEntity<String,String> {
     @TableField(typeHandler = EnumOrdinalTypeHandler.class)
     private SexEnum patientSex;
 
-    @ApiModelProperty(value = "临床号")
-    private String clinicId;
-
     @ApiModelProperty(value = "病区")
     private String ward;
 
     @ApiModelProperty(value = "床号")
     private String bedNo;
-
+    /***************临床固定数据*****************/
     @ApiModelProperty(value = "别名")
     private String alias;
 
@@ -90,7 +91,7 @@ public class BusPumpEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "总按次数")
     private Integer totalCount;
 
-    @ApiModelProperty(value = "镇痛泵运行状态")
+    @ApiModelProperty(value = "泵运行状态")
     @TableField(typeHandler = EnumOrdinalTypeHandler.class)
     private NetPumpStatusEnum runState;
 
@@ -122,4 +123,6 @@ public class BusPumpEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "是否为主泵数据, 0、副泵 1、主泵(即当前临床绑定的泵)")
     private Integer master;
 
+    @ApiModelProperty(value = "泵类型")
+    private String type;
 }

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

@@ -29,7 +29,7 @@ import java.util.Date;
 @Data
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@TableName(value = "bus_netpump_history",autoResultMap = true)
+@TableName(value = "bus_pump_history",autoResultMap = true)
 @ApiModel(value="网络泵历史数据", description="")
 public class BusPumpHistoryEntity extends TenantGenericEntity<String,String> {
 
@@ -140,6 +140,20 @@ public class BusPumpHistoryEntity extends TenantGenericEntity<String,String> {
     @JsonIgnore
     private Long requestId;
 
+    @ApiModelProperty(value = "泵类型")
+    private String type;
+    /**
+     * 填充临床信息
+     * @param clinic
+     */
+    public void fillClinic(BusClinicEntity clinic){
+        this.clinicId=clinic.getId();
+        this.patientName=clinic.getPatientName();
+        this.patientSex=clinic.getPatientGender();
+        this.ward=clinic.getWard();
+        this.bedNo=clinic.getBedNo();
+    }
+
     public static BusPumpHistoryEntity of(BusPumpEntity pump, BusClinicEntity clinic){
         BusPumpHistoryEntity history = new BusPumpHistoryEntity();
 

+ 17 - 0
coffee-system/src/main/java/com/coffee/bus/mapper/BusDeviceRegisteredMapper.java

@@ -0,0 +1,17 @@
+package com.coffee.bus.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.coffee.bus.entity.BusDeviceRegisteredEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BusHospitalMapper.java
+ * @Description 设备注册信息
+ * @createTime 2022年03月19日 09:15:00
+ */
+@Mapper
+public interface BusDeviceRegisteredMapper extends BaseMapper<BusDeviceRegisteredEntity> {
+
+}

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

@@ -6,8 +6,12 @@ import com.coffee.bus.mapper.BusClinicMapper;
 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.stereotype.Service;
 
+import javax.annotation.Resource;
+
 /**
  * @author lifang
  * @version 1.0.0
@@ -16,11 +20,11 @@ import org.springframework.stereotype.Service;
  * @createTime 2022年03月19日 09:27:00
  */
 @Service
-@AllArgsConstructor
 @Slf4j
 public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClinicEntity,String> {
-
-    private final LocalBusPumpService netPumpService;
+    @Autowired
+    @Lazy
+    private LocalBusPumpService netPumpService;
     @Override
     public void validateBeforeSave(BusClinicEntity entity) {
 

+ 34 - 0
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceRegisteredService.java

@@ -0,0 +1,34 @@
+package com.coffee.bus.service;
+
+import com.coffee.bus.entity.BusDeviceRegisteredEntity;
+import com.coffee.bus.mapper.BusDeviceRegisteredMapper;
+import com.coffee.common.crud.BaseService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName LocalBusHospitalService.java
+ * @Description 设备注册
+ * @createTime 2022年03月19日 09:27:00
+ */
+@Service
+@Slf4j
+public class LocalBusDeviceRegisteredService  extends BaseService<BusDeviceRegisteredMapper, BusDeviceRegisteredEntity,String> {
+
+    @Override
+    public void validateBeforeSave(BusDeviceRegisteredEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeUpdate(BusDeviceRegisteredEntity entity) {
+
+    }
+
+    @Override
+    public void validateBeforeDelete(String id) {
+
+    }
+}

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

@@ -69,7 +69,7 @@ public class LocalBusPumpService extends BaseService<BusPumpMapper, BusPumpEntit
         Set<String> clinicIds = pumps.stream().map(BusPumpEntity::getClinicId).collect(Collectors.toSet());
         List<BusClinicEntity> clinics = clinicService.listByIds(clinicIds);
         Map<String, List<BusClinicEntity>> clinicMap = clinics.stream().collect(Collectors.groupingBy(BusClinicEntity::getId));
-        //解析成泵的历史数据
+        //泵的撤泵数据插入到历史数据
         List<BusPumpHistoryEntity> pumpHistories = pumps.stream().map(pump -> {
             BusPumpHistoryEntity history = BusPumpHistoryEntity.of(pump, clinicMap.get(pump.getClinicId()).get(0));
             history.setUndoBy(undoConfig.getUndoBy());

+ 15 - 5
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -7,18 +7,18 @@ import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.enums.NetPumpStatusEnum;
 import com.coffee.bus.listener.event.bean.DeviceAlarmEvent;
 import com.coffee.bus.listener.event.bean.DeviceInfoEvent;
-import com.coffee.bus.service.LocalBusClinicService;
 import com.coffee.bus.service.LocalBusPumpService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.common.config.websocket.WebSocketConstant;
 import lombok.AllArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.PostConstruct;
 import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.Date;
@@ -41,7 +41,19 @@ public class DeviceInfoListener {
 
     private final LocalBusPatientService patientService;
 
-    private final LocalBusClinicService clinicService;
+    @Autowired
+    public DeviceInfoListener(RedisTemplate redisTemplate, LocalBusPumpService deviceRunInfoService, LocalBusPatientService patientService) {
+        this.redisTemplate = redisTemplate;
+        this.deviceRunInfoService = deviceRunInfoService;
+        this.patientService = patientService;
+    }
+
+    private DeviceInfoListener deviceInfoListener;
+
+    @PostConstruct
+    public void init(){
+        deviceInfoListener=SpringUtil.getBean(DeviceInfoListener.class);
+    }
     /**
      * 监听上传的数据信息,
      * 若设备详情发生变化,则及时通知相应的ws通道
@@ -102,7 +114,6 @@ public class DeviceInfoListener {
      * @param alarmEvent
      */
     @EventListener
-    @Async
     public void deviceAlarm(DeviceAlarmEvent alarmEvent){
         BusPumpEntity pump = alarmEvent.getContent();
         //获取医院配置,对医院功能配置进行过滤筛选
@@ -124,7 +135,6 @@ public class DeviceInfoListener {
 
     }
 
-
     @Scheduled(cron = "0/3 * * * * ?")
     public void send(){
         List<BusPumpEntity> list = deviceRunInfoService.list();

+ 53 - 5
coffee-system/src/main/java/com/coffee/bus/websocket/listener/HistoryInfoListener.java

@@ -1,12 +1,15 @@
 package com.coffee.bus.websocket.listener;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.coffee.bus.bean.HisInfo;
 import com.coffee.bus.entity.BusClinicEntity;
+import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.entity.BusPumpHistoryEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.listener.event.bean.HistoryInfoEvent;
@@ -16,11 +19,16 @@ import com.coffee.bus.service.*;
 import com.coffee.common.config.websocket.WebSocketConstant;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.context.event.EventListener;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.PostConstruct;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -32,7 +40,6 @@ import java.util.stream.Collectors;
  * @createTime 2022年03月29日 15:23:00
  */
 @Component
-@AllArgsConstructor
 @Slf4j
 public class HistoryInfoListener {
 
@@ -46,6 +53,25 @@ public class HistoryInfoListener {
 
     private final RedisTemplate redisTemplate;
 
+    private final LocalBusPumpService pumpService;
+
+    @Autowired
+    public HistoryInfoListener(ScriptManager scriptManager, LocalBusPatientService patientService, LocalBusClinicService clinicService, LocalBusPumpHistoryService historyService, RedisTemplate redisTemplate, LocalBusPumpService pumpService) {
+        this.scriptManager = scriptManager;
+        this.patientService = patientService;
+        this.clinicService = clinicService;
+        this.historyService = historyService;
+        this.redisTemplate = redisTemplate;
+        this.pumpService = pumpService;
+    }
+
+    private HistoryInfoListener historyInfoListener;
+
+    @PostConstruct
+    public void init(){
+        historyInfoListener= SpringUtil.getBean(HistoryInfoListener.class);
+    }
+
     @EventListener
     public void historyInfoListener(HistoryInfoEvent infoEvent){
         log.info("接收到了医院数据,[{}]",infoEvent.getContent());
@@ -84,7 +110,7 @@ public class HistoryInfoListener {
         //判断临床的唯一性
         BusClinicEntity currentClinic = clinicService.getCurrentClinic(hisInfo.getHospitalId(), hisInfo.getPatientCode());
         if (currentClinic==null) {
-            updateClinic(clinic,requestId);
+            historyInfoListener.updateClinic(clinic,requestId);
         }else {
             //临床信息已存在,判断上传信息是否发生重复,是否为最新临床信息
             if(currentClinic.getName().equals(clinic.getName())&&currentClinic.getStartTime().equals(clinic.getStartTime())){
@@ -92,7 +118,7 @@ public class HistoryInfoListener {
                 return ;
             }else {
                 //不同的临床信息,则进行更新
-                updateClinic(clinic,requestId);
+                historyInfoListener.updateClinic(clinic,requestId);
             }
         }
         //发送临床信息
@@ -100,7 +126,17 @@ public class HistoryInfoListener {
         redisTemplate.convertAndSend(topic, clinic);
     }
 
-    private void updateClinic(BusClinicEntity clinic,Long requestId){
+
+
+    /**
+     * 针对临床信息更新设备以及设备历史信息
+     * @param clinic
+     * @param clinic
+     */
+
+    @Async
+    @Transactional(rollbackFor = Exception.class)
+    public void updateClinic(BusClinicEntity clinic,Long requestId){
         clinic.setId(String.valueOf(IdWorker.getId()));
         //找到此病号信息且未绑定临床号,获取临床绑定设备号,并将临床信息与此次信息进行绑定
         List<BusPumpHistoryEntity> historyList = historyService.list(
@@ -114,10 +150,22 @@ public class HistoryInfoListener {
                         .isNull(BusPumpHistoryEntity::getClinicId));
         if (CollectionUtil.isNotEmpty(historyList)) {
             //历史信息与临床号绑定
-            historyList.forEach(history->history.setClinicId(clinic.getId()));
+            historyList.forEach(history-> history.fillClinic(clinic));
             historyService.updateBatchById(historyList);
             clinic.setDeviceCodes(historyList.stream().map(BusPumpHistoryEntity::getDeviceId).collect(Collectors.toSet()));
         }
+
+        pumpService.update(new UpdateWrapper<BusPumpEntity>()
+                .lambda()
+                .eq(BusPumpEntity::getPatientCode,clinic.getPatientCode())
+                .eq(BusPumpEntity::getTenantId,clinic.getTenantId())
+                .isNull(BusPumpEntity::getClinicId)
+                .set(BusPumpEntity::getClinicId,clinic.getId())
+                .set(BusPumpEntity::getPatientSex,clinic.getPatientGender())
+                .set(BusPumpEntity::getWard,clinic.getWard())
+                .set(BusPumpEntity::getBedNo,clinic.getBedNo())
+                .set(BusPumpEntity::getPatientName,clinic.getPatientName()));
+
         clinicService.save(clinic);
         log.info("新增临床信息,[{}]",clinic);
     }

+ 1 - 0
pom.xml

@@ -236,6 +236,7 @@
                     <artifactId>spring-boot-maven-plugin</artifactId>
                     <version>${spring-boot.version}</version>
                     <configuration>
+                        <mainClass>com.coffee.admin.AdminApplication</mainClass>
                         <finalName>${project.build.finalName}</finalName>
                         <layers>
                             <enabled>true</enabled>