feiyu02
2025-10-30 9cb8d7e0f4ffca386b14a15f8a0aca4d1db23252
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/DeviceController.kt
@@ -3,6 +3,7 @@
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.MonitorDeviceInfo
import cn.flightfeather.supervision.lightshare.service.DeviceService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
@@ -18,22 +19,22 @@
    @GetMapping
    fun fetchDevice(
        @ApiParam("场景id") @RequestParam sceneId: String,
        @ApiParam("设备类型id", allowableValues = "0,1,2") @RequestParam deviceTypeId: Byte,
    ) = resPack { deviceService.findDevices(sceneId, Constant.DeviceType.fromValue(deviceTypeId)) }
        @ApiParam("设备类型id") @RequestParam deviceTypeId: Byte,
    ) = deviceService.findDevices(sceneId, Constant.DeviceType.fromValue(deviceTypeId))
    @ApiOperation("新增场景设备信息")
    @PutMapping("/upload")
    fun uploadDevice(
        @ApiParam("设备信息") @RequestBody deviceInfo: String,
        @ApiParam("设备类型id") @RequestParam deviceTypeId: Byte,
    ) = resPack { deviceService.insertDevice(deviceInfo, Constant.DeviceType.fromValue(deviceTypeId)) }
    ) = deviceService.insertDevice(deviceInfo, Constant.DeviceType.fromValue(deviceTypeId))
    @ApiOperation("更新场景设备信息")
    @PostMapping("/update")
    fun updateDevice(
        @ApiParam("设备信息") @RequestBody deviceInfo: String,
        @ApiParam("设备类型id") @RequestParam deviceTypeId: Byte,
    ) = resPack { deviceService.updateDevice(deviceInfo, Constant.DeviceType.fromValue(deviceTypeId)) }
    ) = deviceService.updateDevice(deviceInfo, Constant.DeviceType.fromValue(deviceTypeId))
    @ApiOperation("获取场景设备位置变更信息")
    @GetMapping("/status")
@@ -41,14 +42,14 @@
        @ApiParam("场景id") @RequestParam(required = false) sceneId: String?,
        @ApiParam("设备id") @RequestParam deviceId: Int,
        @ApiParam("设备类型id") @RequestParam deviceTypeId: Byte,
    ) = resPack { deviceService.findDeviceLocations(sceneId, deviceId, Constant.DeviceType.fromValue(deviceTypeId)) }
    ) = deviceService.findDeviceLocations(sceneId, deviceId, Constant.DeviceType.fromValue(deviceTypeId))
    @ApiOperation("新增场景设备位置变更信息")
    @PostMapping("/status/upload")
    fun uploadDeviceLocation(
        @ApiParam("设备位置信息json") @RequestParam("status") status: String,
        @ApiParam("设备图片") @RequestPart("images") images: Array<MultipartFile>,
    ) = resPack { deviceService.insertDeviceLocation(status, images) }
    ) = deviceService.insertDeviceLocation(status, images)
    @ApiOperation("更新场景设备位置变更信息")
    @PostMapping("/status/update")
@@ -56,5 +57,18 @@
        @ApiParam("设备位置信息json") @RequestParam("status") status: String,
        @ApiParam("删除的设备图片路径") @RequestParam("deleteImg") deleteImg: List<String>,
        @ApiParam("设备图片") @RequestPart("images") images: Array<MultipartFile>,
    ) = resPack { deviceService.updateDeviceLocation(status, deleteImg, images) }
    ) = deviceService.updateDeviceLocation(status, deleteImg, images)
    @ApiOperation("查询从外部获取的设备信息")
    @PostMapping("/external/search")
    fun searchExternalDevice(
        @ApiParam("区域条件信息") @RequestBody
        areaVo: AreaVo,
        @ApiParam("搜索关键字,匹配设备编号和点位名称") @RequestParam
        keyword: String,
        @ApiParam("查询页码", defaultValue = "1", required = false) @RequestParam("page", required = false)
        page: Int?,
        @ApiParam("单页数据量", defaultValue = "30", required = false) @RequestParam("per_page", required = false)
        perPage: Int?,
    ) = deviceService.searchExternalDevice(areaVo, keyword, page, perPage)
}