src/main/kotlin/cn/flightfeather/supervision/lightshare/web/InspectionController.kt
@@ -1,6 +1,7 @@
package cn.flightfeather.supervision.lightshare.web
import cn.flightfeather.supervision.common.exception.BizException
import cn.flightfeather.supervision.config.IgnoreResponseAdvice
import cn.flightfeather.supervision.domain.ds1.entity.Inspection
import cn.flightfeather.supervision.lightshare.service.InspectionService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
@@ -14,34 +15,44 @@
@RestController
@RequestMapping("/inspection")
class InspectionController(val inspectionService: InspectionService) {
    @IgnoreResponseAdvice
    @GetMapping
    fun getAll() = inspectionService.findAll()
    @IgnoreResponseAdvice
    @PutMapping
    fun add(@RequestBody inspection: Inspection) = inspectionService.save(inspection)
    @IgnoreResponseAdvice
    @PostMapping
    fun update(@RequestBody inspection: Inspection) = inspectionService.update(inspection)
    @IgnoreResponseAdvice
    @GetMapping("/{id}")
    fun getById(@PathVariable id: String) = inspectionService.findByID(id)
    @IgnoreResponseAdvice
    @GetMapping("/{id}/problemlist")
    fun findProblemListById(@PathVariable id: String) = inspectionService.findProblemListById(id)
    @IgnoreResponseAdvice
    @GetMapping("/{id}/gitlist")
    fun findGitListById(@PathVariable id: String) = inspectionService.findGitListById(id)
    @IgnoreResponseAdvice
    @GetMapping("/{id}/{date}/lastproblemlist")
    fun findLastProblemListById(@PathVariable id: String, @PathVariable date: String) =
        inspectionService.findLastProblemListBySenceId(id, date)
    @IgnoreResponseAdvice
    @GetMapping("/find/{id}")
    fun findBySubTaskID(@PathVariable id: String) = inspectionService.findBySubTaskID(id)
    @IgnoreResponseAdvice
    @DeleteMapping("/{id}")
    fun delete(@PathVariable id: String) = inspectionService.delete(id)
    @IgnoreResponseAdvice
    @GetMapping("/getInspectionInfoByScene")
    fun getInspectionInfoByScene(
        @RequestParam(value = "sceneId", required = true) sceneId: String,
@@ -54,15 +65,13 @@
        @ApiParam("总任务id") @RequestParam(required = false) topTaskId: String?,
        @ApiParam("场景类型id") @RequestParam(required = false) sceneTypeId: String?,
        @ApiParam("区域条件") @RequestBody(required = false) areaVo: AreaVo?,
    ): BaseResponse<Any> {
        return resPack {
            if (topTaskId != null && sceneTypeId != null) {
                inspectionService.getStatistic(topTaskId, sceneTypeId)
            } else if (areaVo != null) {
                inspectionService.getStatistic(areaVo)
            } else {
                throw BizException("缺失总任务id和区域条件,请选择传输其中一种参数")
            }
    ) = resPack {
        if (topTaskId != null && sceneTypeId != null) {
            inspectionService.getStatistic(topTaskId, sceneTypeId)
        } else if (areaVo != null) {
            inspectionService.getStatistic(areaVo)
        } else {
            throw BizException("缺失总任务id和区域条件,请选择传输其中一种参数")
        }
    }
}