From 85ef942e7195abeb71466b7159c3ee30161e1e54 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 07 四月 2026 08:51:01 +0800
Subject: [PATCH] 2026.4.7

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ProblemlistServiceImpl.kt |  131 +++++++++++++++++++++++++++++++++----------
 1 files changed, 101 insertions(+), 30 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 0a1dca0..1b7cae2 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
@@ -13,6 +13,7 @@
 import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
 import cn.flightfeather.supervision.lightshare.service.MediafileService
 import cn.flightfeather.supervision.lightshare.service.ProblemlistService
+import cn.flightfeather.supervision.lightshare.service.SubtaskService
 import cn.flightfeather.supervision.lightshare.service.TaskService
 import cn.flightfeather.supervision.lightshare.vo.*
 import com.fasterxml.jackson.core.type.TypeReference
@@ -39,6 +40,8 @@
     val problemlistMapper: ProblemlistMapper,
     val inspectionMapper: InspectionMapper,
     val mediafileMapper: MediafileMapper,
+    private val subtaskService: SubtaskService,
+    private val subtaskMapper: SubtaskMapper,
     private val taskRep: TaskRep,
     private val subTaskRep: SubTaskRep,
     private val problemRep: ProblemRep,
@@ -105,6 +108,42 @@
         return problemListVolistTemp1
     }
 
+    override fun getBySceneMonth(sceneId: String, year: Int?, month: Int?): Pair<List<SubtaskVo>, List<ProblemListVo>> {
+        var _year = year
+        var _month = month
+        var lastSubTasks = listOf<SubtaskVo>()
+        if (year == null) {
+            lastSubTasks = subtaskService.findByDate(sceneId = sceneId)
+//            PageHelper.startPage<Problemlist>(1, 1)
+//            val lastProblem = problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
+//                createCriteria().andEqualTo("sguid", sceneId)
+//                orderBy("time").desc()
+//            }).takeIf { it.isNotEmpty() }?.get(0)
+            if (lastSubTasks.isEmpty()) {
+                return lastSubTasks to emptyList()
+            } else {
+                val lt = LocalDateTime.ofInstant(lastSubTasks[0].planstarttime?.toInstant(), ZoneId.systemDefault())
+                _year = lt.year
+                _month = lt.monthValue
+            }
+        }
+        val sT = LocalDateTime.of(_year!!, _month!!, 1, 0, 0, 0, 0)
+        val eT = sT.plusMonths(1).minusSeconds(1)
+        if (lastSubTasks.isEmpty()) {
+            lastSubTasks = subtaskMapper.selectByExample(Example(Subtask::class.java).apply {
+                createCriteria().andBetween("planstarttime", sT, eT)
+            }).map {
+                SubtaskVo().apply { BeanUtils.copyProperties(it, this) }
+            }
+        }
+        val problemList = problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
+            createCriteria().andBetween("time", sT,eT)
+                .andEqualTo("sguid", sceneId)
+            orderBy("time").desc()
+        }).map { ProblemListVo().apply { BeanUtils.copyProperties(it, this) } }
+        return lastSubTasks to problemList
+    }
+
     //鑾峰彇鏌愰《灞備换鍔′笅锛屾煇涓満鏅笅鐨勯棶棰樻暣鏀规儏鍐�
     override fun getStatisticalResultById(topTaskId: String, sceneTypeId: String): List<StatisticsVo> {
         val map = problemlistMapper.getStatisticalResultById(topTaskId, sceneTypeId)
@@ -130,11 +169,11 @@
 
     //鏍规嵁鍖哄幙銆佸満鏅被鍨嬨�佹椂闂磋幏鍙栧悇涓棶棰樻暟閲�
     override fun getStatisticalResult(areaVo: AreaVo): List<StatisticsVo> {
-        val districtcode = areaVo.districtcode
-        val sceneType = areaVo.scensetypeid
-        val startTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
-        val endTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
-        return problemlistMapper.getStatisticalResult(districtcode, startTime, endTime, sceneType, areaVo.sceneId)
+//        val districtcode = areaVo.districtcode
+//        val sceneType = areaVo.scensetypeid
+//        val startTime = areaVo.starttime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+//        val endTime = areaVo.endtime?.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+        return problemlistMapper.getStatisticalResult(areaVo)
     }
 
     override fun getChargeResult(areaVo: AreaVo): ChargeInfoVo {
@@ -314,12 +353,12 @@
 
     override fun delete(id: String): Int = problemlistMapper.deleteByPrimaryKey(id)
 
-    override fun setDeleteStatus(id: String): BaseResponse<Int> {
+    override fun setDeleteStatus(id: String): Int {
         val p = problemlistMapper.selectByPrimaryKey(id)
 
         return when {
-            p.ischanged == true -> BaseResponse(false, "闂宸叉暣鏀癸紝鏃犳硶鍒犻櫎", data = 0)
-            p.extension3 != Constant.PROBLEM_UNCHECKED -> BaseResponse(false, "闂宸插鏍革紝鏃犳硶鍒犻櫎", data = 0)
+            p.ischanged == true -> throw BizException("闂宸叉暣鏀癸紝鏃犳硶鍒犻櫎")
+            p.extension3 != Constant.PROBLEM_UNCHECKED -> throw BizException("闂宸插鏍革紝鏃犳硶鍒犻櫎")
             else -> {
                 // 2021/4/25 灏嗗師鏉ョ殑娣诲姞鍒犻櫎鐘舵�佹敼涓虹洿鎺ュ垹闄�
 //                p.remark = Constant.PROBLEM_DELETED
@@ -333,7 +372,7 @@
                     inspection.problemcount = inspection.problemcount!! - 1
                     inspectionMapper.updateByPrimaryKey(inspection)
                 }
-                BaseResponse(true, "闂鍒犻櫎鎴愬姛", data = i)
+                i
             }
         }
     }
@@ -372,11 +411,11 @@
         remark: String,
         userId: String,
         userName: String,
-    ): BaseResponse<String> {
-        if (action !in 0..3) {
-            return BaseResponse(false, "闈炴硶鐨勬搷浣滄寚浠�")
+    ): String {
+        if (action !in 0..5) {
+            throw BizException("闈炴硶鐨勬搷浣滄寚浠�")
         }
-        val p = problemlistMapper.selectByPrimaryKey(pId) ?: return BaseResponse(false, "闂涓嶅瓨鍦�")
+        val p = problemlistMapper.selectByPrimaryKey(pId) ?: throw BizException("闂涓嶅瓨鍦�")
         val subtask = p.stguid?.let { subTaskRep.findOne(it) }
         val response = BaseResponse<String>(true)
         var event = ""
@@ -397,6 +436,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) {
@@ -419,6 +466,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 +485,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 +504,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
+                    }
                 }
             }
         }
