소스 검색

add 其他监控修改、新增
update 病人监控结束管理
update 流速图数据格式修改

A17404李放 3 년 전
부모
커밋
a883b112d2

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

@@ -44,7 +44,7 @@ public class BusDeviceManualController {
     @SaCheckPermission("device:manual:edit")
     @ApiOperation(value = "编辑病人信息",notes = "编辑病人信息,权限【device:manual:edit】")
     public R edit(@RequestBody DeviceManualVo entity){
-//        deviceManualService.update(entity.getManual(),entity.getClinic());
+        deviceManualService.edit(entity.getManual(),entity.getClinic());
         return R.success();
     }
 

+ 37 - 4
coffee-system/src/main/java/com/coffee/bus/controller/BusPatientController.java

@@ -97,11 +97,29 @@ public class BusPatientController  {
                 .in(BusDeviceRunningEntity::getPatientCode,patientCodes)));
     }
 
-    @PostMapping("/do/finished")
+    @PostMapping("/do/{monitorType}/finished")
     @SaCheckPermission("bus:patient:finished")
     @ApiResponse(code = 4001,message = "病号当前绑定了多个设备,不可结束管理")
-    @ApiOperation(value = "即结束管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
-    public R finished(@RequestBody MonitorFinishedVo monitorFinishedVo, @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
+    @ApiOperation(value = "结束管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
+    public R finished(@PathVariable("monitorType")@ApiParam(value = "是否为无泵管理",defaultValue = "false",example = "0、无泵 1、有泵") boolean haveDevice,
+                      @RequestBody MonitorFinishedVo monitorFinishedVo,
+                      @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
+        if(haveDevice){
+            return monitorFinished(monitorFinishedVo,tenantId);
+        }else {
+            return manualFinished(monitorFinishedVo);
+        }
+    }
+
+    /**
+     * 描述: 输注监控结束管理(即使用驼人网络泵产品)
+     * @author lifang
+     * @date 2022/5/10 11:48
+     * @param monitorFinishedVo
+     * @param tenantId
+     * @return R
+     */
+    private R monitorFinished(MonitorFinishedVo monitorFinishedVo, String tenantId){
         List<String> patientCodes = monitorFinishedVo.getPatientCodes();
         if(CollectionUtil.isEmpty(patientCodes)){
             throw new CustomException("请选择一个病患");
@@ -124,13 +142,28 @@ public class BusPatientController  {
         List<ManualUndoConfig> undoConfigs = patientOperators.stream().map(operator ->
                 ManualUndoConfig.of(Collections.singletonList(operator.getBindDeviceId()), operator.getCode(), tenantId,true, monitorFinishedVo.getUndo())
         )
-//                .filter(undoConfig -> undoConfig.getDeviceIds() != null && undoConfig.getDeviceIds().size() > 0)
                 .collect(Collectors.toList());
         //病患绑定的有设备,对设备进行撤泵操作,且结束临床
         deviceRunningService.batchUndo(undoConfigs,true);
         return R.success();
     }
 
+    /**
+     * 描述: 其他监控手动结束管理(即未采用驼人网络泵产品)
+     * @author lifang
+     * @date 2022/5/10 11:49
+     * @param monitorFinishedVo
+     * @return R
+     */
+    private R manualFinished(MonitorFinishedVo monitorFinishedVo){
+        List<String> clinicIds = monitorFinishedVo.getClinicIds();
+        if (CollectionUtil.isEmpty(clinicIds)) {
+            throw new CustomException("未选择临床信息");
+        }
+        manualService.finishedMonitor(monitorFinishedVo);
+        return R.success();
+    }
+
 
     @PostMapping("/monitor/reset/{patientCode}")
     @SaCheckPermission("device:patient:edit")

+ 4 - 1
coffee-system/src/main/java/com/coffee/bus/controller/vo/MonitorFinishedVo.java

@@ -18,9 +18,12 @@ import java.util.List;
 @ApiModel("监控结束")
 @Data
 public class MonitorFinishedVo {
-    @ApiModelProperty("结束监控的病号")
+    @ApiModelProperty("结束监控的病号-临床监护必填")
     private List<String> patientCodes;
 
+    @ApiModelProperty("结束监控的临床号-无泵管理必填")
+    private List<String> clinicIds;
+
     @ApiModelProperty("撤泵配置")
     @NotNull(message = "撤泵配置")
     private UndoDeviceConfig undo;

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

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import com.coffee.bus.bean.HisInfo;
+import com.coffee.bus.service.dto.UndoDeviceConfig;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.enums.SexEnum;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -104,6 +105,10 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
     @TableLogic(value = "0",delval = "1")
     private Integer isDelete;
 
+    @ApiModelProperty("结束管理(撤泵)配置,仅在 其他监控中使用")
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private UndoDeviceConfig undoConfig;
+
     //todo
     @ApiModelProperty(value = "监护类型,1、有泵监护 0、无泵监护")
     @JsonIgnoreProperties(allowGetters = true)

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

@@ -1,10 +1,7 @@
 package com.coffee.bus.entity;
 
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.coffee.bus.enums.DeviceAlarmEnum;
-import com.coffee.bus.enums.FlowStatusEnum;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;

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

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.coffee.bus.enums.DeviceManualEnum;
-import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.common.entity.GenericEntity;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import io.swagger.annotations.ApiModel;

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

@@ -27,11 +27,11 @@ import javax.validation.constraints.NotNull;
 public class BusEvaluationEntity extends TenantGenericEntity<String,String> {
 
     @ApiModelProperty(value = "病号")
+    @NotNull(groups = Insert.class,message = "病号不可为空")
     @Length(max = 255,message = "病号长度不得超过255个字节")
     public String patientCode;
 
     @ApiModelProperty(value = "临床号")
-    @NotNull(groups = Insert.class,message = "临床不可为空")
     @Length(max = 255,message = "临床号长度不得超过255个字节")
     private String clinicId;
 
@@ -92,7 +92,7 @@ public class BusEvaluationEntity extends TenantGenericEntity<String,String> {
     private Integer satisfaction;
 
 
-    @ApiModelProperty(value = "评价时间",hidden = true)
+    @ApiModelProperty(value = "评价时间")
     @NotNull(groups = Insert.class,message = "评价时间不可为空")
     private Date evaluateTime;
 

+ 49 - 3
coffee-system/src/main/java/com/coffee/bus/service/LocalBusDeviceManualService.java

@@ -1,13 +1,17 @@
 package com.coffee.bus.service;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.coffee.bus.controller.vo.MonitorFinishedVo;
 import com.coffee.bus.entity.BusClinicEntity;
 import com.coffee.bus.entity.BusDeviceManualEntity;
 import com.coffee.bus.mapper.BusDeviceManualMapper;
 import com.coffee.bus.service.dto.ManualMonitorQuery;
 import com.coffee.bus.service.dto.ManualMonitorResult;
-import com.coffee.bus.service.dto.PatientMonitorResult;
 import com.coffee.common.crud.BaseService;
+import com.coffee.common.exception.CustomException;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -43,6 +47,27 @@ public class LocalBusDeviceManualService extends BaseService<BusDeviceManualMapp
 
     }
 
+    /**
+     * 编辑其他监控信息
+     * @param manual
+     * @param clinic
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void edit(BusDeviceManualEntity manual, BusClinicEntity clinic) {
+        if(StrUtil.isEmpty(clinic.getId())){
+            throw new CustomException("请选择临床信息");
+        }
+        clinicService.updateById(clinic);
+        if(StrUtil.isEmpty(manual.getId())){
+            BusDeviceManualEntity one = this.getOne(new QueryWrapper<BusDeviceManualEntity>().lambda().eq(BusDeviceManualEntity::getClinicId, clinic.getId()).last("limit 1"));
+            if(one!=null){
+                throw new CustomException("设备信息id不可为空");
+            }
+            manual.setClinicId(clinic.getId());
+        }
+        this.saveOrUpdate(manual);
+    }
+
     /**
      * 新增其他监控信息
      * @param manual
@@ -52,13 +77,34 @@ public class LocalBusDeviceManualService extends BaseService<BusDeviceManualMapp
     public void save(BusDeviceManualEntity manual, BusClinicEntity clinic) {
         //将临床设置为无泵监控临床
         clinic.setMonitorType(false);
+        if(clinic.getStartTime()==null){
+            clinic.setStartTime(new Date());
+        }
         clinicService.save(clinic);
-        manual.setClinicId(clinic.getId());
-        this.save(manual);
+        if(manual!=null){
+            manual.setClinicId(clinic.getId());
+            this.save(manual);
+        }
     }
 
     public List<ManualMonitorResult> selectMonitor(ManualMonitorQuery query){
         Page<ManualMonitorResult> page = new Page<>(0, 500, false);
         return this.baseMapper.selectMonitor(page,query).getRecords();
     }
+
+    /**
+     * 描述: 结束监控
+     * @author lifang
+     * @date 2022/5/10 11:52
+     * @param vo
+     * @return void
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void finishedMonitor(MonitorFinishedVo vo) {
+        clinicService.update(new UpdateWrapper<BusClinicEntity>().lambda()
+                .in(BusClinicEntity::getId,vo.getClinicIds())
+                .set(BusClinicEntity::getFinished,true)
+                .set(BusClinicEntity::getEndTime,vo.getUndo().getUndoTime())
+                .set(BusClinicEntity::getUndoConfig,vo.getUndo()));
+    }
 }

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

@@ -22,6 +22,7 @@ import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
 import com.coffee.bus.utils.WsPublishUtils;
 import com.coffee.common.config.websocket.WebSocketConstant;
 import com.coffee.common.crud.BaseService;
+import com.coffee.common.enums.SexEnum;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -58,11 +59,16 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
 
     private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
 
+    @Autowired
+    @Lazy
+    private LocalBusPatientService patientService;
 
 
     @Override
     public void validateBeforeSave(BusPatientEntity entity) {
-
+        if(entity.getGender()==null){
+            entity.setGender(SexEnum.UNKNOW);
+        }
     }
 
     @Override
@@ -83,7 +89,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
                     wsPublishUtils.publish(WebSocketConstant.getPatientAdd(entity.getTenantId()).getTopic(),
                             new JSONObject().putOpt("patientCode",entity.getCode()));
                 }
-        ,3, TimeUnit.SECONDS);
+                ,3, TimeUnit.SECONDS);
     }
 
     /**
@@ -192,6 +198,11 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
         patientOperator.setName(patient.getName());
         patientOperator.setBedNo(clinic.getBedNo());
         patientOperator.setWard(clinic.getWard());
+
+        CompletableFuture.runAsync(()->{
+            wsPublishUtils.publish(WebSocketConstant.getPatientMonitor(null,patient.getCode(), patient.getTenantId()).getTopic(),
+                    patientService.lookMonitorByPatientCode(patient.getCode(),patient.getTenantId()));
+        });
     }
 
     /**

+ 21 - 26
coffee-system/src/main/java/com/coffee/bus/service/dto/ClinicStatsReturnResult.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DatePattern;
 import cn.hutool.core.date.DateUtil;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
 import lombok.Data;
 import org.python.antlr.ast.Str;
 
@@ -21,16 +22,18 @@ import java.util.*;
 @ApiModel("统计返回前端数据")
 public class ClinicStatsReturnResult implements Serializable {
     @ApiModelProperty("流速数据集")
-    private List<List<Object>> continueDose;
+    private List<BigDecimal> continueDose;
     @ApiModelProperty("追加量数据集")
-    private List<List<Object>> appendDose;
+    private List<BigDecimal> appendDose;
     @ApiModelProperty("已输注量数据集")
-    private List<List<Object>> inputDose;
+    private List<BigDecimal> inputDose;
     @ApiModelProperty("有效次数数据集")
-    private List<List<Object>> validCount;
+    private List<Integer> validCount;
     @ApiModelProperty("无效次数数据集")
-    private List<List<Object>> inValidCount;
+    private List<Integer> inValidCount;
 
+    @ApiModelProperty("上传时间")
+    private List<String> uploadTimes;
     public static ClinicStatsReturnResult of(List<ClinicStatsQueryResult> queryResults){
         ClinicStatsReturnResult result = new ClinicStatsReturnResult();
         if(CollectionUtil.isEmpty(queryResults)){
@@ -38,33 +41,25 @@ public class ClinicStatsReturnResult implements Serializable {
         }
         queryResults.forEach(queryResult -> {
             String uploadTime = DateUtil.format(queryResult.getUploadTime(), DatePattern.NORM_DATETIME_PATTERN);
-            List<List<Object>> continueDoses = Optional.ofNullable(result.getContinueDose()).orElse(new ArrayList<>());
-            List<List<Object>> appendDoses = Optional.ofNullable(result.getAppendDose()).orElse(new ArrayList<>());
-            List<List<Object>> inputDoses = Optional.ofNullable(result.getInputDose()).orElse(new ArrayList<>());
-            List<List<Object>> validCounts = Optional.ofNullable(result.getValidCount()).orElse(new ArrayList<>());
-            List<List<Object>> inValidCounts = Optional.ofNullable(result.getInValidCount()).orElse(new ArrayList<>());
-
-            if( queryResult.getContinueDose()!=null){
-                continueDoses.add(Arrays.asList(uploadTime, queryResult.getContinueDose()));
-            }
-            if(queryResult.getAppendDose()!=null){
-                appendDoses.add(Arrays.asList(uploadTime,queryResult.getAppendDose()));
-            }
-            if( queryResult.getInputDose()!=null){
-                inputDoses.add(Arrays.asList(uploadTime, queryResult.getInputDose()));
-            }
-            if(queryResult.getValidCount()!=null){
-                validCounts.add(Arrays.asList(uploadTime,queryResult.getValidCount()));
-            }
-            if(queryResult.getInValidCount()!=null){
-                inValidCounts.add(Arrays.asList(uploadTime,queryResult.getInValidCount()));
-            }
+            List<BigDecimal> continueDoses = Optional.ofNullable(result.getContinueDose()).orElse(new ArrayList<>());
+            List<BigDecimal> appendDoses = Optional.ofNullable(result.getAppendDose()).orElse(new ArrayList<>());
+            List<BigDecimal> inputDoses = Optional.ofNullable(result.getInputDose()).orElse(new ArrayList<>());
+            List<Integer> validCounts = Optional.ofNullable(result.getValidCount()).orElse(new ArrayList<>());
+            List<Integer> inValidCounts = Optional.ofNullable(result.getInValidCount()).orElse(new ArrayList<>());
+            List<String> uploadTimes = Optional.ofNullable(result.getUploadTimes()).orElse(new ArrayList<>());
+            continueDoses.add(queryResult.getContinueDose()!=null?queryResult.getContinueDose():BigDecimal.ZERO);
+            appendDoses.add(queryResult.getAppendDose()!=null?queryResult.getAppendDose():BigDecimal.ZERO);
+            inputDoses.add( queryResult.getInputDose()!=null?queryResult.getInputDose():BigDecimal.ZERO);
+            validCounts.add(queryResult.getValidCount()!=null?queryResult.getValidCount():0);
+            validCounts.add(queryResult.getInValidCount()!=null?queryResult.getInValidCount():0);
+            uploadTimes.add(uploadTime);
 
             result.setContinueDose(continueDoses);
             result.setAppendDose(appendDoses);
             result.setInputDose(inputDoses);
             result.setValidCount(validCounts);
             result.setInValidCount(inValidCounts);
+            result.setUploadTimes(uploadTimes);
         });
         return result;
     }

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

@@ -23,6 +23,9 @@ import java.util.List;
 @Data
 @ApiModel("其他监护查询返回结果")
 public class ManualMonitorResult {
+    @ApiModelProperty(value = "临床手术id")
+    private String clinicId;
+
     @ApiModelProperty(value = "临床手术名称")
     private String surgeryName;
 

+ 0 - 1
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientDeviceNoneResult.java

@@ -21,7 +21,6 @@ public class PatientDeviceNoneResult {
     private String name;
 
     @ApiModelProperty("病患性别")
-    @TableField(typeHandler = MybatisEnumTypeHandler.class)
     private SexEnum gender;
 
     @ApiModelProperty("病号")

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

@@ -14,7 +14,7 @@
         <result column="ana_doctor" property="anaDoctor"/>
         <result column="start_time" property="startTime"/>
         <result column="device_type" property="deviceType"/>
-
+        <result column="clinic_id" property="clinicId"/>
     </resultMap>
 
     <select id="selectMonitor" resultMap="monitorResult" parameterType="com.coffee.bus.service.dto.ManualMonitorQuery">
@@ -23,6 +23,7 @@
         c.patient_name as patient_name,
         c.patient_gender as patient_gender,
         c.patient_age as patient_age,
+        c.id as clinic_id,
         c.ward as ward,
         c.bed_no as bed_no,
         c.`name` as surgery_name,

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

@@ -74,7 +74,7 @@
 
     <resultMap id="deviceNone" type="com.coffee.bus.service.dto.PatientDeviceNoneResult">
         <result column="name" property="name"/>
-        <result column="gender" property="gender" typeHandler="com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler"/>
+        <result column="gender" property="gender"/>
         <result column="code" property="code"/>
         <result column="age" property="age"/>
         <result column="ward" property="ward"/>