A17404李放 3 rokov pred
rodič
commit
1b86966c2c
23 zmenil súbory, kde vykonal 176 pridanie a 162 odobranie
  1. 1 1
      coffee-common/src/main/java/com/coffee/common/cache/value/Value.java
  2. 1 0
      coffee-common/src/main/java/com/coffee/common/crud/BaseService.java
  3. 4 1
      coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java
  4. 0 1
      coffee-system/src/main/java/com/coffee/bus/controller/BusDeviceController.java
  5. 20 21
      coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java
  6. 44 42
      coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceHistoryEntity.java
  7. 2 1
      coffee-system/src/main/java/com/coffee/bus/entity/BusFormulaEntity.java
  8. 2 2
      coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java
  9. 47 57
      coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionHistoryEntity.java
  10. 5 2
      coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFinishMonitorConfigHandler.java
  11. 2 1
      coffee-system/src/main/java/com/coffee/bus/hospital/script/PythonParse.java
  12. 2 5
      coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java
  13. 0 5
      coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientRegistry.java
  14. 13 3
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java
  15. 1 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusInfusionHistoryService.java
  16. 1 1
      coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java
  17. 4 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/ManualMonitorQuery.java
  18. 3 0
      coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java
  19. 2 2
      coffee-system/src/main/java/com/coffee/bus/utils/WsPublishUtils.java
  20. 13 14
      coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java
  21. 3 0
      coffee-system/src/main/resources/mapper/bus/BusDeviceManualMapper.xml
  22. 1 1
      coffee-system/src/main/resources/mapper/bus/BusInfusionModifyMapper.xml
  23. 5 1
      coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

+ 1 - 1
coffee-common/src/main/java/com/coffee/common/cache/value/Value.java

