From 0392c333ed3d987cb2ab3dac4e1a972cff405f21 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 25 四月 2024 17:42:08 +0800
Subject: [PATCH] 1. 新增后台任务关联模块 2. 新增自动评分后台任务; 3. 修复部分bug

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/InspectionServiceImpl.kt |   51 +++++++++++++++++++--------------------------------
 1 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/InspectionServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/InspectionServiceImpl.kt
index b73efb9..2240ac3 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/InspectionServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/InspectionServiceImpl.kt
@@ -1,9 +1,11 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.domain.ds1.entity.Inspection
 import cn.flightfeather.supervision.domain.ds1.mapper.InspectionMapper
 import cn.flightfeather.supervision.common.utils.DateUtil
 import cn.flightfeather.supervision.common.utils.UUIDGenerator
+import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
 import cn.flightfeather.supervision.lightshare.service.*
 import cn.flightfeather.supervision.lightshare.vo.*
 import org.springframework.beans.BeanUtils
@@ -12,7 +14,10 @@
 import tk.mybatis.mapper.entity.Example
 
 @Service
-class InspectionServiceImpl(val inspectionMapper: InspectionMapper) : InspectionService {
+class InspectionServiceImpl(
+    val inspectionMapper: InspectionMapper,
+    private val taskRep: TaskRep,
+) : InspectionService {
 
     @Autowired
     lateinit var problemlistService: ProblemlistService
@@ -29,32 +34,12 @@
     @Autowired
     lateinit var subtaskService: SubtaskService
 
+    private val dateUtil = DateUtil()
+
     //鑾峰彇姹℃煋鍦烘櫙鐗堟湰涓婚〉鐨勭洃绠℃儏鍐靛睍绀哄唴瀹�
-    override fun getInspectionInfoByScene(sceneId: String, topTaskId: String): InspectionInfoVo {
-        val maps = inspectionMapper.getInspectionInfoByScene(sceneId, topTaskId)
-        val inspectionInfoVo = InspectionInfoVo()
-        if (maps.isNotEmpty()) {
-            val map = maps[0]
-            if (map.isNotEmpty()) {
-                inspectionInfoVo.topTaskid = map["topTaskId"].toString()
-                inspectionInfoVo.topTaskName = map["topTaskName"].toString()
-                inspectionInfoVo.sceneId = map["sceneId"].toString()
-                inspectionInfoVo.sceneName = map["sceneName"].toString()
-                inspectionInfoVo.inspectionId = map["inspectionId"].toString()
-                inspectionInfoVo.subtaskId = map["subtaskId"].toString()
-                inspectionInfoVo.inspected = map["isInspected"].toString().equals("1")
-                inspectionInfoVo.inspectionTime = map["inspectionTime"].toString()
-                val time = inspectionInfoVo.inspectionTime
-                inspectionInfoVo.inspectionTime = time?.substring(0, time.length-11)
-                inspectionInfoVo.inspectionTimes = map["inspectionTimes"].toString().toInt()
-                inspectionInfoVo.promised = map["isPromised"].toString().equals("1")
-                inspectionInfoVo.changed = map["isChanged"].toString().equals("1")
-                inspectionInfoVo.unChangedCount = map["unChangedCount"].toString().toInt()
-                inspectionInfoVo.changedCount = map["changedCount"].toString().toInt()
-                inspectionInfoVo.promisedTime = map["promisedTime"].toString()
-            }
-        }
-        return inspectionInfoVo
+    override fun getInspectionInfoByScene(sceneId: String, topTaskId: String): InspectionInfoVo? {
+        val resList = inspectionMapper.getInspectionInfoByScene(sceneId, topTaskId)
+        return if (resList.isNotEmpty()) resList[0] else InspectionInfoVo()
     }
 
     //鏍规嵁宸℃煡ID鑾峰彇闂鍒楄〃
@@ -238,12 +223,14 @@
 
     override fun delete(id: String): Int = inspectionMapper.deleteByPrimaryKey(id)
 
-    override fun getStatistic(topTaskId: String, sceneTypeId: String): BaseResponse<List<InspectionStatisticVo>> {
+    override fun getStatistic(topTaskId: String, sceneTypeId: String): List<InspectionStatisticVo> {
         val result = inspectionMapper.getStatistic(topTaskId, sceneTypeId)
-        return if (result.isNotEmpty()) {
-            BaseResponse(true, data = result)
-        } else {
-            BaseResponse(false)
-        }
+        return result.ifEmpty { throw BizException("鏃犲贰鏌ヨ褰�") }
+    }
+
+    override fun getStatistic(areaVo: AreaVo): List<InspectionStatisticVo> {
+        areaVo.scensetypeid ?: throw BizException("璇锋眰鍙傛暟requestBody涓満鏅被鍨媠censetypeid涓嶈兘涓虹┖")
+        val topTask = taskRep.findOneTask(areaVo) ?: throw BizException("鏈壘鍒扮浉鍏冲贰鏌ユ�讳换鍔�")
+        return getStatistic(topTask.tguid!!, areaVo.scensetypeid!!)
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3