From 0674dea7dd0e75199c0c200e6a41070c25677082 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 19 十一月 2024 14:58:16 +0800
Subject: [PATCH] 问题整改的审核撤回

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt |  125 +++++++++++++++++++++++------------------
 1 files changed, 69 insertions(+), 56 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
index e84b05a..640585d 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt
@@ -373,7 +373,7 @@
         userId: String,
         userName: String,
     ): BaseResponse<String> {
-        if (action !in 0..3) {
+        if (action !in 0..5) {
             return BaseResponse(false, "闈炴硶鐨勬搷浣滄寚浠�")
         }
         val p = problemlistMapper.selectByPrimaryKey(pId) ?: return BaseResponse(false, "闂涓嶅瓨鍦�")
@@ -398,6 +398,14 @@
                         response.success = false
                         response.message = "闂鎻愪氦杩樻湭瀹℃牳锛屾棤娉曡繘琛屾暣鏀瑰鏍革紒"
                     }
+                    4.toByte() -> {
+                        response.success = false
+                        response.message = "闂鎻愪氦杩樻湭瀹℃牳锛屾棤娉曡繘琛屾挙鍥炲鏍革紒"
+                    }
+                    5.toByte() -> {
+                        response.success = false
+                        response.message = "闂鏁存敼杩樻湭鎻愪氦锛屾棤娉曡繘琛屾挙鍥炲鏍革紒"
+                    }
                 }
             } else if (extension3 == Constant.PROBLEM_CHECK_PASS || extension3 == Constant.PROBLEM_CHECK_FAIL) {
                 when (action) {
@@ -419,6 +427,13 @@
                             response.message = "闂杩樻湭鏁存敼锛屾棤娉曡繘琛屾暣鏀瑰鏍革紒鎿嶄綔鏃犳晥"
                         }
                     }
+                    4.toByte() -> {
+                        extension3 = Constant.PROBLEM_UNCHECKED
+                    }
+                    5.toByte() -> {
+                        response.success = false
+                        response.message = "闂鏁存敼杩樻湭瀹℃牳锛屾棤娉曡繘琛屾暣鏀瑰鏍告挙鍥炴搷浣滐紒鎿嶄綔鏃犳晥"
+                    }
                 }
             } else if (extension3 == Constant.CHANGE_UNCHECKED) {
                 event = "鍦�${subtask?.scensename}瀹℃牳浜嗕竴涓暣鏀�"
@@ -431,6 +446,14 @@
                     }
                     2.toByte() -> extension3 = Constant.CHANGE_CHECK_PASS
                     3.toByte() -> extension3 = Constant.CHANGE_CHECK_FAIL
+                    4.toByte() -> {
+                        response.success = false
+                        response.message = "闂鏁存敼杩樻湭瀹℃牳锛屾棤娉曡繘琛屾挙鍥炲鏍革紒"
+                    }
+                    5.toByte() -> {
+                        response.success = false
+                        response.message = "闂鎻愪氦宸插鏍革紝骞朵笖宸茶鏁存敼銆傛搷浣滄棤鏁�"
+                    }
                 }
             } else if (extension3 == Constant.CHANGE_CHECK_PASS || extension3 == Constant.CHANGE_CHECK_FAIL) {
                 when (action) {
@@ -442,6 +465,13 @@
                     }
                     2.toByte() -> extension3 = Constant.CHANGE_CHECK_PASS
                     3.toByte() -> extension3 = Constant.CHANGE_CHECK_FAIL
+                    4.toByte() -> {
+                        response.success = false
+                        response.message = "闂鎻愪氦宸插鏍革紝骞朵笖宸茶鏁存敼锛屾棤娉曡繘琛岄棶棰樺鏍告挙閿�鎿嶄綔銆傛搷浣滄棤鏁�"
+                    }
+                    5.toByte() -> {
+                        extension3 = Constant.CHANGE_UNCHECKED
+                    }
                 }
             }
         }