@@ -455,15 +524,15 @@
                 bizLog.info(WorkStreamLogInfo(userId, userName, event))
             }
         }
-        return response
+        return if (response.success) "闂瀹℃牳鎴愬姛" else throw BizException(response.message)
     }
 
-    override fun newProblem(problem: String, files: Array<MultipartFile>): BaseResponse<String> {
+    override fun newProblem(problem: String, files: Array<MultipartFile>): String {
         //json杞琽bject
         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 inspection = inspectionMapper.selectByPrimaryKey(problemVo.insGuid) ?: throw BizException("宸℃煡璁板綍涓嶅瓨鍦�")
+        val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: throw BizException("宸℃煡璁板綍瀵瑰簲鍦烘櫙涓嶅瓨鍦�")
         // 淇濆瓨闂
         val problemlist = ProblemListVo.newPro(inspection, problemVo, scene)
         problemlistMapper.insert(problemlist)
@@ -483,28 +552,29 @@
             bizLog.info(WorkStreamLogInfo(subtask?.executorguids, subtask?.executorrealtimes, event))
         }
 
-        return BaseResponse(true)
+        return "success"
     }
 
-    override fun updateProblem(problem: ProblemListVo, deleteImg: List<String>, files: Array<MultipartFile>): String {
+    override fun updateProblem(problem: ProblemListVo, deleteImg: List<String>?, files: Array<MultipartFile>): String {
         problemRep.findOne(problem.guid) ?: throw BizException("璇ラ棶棰樹笉瀛樺湪")
         problemRep.update(problem)
         val inspection = inspectionMapper.selectByPrimaryKey(problem.iguid) ?: throw BizException("宸℃煡璁板綍涓嶅瓨鍦�")
         val scene = scenseMapper.selectByPrimaryKey(inspection.sguid) ?: throw BizException("宸℃煡璁板綍瀵瑰簲鍦烘櫙涓嶅瓨鍦�")
         mediafileService.saveMediaFile(files) { MediaFileVo.newProFile(inspection, problem, scene) }
-        mediafileService.deleteList(deleteImg)
+        deleteImg?.let { mediafileService.deleteList(it) }
         return "success"
     }
 
-    override fun changeProblem(problemId: String, files: Array<MultipartFile>): BaseResponse<String> {
+
+    override fun changeProblem(problemId: String, files: Array<MultipartFile>): String {
         // 闂鍜岄棶棰樺浘鐗囧悎娉曟�ф鏌�
-        val p = problemlistMapper.selectByPrimaryKey(problemId) ?: return BaseResponse(false, "闂涓嶅瓨鍦�")
+        val p = problemlistMapper.selectByPrimaryKey(problemId) ?: throw BizException("闂涓嶅瓨鍦�")
         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, "闂涓嶅瓨鍦ㄦ垨宸叉暣鏀癸紝鏃犳硶閲嶅鏁存敼")
+        if (mediaFiles.isEmpty()) throw BizException("闂涓嶅瓨鍦ㄦ垨宸叉暣鏀癸紝鏃犳硶閲嶅鏁存敼")
 
         // 鏇存柊闂
         p.apply {
@@ -537,7 +607,7 @@
             }
         }
 
-        return BaseResponse(true)
+        return "success"
     }
 
     override fun updateChange(problemId: String, deleteImg: List<String>, files: Array<MultipartFile>): String {
@@ -545,9 +615,10 @@
         val mediaFiles = mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
             createCriteria().andEqualTo("businessguid", problemId)
                 .andEqualTo("businesstypeid", 1)
-                .andEqualTo("ischanged", true)
+//                .andEqualTo("ischanged", true)
         })
