feiyu02
2025-09-18 baf2cc2ce3dfd1235c012a3750132769fcd9ad2f
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
105
106
107
108
109
110
111
112
package cn.flightfeather.supervision.lightshare.web
 
import cn.flightfeather.supervision.common.log.BizLog
import cn.flightfeather.supervision.common.log.WorkStreamLogInfo
import cn.flightfeather.supervision.common.utils.Constant
import cn.flightfeather.supervision.domain.ds1.entity.Subtask
import cn.flightfeather.supervision.lightshare.service.SubtaskService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.TaskVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.format.annotation.DateTimeFormat
import org.springframework.web.bind.annotation.*
import java.time.LocalDateTime
 
@Api(tags = ["SubtaskController"], description = "巡查子任务API接口")
@RestController
@RequestMapping("/subtask")
class SubtaskController(val subtaskService: SubtaskService, private val bizLog: BizLog) {
    @GetMapping
    fun getAll() = subtaskService.findAll()
 
    @PutMapping
    fun add(@RequestBody subtask: Subtask) = subtaskService.save(subtask)
 
    @PutMapping("/addlist")
    fun addList(@RequestBody subtasklist: List<Subtask>) = subtaskService.saveList(subtasklist)
 
    @PostMapping
    fun update(@RequestBody subtask: Subtask): Int {
        val res = subtaskService.changeStatus(subtask)
        if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text) {
            val event = "在${subtask.scensename}结束巡查"
            bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event))
        }else if (subtask.status == Constant.TaskProgress.RUNINGSTATUS2.text) {
            val event = "在${subtask.scensename}开始巡查"
            bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event))
        }
        return res
    }
 
    @ApiOperation("调整巡查任务信息")
    @PostMapping("/adjust")
    fun adjust(@RequestBody subtask: Subtask) = resPack { subtaskService.update(subtask) }
 
    @GetMapping("/{id}")
    fun getById(@PathVariable id: String) = subtaskService.findByID(id)
 
    @DeleteMapping("/{id}")
    fun delete(@PathVariable id: String) = subtaskService.delete(id)
 
    @GetMapping("/{date}/{guid}/{type}")
    fun getTaskPackList(@PathVariable date: String, @PathVariable guid: String, @PathVariable type: String) = subtaskService.getTaskPackList(date, guid, type)
 
    //临时添加用户类型作为筛选条件
    @GetMapping("/{date}/{guid}/{type}/{userType}")
    fun getTaskPackList(@PathVariable date: String, @PathVariable guid: String, @PathVariable type: String, @PathVariable userType: String) = subtaskService.getTaskPackList(date, guid, type, userType)
 
    @GetMapping("/{date}/{guid}")
    fun getTaskPack(@PathVariable date: String, @PathVariable guid: String) = subtaskService.getTaskPack(date, guid)
 
    @PostMapping("/subtaskprogress")
    fun getTaskProgress(@RequestBody areaVo: AreaVo, @RequestParam(value = "userguid", required = true) userGuid: String): TaskVo = subtaskService.getTaskProgress(areaVo, userGuid)
 
    @GetMapping("/byDayTaskId")
    fun findByDayTaskID(
            @RequestParam("dayTaskId") dayTaskId: String,
            @RequestParam("userId") userId: String,
            @RequestParam("userType") userType: String
    ) = subtaskService.findByDayTaskID(dayTaskId, userId, userType)
 
    @GetMapping("/byDate")
    fun findByDate(
            @RequestParam("date") date: String,
            @RequestParam("userId") userId: String
    ) = subtaskService.findByDate(date, userId)
 
    @GetMapping("/getSubTask")
    fun getByTopTaskAndDate(
            @RequestParam("topTaskId") topTaskId: String,
            @RequestParam(value = "startTime", required = false) startTime: String?,
            @RequestParam(value = "endTime", required = false) endTime: String?,
            @RequestParam(value = "sceneTypeId", required = false) sceneTypeId: Int?
    ) = subtaskService.getByTopTaskAndDate(topTaskId, startTime, endTime, sceneTypeId)
 
    @ApiOperation("获取某类场景的巡查任务统计信息")
    @GetMapping("/summary")
    fun getByTopTaskAndDate(
        @RequestParam("topTaskId") topTaskId: String,
        @RequestParam(value = "sceneTypeId", required = false) sceneTypeId: Int?
    ) = subtaskService.getSummary(topTaskId, sceneTypeId)
 
    @ApiOperation("获取某类场景的巡查任务统计信息")
    @PostMapping("/summary/area")
    fun getTaskProgressByArea(
        @RequestBody areaVo: AreaVo,
    ) = subtaskService.getTaskProgressByArea(areaVo)
 
    @ApiOperation("获取某个场景的巡查任务")
    @GetMapping("/byScene")
    fun getByScene(
        @RequestParam sceneId: String,
        @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") startTime: LocalDateTime?,
        @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") endTime: LocalDateTime?,
    ) = subtaskService.getByScene(sceneId, startTime, endTime)
 
    @ApiOperation("获取某类场景的巡查任务统计信息")
    @PostMapping("/summary/area/problem")
    fun getSummaryByArea(
        @RequestBody areaVo: AreaVo,
    ) = resPack { subtaskService.getSummaryByArea(areaVo) }
}