@@ -459,20 +489,17 @@
     }
 
     override fun newProblem(problem: String, files: Array<MultipartFile>): BaseResponse<String> {
-        val mapper = ObjectMapper()
-
         //json杞琽bject
-        val problemVo = mapper.readValue(problem, object : TypeReference<ProblemVo>() {})
+        val problemVo = ObjectMapper().readValue(problem, object : TypeReference<ProblemVo>() {})
 
         val inspection = inspectionMapper.selectByPrimaryKey(problemVo.insGuid) ?: return BaseResponse(false, "宸℃煡璁板綍涓嶅瓨鍦�")
         val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: return BaseResponse(false, "宸℃煡璁板綍瀵瑰簲鍦烘櫙涓嶅瓨鍦�")
-
         // 淇濆瓨闂
         val problemlist = ProblemListVo.newPro(inspection, problemVo, scene)
         problemlistMapper.insert(problemlist)
 
         // 淇濆瓨鍥剧墖
-        saveProFile(problemlist, inspection, scene, files)
+        mediafileService.saveMediaFile(files) { MediaFileVo.newProFile(inspection, problemlist, scene) }
 
         //鏇存柊宸℃煡淇℃伅鐨勯棶棰樻暟
         if (inspection.problemcount != null) {
@@ -491,41 +518,25 @@
 
     override fun updateProblem(problem: ProblemListVo, deleteImg: List<String>, files: Array<MultipartFile>): String {
         problemRep.findOne(problem.guid) ?: throw BizException("璇ラ棶棰樹笉瀛樺湪")
-        val inspection = inspectionMapper.selectByPrimaryKey(problem.guid) ?: throw BizException("宸℃煡璁板綍涓嶅瓨鍦�")
+        problemRep.update(problem)
+        val inspection = inspectionMapper.selectByPrimaryKey(problem.iguid) ?: throw BizException("宸℃煡璁板綍涓嶅瓨鍦�")
         val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: throw BizException("宸℃煡璁板綍瀵瑰簲鍦烘櫙涓嶅瓨鍦�")
-        saveProFile(problem, inspection, scene, files)
+        mediafileService.saveMediaFile(files) { MediaFileVo.newProFile(inspection, problem, scene) }
         mediafileService.deleteList(deleteImg)
         return "success"
     }
 
-    override fun saveProFile(
-        problemlist: Problemlist,
-        inspection: Inspection,
-        scene: Scense,
-        files: Array<MultipartFile>,
-    ): Int {
-        var res = 0
-        // 淇濆瓨鍥剧墖
-        for (image in files) {
-            val mediaFile = MediaFileVo.newProFile(inspection, problemlist, scene)
-            res += mediafileMapper.insert(mediaFile)
-
-            val path = mediaFile.extension1
-            val fileName = mediaFile.guid + ".jpg"
-            val filePath = "${imgPath}/$path/"
-            try {
-                //璋冪敤鏂囦欢淇濆瓨鏂规硶
-                FileUtil.uploadFile(image.bytes, filePath, fileName)
-            } catch (e: Exception) {
-                // TODO: handle exception
-            }
-        }
-        return res
-    }
-
     override fun changeProblem(problemId: String, files: Array<MultipartFile>): BaseResponse<String> {
-        // 鏇存柊闂
+        // 闂鍜岄棶棰樺浘鐗囧悎娉曟�ф鏌�
         val p = problemlistMapper.selectByPrimaryKey(problemId) ?: return BaseResponse(false, "闂涓嶅瓨鍦�")
+        val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
+            createCriteria().andEqualTo("businessguid", p.guid)
+                .andEqualTo("businesstypeid", 1)
+                .andEqualTo("ischanged", false)
+        })
+        if (mediaFiles.isEmpty()) return BaseResponse(false, "闂涓嶅瓨鍦ㄦ垨宸叉暣鏀癸紝鏃犳硶閲嶅鏁存敼")
+
+        // 鏇存柊闂
         p.apply {
             ischanged = true
             changedtime = Date()
@@ -544,41 +555,43 @@
         }
         problemlistMapper.updateByPrimaryKey(p)
 
-        // 淇濆瓨鍥剧墖
-        val now = LocalDateTime.now()
-        val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
-            createCriteria().andEqualTo("businessguid", p.guid)
-                .andEqualTo("businesstypeid", 1)
-                .andEqualTo("ischanged", false)
-        })
-        if (mediaFiles.isEmpty()) return BaseResponse(false, "鍦烘櫙闂鏁伴噺涓�0锛屾棤娉曟暣鏀�")
+        // 淇濆瓨鏁存敼鍥剧墖
         val m = mediaFiles[0]
         m.path = m.path + "鏁存敼/"
         m.savetime = Date()
         m.ischanged = true
-
-        for (image in files) {
+        mediafileService.saveMediaFile(files) {
             m.apply {
                 guid = UUIDGenerator.generate16ShortUUID()
                 description = p.problemname + " " + p.location + " 鏁存敼 " + UUIDGenerator.generateUUID(4) + ".jpg"
             }
-            mediafileMapper.insert(m)
-
-            val path = m.extension1
-            val fileName = m.guid + ".jpg"
-//            val filePath = "E:\\work\\绗笁鏂圭洃绠pp\\鑷姩璇勫垎\\椁愰ギ\\"
-            val filePath = "${imgPath}/$path"
-            try {
-                //璋冪敤鏂囦欢淇濆瓨鏂规硶
-                FileUtil.uploadFile(image.bytes, filePath, fileName)
-            } catch (e: Exception) {
-                println(e)
-            }
         }
 
         return BaseResponse(true)
     }
 
+    override fun updateChange(problemId: String, deleteImg: List<String>, files: Array<MultipartFile>): String {
+        val p = problemRep.findOne(problemId) ?: throw BizException("璇ラ棶棰樹笉瀛樺湪")
+        val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
+            createCriteria().andEqualTo("businessguid", problemId)
+                .andEqualTo("businesstypeid", 1)
+                .andEqualTo("ischanged", true)
+        })
+        if (mediaFiles.isEmpty()) throw BizException("闂杩樻湭鏁存敼锛屾棤娉曚慨鏀规暣鏀�")
+
+        // 淇濆瓨鏂扮殑鏁存敼鍥剧墖
+        val m = mediaFiles[0]
+        m.savetime = Date()
+        mediafileService.saveMediaFile(files) {
+            m.apply {
+                guid = UUIDGenerator.generate16ShortUUID()
+                description = p.problemname + " " + p.location + " 鏁存敼 " + UUIDGenerator.generateUUID(4) + ".jpg"
+            }
+        }
+        mediafileService.deleteList(deleteImg)
+        return "success"
+    }
+
     override fun getBySubTask(stGuid: String, all: Boolean?): List<ProblemListVo> {
         //鏍规嵁瀛愪换鍔D鑾峰彇闂鍒楄〃
         val problemListVo = mutableListOf<ProblemListVo>()

--
Gitblit v1.9.3