-        if (mediaFiles.isEmpty()) throw BizException("闂杩樻湭鏁存敼锛屾棤娉曚慨鏀规暣鏀�")
+        if (mediaFiles.isEmpty()) throw BizException("缂哄皯闂鍜屾暣鏀瑰浘鐗囷紝鏃犳硶淇敼")
+        if (p.ischanged != true) throw BizException("鏈暣鏀归棶棰樻棤娉曚慨鏀�")
 
         // 淇濆瓨鏂扮殑鏁存敼鍥剧墖
         val m = mediaFiles[0]
@@ -556,6 +627,7 @@
             m.apply {
                 guid = UUIDGenerator.generate16ShortUUID()
                 description = p.problemname + " " + p.location + " 鏁存敼 " + UUIDGenerator.generateUUID(4) + ".jpg"
+                ischanged = true
             }
         }
         mediafileService.deleteList(deleteImg)
@@ -595,14 +667,13 @@
 
     override fun getSceneProSummary(
         areaVo: AreaVo,
-        sortBy: String,
         page: Int,
         per_page: Int,
     ): Pair<DataHead?, List<SceneProblemSummary>?> {
-        areaVo.scensetypeid ?: throw BizException("缂哄皯鍦烘櫙绫诲瀷鍙傛暟")
-        val task = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒板搴旂殑宸℃煡鎬讳换鍔�")
+//        areaVo.scensetypeid ?: throw BizException("缂哄皯鍦烘櫙绫诲瀷鍙傛暟")
+//        val task = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒板搴旂殑宸℃煡鎬讳换鍔�")
         val p = PageHelper.startPage<SceneProblemSummary>(page, per_page)
-        val res = problemRep.selectSceneProSummary(task.tguid!!, areaVo.scensetypeid!!, areaVo.sort, sortBy)
+        val res = problemRep.selectSceneProSummary(areaVo)
         return DataHead(p.pageNum, p.pages, p.total) to res
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3