From 6c7f45871b93ef26d353a5a3596701ac2f39ed9c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 10 九月 2024 17:48:27 +0800
Subject: [PATCH] 1. 新增问题更新接口

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt |   43 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt
index de6e270..8baf3fa 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ProblemlistController.kt
@@ -1,8 +1,13 @@
 package cn.flightfeather.supervision.lightshare.web
 
+import cn.flightfeather.supervision.common.log.BizLog
+import cn.flightfeather.supervision.common.log.WorkStreamLogInfo
 import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
 import cn.flightfeather.supervision.lightshare.service.ProblemlistService
+import cn.flightfeather.supervision.lightshare.service.SubtaskService
 import cn.flightfeather.supervision.lightshare.vo.*
+import com.fasterxml.jackson.core.type.TypeReference
+import com.fasterxml.jackson.databind.ObjectMapper
 import io.swagger.annotations.Api
 import io.swagger.annotations.ApiOperation
 import io.swagger.annotations.ApiParam
@@ -12,7 +17,10 @@
 @Api(tags = ["ProblemlistController"], description = "鐩戠闂API鎺ュ彛")
 @RestController
 @RequestMapping("/problemlist")
-class ProblemlistController(val problemlistService: ProblemlistService) {
+class ProblemlistController(
+    val problemlistService: ProblemlistService,
+    val subtaskService: SubtaskService, private val bizLog: BizLog,
+) {
     @GetMapping
     fun getAll() = problemlistService.findAll()
 
@@ -20,7 +28,15 @@
     fun add(@RequestBody problemlist: Problemlist) = problemlistService.save(problemlist)
 
     @PostMapping
-    fun update(@RequestBody problemlist: Problemlist) = problemlistService.update(problemlist)
+    fun update(@RequestBody problemlist: Problemlist):Int{
+        val res = problemlistService.update(problemlist)
+        problemlist.stguid?.let {
+            val subtask = subtaskService.findByID(it)
+            val event = "鍦�${subtask.scensename}鏂板涓�涓棶棰�"
+            bizLog.info(WorkStreamLogInfo(subtask.executorguids, subtask.executorrealtimes, event))
+        }
+        return res
+    }
 
     @GetMapping("/{id}")
     fun getById(@PathVariable id: String) = problemlistService.findByID(id)
@@ -32,15 +48,15 @@
     fun setDeleteStatus(@PathVariable id: String) = problemlistService.setDeleteStatus(id)
 
     @PostMapping("/add")
-    fun addProblem(@RequestBody problemlistVo: ProblemlistVo) {
+    fun addProblem(@RequestBody problemlistVo: ProblemListVo) {
         problemlistService.addProblem(problemlistVo)
     }
 
     @PostMapping("/getbyarea")
-    fun getByArea(@RequestBody areaVo: AreaVo): List<ProblemlistVo> = problemlistService.getByArea(areaVo)
+    fun getByArea(@RequestBody areaVo: AreaVo): List<ProblemListVo> = problemlistService.getByArea(areaVo)
 
     @GetMapping("/getbytoptask")
-    fun getByTopTask(@RequestParam(value = "tguid", required = true) tguid: String): List<ProblemlistVo> =
+    fun getByTopTask(@RequestParam(value = "tguid", required = true) tguid: String): List<ProblemListVo> =
         problemlistService.getByTopTask(tguid)
 
     @PostMapping("/getStatisticalResult")
@@ -60,7 +76,7 @@
     fun getProblemsByScene(
         @RequestParam(value = "sceneId", required = true) sceneId: String,
         @RequestParam date: String,
-    ): List<ProblemlistVo> = problemlistService.getProblemByScene(sceneId, date)
+    ): List<ProblemListVo> = problemlistService.getProblemByScene(sceneId, date)
 
     @GetMapping("/month_anlysis")
     fun getMonthProblemsById(
@@ -82,10 +98,21 @@
     @ApiOperation(value = "鏂板涓�涓棶棰�", notes = "绠�鍖栦笂浼犳墍闇�闂淇℃伅锛屽皢澶ч儴鍒嗘搷浣滀氦鐢卞悗鍙板畬鎴�")
     @PostMapping("/newProblem")
     fun newProblem(
-        @RequestParam("problemVo") problemVo: String,
-        @RequestPart("images") files: Array<MultipartFile>,
+        @ApiParam("闂淇℃伅json") @RequestParam("problemVo") problemVo: String,
+        @ApiParam("闂鍥剧墖") @RequestPart("images") files: Array<MultipartFile>,
     ) = problemlistService.newProblem(problemVo, files)
 
+    @ApiOperation("鏇存柊涓�涓棶棰�")
+    @PostMapping("/updateProblem")
+    fun updateDeviceLocation(
+        @ApiParam("闂淇℃伅json") @RequestParam("problem") problem: String,
+        @ApiParam("鍒犻櫎鐨勯棶棰樺浘鐗噄d") @RequestParam("deleteImg") deleteImg: List<String>,
+        @ApiParam("闂鍥剧墖") @RequestPart("images") images: Array<MultipartFile>,
+    ) = resPack {
+        val problemVo = ObjectMapper().readValue(problem, object : TypeReference<ProblemListVo>() {})
+        problemlistService.updateProblem(problemVo, deleteImg, images)
+    }
+
     @ApiOperation(value = "鏁存敼涓�涓棶棰�", notes = "绠�鍖栦笂浼犳墍闇�闂淇℃伅锛屽皢澶ч儴鍒嗘搷浣滀氦鐢卞悗鍙板畬鎴�")
     @PostMapping("/changeProblem")
     fun changeProblem(

--
Gitblit v1.9.3