|
|
@@ -1,24 +1,31 @@
|
|
|
package com.coffee.bus.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.mapper.Mapper;
|
|
|
+import com.coffee.bus.controller.vo.MonitorFinished;
|
|
|
+import com.coffee.bus.entity.BusDeviceRunningEntity;
|
|
|
import com.coffee.bus.entity.BusPatientEntity;
|
|
|
+import com.coffee.bus.enums.DeviceStatusEnum;
|
|
|
+import com.coffee.bus.service.LocalBusClinicService;
|
|
|
+import com.coffee.bus.service.LocalBusDeviceRunningService;
|
|
|
import com.coffee.bus.service.LocalBusPatientService;
|
|
|
-import com.coffee.bus.service.dto.DeviceShiftConfig;
|
|
|
+import com.coffee.bus.service.dto.ManualUndoConfig;
|
|
|
+import com.coffee.bus.service.dto.PatientDeviceNoneResult;
|
|
|
import com.coffee.bus.service.dto.PatientDeviceRepeatResult;
|
|
|
-import com.coffee.common.bo.LoginUser;
|
|
|
import com.coffee.common.crud.BaseService;
|
|
|
import com.coffee.common.crud.controller.BaseCrudController;
|
|
|
+import com.coffee.common.entity.QueryParamEntity;
|
|
|
+import com.coffee.common.exception.CustomException;
|
|
|
import com.coffee.common.result.R;
|
|
|
-import com.coffee.common.util.SecurityUtil;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.context.request.async.DeferredResult;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author lifang
|
|
|
@@ -34,11 +41,76 @@ import java.util.List;
|
|
|
public class BusPatientController extends BaseCrudController<BusPatientEntity, String> {
|
|
|
private final LocalBusPatientService patientService;
|
|
|
|
|
|
+ private final LocalBusDeviceRunningService deviceRunningService;
|
|
|
|
|
|
+ private final LocalBusClinicService clinicService;
|
|
|
@GetMapping("/repeat/device")
|
|
|
- @ApiOperation(value = "获取当前医院绑定设备重复的所有病患信息",notes = "当出现病患统一时间绑定了多个泵时,调用该接口查询出所有设备重复报警数据【无】")
|
|
|
- public R<List<PatientDeviceRepeatResult>> repeatDevice(@RequestParam(value = "tenantId",required = false)String tenantId){
|
|
|
- return R.success(patientService.repeatDevice(tenantId));
|
|
|
+ @ApiOperation(value = "获取当前医院绑定设备重复的所有病患信息",notes = "当出现病患同一时间绑定了多个泵时,调用该接口查询出所有设备重复报警数据,权限【无】")
|
|
|
+ public R<List<PatientDeviceRepeatResult>> repeatDevice(){
|
|
|
+ return R.success(patientService.repeatDevice());
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/none/device")
|
|
|
+ @ApiOperation(value = "获取当前医院没有绑定泵的所有病患临床信息",notes = "当出现病患同一时间没有泵时,调用该接口查询出所有没有泵信息的病患临床数据,权限【无】")
|
|
|
+ public R<List<PatientDeviceNoneResult>> noneDevice(){
|
|
|
+ return R.success(patientService.noneDevice());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/judge/repeat")
|
|
|
+ @ApiOperation(value = "判断所给病号中是否出现了绑定设备重复",notes = "当结束管理时,调用改接口判断所结束病号是否出现了设备重复异常,权限【无】")
|
|
|
+ @ApiResponses({
|
|
|
+ @ApiResponse(code = 200,message = "true 设备中未出现重复"),
|
|
|
+ @ApiResponse(code = 200,message = "false 设备中出现重复")
|
|
|
+ })
|
|
|
+ public R<Boolean> judgeRepeat(@RequestBody List<String> patientCode){
|
|
|
+ return R.success(patientService.count(new QueryWrapper<BusPatientEntity>().lambda().in(BusPatientEntity::getCode,patientCode))==0);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/judge/finished")
|
|
|
+ @ApiOperation(value = "判断给定病号中是否可以结束临床管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【无】")
|
|
|
+ @ApiResponses({
|
|
|
+ @ApiResponse(code = 500,message = "没有选择病号"),
|
|
|
+ @ApiResponse(code =200 ,message = "若存在不可以结束的临床信息,将会把该临床的主泵信息返回",response = BusDeviceRunningEntity.class)
|
|
|
+ })
|
|
|
+ public R<List<BusDeviceRunningEntity>> judgeFinished(@RequestBody List<String> patientCodes){
|
|
|
+ if(CollectionUtil.isEmpty(patientCodes)){
|
|
|
+ throw new CustomException("请选择一个病患");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.success(deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
|
|
|
+ .lambda()
|
|
|
+ .select(BusDeviceRunningEntity::getDeviceId,BusDeviceRunningEntity::getPatientCode,BusDeviceRunningEntity::getRunState,BusDeviceRunningEntity::getAlarm)
|
|
|
+ .eq(BusDeviceRunningEntity::getMaster,true)
|
|
|
+ .eq(BusDeviceRunningEntity::getMonitorType,true)
|
|
|
+ .ne(BusDeviceRunningEntity::getRunState, DeviceStatusEnum.Shutdown)
|
|
|
+ .in(BusDeviceRunningEntity::getPatientCode,patientCodes)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/finished")
|
|
|
+ @SaCheckPermission("bus:patient:finished")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(value = "结束监控数据结构",name = "monitorFinished",dataTypeClass = MonitorFinished.class)
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "判断给定病号中是否可以结束临床管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
|
|
|
+ public R finished(@RequestBody MonitorFinished monitorFinished, @RequestAttribute("tenantId")String tenantId){
|
|
|
+ List<String> patientCodes = monitorFinished.getPatientCodes();
|
|
|
+ if(CollectionUtil.isEmpty(patientCodes)){
|
|
|
+ throw new CustomException("请选择一个病患");
|
|
|
+ }
|
|
|
+ List<BusDeviceRunningEntity> runningDevices = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
|
|
|
+ .lambda()
|
|
|
+ .select(BusDeviceRunningEntity::getDeviceId)
|
|
|
+ .in(BusDeviceRunningEntity::getPatientCode, patientCodes)
|
|
|
+ .eq(BusDeviceRunningEntity::getIsUndo, false)
|
|
|
+ .eq(BusDeviceRunningEntity::getMonitorType, true));
|
|
|
+ if(CollectionUtil.isNotEmpty(runningDevices)){
|
|
|
+ //病患绑定的有设备,对设备进行撤泵操作
|
|
|
+ ManualUndoConfig undoConfig = ManualUndoConfig.of(runningDevices.stream().map(BusDeviceRunningEntity::getId).collect(Collectors.toList()), true, monitorFinished.getUndo());
|
|
|
+ deviceRunningService.undo(undoConfig);
|
|
|
+ }
|
|
|
+ //结束临床
|
|
|
+ clinicService.finish(patientCodes,tenantId);
|
|
|
+ return R.success();
|
|
|
}
|
|
|
/**
|
|
|
* 权限控制前缀
|
|
|
@@ -74,4 +146,6 @@ public class BusPatientController extends BaseCrudController<BusPatientEntity, S
|
|
|
public R async(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
|
|
|
return R.success();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|