|
|
@@ -1,8 +1,11 @@
|
|
|
package com.nb.app.doctor.controller;
|
|
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -21,6 +24,7 @@ import com.nb.auth.utils.SecurityUtil;
|
|
|
import com.nb.common.lock.annotation.DistributeLock;
|
|
|
import com.nb.common.websocket.WebSocketSessionLifeCycleManage;
|
|
|
import com.nb.core.annotation.Log;
|
|
|
+import com.nb.core.entity.QueryParamEntity;
|
|
|
import com.nb.core.exception.CustomException;
|
|
|
import com.nb.core.result.R;
|
|
|
import com.nb.web.api.entity.BusClinicEntity;
|
|
|
@@ -33,24 +37,25 @@ import com.nb.web.api.feign.result.PatientMonitorDetailResult;
|
|
|
import com.nb.web.api.feign.result.PatientMonitorResult;
|
|
|
import com.nb.web.service.bus.controller.vo.MonitorFinishedVo;
|
|
|
import com.nb.web.service.bus.entity.BusPatientEntity;
|
|
|
+import com.nb.web.service.bus.enums.ConstantEnum;
|
|
|
import com.nb.web.service.bus.service.LocalBusDeviceHistoryService;
|
|
|
import com.nb.web.service.bus.service.LocalBusDeviceManualService;
|
|
|
import com.nb.web.service.bus.service.LocalBusInfusionHistoryService;
|
|
|
import com.nb.web.service.bus.service.LocalBusPatientService;
|
|
|
+import com.nb.web.service.bus.service.constant.AbstractConstantService;
|
|
|
import com.nb.web.service.bus.service.dto.DeviceHistoryQuery;
|
|
|
import com.nb.web.service.bus.service.dto.ManualUndoConfig;
|
|
|
import com.nb.web.service.bus.utils.WsPublishUtils;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
-import io.swagger.annotations.ApiResponse;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.context.request.async.DeferredResult;
|
|
|
|
|
|
+import java.io.Serializable;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -68,23 +73,40 @@ import java.util.stream.Collectors;
|
|
|
@Api(tags = "病人输注监护")
|
|
|
@Slf4j
|
|
|
public class PatientMonitorController {
|
|
|
- private final IPatientClient patientClient;
|
|
|
+ @Autowired
|
|
|
+ private IPatientClient patientClient;
|
|
|
|
|
|
- private final LocalBusPatientService patientService;
|
|
|
+ @Autowired
|
|
|
+ private LocalBusPatientService patientService;
|
|
|
|
|
|
- private final LocalBusDeviceHistoryService historyService;
|
|
|
+ @Autowired
|
|
|
+ private LocalBusDeviceHistoryService historyService;
|
|
|
+ @Autowired
|
|
|
+ private WsPublishUtils wsPublishUtils;
|
|
|
|
|
|
- private final WsPublishUtils wsPublishUtils;
|
|
|
+ @Autowired
|
|
|
+ private LocalBusDeviceManualService manualService;
|
|
|
|
|
|
- private final LocalBusDeviceManualService manualService;
|
|
|
-
|
|
|
- private final LocalBusInfusionHistoryService infusionService;
|
|
|
+ @Autowired
|
|
|
+ private LocalBusInfusionHistoryService infusionService;
|
|
|
|
|
|
//判断是否在线
|
|
|
- private final WebSocketSessionLifeCycleManage lifeCycleManage;
|
|
|
- private final IAssistantUserBindClient userBindClient;
|
|
|
+ @Autowired
|
|
|
+ private WebSocketSessionLifeCycleManage lifeCycleManage;
|
|
|
+ @Autowired
|
|
|
+ private IAssistantUserBindClient userBindClient;
|
|
|
+
|
|
|
+ private Map<ConstantEnum, AbstractConstantService> constantHashMap=new HashMap<>();
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public PatientMonitorController(List<AbstractConstantService> constantList) {
|
|
|
+ constantList.stream().collect(Collectors.groupingBy(AbstractConstantService::getName)).forEach((k, vs)->{
|
|
|
+ constantHashMap.merge(k,vs.get(0),(o1,o2)->{
|
|
|
+ throw new RuntimeException("常量服务类名称不可重复[{"+o1.getName()+"}]");
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@PostMapping("/monitor/{consult}/no_page")
|
|
|
@@ -292,5 +314,76 @@ public class PatientMonitorController {
|
|
|
return R.success(historyService.pageQuery(query));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/{type}/page")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "mix,doctor,alarm",allowMultiple = true,dataTypeClass = ConstantEnum.class),
|
|
|
+ @ApiImplicitParam(name = "query",value = "查询参数",required = true)
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "使用POST方式分页动态查询")
|
|
|
+ public R<IPage<?>> queryPager(@PathVariable("type") ConstantEnum type,@RequestBody QueryParamEntity<?> query) {
|
|
|
+ AbstractConstantService constantService = constantHashMap.get(type);
|
|
|
+ if(constantService==null){
|
|
|
+ return R.fail("常量类型{"+type+"}不存在");
|
|
|
+ }
|
|
|
+ return R.success(constantService.list(query));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update/{type}")
|
|
|
+ @SaCheckPermission("bus:constant:edit")
|
|
|
+ @ApiOperation(value = "更新数据",notes = "权限【bus:constant:edit】")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "doctor,alarm,mix",allowMultiple = true,dataTypeClass = ConstantEnum.class)
|
|
|
+ })
|
|
|
+ public R update(@PathVariable("type") ConstantEnum type,@RequestBody JSONObject payload) {
|
|
|
+ AbstractConstantService constantService = constantHashMap.get(type);
|
|
|
+ if(constantService==null){
|
|
|
+ return R.success("常量类型{"+type+"}不存在");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return constantService.updateById( payload.toBean(constantService.getEntityClass()))?R.success(payload):R.fail("数据更新失败");
|
|
|
+ }catch (DuplicateKeyException e){
|
|
|
+ throw new CustomException("常量名称不可重复");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/{type}/remove")
|
|
|
+ @SaCheckPermission("bus:constant:remove")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id",value = "主键id",required = true),
|
|
|
+ @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "mix,doctor,alarm",allowMultiple = true,dataTypeClass = ConstantEnum.class)
|
|
|
+ })
|
|
|
+ @ApiOperation(value = "根据ID删除",notes = "权限【bus:constant:remove】")
|
|
|
+ public R delete(@PathVariable("type") ConstantEnum type,@RequestParam("id") Serializable id) {
|
|
|
+ if(StrUtil.isNullOrUndefined(String.valueOf(id))){
|
|
|
+ return R.success();
|
|
|
+ }
|
|
|
+ AbstractConstantService constantService = constantHashMap.get(type);
|
|
|
+ if(constantService==null){
|
|
|
+ return R.success("常量类型{"+type+"}不存在");
|
|
|
+ }
|
|
|
+ String key=String.valueOf(id);
|
|
|
+ return constantService
|
|
|
+ .removeById(key)? R.success():R.fail("删除失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/save/{type}")
|
|
|
+ @SaCheckPermission("bus:constant:add")
|
|
|
+ @ApiOperation(value = "新增数据",notes = "权限【bus:constant:add】")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "type",value = "常量类型",required = true,allowableValues = "doctor,alarm,mix",allowMultiple = true,dataTypeClass = ConstantEnum.class)
|
|
|
+ })
|
|
|
+ public R add(@PathVariable("type") ConstantEnum type,@RequestBody JSONObject payload) {
|
|
|
+ AbstractConstantService constantService = constantHashMap.get(type);
|
|
|
+ if(constantService==null){
|
|
|
+ return R.success("常量类型{"+type+"}不存在");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return constantService.save( payload.toBean(constantService.getEntityClass()))?R.success(payload):R.fail("数据新增失败");
|
|
|
+ }catch (DuplicateKeyException e){
|
|
|
+ throw new CustomException("常量名称不可重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|