feiyu02
2024-07-19 4e20a1aaaba1bb843820fca844c20055a33febce
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SubtaskController.kt
@@ -1,10 +1,12 @@
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 com.fasterxml.jackson.annotation.JsonFormat
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.format.annotation.DateTimeFormat
@@ -14,7 +16,7 @@
@Api(tags = ["SubtaskController"], description = "巡查子任务API接口")
@RestController
@RequestMapping("/subtask")
class SubtaskController(val subtaskService: SubtaskService) {
class SubtaskController(val subtaskService: SubtaskService, private val bizLog: BizLog) {
    @GetMapping
    fun getAll() = subtaskService.findAll()
@@ -25,7 +27,17 @@
    fun addList(@RequestBody subtasklist: List<Subtask>) = subtaskService.saveList(subtasklist)
    @PostMapping
    fun update(@RequestBody subtask: Subtask) = subtaskService.update(subtask)
    fun update(@RequestBody subtask: Subtask): Int {
        val res = subtaskService.update(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
    }
    @GetMapping("/{id}")
    fun getById(@PathVariable id: String) = subtaskService.findByID(id)
@@ -76,9 +88,9 @@
    @ApiOperation("获取某类场景的巡查任务统计信息")
    @PostMapping("/summary/area")
    fun getSummaryByArea(
    fun getTaskProgressByArea(
        @RequestBody areaVo: AreaVo,
    ) = subtaskService.getSummaryByArea(areaVo)
    ) = resPack { subtaskService.getTaskProgressByArea(areaVo) }
    @ApiOperation("获取某个场景的巡查任务")
    @GetMapping("/byScene")
@@ -87,4 +99,10 @@
        @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) }
}