18339543638 3 anni fa
parent
commit
efebbe2cc4

+ 7 - 7
coffee-admin/src/main/test/java/com/coffee/admin/BusNetpumpTest.java

@@ -1,9 +1,9 @@
 package com.coffee.admin;
 
-import com.coffee.bus.controller.BusNetPumpController;
-import com.coffee.bus.entity.BusNetPumpEntity;
+import com.coffee.bus.controller.BusPumpController;
+import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.enums.NetPumpWarnEnum;
-import com.coffee.bus.service.LocalBusNetPumpService;
+import com.coffee.bus.service.LocalBusPumpService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,14 +24,14 @@ import java.util.List;
 @SpringBootTest(classes = AdminApplication.class)
 public class BusNetpumpTest {
     @Autowired
-    private LocalBusNetPumpService netPumpService;
+    private LocalBusPumpService netPumpService;
 
     @Autowired
-    private BusNetPumpController netPumpController;
+    private BusPumpController netPumpController;
     @Test
     public void save(){
 //        StpUtil.login();
-        BusNetPumpEntity netPumpEntity = new BusNetPumpEntity();
+        BusPumpEntity netPumpEntity = new BusPumpEntity();
         netPumpEntity.setWarn(NetPumpWarnEnum.ComingEnd);
         netPumpEntity.setAlias("1");
         netPumpEntity.setBedNo("1");
@@ -43,7 +43,7 @@ public class BusNetpumpTest {
 
     @Test
     public void query(){
-        List<BusNetPumpEntity> list = netPumpService.list();
+        List<BusPumpEntity> list = netPumpService.list();
         System.out.println(list);
     }
 

+ 5 - 5
coffee-system/src/main/java/com/coffee/bus/controller/BusNetPumpController.java → coffee-system/src/main/java/com/coffee/bus/controller/BusPumpController.java

@@ -3,10 +3,10 @@ package com.coffee.bus.controller;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import com.baomidou.mybatisplus.core.mapper.Mapper;
 import com.coffee.bus.controller.vo.UndoConfig;
-import com.coffee.bus.entity.BusNetPumpEntity;
+import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.enums.NetPumpWarnEnum;
 import com.coffee.bus.enums.NetPumpStatusEnum;
-import com.coffee.bus.service.LocalBusNetPumpService;
+import com.coffee.bus.service.LocalBusPumpService;
 import com.coffee.common.crud.BaseService;
 import com.coffee.common.crud.controller.BaseCrudController;
 import com.coffee.common.result.R;
@@ -26,8 +26,8 @@ import org.springframework.web.bind.annotation.*;
 @AllArgsConstructor
 @RequestMapping("/bus/netpump")
 @Api(tags = "网络泵管理",description = "统一权限前缀(bus:pump),例如新增bus:pump:add")
-public class BusNetPumpController extends BaseCrudController<BusNetPumpEntity, String> {
-    private final LocalBusNetPumpService netPumpService;
+public class BusPumpController extends BaseCrudController<BusPumpEntity, String> {
+    private final LocalBusPumpService netPumpService;
 
     @GetMapping("/warn/dict")
     @Operation(summary = "网络泵提醒信息枚举,无权限配置")
@@ -60,7 +60,7 @@ public class BusNetPumpController extends BaseCrudController<BusNetPumpEntity, S
     }
 
     @Override
-    public BaseService<? extends Mapper<BusNetPumpEntity>, BusNetPumpEntity, String> getService() {
+    public BaseService<? extends Mapper<BusPumpEntity>, BusPumpEntity, String> getService() {
         return netPumpService;
     }
 }

+ 6 - 11
coffee-system/src/main/java/com/coffee/bus/controller/BusNetPumpHistoryController.java → coffee-system/src/main/java/com/coffee/bus/controller/BusPumpHistoryController.java

@@ -1,17 +1,12 @@
 package com.coffee.bus.controller;
 
 import com.baomidou.mybatisplus.core.mapper.Mapper;
-import com.coffee.bus.entity.BusNetPumpEntity;
-import com.coffee.bus.enums.NetPumpStatusEnum;
-import com.coffee.bus.enums.NetPumpWarnEnum;
-import com.coffee.bus.service.LocalBusNetPumpService;
+import com.coffee.bus.entity.BusPumpHistoryEntity;
+import com.coffee.bus.service.LocalBusPumpHistoryService;
 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.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -26,8 +21,8 @@ import org.springframework.web.bind.annotation.RestController;
 @AllArgsConstructor
 @RequestMapping("/bus/netpump/history")
 @Api(tags = "网络泵历史数据管理",description = "统一权限前缀(netpump:history),netpump:history:add")
-public class BusNetPumpHistoryController extends BaseCrudController<BusNetPumpEntity, String> {
-    private final LocalBusNetPumpService netPumpService;
+public class BusPumpHistoryController extends BaseCrudController<BusPumpHistoryEntity, String> {
+    private final LocalBusPumpHistoryService historyService;
 
     /**
      * 权限控制前缀
@@ -39,7 +34,7 @@ public class BusNetPumpHistoryController extends BaseCrudController<BusNetPumpEn
     }
 
     @Override
-    public BaseService<? extends Mapper<BusNetPumpEntity>, BusNetPumpEntity, String> getService() {
-        return netPumpService;
+    public BaseService<? extends Mapper<BusPumpHistoryEntity>, BusPumpHistoryEntity, String> getService() {
+        return historyService;
     }
 }

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/entity/BusNetPumpEntity.java → coffee-system/src/main/java/com/coffee/bus/entity/BusPumpEntity.java

@@ -30,7 +30,7 @@ import java.util.Date;
 @Accessors(chain = true)
 @TableName(value = "bus_netpump",autoResultMap = true)
 @ApiModel(value="网络泵", description="")
-public class BusNetPumpEntity extends TenantGenericEntity<String,String> {
+public class BusPumpEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "网络泵id")
     private String deviceId;

+ 9 - 3
coffee-system/src/main/java/com/coffee/bus/entity/BusNetPumpHistoryEntity.java → coffee-system/src/main/java/com/coffee/bus/entity/BusPumpHistoryEntity.java

@@ -7,6 +7,7 @@ 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.JsonIgnore;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -30,7 +31,7 @@ import java.util.Date;
 @Accessors(chain = true)
 @TableName(value = "bus_netpump_history",autoResultMap = true)
 @ApiModel(value="网络泵历史数据", description="")
-public class BusNetPumpHistoryEntity extends TenantGenericEntity<String,String> {
+public class BusPumpHistoryEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "网络泵id")
     private String deviceId;
@@ -134,8 +135,13 @@ public class BusNetPumpHistoryEntity extends TenantGenericEntity<String,String>
     @ApiModelProperty(value = "是否为主泵数据")
     private Integer master;
 
-    public static BusNetPumpHistoryEntity of(BusNetPumpEntity pump,BusClinicEntity clinic){
-        BusNetPumpHistoryEntity history = new BusNetPumpHistoryEntity();
+    @ApiModelProperty(value = "当his信息不存在时,向his发起的请求id",hidden = true)
+    @TableField(exist = false)
+    @JsonIgnore
+    private Long requestId;
+
+    public static BusPumpHistoryEntity of(BusPumpEntity pump, BusClinicEntity clinic){
+        BusPumpHistoryEntity history = new BusPumpHistoryEntity();
 
         //临床信息
         history.setClinicId(clinic.getId());

+ 4 - 4
coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceAlarmEvent.java

@@ -1,6 +1,6 @@
 package com.coffee.bus.listener.event.bean;
 
-import com.coffee.bus.entity.BusNetPumpEntity;
+import com.coffee.bus.entity.BusPumpEntity;
 import lombok.Data;
 import org.springframework.context.ApplicationEvent;
 
@@ -16,13 +16,13 @@ import java.time.Clock;
 @Data
 public class DeviceAlarmEvent extends ApplicationEvent {
 
-    private final BusNetPumpEntity content;
-    public DeviceAlarmEvent(Object source,BusNetPumpEntity content) {
+    private final BusPumpEntity content;
+    public DeviceAlarmEvent(Object source, BusPumpEntity content) {
         super(source);
         this.content=content;
     }
 
-    public DeviceAlarmEvent(Object source, BusNetPumpEntity content,Clock clock) {
+    public DeviceAlarmEvent(Object source, BusPumpEntity content, Clock clock) {
         super(source, clock);
         this.content=content;
     }

+ 5 - 9
coffee-system/src/main/java/com/coffee/bus/listener/event/bean/DeviceInfoEvent.java

@@ -1,11 +1,7 @@
 package com.coffee.bus.listener.event.bean;
 
-import cn.hutool.extra.spring.SpringUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.coffee.bus.entity.BusNetPumpEntity;
-import com.coffee.bus.listener.enums.ReportType;
+import com.coffee.bus.entity.BusPumpEntity;
 import lombok.Getter;
-import lombok.Setter;
 import org.springframework.context.ApplicationEvent;
 
 import javax.validation.constraints.NotNull;
@@ -17,7 +13,7 @@ import java.time.Clock;
  * @ClassName DeviceInfoEvent.java
  * @Description 所有通过第三方传过来的数据,请先解析成netpump格式类型,然后分发到系统中
  *
- * @see  BusNetPumpEntity
+ * @see  BusPumpEntity
  * @createTime 2022年03月21日 16:21:00
  */
 @Getter
@@ -26,7 +22,7 @@ public class DeviceInfoEvent extends ApplicationEvent {
     /**
      * 设备属性值
      */
-    private final BusNetPumpEntity content;
+    private final BusPumpEntity content;
 
     /**
      * 设备id,即泵设备号
@@ -34,13 +30,13 @@ public class DeviceInfoEvent extends ApplicationEvent {
     private final String deviceId;
 
 
-    public DeviceInfoEvent(Object source, @NotNull BusNetPumpEntity content, @NotNull String deviceId) {
+    public DeviceInfoEvent(Object source, @NotNull BusPumpEntity content, @NotNull String deviceId) {
         super(source);
         this.content=content;
         this.deviceId=deviceId;
     }
 
-    public DeviceInfoEvent(Object source, Clock clock, @NotNull BusNetPumpEntity content, @NotNull String deviceId) {
+    public DeviceInfoEvent(Object source, Clock clock, @NotNull BusPumpEntity content, @NotNull String deviceId) {
         super(source, clock);
         this.content=content;
         this.deviceId=deviceId;

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/mapper/BusNetPumpHistoryMapper.java → coffee-system/src/main/java/com/coffee/bus/mapper/BusPumpHistoryMapper.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusNetPumpHistoryEntity;
+import com.coffee.bus.entity.BusPumpHistoryEntity;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
  * @createTime 2022年03月19日 09:15:00
  */
 @Mapper
-public interface BusNetPumpHistoryMapper extends BaseMapper<BusNetPumpHistoryEntity> {
+public interface BusPumpHistoryMapper extends BaseMapper<BusPumpHistoryEntity> {
 }

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/mapper/BusNetPumpMapper.java → coffee-system/src/main/java/com/coffee/bus/mapper/BusPumpMapper.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.coffee.bus.entity.BusNetPumpEntity;
+import com.coffee.bus.entity.BusPumpEntity;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
  * @createTime 2022年03月19日 09:15:00
  */
 @Mapper
-public interface BusNetPumpMapper extends BaseMapper<BusNetPumpEntity> {
+public interface BusPumpMapper extends BaseMapper<BusPumpEntity> {
 }

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

@@ -1,18 +1,12 @@
 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.entity.BusNetPumpEntity;
-import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.mapper.BusClinicMapper;
-import com.coffee.bus.mapper.BusPatientMapper;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * @author lifang
@@ -26,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 @Slf4j
 public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClinicEntity,String> {
 
-    private final LocalBusNetPumpService netPumpService;
+    private final LocalBusPumpService netPumpService;
     @Override
     public void validateBeforeSave(BusClinicEntity entity) {
 
@@ -65,4 +59,8 @@ public class LocalBusClinicService extends BaseService<BusClinicMapper, BusClini
         return this.baseMapper.getCurrentClinic(hospitalId,patientCode);
     }
 
+    @Override
+    public boolean save(BusClinicEntity entity) {
+        return super.save(entity);
+    }
 }

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

@@ -2,7 +2,7 @@ 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.BusNetPumpEntity;
+import com.coffee.bus.entity.BusPumpEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.mapper.BusPatientMapper;
 import com.coffee.common.crud.BaseService;
@@ -25,7 +25,7 @@ import java.util.Date;
 @AllArgsConstructor
 @Slf4j
 public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPatientEntity,String> {
-    private final LocalBusNetPumpService netPumpService;
+    private final LocalBusPumpService netPumpService;
     @Override
     public void validateBeforeSave(BusPatientEntity entity) {
 
@@ -60,9 +60,9 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
      * @return
      */
     public boolean isChangedDevice(String hospitalId, String patientCode, String checkDeviceId, Date checkStartTime){
-        BusNetPumpEntity existDevice = netPumpService
-                .getOne(new QueryWrapper<BusNetPumpEntity>().lambda().eq(BusNetPumpEntity::getTenantId, hospitalId)
-                        .eq(BusNetPumpEntity::getPatientCode, patientCode));
+        BusPumpEntity existDevice = netPumpService
+                .getOne(new QueryWrapper<BusPumpEntity>().lambda().eq(BusPumpEntity::getTenantId, hospitalId)
+                        .eq(BusPumpEntity::getPatientCode, patientCode));
         if(existDevice==null){
             return true;
         }
@@ -82,8 +82,8 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     @Transactional(rollbackFor = Exception.class)
     public void changePump(String hospitalId,String patientCode,String newDeviceId){
         log.info("医院id:[{}],病号:[{}],进行换泵操作,现设备id:[{}]",patientCode,hospitalId,newDeviceId);
-        netPumpService.update(new UpdateWrapper<BusNetPumpEntity>().lambda().eq(BusNetPumpEntity::getPatientCode,patientCode).set(BusNetPumpEntity::getMaster,0));
-        netPumpService.update(new UpdateWrapper<BusNetPumpEntity>().lambda().eq(BusNetPumpEntity::getDeviceId,newDeviceId).set(BusNetPumpEntity::getMaster,1));
+        netPumpService.update(new UpdateWrapper<BusPumpEntity>().lambda().eq(BusPumpEntity::getPatientCode,patientCode).set(BusPumpEntity::getMaster,0));
+        netPumpService.update(new UpdateWrapper<BusPumpEntity>().lambda().eq(BusPumpEntity::getDeviceId,newDeviceId).set(BusPumpEntity::getMaster,1));
     }
 
 

+ 5 - 5
coffee-system/src/main/java/com/coffee/bus/service/LocalBusNetPumpHistoryService.java → coffee-system/src/main/java/com/coffee/bus/service/LocalBusPumpHistoryService.java

@@ -1,7 +1,7 @@
 package com.coffee.bus.service;
 
-import com.coffee.bus.entity.BusNetPumpHistoryEntity;
-import com.coffee.bus.mapper.BusNetPumpHistoryMapper;
+import com.coffee.bus.entity.BusPumpHistoryEntity;
+import com.coffee.bus.mapper.BusPumpHistoryMapper;
 import com.coffee.common.crud.BaseService;
 import org.springframework.stereotype.Service;
 
@@ -13,14 +13,14 @@ import org.springframework.stereotype.Service;
  * @createTime 2022年03月19日 09:27:00
  */
 @Service
-public class LocalBusNetPumpHistoryService extends BaseService<BusNetPumpHistoryMapper, BusNetPumpHistoryEntity,String> {
+public class LocalBusPumpHistoryService extends BaseService<BusPumpHistoryMapper, BusPumpHistoryEntity,String> {
     @Override
-    public void validateBeforeSave(BusNetPumpHistoryEntity entity) {
+    public void validateBeforeSave(BusPumpHistoryEntity entity) {
 
     }
 
     @Override
-    public void validateBeforeUpdate(BusNetPumpHistoryEntity entity) {
+    public void validateBeforeUpdate(BusPumpHistoryEntity entity) {
 
     }
 

+ 15 - 18
coffee-system/src/main/java/com/coffee/bus/service/LocalBusNetPumpService.java → coffee-system/src/main/java/com/coffee/bus/service/LocalBusPumpService.java

@@ -4,14 +4,11 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.coffee.bus.controller.vo.UndoConfig;
 import com.coffee.bus.entity.BusClinicEntity;
-import com.coffee.bus.entity.BusDoctorEntity;
-import com.coffee.bus.entity.BusNetPumpEntity;
-import com.coffee.bus.entity.BusNetPumpHistoryEntity;
-import com.coffee.bus.mapper.BusDoctorMapper;
-import com.coffee.bus.mapper.BusNetPumpMapper;
+import com.coffee.bus.entity.BusPumpEntity;
+import com.coffee.bus.entity.BusPumpHistoryEntity;
+import com.coffee.bus.mapper.BusPumpMapper;
 import com.coffee.common.crud.BaseService;
 import lombok.AllArgsConstructor;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -30,16 +27,16 @@ import java.util.stream.Collectors;
  */
 @Service
 @AllArgsConstructor
-public class LocalBusNetPumpService extends BaseService<BusNetPumpMapper, BusNetPumpEntity,String> {
+public class LocalBusPumpService extends BaseService<BusPumpMapper, BusPumpEntity,String> {
     private final LocalBusClinicService clinicService;
-    private final LocalBusNetPumpHistoryService historyService;
+    private final LocalBusPumpHistoryService historyService;
     @Override
-    public void validateBeforeSave(BusNetPumpEntity entity) {
+    public void validateBeforeSave(BusPumpEntity entity) {
 
     }
 
     @Override
-    public void validateBeforeUpdate(BusNetPumpEntity entity) {
+    public void validateBeforeUpdate(BusPumpEntity entity) {
 
     }
 
@@ -49,12 +46,12 @@ public class LocalBusNetPumpService extends BaseService<BusNetPumpMapper, BusNet
     }
 
     public boolean firstRegister(String deviceId){
-        return this.getOne(new QueryWrapper<BusNetPumpEntity>().lambda().eq(BusNetPumpEntity::getDeviceId,deviceId))!=null;
+        return this.getOne(new QueryWrapper<BusPumpEntity>().lambda().eq(BusPumpEntity::getDeviceId,deviceId))!=null;
     }
 
 
-    public BusNetPumpEntity getByDeviceId(String deviceId){
-        return this.getOne(new QueryWrapper<BusNetPumpEntity>().lambda().eq(BusNetPumpEntity::getDeviceId,deviceId));
+    public BusPumpEntity getByDeviceId(String deviceId){
+        return this.getOne(new QueryWrapper<BusPumpEntity>().lambda().eq(BusPumpEntity::getDeviceId,deviceId));
     }
     /**
      * 撤泵操作
@@ -67,14 +64,14 @@ public class LocalBusNetPumpService extends BaseService<BusNetPumpMapper, BusNet
             return;
         }
         /****************将撤泵记录存入到泵的使用历史记录中***************/
-        List<BusNetPumpEntity> pumps = this.listByIds(ids);
+        List<BusPumpEntity> pumps = this.listByIds(ids);
         //获取有泵监护的临床信息
-        Set<String> clinicIds = pumps.stream().map(BusNetPumpEntity::getClinicId).collect(Collectors.toSet());
+        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<BusNetPumpHistoryEntity> pumpHistories = pumps.stream().map(pump -> {
-            BusNetPumpHistoryEntity history = BusNetPumpHistoryEntity.of(pump, clinicMap.get(pump.getClinicId()).get(0));
+        List<BusPumpHistoryEntity> pumpHistories = pumps.stream().map(pump -> {
+            BusPumpHistoryEntity history = BusPumpHistoryEntity.of(pump, clinicMap.get(pump.getClinicId()).get(0));
             history.setUndoBy(undoConfig.getUndoBy());
             history.setUndoTime(undoConfig.getUndoTime());
             history.setDestroyer(undoConfig.getDestroyer());
@@ -87,7 +84,7 @@ public class LocalBusNetPumpService extends BaseService<BusNetPumpMapper, BusNet
 
         /****************将泵改为撤泵状态***************/
         this.updateBatchById(ids.stream().map(id->{
-            BusNetPumpEntity pump = new BusNetPumpEntity();
+            BusPumpEntity pump = new BusPumpEntity();
             pump.setId(id);
             pump.setIsUndo(true);
             return pump;

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

@@ -3,12 +3,12 @@ package com.coffee.bus.websocket.listener;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.coffee.bus.entity.BusNetPumpEntity;
+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.LocalBusNetPumpService;
+import com.coffee.bus.service.LocalBusPumpService;
 import com.coffee.bus.service.LocalBusPatientService;
 import com.coffee.common.config.websocket.WebSocketConstant;
 import lombok.AllArgsConstructor;
@@ -37,7 +37,7 @@ public class DeviceInfoListener {
 
     private final RedisTemplate redisTemplate;
 
-    private final LocalBusNetPumpService deviceRunInfoService;
+    private final LocalBusPumpService deviceRunInfoService;
 
     private final LocalBusPatientService patientService;
 
@@ -50,9 +50,9 @@ public class DeviceInfoListener {
     @EventListener
     @Transactional(rollbackFor = Exception.class)
     public void deviceInfoDetail(DeviceInfoEvent infoEvent){
-        BusNetPumpEntity device = infoEvent.getContent();
+        BusPumpEntity device = infoEvent.getContent();
         //1、判断设备是否为首次注册
-        BusNetPumpEntity exist = deviceRunInfoService.getByDeviceId(device.getDeviceId());
+        BusPumpEntity exist = deviceRunInfoService.getByDeviceId(device.getDeviceId());
         //2、设备信息发生变化
         device.setMonitorType(1);
         if(exist==null){
@@ -104,7 +104,7 @@ public class DeviceInfoListener {
     @EventListener
     @Async
     public void deviceAlarm(DeviceAlarmEvent alarmEvent){
-        BusNetPumpEntity pump = alarmEvent.getContent();
+        BusPumpEntity pump = alarmEvent.getContent();
         //获取医院配置,对医院功能配置进行过滤筛选
         NetPumpStatusEnum runState = pump.getRunState();
         //是否解除报警状态
@@ -113,10 +113,10 @@ public class DeviceInfoListener {
             //存储报警信息 todo
             String topic = WebSocketConstant.getDeviceStateCount(null, runState.name(), pump.getTenantId());
             //获取报警设备数量
-            List<BusNetPumpEntity> alarmList = deviceRunInfoService.list(new QueryWrapper<BusNetPumpEntity>()
+            List<BusPumpEntity> alarmList = deviceRunInfoService.list(new QueryWrapper<BusPumpEntity>()
                     .lambda()
-                    .select(BusNetPumpEntity::getId)
-                    .eq(BusNetPumpEntity::getRunState, runState));
+                    .select(BusPumpEntity::getId)
+                    .eq(BusPumpEntity::getRunState, runState));
             //发送告警通知,获取报警设备数量, 下标为0是报警设备总数量,下标为1是设备所属医院的报警设备总数量
             List<? extends Number> result = Arrays.asList(alarmList.size(), alarmList.stream().filter(alarm -> alarm.getTenantId().equals(pump.getTenantId())).count());
             redisTemplate.convertAndSend(topic, result);
@@ -127,7 +127,7 @@ public class DeviceInfoListener {
 
     @Scheduled(cron = "0/3 * * * * ?")
     public void send(){
-        List<BusNetPumpEntity> list = deviceRunInfoService.list();
+        List<BusPumpEntity> list = deviceRunInfoService.list();
         list.forEach(pump->{
             pump.setRemainQuantity(BigDecimal.valueOf(RandomUtil.randomInt(100)));
             pump.setContinueQuantity(BigDecimal.valueOf(RandomUtil.randomInt(100)));

+ 34 - 33
coffee-system/src/main/java/com/coffee/bus/websocket/listener/HistoryInfoListener.java

@@ -4,11 +4,10 @@ import cn.hutool.core.collection.CollectionUtil;
 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.BusNetPumpHistoryEntity;
+import com.coffee.bus.entity.BusPumpHistoryEntity;
 import com.coffee.bus.entity.BusPatientEntity;
 import com.coffee.bus.listener.event.bean.HistoryInfoEvent;
 import com.coffee.bus.script.ExecuteResult;
@@ -43,9 +42,7 @@ public class HistoryInfoListener {
 
     private final LocalBusClinicService clinicService;
 
-    private final LocalBusNetPumpHistoryService historyService;
-
-    private final LocalBusNetPumpService netPumpService;
+    private final LocalBusPumpHistoryService historyService;
 
     private final RedisTemplate redisTemplate;
 
@@ -62,7 +59,7 @@ public class HistoryInfoListener {
             List<HisInfo> hisInfos = resultArray.parallelStream()
                     .map(result -> JSONUtil.toBean(JSONUtil.toJsonStr(result), HisInfo.class))
                     .peek(info-> info.setHospitalId(historyId))
-                    .peek(this::handle)
+                    .peek(hisInfo -> this.handle(hisInfo,infoEvent.getRequestId()))
                     .collect(Collectors.toList());
             //获取到his信息进行处理 todo
         }else {
@@ -75,7 +72,7 @@ public class HistoryInfoListener {
      * @param hisInfo
      */
     @Transactional(rollbackFor = Exception.class)
-    public void handle(HisInfo hisInfo){
+    public void handle(HisInfo hisInfo,Long requestId){
         //获取病人信息
         BusPatientEntity patient = BusPatientEntity.of(hisInfo);
         if(!patientService.exist(patient.getCode(),patient.getTenantId())){
@@ -87,37 +84,41 @@ public class HistoryInfoListener {
         //判断临床的唯一性
         BusClinicEntity currentClinic = clinicService.getCurrentClinic(hisInfo.getHospitalId(), hisInfo.getPatientCode());
         if (currentClinic==null) {
-            clinic.setId(String.valueOf(IdWorker.getId()));
-            //不存在此次临床信息,保存新的临床信息记录
-            clinicService.update(
-                    new UpdateWrapper<BusClinicEntity>().lambda()
-                            .eq(BusClinicEntity::getStartTime,clinic.getStartTime())
-                            .eq(BusClinicEntity::getPatientCode,clinic.getPatientCode())
-                            .eq(BusClinicEntity::getTenantId,clinic.getTenantId())
-                            .set(BusClinicEntity::getFinished,true));
-            //找到此病号信息且未绑定临床号,获取临床绑定设备号,并将临床信息与此次信息进行绑定 todo
-            List<BusNetPumpHistoryEntity> historyList = historyService.list(
-                    new QueryWrapper<BusNetPumpHistoryEntity>()
-                            .lambda()
-                            .select(BusNetPumpHistoryEntity::getId)
-                            .select(BusNetPumpHistoryEntity::getDeviceId)
-                            .eq(BusNetPumpHistoryEntity::getTenantId, clinic.getTenantId())
-                            .eq(BusNetPumpHistoryEntity::getPatientCode, clinic.getPatientCode())
-                            .isNull(BusNetPumpHistoryEntity::getClinicId));
-            if (CollectionUtil.isNotEmpty(historyList)) {
-                //历史信息与临床号绑定
-                historyList.forEach(history->history.setClinicId(clinic.getId()));
-                historyService.updateBatchById(historyList);
-                clinic.setDeviceCodes(historyList.stream().map(BusNetPumpHistoryEntity::getDeviceId).collect(Collectors.toSet()));
-            }
-            clinicService.save(clinic);
-            log.info("新增临床信息,[{}]",clinic);
+            updateClinic(clinic,requestId);
         }else {
             //临床信息已存在,判断上传信息是否发生重复,是否为最新临床信息
-
+            if(currentClinic.getName().equals(clinic.getName())&&currentClinic.getStartTime().equals(clinic.getStartTime())){
+                //判断为同一临床信息,不予处理
+                return ;
+            }else {
+                //不同的临床信息,则进行更新
+                updateClinic(clinic,requestId);
+            }
         }
         //发送临床信息
         String topic = WebSocketConstant.getClinicInfoTopic(null, clinic.getPatientCode(), clinic.getTenantId());
         redisTemplate.convertAndSend(topic, clinic);
     }
+
+    private void updateClinic(BusClinicEntity clinic,Long requestId){
+        clinic.setId(String.valueOf(IdWorker.getId()));
+        //找到此病号信息且未绑定临床号,获取临床绑定设备号,并将临床信息与此次信息进行绑定
+        List<BusPumpHistoryEntity> historyList = historyService.list(
+                new QueryWrapper<BusPumpHistoryEntity>()
+                        .lambda()
+                        .select(BusPumpHistoryEntity::getId)
+                        .select(BusPumpHistoryEntity::getDeviceId)
+                        .eq(BusPumpHistoryEntity::getTenantId, clinic.getTenantId())
+                        .eq(BusPumpHistoryEntity::getPatientCode, clinic.getPatientCode())
+                        .le(requestId!=null, BusPumpHistoryEntity::getRequestId,requestId)
+                        .isNull(BusPumpHistoryEntity::getClinicId));
+        if (CollectionUtil.isNotEmpty(historyList)) {
+            //历史信息与临床号绑定
+            historyList.forEach(history->history.setClinicId(clinic.getId()));
+            historyService.updateBatchById(historyList);
+            clinic.setDeviceCodes(historyList.stream().map(BusPumpHistoryEntity::getDeviceId).collect(Collectors.toSet()));
+        }
+        clinicService.save(clinic);
+        log.info("新增临床信息,[{}]",clinic);
+    }
 }