|
|
@@ -3,17 +3,24 @@ package com.coffee.bus.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.dev33.satoken.annotation.SaMode;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.mapper.Mapper;
|
|
|
import com.coffee.bus.bean.Script;
|
|
|
import com.coffee.bus.controller.vo.ExecScript;
|
|
|
import com.coffee.bus.entity.BusHospitalEntity;
|
|
|
+import com.coffee.bus.hospital.HospitalManagerRegister;
|
|
|
+import com.coffee.bus.hospital.his.strategy.HisStrategyEnum;
|
|
|
import com.coffee.bus.hospital.script.ScriptManager;
|
|
|
import com.coffee.bus.service.LocalBusHospitalService;
|
|
|
import com.coffee.common.crud.BaseService;
|
|
|
import com.coffee.common.crud.controller.BaseCrudController;
|
|
|
+import com.coffee.common.exception.CustomException;
|
|
|
import com.coffee.common.result.R;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -30,7 +37,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
@Api(tags = "医院管理",description = "统一权限前缀(bus:hospital),例如新增bus:hospital:add")
|
|
|
public class BusHospitalController extends BaseCrudController<BusHospitalEntity, String> {
|
|
|
private final LocalBusHospitalService hospitalService;
|
|
|
-
|
|
|
+ private final HospitalManagerRegister hospitalManagerRegister;
|
|
|
private final ScriptManager scriptManager;
|
|
|
|
|
|
/**
|
|
|
@@ -61,11 +68,50 @@ public class BusHospitalController extends BaseCrudController<BusHospitalEntity,
|
|
|
}
|
|
|
|
|
|
@PostMapping("/debug")
|
|
|
- @ApiOperation(value = "执行解析脚本")
|
|
|
+ @SaCheckPermission("bus:hospital:script")
|
|
|
+ @ApiOperation(value = "执行解析脚本",notes = "医院必选,根据入参执行解析脚本,权限【bus:hospital:script】")
|
|
|
public R debug(@RequestBody ExecScript execScript){
|
|
|
return R.success( scriptManager.debug(execScript.getContent(),execScript.getInput()));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/draft/script")
|
|
|
+ @SaCheckPermission("bus:hospital:script")
|
|
|
+ @ApiOperation(value = "保存脚本草稿脚本",notes = "医院必选,保存脚本草稿脚本,权限【bus:hospital:script】")
|
|
|
+ public R draftScript(@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId, @RequestBody Script script){
|
|
|
+ scriptManager.check(script.getContent(),script.getType());
|
|
|
+ hospitalService.update(new UpdateWrapper<BusHospitalEntity>().lambda().eq(BusHospitalEntity::getId,tenantId)
|
|
|
+ .set(BusHospitalEntity::getScript,script));
|
|
|
+ return R.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/publish/script")
|
|
|
+ @SaCheckPermission("bus:hospital:script")
|
|
|
+ @ApiOperation(value = "发布脚本",notes = "医院必选,发布脚本,发布后即用该脚本解析his数据,权限【bus:hospital:script】")
|
|
|
+ public R publishScript(@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
|
|
|
+ BusHospitalEntity hospital = hospitalService.getById(tenantId);
|
|
|
+ if (ObjectUtil.isNull(hospital.getScript())||StrUtil.isEmpty(hospital.getScript().getContent())) {
|
|
|
+ throw new CustomException("草稿脚本内容为空,发布失败");
|
|
|
+ }
|
|
|
+ hospitalService.update(new UpdateWrapper<BusHospitalEntity>().lambda().eq(BusHospitalEntity::getId,tenantId)
|
|
|
+ .set(BusHospitalEntity::getScript,hospital.getDraftScript()));
|
|
|
+ hospitalManagerRegister.refresh(tenantId,false,false,true);
|
|
|
+ return R.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/strategy/{type}")
|
|
|
+ @SaCheckPermission("bus:hospital:strategy")
|
|
|
+ @ApiOperation(value = "His对接策略编辑",notes = "His对接策略编辑,权限【bus:hospital:strategy】")
|
|
|
+ public R editStrategy(@PathVariable("type")@ApiParam("接收his数据的策略, 0、无his 1(默认)、获取病人全部信息 2、获取病人部分信息 3、获取病人最新信息") Integer type,@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
|
|
|
+ HisStrategyEnum strategy = HisStrategyEnum.valueOf(type);
|
|
|
+ if(strategy==null){
|
|
|
+ throw new CustomException("所选策略不存在");
|
|
|
+ }
|
|
|
+ hospitalService.update(new UpdateWrapper<BusHospitalEntity>()
|
|
|
+ .lambda()
|
|
|
+ .eq(BusHospitalEntity::getId,tenantId)
|
|
|
+ .set(BusHospitalEntity::getStrategy,strategy));
|
|
|
+ return R.success(true);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@PostMapping("/validate")
|