feiyu02
2024-09-25 0516cba27e632f20efac2752787f38f0c87baafa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package cn.flightfeather.supervision.lightshare.web
 
import cn.flightfeather.supervision.domain.ds1.entity.Scense
import cn.flightfeather.supervision.domain.ds1.entity.Task
import cn.flightfeather.supervision.lightshare.service.ScenseService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
import cn.flightfeather.supervision.lightshare.vo.SceneDetailStr
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiOperation
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
 
@Api(tags = ["ScenseController"], description = "监管场景API接口")
@RestController
@RequestMapping("/scense")
class ScenseController(val scenseService: ScenseService) {
    @GetMapping
    fun getAll() = scenseService.findAll()
 
    @PutMapping
    fun add(@RequestBody scense: Scense) = scenseService.save(scense)
 
    @PostMapping
    fun update(@RequestBody scense: Scense) = scenseService.update(scense)
 
    @PostMapping("/update/list")
    fun updateList(@RequestBody sceneList: MutableList<Scense>) = scenseService.updateList(sceneList)
 
    @PostMapping("/search")
    fun find(@RequestBody scense: Scense) = scenseService.search(scense)
 
    @GetMapping("/{id}")
    fun getById(@PathVariable id: String) = scenseService.findOne(id)
 
    @DeleteMapping("/{id}")
    fun delete(@PathVariable id: String) = scenseService.delete(id)
 
    @GetMapping("/alltype")
    fun getSceneType() = scenseService.getSceneType()
 
    /**
     *
     * @param task 总任务
     * @param mode 0:只会获取总任务对应的监管版本中存在的场景;1:除了监管版本中存在的场景,还会获取剩余的可用场景
     * @return 场景列表
     */
    @PostMapping("/getByTask")
    fun getByTaskId(@RequestBody task: Task, @RequestParam(value = "mode") mode: Int) = scenseService.getByTaskId(task, mode)
 
    @GetMapping("/getByToken")
    fun getSceneByToken(
            @RequestParam("token") token: String,
            @RequestParam("page", required = false) page: Int?,
            @RequestParam("per_page", required = false) perPage: Int?
    ) = scenseService.getSceneByToken(token, page, perPage)
 
    @ApiOperation(value = "查询场景特有信息", notes = "查询场景特有信息", produces = "application/json", httpMethod = "GET", response = BaseResponse::class)
    @ApiImplicitParam(name = "sceneId", value = "场景主键id", paramType = "query", required = true, dataType = "String", defaultValue = "")
    @GetMapping("/detail")
    fun getSceneDetail(
            @RequestParam("sceneId") sceneId: String
    ) = scenseService.getSceneDetail(sceneId)
 
 
    @ApiOperation(value = "更新场景详情")
//    @ApiImplicitParams(
//            ApiImplicitParam(name = "sceneTypeId", value = "场景类型id", paramType = "query", required = true, dataType = "Long", defaultValue = "1"),
//            ApiImplicitParam(name = "sceneDetailStr", value = "场景详情", paramType = "body", required = true, dataTypeClass = SceneDetailStr::class)
//    )
    @PostMapping("/detail/update")
    fun updateSceneDetail(
            @RequestParam("sceneTypeId") typeId: Int,
            @RequestBody sceneDetailStr: SceneDetailStr
    ) = scenseService.updateSceneDetail(typeId, sceneDetailStr)
 
    @PostMapping("/find")
    fun searchScene(
        @RequestBody areaVo: AreaVo,
        @RequestParam("page", required = false) page: Int?,
        @RequestParam("per_page", required = false) perPage: Int?
    ) = scenseService.searchScene(areaVo, page, perPage)
 
    @ApiOperation(value = "根据圆心和半径找到范围内的场景")
    @PostMapping("/find/coor")
    fun searchByCoordinate(
        @RequestParam("lng") lng: Double,
        @RequestParam("lat") lat: Double,
        @RequestParam("radius") radius: Double,
    ) = resPack { scenseService.searchByCoordinate(lng, lat, radius) }
 
    @ApiOperation(value = "通过文件导入场景信息")
    @PostMapping("/import")
    fun importSceneInfo(
        @RequestPart("file") file: MultipartFile,
    ) = resPack { scenseService.importSceneInfo(file) }
 
    @ApiOperation(value = "创建场景信息")
    @PutMapping("/create")
    fun createScene(
        @RequestBody scense: Scense
    ) = resPack { scenseService.createScene(scense) }
}