@@ -22,7 +22,7 @@ public interface Value {
 
     default boolean asBoolean() {
         return Boolean.TRUE.equals(get())
-                || "true".equals(get());
+                || "true".equals(get())||"1".equals(String.valueOf(get()));
     }
 
     default Number asNumber() {

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

@@ -77,6 +77,7 @@ public abstract class BaseService<M extends BaseMapper<E>, E,PK extends Serializ
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean save(E entity) {
+        this.validateBeforeSave(entity);
         if (super.save(entity)) {
             postSave(entity);
             return true;

+ 4 - 1
coffee-framework/src/main/java/com/coffee/framework/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java

@@ -53,7 +53,10 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
             }
             if (metaObject.hasGetter(TENANT_ID) && metaObject.getValue(TENANT_ID) == null) {
                 ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
-                String tenantId = String.valueOf(request.getAttribute("tenantId", SCOPE_REQUEST));
+                String tenantId ="1";
+                if(request!=null){
+                     tenantId = String.valueOf(request.getAttribute("tenantId", SCOPE_REQUEST));
+                }
                 this.strictInsertFill(metaObject, TENANT_ID, String.class, tenantId);
             }
         } catch (Exception e) {

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

@@ -52,7 +52,6 @@ import java.util.stream.Collectors;
 @Api(tags = "设备管理",description = "统一权限前缀(device:info),device:info:add")
 public class BusDeviceController extends BaseCrudController<BusDeviceEntity, String> {
     private final LocalBusDeviceService deviceService;
-    private final LocalBusDeviceRunningService runningService;
     @PostMapping("/shift/bind")
     @ApiOperation(value = "设备换绑",notes = "权限【device:info:shift】")
     public R shift(@RequestBody DeviceBindVo vo){

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

@@ -147,26 +147,27 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
                 throw new CustomException("临床信息不存在");
             }
         }
-        List<PatientOperator<PatientCacheInfo>> patientOperators = patientCodes.stream().map(code -> patientRegistry.getOperator(tenantId, code)).collect(Collectors.toList());
-
-        //重复设备
-        Optional<PatientOperator<PatientCacheInfo>> existRepeatDevice = patientOperators.stream()
-                .filter(patientOperator -> {
-                    Set<DeviceTimeSmallInfo> allDevice = patientOperator.getAllDevice();
-                    if (allDevice != null && allDevice.size() > 1) {
-                        return true;
-                    }
-                    return false;
-                })
-                .findAny();
-        if(existRepeatDevice.isPresent()){
-            return R.fail(String.format("病号【%s】当前绑定了多个设备,请将多余设备结束后结束管理",existRepeatDevice.get().getCode()));
+        List<BusDeviceRunningEntity> runningInfos = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
+                .lambda()
+                .select(BusDeviceRunningEntity::getDeviceId,BusDeviceRunningEntity::getPatientCode,BusDeviceRunningEntity::getClinicId)
+                .in(BusDeviceRunningEntity::getPatientCode, patientCodes)
+                .eq(BusDeviceRunningEntity::getTenantId, tenantId));
+        Map<String, List<BusDeviceRunningEntity>> runningByCode=new HashMap<>();
+        if(CollectionUtil.isNotEmpty(runningInfos)){
+            runningByCode=runningInfos.stream().collect(Collectors.groupingBy(BusDeviceRunningEntity::getPatientCode));
+        }
+        List<ManualUndoConfig> undoConfigs=new ArrayList<>();
+
+        for (String patientCode : patientCodes) {
+            PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(tenantId,patientCode);
+            undoConfigs.add(
+                    ManualUndoConfig.of(runningByCode.getOrDefault(patientCode,new ArrayList<>()).stream().map(BusDeviceRunningEntity::getDeviceId).collect(Collectors.toList()),
+                            patientCode,operator.getClinicId(),
+                            tenantId,
+                            true,
+                            monitorFinishedVo.getUndo())
+            );
         }
-        //组装撤泵信息
-        List<ManualUndoConfig> undoConfigs = patientOperators.stream().map(operator ->
-                ManualUndoConfig.of(Collections.singletonList(operator.getBindDeviceId()), operator.getCode(),operator.getClinicId(), tenantId,true, monitorFinishedVo.getUndo())
-        )
-                .collect(Collectors.toList());
         //病患绑定的有设备,对设备进行撤泵操作,且结束临床
         deviceRunningService.batchUndo(undoConfigs,true);
         return R.success(true);
@@ -236,8 +237,6 @@ public class BusPatientController  implements BaseQueryController<BusPatientEnti
         PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(undoConfig.getTenantId(), undoConfig.getPatientCode());
         if(runningInfo.size()>1){
             //仅撤泵,病号报警不解除
-            Set<DeviceTimeSmallInfo> allDevice = runningInfo.stream().map(running -> DeviceTimeSmallInfo.of(running.getDeviceId(), running.getStartTime())).collect(Collectors.toSet());
-            operator.setAllDevice(allDevice);
             Optional<BusDeviceRunningEntity> master = runningInfo.stream().filter(running -> Boolean.TRUE.equals(running.getMaster())).findAny();
             if(master.isPresent()){
                 operator.setBindDeviceId(master.get().getDeviceId());

+ 44 - 42
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceHistoryEntity.java

@@ -1,5 +1,6 @@
 package com.coffee.bus.entity;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -55,52 +56,53 @@ public class BusDeviceHistoryEntity extends CommonDeviceParam<String,String> {
 
     public static BusDeviceHistoryEntity parseRunningInfo(BusDeviceRunningEntity running){
         BusDeviceHistoryEntity entity = new BusDeviceHistoryEntity();
-        entity.setDeviceId(running.getDeviceId());
-        entity.setType(running.getType());
-        entity.setClassification(running.getClassification());
-        entity.setTenantId(running.getTenantId());
+        BeanUtil.copyProperties(running,entity);
+//        entity.setDeviceId(running.getDeviceId());
+//        entity.setType(running.getType());
+//        entity.setClassification(running.getClassification());
+//        entity.setTenantId(running.getTenantId());
         entity.setInfusionId(running.getInfusionId());
         entity.setInfusionModifyId(running.getInfusionModifyId());
 
-        entity.setTotalDose(running.getTotalDose());
-        entity.setFirstDose(running.getFirstDose());
-        entity.setRemainDose(running.getRemainDose());
-        entity.setInputDose(running.getInputDose());
-        entity.setContinueDose(running.getContinueDose());
-        entity.setAppendDose(running.getAppendDose());
-        entity.setMaxDose(running.getMaxDose());
-        entity.setSelfControlLockTime(running.getSelfControlLockTime());
-        entity.setSelfControlCount(running.getSelfControlCount());
-        entity.setPcaValidCount(running.getPcaValidCount());
-        entity.setPcaInvalidCount(running.getPcaInvalidCount());
-        entity.setPcaTotalCount(running.getPcaTotalCount());
-        entity.setDataNumber(running.getDataNumber());
-        /**
-         * 脉冲泵参数
-         */
-        entity.setPulseDose(running.getPulseDose());
-        entity.setPulseFirstLockTime(running.getPulseFirstLockTime());
-        entity.setPulseLockTime(running.getPulseLockTime());
-        /**
-         * 智能泵参数
-         */
-        entity.setFlowAdjustRate(running.getFlowAdjustRate());
-        entity.setFlowCount(running.getFlowCount());
-        entity.setFlowDownCycle(running.getFlowDownCycle());
-        entity.setFlowUpCycle(running.getFlowUpCycle());
-        entity.setFlowDownLimit(running.getFlowDownLimit());
-        entity.setFlowUpLimit(running.getFlowUpLimit());
-
+//        entity.setTotalDose(running.getTotalDose());
+//        entity.setFirstDose(running.getFirstDose());
+//        entity.setRemainDose(running.getRemainDose());
+//        entity.setInputDose(running.getInputDose());
+//        entity.setContinueDose(running.getContinueDose());
+//        entity.setAppendDose(running.getAppendDose());
+//        entity.setMaxDose(running.getMaxDose());
+//        entity.setSelfControlLockTime(running.getSelfControlLockTime());
+//        entity.setSelfControlCount(running.getSelfControlCount());
+//        entity.setPcaValidCount(running.getPcaValidCount());
+//        entity.setPcaInvalidCount(running.getPcaInvalidCount());
+//        entity.setPcaTotalCount(running.getPcaTotalCount());
+//        entity.setDataNumber(running.getDataNumber());
+//        /**
+//         * 脉冲泵参数
+//         */
+//        entity.setPulseDose(running.getPulseDose());
+//        entity.setPulseFirstLockTime(running.getPulseFirstLockTime());
+//        entity.setPulseLockTime(running.getPulseLockTime());
+//        /**
+//         * 智能泵参数
+//         */
+//        entity.setFlowAdjustRate(running.getFlowAdjustRate());
+//        entity.setFlowCount(running.getFlowCount());
+//        entity.setFlowDownCycle(running.getFlowDownCycle());
+//        entity.setFlowUpCycle(running.getFlowUpCycle());
+//        entity.setFlowDownLimit(running.getFlowDownLimit());
+//        entity.setFlowUpLimit(running.getFlowUpLimit());
+//
         entity.setUploadTime(running.getUploadTime());
-        entity.setRunState(running.getRunState());
-        entity.setWarnAnalgesicPoor(running.getWarnAnalgesicPoor());
-        entity.setWarnLowBattery(running.getWarnAnalgesicPoor());
-        entity.setWarnWillFinished(running.getWarnAnalgesicPoor());
-        entity.setAlarm(running.getAlarm());
-
-        entity.setWard(running.getWard());
-        entity.setBedNo(running.getBedNo());
-        entity.setDataNumber(running.getDataNumber());
+//        entity.setRunState(running.getRunState());
+//        entity.setWarnAnalgesicPoor(running.getWarnAnalgesicPoor());
+//        entity.setWarnLowBattery(running.getWarnAnalgesicPoor());
+//        entity.setWarnWillFinished(running.getWarnAnalgesicPoor());
+//        entity.setAlarm(running.getAlarm());
+//
+//        entity.setWard(running.getWard());
+//        entity.setBedNo(running.getBedNo());
+//        entity.setDataNumber(running.getDataNumber());
         entity.setMaster(running.getMaster());
         entity.setTenantId(running.getTenantId());
         return entity;

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

@@ -3,6 +3,7 @@ package com.coffee.bus.entity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.coffee.bus.service.dto.FormulaDrugDetailDomain;
 import com.coffee.bus.service.dto.FormulaDrugDomain;
 import com.coffee.common.entity.TenantGenericEntity;
 import io.swagger.annotations.ApiModel;
@@ -34,6 +35,6 @@ public class BusFormulaEntity extends TenantGenericEntity<String,String> {
     @ApiModelProperty(value = "配方内容")
     @Length(max = 2048,message = "配方内容不得超过2048个字符")
     @TableField(typeHandler = FastjsonTypeHandler.class,javaType = true)
-    private List<FormulaDrugDomain> content;
+    private List<FormulaDrugDetailDomain> content;
 
 }

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

@@ -73,11 +73,11 @@ public class BusHospitalEntity implements RecordModifierEntity, RecordCreationEn
     private GeoPoint coordinate;
 
     @ApiModelProperty("发布的脚本内容")
-    @TableField(typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.NEVER)
+    @TableField(typeHandler = FastjsonTypeHandler.class)
     private Script script;
 
     @ApiModelProperty("草稿(编辑中的脚本内容)")
-    @TableField(typeHandler = FastjsonTypeHandler.class,updateStrategy = FieldStrategy.NEVER)
+    @TableField(typeHandler = FastjsonTypeHandler.class)
     private Script draftScript;
 
     @ApiModelProperty("医院唯一编码,自动生成")

+ 47 - 57
coffee-system/src/main/java/com/coffee/bus/entity/BusInfusionHistoryEntity.java

@@ -1,15 +1,9 @@
 package com.coffee.bus.entity;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.annotation.*;
 import com.coffee.aliyun.utils.*;
 import com.coffee.bus.entity.common.CommonDeviceParam;
-import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.DeviceTypeEnum;
-import com.coffee.bus.enums.DeviceStatusEnum;
-import com.coffee.bus.enums.FlowStatusEnum;
-import com.coffee.common.entity.RecordCreationEntity;
-import com.coffee.common.entity.RecordModifierEntity;
-import com.coffee.common.entity.TenantGenericEntity;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
@@ -19,11 +13,6 @@ import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.experimental.Accessors;
 
-import javax.validation.constraints.DecimalMax;
-import javax.validation.constraints.DecimalMin;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -89,59 +78,60 @@ public class BusInfusionHistoryEntity extends CommonDeviceParam<String,String> {
 
     public static BusInfusionHistoryEntity parseRunningInfo(BusDeviceRunningEntity running){
         BusInfusionHistoryEntity entity = new BusInfusionHistoryEntity();
-        entity.setDeviceId(running.getDeviceId());
+        BeanUtil.copyProperties(running,entity);
+//        entity.setDeviceId(running.getDeviceId());
         entity.setClinicId(running.getClinicId());
-        entity.setPatientCode(running.getPatientCode());
-        entity.setType(running.getType());
-        entity.setWard(running.getWard());
-        entity.setBedNo(running.getBedNo());
-        entity.setClassification(running.getClassification());
+//        entity.setPatientCode(running.getPatientCode());
+//        entity.setType(running.getType());
+//        entity.setWard(running.getWard());
+//        entity.setBedNo(running.getBedNo());
+//        entity.setClassification(running.getClassification());
         entity.setStartTime(running.getStartTime());
-        entity.setTenantId(running.getTenantId());
-
-        entity.setTotalDose(running.getTotalDose());
-        entity.setFirstDose(running.getFirstDose());
-        entity.setRemainDose(running.getRemainDose());
-        entity.setInputDose(running.getInputDose());
-        entity.setContinueDose(running.getContinueDose());
-        entity.setAppendDose(running.getAppendDose());
-        entity.setMaxDose(running.getMaxDose());
-        entity.setSelfControlLockTime(running.getSelfControlLockTime());
-        entity.setSelfControlCount(running.getSelfControlCount());
-        entity.setPcaValidCount(running.getPcaValidCount());
-        entity.setPcaInvalidCount(running.getPcaInvalidCount());
-        entity.setPcaTotalCount(running.getPcaTotalCount());
-        entity.setDataNumber(running.getDataNumber());
-        /**
-         * 脉冲泵参数
-         */
-        entity.setPulseDose(running.getPulseDose());
-        entity.setPulseFirstLockTime(running.getPulseFirstLockTime());
-        entity.setPulseLockTime(running.getPulseLockTime());
-
-        /**
-         * 智能泵参数
-         */
-        entity.setFlowAdjustRate(running.getFlowAdjustRate());
-        entity.setFlowCount(running.getFlowCount());
-        entity.setFlowDownCycle(running.getFlowDownCycle());
-        entity.setFlowUpCycle(running.getFlowUpCycle());
-        entity.setFlowDownLimit(running.getFlowDownLimit());
-        entity.setFlowUpLimit(running.getFlowUpLimit());
-
+//        entity.setTenantId(running.getTenantId());
+
+//        entity.setTotalDose(running.getTotalDose());
+//        entity.setFirstDose(running.getFirstDose());
+//        entity.setRemainDose(running.getRemainDose());
+//        entity.setInputDose(running.getInputDose());
+//        entity.setContinueDose(running.getContinueDose());
+//        entity.setAppendDose(running.getAppendDose());
+//        entity.setMaxDose(running.getMaxDose());
+//        entity.setSelfControlLockTime(running.getSelfControlLockTime());
+//        entity.setSelfControlCount(running.getSelfControlCount());
+//        entity.setPcaValidCount(running.getPcaValidCount());
+//        entity.setPcaInvalidCount(running.getPcaInvalidCount());
+//        entity.setPcaTotalCount(running.getPcaTotalCount());
+//        entity.setDataNumber(running.getDataNumber());
+//        /**
+//         * 脉冲泵参数
+//         */
+//        entity.setPulseDose(running.getPulseDose());
+//        entity.setPulseFirstLockTime(running.getPulseFirstLockTime());
+//        entity.setPulseLockTime(running.getPulseLockTime());
+//
+//        /**
+//         * 智能泵参数
+//         */
+//        entity.setFlowAdjustRate(running.getFlowAdjustRate());
+//        entity.setFlowCount(running.getFlowCount());
+//        entity.setFlowDownCycle(running.getFlowDownCycle());
+//        entity.setFlowUpCycle(running.getFlowUpCycle());
+//        entity.setFlowDownLimit(running.getFlowDownLimit());
+//        entity.setFlowUpLimit(running.getFlowUpLimit());
+//
         entity.setLastUploadTime(running.getUploadTime());
-        entity.setRunState(running.getRunState());
-        entity.setWarnAnalgesicPoor(running.getWarnAnalgesicPoor());
-        entity.setWarnLowBattery(running.getWarnAnalgesicPoor());
-        entity.setWarnWillFinished(running.getWarnAnalgesicPoor());
-        entity.setAlarm(running.getAlarm());
+//        entity.setRunState(running.getRunState());
+//        entity.setWarnAnalgesicPoor(running.getWarnAnalgesicPoor());
+//        entity.setWarnLowBattery(running.getWarnAnalgesicPoor());
+//        entity.setWarnWillFinished(running.getWarnAnalgesicPoor());
+//        entity.setAlarm(running.getAlarm());
 
         //若当前临床信息不存在,则将时间戳置为 3000/01/01 01:01:01
-        entity.setClinicStartTime(defautClinicStartTime());
+        entity.setClinicStartTime(defaultClinicStartTime());
         return entity;
     }
 
-    public static Date defautClinicStartTime(){
+    public static Date defaultClinicStartTime(){
         return new Date(32503654861L);
     }
     /**

+ 5 - 2
coffee-system/src/main/java/com/coffee/bus/hospital/config/HospitalFinishMonitorConfigHandler.java

@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RDelayedQueue;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -146,7 +147,6 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
                 .eq(BusDeviceRunningEntity::getMaster,true)
                 .eq(BusDeviceRunningEntity::getTenantId, tenantId));
         if(entity!=null){
-            PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(tenantId, patientCode);
             ManualUndoConfig manualUndoConfig = new ManualUndoConfig();
             config.setUndoTime(new Date());
             manualUndoConfig.setTenantId(source.getTenantId());
@@ -154,7 +154,10 @@ public class HospitalFinishMonitorConfigHandler extends AbstractHospitalConfigHa
             manualUndoConfig.setMonitorType(true);
             manualUndoConfig.setClinicId(entity.getClinicId());
             manualUndoConfig.setPatientCode(patientCode);
-            manualUndoConfig.setDeviceIds(patientOperator.getAllDevice().stream().map(DeviceTimeSmallInfo::getDeviceId).collect(Collectors.toList()));
+            List<BusDeviceRunningEntity> devices = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getDeviceId, deviceId)
+                    .eq(BusDeviceRunningEntity::getPatientCode, patientCode)
+                    .eq(BusDeviceRunningEntity::getTenantId, tenantId));
+            manualUndoConfig.setDeviceIds(devices.stream().map(BusDeviceRunningEntity::getDeviceId).collect(Collectors.toList()));
             deviceRunningService.undo(manualUndoConfig,true);
         }
     }

+ 2 - 1
coffee-system/src/main/java/com/coffee/bus/hospital/script/PythonParse.java

@@ -28,7 +28,7 @@ public class PythonParse implements ScriptParse {
     public PythonParse() {
         Properties props = new Properties();
         props.setProperty("python.console.encoding", "UTF-8");
-        props.put("python.home", "\\jython-standalone-2.7.1.jar");
+        props.put("python.home", "jython-standalone-2.7.1.jar");
         props.put("python.console.encoding", "UTF-8");
         props.put("python.security.respectJavaAccessibility", "false");
         props.put("python.import.site", "false");
@@ -38,6 +38,7 @@ public class PythonParse implements ScriptParse {
 //        PyString standalone = new PyString("\\python-modules\\Lib");
 //        PyString xml = new PyString("E:\\software\\coffee-boot\\coffee-admin\\src\\main\\resources\\python");
 //        systemState.path.append(standalone);
+        log.info("python path >>>>>>>>>>>>>>>>>:{}",systemState.path);
         PythonInterpreter.initialize(System.getProperties(), props, new String[] {});
         interpreter = new PythonInterpreter();
 

+ 2 - 5
coffee-system/src/main/java/com/coffee/bus/registry/device/ClusterDeviceOperator.java

@@ -1,14 +1,11 @@
 package com.coffee.bus.registry.device;
 
-import cn.hutool.core.util.StrUtil;
-import com.coffee.bus.enums.DeviceAlarmEnum;
+
 import com.coffee.bus.enums.DeviceStatusEnum;
 import com.coffee.bus.registry.constant.DeviceKeyConstant;
 import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
 import com.coffee.common.cache.ConfigStorage;
-import com.coffee.common.cache.value.Value;
-import lombok.AllArgsConstructor;
-import org.python.antlr.ast.Str;
+import lombok.AllArgsConstructor;   
 
 import java.util.Date;
 import java.util.*;

+ 0 - 5
coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientRegistry.java

@@ -110,15 +110,10 @@ public class ClusterPatientRegistry implements PatientRegistry {
             //填充主副泵信息
             List<BusDeviceRunningEntity> runningList = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getPatientCode, patientCode).eq(BusDeviceRunningEntity::getTenantId, hospitalId));
             if (CollectionUtil.isNotEmpty(runningList)) {
-                Set<DeviceTimeSmallInfo> allDevice = runningList.stream().map(running ->
-                        DeviceTimeSmallInfo.of(running.getDeviceId(), running.getStartTime())
-                )
-                        .collect(Collectors.toSet());
                 Optional<BusDeviceRunningEntity> first = runningList.stream().filter(running -> Boolean.TRUE.equals(running.getMaster())).findFirst();
                 if(first.isPresent()){
                     patientOperator.setBindDeviceId(first.get().getDeviceId());
                 }
-                patientOperator.setAllDevice(allDevice);
             }
             if(insert){
                 try {

+ 13 - 3
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceService.java

@@ -13,6 +13,7 @@ import com.coffee.bus.registry.device.DeviceRegistry;
 import com.coffee.bus.entity.BusDeviceEntity;
 import com.coffee.bus.mapper.BusDeviceMapper;
 import com.coffee.bus.registry.device.DeviceOperator;
+import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
 import com.coffee.bus.service.dto.DeviceQuery;
 import com.coffee.bus.service.dto.DeviceResult;
 import com.coffee.common.crud.BaseService;
@@ -28,6 +29,7 @@ import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * @author lifang
@@ -137,7 +139,13 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
             return this.updateDevice(entity);
         }else {
             // 添加设备
-            return this.save(entity);
+            try {
+                return this.save(entity);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+            return false;
+
         }
     }
 
@@ -262,11 +270,13 @@ public class LocalBusDeviceService extends BaseService<BusDeviceMapper, BusDevic
      */
     @Transactional(rollbackFor = Exception.class)
     public void shift(List<String> deviceIds, String afterTenantId) {
+        List<DeviceOperator<DeviceCacheInfo>> operators = deviceIds.stream()
+                .map(deviceRegistry::getOperator)
+                .collect(Collectors.toList());
         this.update(new UpdateWrapper<BusDeviceEntity>().lambda()
                 .in(BusDeviceEntity::getDeviceId,deviceIds)
                 .set(BusDeviceEntity::getTenantId,afterTenantId));
-        deviceIds.stream()
-                .map(deviceRegistry::getOperator)
+        operators
                 .forEach(deviceOperator -> deviceOperator.setTenantId(afterTenantId));
     }
 }

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

@@ -143,7 +143,7 @@ public class LocalBusInfusionHistoryService extends BaseService<BusInfusionHisto
     public void resetClinicStartTime(String tenantId,String patientCode){
         this.update(new UpdateWrapper<BusInfusionHistoryEntity>().lambda().eq(BusInfusionHistoryEntity::getTenantId,tenantId)
                 .eq(BusInfusionHistoryEntity::getPatientCode,patientCode)
-                .set(BusInfusionHistoryEntity::getClinicStartTime,BusInfusionHistoryEntity.defautClinicStartTime()));
+                .set(BusInfusionHistoryEntity::getClinicStartTime,BusInfusionHistoryEntity.defaultClinicStartTime()));
     }
     /**
      * 描述: 通过临床手术的开始时间调整输注信息所绑定的手术信息

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

@@ -273,7 +273,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
                     result.setRunningCount(result.getRunningCount()+1);
                 }
                 if(monitor.getDeviceRunState()!=null&&(DeviceStatusEnum.Shutdown.equals(monitor.getDeviceRunState())||DeviceStatusEnum.NoSignal.equals(monitor.getDeviceRunState()))){
-                    result.setAlarmCount(result.getAlarmCount()+1);
+                    result.setWaitingFinish(result.getAlarmCount()+1);
                 }
                 //报警数量
                 if(monitor.getDeviceAlarm()!=null&&!monitor.getDeviceAlarm().equals(DeviceAlarmEnum.None)){

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

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.sql.Timestamp;
 import java.util.*;
 /**
  * @author lifang
@@ -23,4 +24,7 @@ public class ManualMonitorQuery {
      */
     @ApiModelProperty("设备类型;-1、无设备;0、机械泵;1、电子脉冲泵;2、电子泵;3、其他泵")
     private List<Integer> types;
+
+    @ApiModelProperty("查询时间区间")
+    private List<Timestamp> timeRange;
 }

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

@@ -93,6 +93,9 @@ public class PatientMonitorQuery  implements Serializable {
     @ApiModelProperty("查询时间区间")
     private List<Timestamp> timeRange;
 
+    @ApiModelProperty("输注是否结束")
+    private Boolean infusionFinished;
+
     @ApiModelProperty(value = "医院id",hidden = true)
     @JsonIgnore
     private String tenantId;

+ 2 - 2
coffee-system/src/main/java/com/coffee/bus/utils/WsPublishUtils.java

@@ -76,7 +76,7 @@ public class WsPublishUtils implements Serializable{
     }
 
     /**
-     * 描述: 推送医院临床设备重复数量统计
+     * 描述: 新增病人订阅
      * @author lifang
      * @date 2022/5/13 9:39
      * @param
@@ -115,7 +115,7 @@ public class WsPublishUtils implements Serializable{
     @Async
     public void publishDeviceNone(String tenantId){
         Assert.hasText(tenantId,"医院id不能为空");
-        JSONObject message = new JSONObject().putOpt("count",patientService.patientAlarmCount(tenantId,PatientAlarmEnum.NONE));
+        JSONObject message = new JSONObject().putOpt("count",patientService.patientAlarmCount(tenantId,PatientAlarmEnum.DEVICE_NONE));
         this.publish(WebSocketConstant.getDeviceNone(tenantId).getTopic(),
                 TopicMessage.of(message,tenantId)
         );

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

@@ -10,7 +10,6 @@ import cn.hutool.crypto.asymmetric.SignAlgorithm;
 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.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.coffee.bus.entity.*;
 import com.coffee.bus.enums.PatientAlarmEnum;
@@ -21,7 +20,6 @@ import com.coffee.bus.registry.device.bean.DeviceCacheInfo;
 import com.coffee.bus.registry.device.DeviceOperator;
 import com.coffee.bus.registry.patient.PatientOperator;
 import com.coffee.bus.registry.patient.PatientRegistry;
-import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
 import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.service.*;
 import com.coffee.bus.utils.WsPublishUtils;
@@ -33,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.*;
 import java.util.List;
 import java.util.function.Supplier;
-import java.util.stream.Collectors;
 
 /**
  * @author lifang
@@ -86,7 +83,8 @@ public class DeviceInfoListener {
     public void deviceInfoDetail(DeviceInfoEvent infoEvent){
         //保证统一设备数据顺序处理,若数据发送过快,为防止冲突,请在此加锁处理 todo
         synchronized (infoEvent.getDeviceId()){
-            log.info("开始处理时间------------------------[{}]",System.currentTimeMillis());
+            log.info("接收到设备消息:{}",JSONUtil.toJsonStr(infoEvent.getContent()));
+            long startTime = System.currentTimeMillis();
             /****************处理泵数据 todo 后续交由上游处理****************/
             BusDeviceRunningEntity device = infoEvent.getContent();
 //            device=device.startUpHandle();
@@ -97,6 +95,8 @@ public class DeviceInfoListener {
             device.setUploadTime(device.getUploadTime()==null?new Date():device.getUploadTime());
             DeviceOperator<DeviceCacheInfo> deviceOperator = deviceRegistry.getOperator(deviceId);
             device.setMaster(deviceOperator.getMaster());
+            device.setIsUndo(deviceOperator.getUndo());
+            device.setTenantId(deviceOperator.getTenantId());
 
             //数据准确性判断
             String classification = device.getClassification();
@@ -122,13 +122,10 @@ public class DeviceInfoListener {
             handleHospitalConfig(device,cacheOperation);
             if(first){
                 deviceService.update(new UpdateWrapper<BusDeviceEntity>().lambda().eq(BusDeviceEntity::getDeviceId,deviceId).set(BusDeviceEntity::getType,device.getType()));
-                PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
-                //首次插入则设置设备别名
-                device.setAlias(deviceOperator.getAlias());
                 //首次上传数据,开启病号监控时长
                 clinicService.update(new UpdateWrapper<BusClinicEntity>()
                         .lambda()
-                        .eq(BusClinicEntity::getId,operator.getClinicId())
+                        .eq(BusClinicEntity::getId,device.getClinicId())
                         .set(BusClinicEntity::getWard,device.getWard())
                         .set(BusClinicEntity::getBedNo,device.getBedNo())
                         .set(BusClinicEntity::getMonitorStartTime,device.getStartTime())
@@ -148,9 +145,8 @@ public class DeviceInfoListener {
 
             //所有事务处理完成后更新缓存信息
             cacheOperation.forEach(Supplier::get);
+            log.info("设备数据处理耗时:{}",(System.currentTimeMillis()-startTime));
         }
-        log.info("结束处理时间------------------------[{}]",System.currentTimeMillis());
-
     }
 
 
@@ -165,9 +161,6 @@ public class DeviceInfoListener {
         String originClassify = deviceOperator.getClassification();
         String classification = device.getClassification();
         String usingId = deviceOperator.getUsingId();
-        device.setIsUndo(deviceOperator.getUndo());
-        //todo 这部分操作交由上游处理
-        device.setTenantId(deviceOperator.getTenantId());
         if(!classification.equals(originClassify)){
             device.setNewInfusion(true);
             //启动新的输注,则撤泵标识取消
@@ -223,6 +216,7 @@ public class DeviceInfoListener {
                     .set(device.isNewInfusion(),BusPatientEntity::getInfusionId,device.getInfusionId())
                     .set(BusPatientEntity::getAlarm, PatientAlarmEnum.NONE)
             );
+            device.setMaster(true);
             suppliers.add(()->{
                 wsPublishUtils.publishDeviceNone(device.getTenantId());
                 return null;
@@ -236,10 +230,12 @@ public class DeviceInfoListener {
                         .eq(BusPatientEntity::getTenantId,device.getTenantId())
                         .set(device.isNewInfusion(),BusPatientEntity::getInfusionId,device.getInfusionId()));
             }
+            device.setMaster(true);
         }
         //更新泵所绑定当前病人缓存信息
         suppliers.add(()->{
             if(Boolean.TRUE.equals(device.getMaster())){
+                currentDeviceOperator.setMaster(true);
                 currentPatientOperator.setBindDeviceId(deviceId);
             }
             return null;
@@ -257,7 +253,7 @@ public class DeviceInfoListener {
     private void handleConflictOriginPatient(String deviceId, String hospitalId, String patientCode, List<Supplier<?>> suppliers){
         PatientOperator<PatientCacheInfo> patientOperator = patientRegistry.getOperator(hospitalId, patientCode);
         //过滤掉已换绑的泵,获取剩余所绑定的泵数据
-        List<BusDeviceRunningEntity> currentBindDevices = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getTenantId, patientCode)
+        List<BusDeviceRunningEntity> currentBindDevices = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getTenantId, hospitalId)
                 .eq(BusDeviceRunningEntity::getTenantId, hospitalId)
                 .ne(BusDeviceRunningEntity::getDeviceId, deviceId));
         if(CollectionUtil.isEmpty(currentBindDevices)){
@@ -341,6 +337,9 @@ public class DeviceInfoListener {
                     .set(Boolean.TRUE.equals(device.getMaster()),BusPatientEntity::getInfusionId,device.getInfusionId())
                     .set(BusPatientEntity::getAlarm,PatientAlarmEnum.DEVICE_REPEAT));
             suppliers.add(()->{
+                if(Boolean.TRUE.equals(device.getMaster())){
+                    patientCurrentBindDevice.setMaster(false);
+                }
                 wsPublishUtils.publishDeviceRepeat(device.getTenantId());
                 return null;
             });

+ 3 - 0
coffee-system/src/main/resources/mapper/bus/BusDeviceManualMapper.xml

@@ -47,6 +47,9 @@
                     #{type, jdbcType=VARCHAR}
                 </foreach>
             </if>
+            <if test="query.timeRange != null and query.timeRange.size >0">
+                and monitor_start_time &gt; #{query.timeRange[0]} and  monitor_start_time &lt; #{query.timeRange[1]}
+            </if>
         </where>
         order by c.monitor_start_time desc,c.patient_code desc
     </select>

+ 1 - 1
coffee-system/src/main/resources/mapper/bus/BusInfusionModifyMapper.xml

@@ -9,7 +9,7 @@
         <where>
             clinic_id=#{clinicId}
             <if test="tenantId!=null">
-                tenant_id=#{tenantId}
+                and tenant_id=#{tenantId}
             </if>
         </where>
 

+ 5 - 1
coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

@@ -114,6 +114,7 @@
              r.master
             FROM (SELECT `name`,gender,CODE FROM bus_patient WHERE bus_patient.`alarm`=1) AS p
             join (SELECT * from bus_device_running where monitor_type=1 ) as r on p.CODE=r.patient_code
+            join  (select * from bus_infusion_history where is_undo=0) as i on i.id=r.infusion_id
             join (select device_id,alias from bus_device) as d on d.device_id=r.device_id
             join  (SELECT * FROM bus_clinic WHERE finished=0 ) AS c ON  c.`patient_code`=p.code;
         </select>
@@ -217,6 +218,9 @@
                         #{ward, jdbcType=VARCHAR}
                     </foreach>
                 </if>
+                <if test="query.infusionFinished == true">
+                    and finished=#{query.infusionFinished}
+                </if>
                 <if test="query.types != null and query.types.size > 0">
                     and type in
                     <foreach item="type" index="index" collection="query.types" open="(" separator="," close=")">
@@ -271,7 +275,7 @@
                 </choose>
             </where>
             ) as i on p.infusion_id=i.id
-            join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
+            left join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
             join (select * from bus_clinic
             <where>
                 finished=0