|
|
@@ -19,6 +19,7 @@ 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 lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -42,37 +43,25 @@ import java.util.Objects;
|
|
|
@Api(tags = "设备管理",description = "统一权限前缀(device:info),device:info:add")
|
|
|
public class BusDeviceController extends BaseCrudController<BusDeviceEntity, String> {
|
|
|
private final LocalBusDeviceService deviceService;
|
|
|
- private final DeviceRegistry deviceRegistry;
|
|
|
|
|
|
@PostMapping("/shift/bind")
|
|
|
@ApiOperation(value = "设备换绑",notes = "权限【device:info:shift】")
|
|
|
- public R shift(@RequestBody DeviceBindVo vo){
|
|
|
+ public R shift(@RequestBody DeviceBindVo vo,@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
|
|
|
if(StrUtil.isEmpty(vo.getBindTenantId())|| CollectionUtil.isEmpty(vo.getDeviceIds())){
|
|
|
throw new CustomException("选择的医院、设备不能为空");
|
|
|
}
|
|
|
- List<String> deviceIds = vo.getDeviceIds();
|
|
|
- deviceService.update(new UpdateWrapper<BusDeviceEntity>().lambda()
|
|
|
- .in(BusDeviceEntity::getDeviceId,deviceIds)
|
|
|
- .set(BusDeviceEntity::getTenantId,vo.getBindTenantId()));
|
|
|
- deviceIds.stream()
|
|
|
- .map(deviceRegistry::getOperator)
|
|
|
- .forEach(deviceOperator -> deviceOperator.setTenantId(vo.getBindTenantId()));
|
|
|
+ deviceService.shift(tenantId,vo.getDeviceIds(),vo.getBindTenantId());
|
|
|
return R.success(DeviceAlarmEnum.values());
|
|
|
}
|
|
|
|
|
|
@PostMapping("/undo/bind")
|
|
|
@ApiOperation(value = "设备解绑",notes = "即自动将该设备绑定到默认医院上,权限【device:info:undo】")
|
|
|
- public R undo(@RequestBody DeviceBindVo vo){
|
|
|
+ public R undo(@RequestBody DeviceBindVo vo,@RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
|
|
|
if( CollectionUtil.isEmpty(vo.getDeviceIds())){
|
|
|
throw new CustomException("选择的设备不能为空");
|
|
|
}
|
|
|
- List<String> deviceIds = vo.getDeviceIds();
|
|
|
- deviceService.update(new UpdateWrapper<BusDeviceEntity>().lambda()
|
|
|
- .in(BusDeviceEntity::getDeviceId,deviceIds)
|
|
|
- .set(BusDeviceEntity::getTenantId,"1"));
|
|
|
- deviceIds.stream()
|
|
|
- .map(deviceRegistry::getOperator)
|
|
|
- .forEach(deviceOperator -> deviceOperator.setTenantId("1"));
|
|
|
+ //1为默认医院id
|
|
|
+ deviceService.shift(tenantId,vo.getDeviceIds(),"1");
|
|
|
return R.success(DeviceAlarmEnum.values());
|
|
|
}
|
|
|
|