From 9de446b0b83610055437fbc5172d216bb374900f Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 21 十一月 2024 09:22:19 +0800
Subject: [PATCH] 1. 2024.11.21 修复部分bug

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt |  405 +++++++++++++++++++++++----------------------------------
 1 files changed, 162 insertions(+), 243 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
index b4118b8..62f46fb 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt
@@ -1,15 +1,14 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
-import cn.flightfeather.supervision.business.AutoScore
-import cn.flightfeather.supervision.business.AutoScore2
-import cn.flightfeather.supervision.business.storage.StAutoScore
-import cn.flightfeather.supervision.business.storage.item.StScoreItem_1
-import cn.flightfeather.supervision.business.storage.item.StScoreItem_2
+import cn.flightfeather.supervision.business.autooutput.score.AopEvaluation
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.domain.ds1.entity.*
 import cn.flightfeather.supervision.domain.ds1.mapper.*
 import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.common.utils.DateUtil
 import cn.flightfeather.supervision.common.utils.UUIDGenerator
+import cn.flightfeather.supervision.domain.ds1.repository.SubTaskRep
+import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
 import cn.flightfeather.supervision.lightshare.service.SubtaskService
 import cn.flightfeather.supervision.lightshare.service.TaskService
 import cn.flightfeather.supervision.lightshare.vo.*
@@ -20,17 +19,18 @@
 import org.springframework.transaction.annotation.Transactional
 import tk.mybatis.mapper.entity.Example
 import tk.mybatis.mapper.util.StringUtil
+import java.time.LocalDateTime
 import java.util.*
+import kotlin.math.ceil
 
 @Service
-class SubtaskServiceImpl(val subtaskMapper: SubtaskMapper) : SubtaskService {
+class SubtaskServiceImpl(
+    private val subtaskMapper: SubtaskMapper,
+    private val aopEvaluation: AopEvaluation,
+    private val taskRep: TaskRep,
+    private val subTaskRep: SubTaskRep,
+) : SubtaskService {
 
-    val dateUtil = DateUtil()
-
-    @Autowired
-    lateinit var scoreItem1: StScoreItem_1
-    @Autowired
-    lateinit var scoreItem2: StScoreItem_2
     @Autowired
     lateinit var taskService: TaskService
     @Autowired
@@ -64,7 +64,7 @@
         if (StringUtil.isNotEmpty(areaVo.towncode))
             criteria.andEqualTo("towncode", areaVo.towncode)
         criteria.andBetween("planstarttime", areaVo.starttime, areaVo.endtime)
-        if (!Objects.equals(userGuid, Constant.UserType.ALLUSER.text))
+        if (!Objects.equals(userGuid, Constant.UserType.ALL_USER.des))
             criteria.andLike("executorguids","%"+userGuid+"%")
         var completecount = 0
         var subtasklist = subtaskMapper.selectByExample(example)
@@ -149,6 +149,7 @@
     @Transactional
     override fun saveList(subtasklist: List<Subtask>): Int {
         subtasklist.forEach {
+            if (it.stguid == null) it.stguid = UUIDGenerator.generate16ShortUUID()
             subtaskMapper.insert(it)
         }
         return subtasklist.size
@@ -186,25 +187,25 @@
             dateString = date.substring(0, 7)
         }
         //鍒ゆ柇鍙傛暟鏄惁姝g‘
-        if (dateUtil.StringToDate(dateString) == null) {
+        if (DateUtil.StringToDate(dateString) == null) {
             return taskPackList
         }
         //鏍规嵁type绫诲瀷,寰楀埌鍏蜂綋鏄鍝笁涓湀鏁版嵁
         when (type) {
             "Middle" -> {
-                one = dateUtil.addMonth(dateString, -1)
+                one = DateUtil.addMonth(dateString, -1)
                 two = dateString
-                three = dateUtil.addMonth(dateString, 1)
+                three = DateUtil.addMonth(dateString, 1)
             }
             "Left" -> {
-                one = dateUtil.addMonth(dateString, 1)
-                two = dateUtil.addMonth(dateString, 2)
-                three = dateUtil.addMonth(dateString, 3)
+                one = DateUtil.addMonth(dateString, 1)
+                two = DateUtil.addMonth(dateString, 2)
+                three = DateUtil.addMonth(dateString, 3)
             }
             "Right" -> {
-                one = dateUtil.addMonth(dateString, -1)
-                two = dateUtil.addMonth(dateString, -2)
-                three = dateUtil.addMonth(dateString, -3)
+                one = DateUtil.addMonth(dateString, -1)
+                two = DateUtil.addMonth(dateString, -2)
+                three = DateUtil.addMonth(dateString, -3)
             }
             else -> {
                 //鍙傛暟涓嶆纭氨杩斿洖
@@ -240,25 +241,25 @@
             dateString = date.substring(0, 7)
         }
         //鍒ゆ柇鍙傛暟鏄惁姝g‘
-        if (dateUtil.StringToDate(dateString) == null) {
+        if (DateUtil.StringToDate(dateString) == null) {
             return taskPackList
         }
         //鏍规嵁type绫诲瀷,寰楀埌鍏蜂綋鏄鍝笁涓湀鏁版嵁
         when (type) {
             "Middle" -> {
-                one = dateUtil.addMonth(dateString, -1)
+                one = DateUtil.addMonth(dateString, -1)
                 two = dateString
-                three = dateUtil.addMonth(dateString, 1)
+                three = DateUtil.addMonth(dateString, 1)
             }
             "Left" -> {
-                one = dateUtil.addMonth(dateString, 1)
-                two = dateUtil.addMonth(dateString, 2)
-                three = dateUtil.addMonth(dateString, 3)
+                one = DateUtil.addMonth(dateString, 1)
+                two = DateUtil.addMonth(dateString, 2)
+                three = DateUtil.addMonth(dateString, 3)
             }
             "Right" -> {
-                one = dateUtil.addMonth(dateString, -1)
-                two = dateUtil.addMonth(dateString, -2)
-                three = dateUtil.addMonth(dateString, -3)
+                one = DateUtil.addMonth(dateString, -1)
+                two = DateUtil.addMonth(dateString, -2)
+                three = DateUtil.addMonth(dateString, -3)
             }
             else -> {
                 //鍙傛暟涓嶆纭氨杩斿洖
@@ -383,18 +384,21 @@
 
     override fun findAll(): MutableList<Subtask> = subtaskMapper.selectAll()
 
-    override fun save(subtask: Subtask): Int = subtaskMapper.insert(subtask)
+    override fun save(subtask: Subtask): Int {
+        if (subtask.stguid == null) subtask.stguid = UUIDGenerator.generate16ShortUUID()
+        return subtaskMapper.insert(subtask)
+    }
 
-    //鏇存柊瀛愪换鍔�
     override fun update(subtask: Subtask): Int {
+        var res = 0
         //鏍规嵁瀛愪换鍔uid鑾峰彇椤跺眰浠诲姟
         val toptaskVo = taskService.findByID(subtask.tguid.toString())
 
 //        //鏍规嵁鏃ユ湡鑾峰彇鏃ヤ换鍔�
-//        val daytaskVo = taskService.findByDate(dateUtil.getDate(subtask.planstarttime)!!)
+        val daytaskVo = taskService.findByDate(subtask.tguid!!, DateUtil.getDate(subtask.planstarttime)!!)
 
-        //2019.3.1 by Riku 搴旇鐩存帴鏍规嵁瀛愪换鍔$殑鏃ヤ换鍔d鏌ヨ鏃ヤ换鍔�
-        val daytaskVo = taskService.findByID(subtask.tsguid!!)
+        //搴旇鐩存帴鏍规嵁瀛愪换鍔$殑鏃ヤ换鍔d鏌ヨ鏃ヤ换鍔�
+//        val daytaskVo = taskService.findByID(subtask.tsguid!!)
 
         //鍒ゆ柇鏄惁鏈夋棩浠诲姟
         if (StringUtil.isEmpty(daytaskVo.tguid)) {
@@ -405,20 +409,20 @@
             task.tsguid = toptaskVo.tguid
             task.tguid = guid
             task.name = subtask.name
-            task.starttime = dateUtil.StringToDate(dateUtil.getDate(subtask.planstarttime)!!.substring(0, 10))
+            task.starttime = DateUtil.StringToDate(DateUtil.getDate(subtask.planstarttime)!!.substring(0, 10))
             task.endtime =
-                    dateUtil.StringToDate(dateUtil.getDate(subtask.planstarttime)!!.substring(0, 10) + " 23:59:59")
+                DateUtil.StringToDate(DateUtil.getDate(subtask.planstarttime)!!.substring(0, 10) + " 23:59:59")
             //****鏃ヤ换鍔℃墽琛岀姸鎬佺户鎵垮瓙浠诲姟鐨勭姸鎬�*锛堜慨鏀癸級***
             task.runingstatus = subtask.status
             //********************************************
             taskService.save(task)
             subtask.tsguid = guid
-            subtaskMapper.updateByPrimaryKeySelective(subtask)
+            res = subtaskMapper.updateByPrimaryKeySelective(subtask)
         } else {
-//            subtask.tsguid = daytaskVo.tguid
+            subtask.tsguid = daytaskVo.tguid
             //*锛堜慨鏀癸級*鏃ヤ换鍔℃鍦ㄦ墽琛岋紝瀛愪换鍔$粨鏉燂紝閬嶅巻鎵�鏈夊叾浣欏瓙浠诲姟锛岄兘鏄粨鏉熸椂鎵嶅皢鏃ヤ换鍔′慨鏀逛负缁撴潫****
             if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text
-                    && daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text){
+                && daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text){
                 val subtaskVolist = findByDayTaskID(daytaskVo.tguid!!)
                 var bool = false
                 subtaskVolist.forEach {
@@ -429,6 +433,7 @@
                 if (!bool){
                     daytaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text
                 }
+
             }
             //涓よ�呯姸鎬佺浉鍚屾椂涓嶅仛淇敼锛屽叾浣欐儏鍐垫棩浠诲姟閮戒负姝e湪鎵ц
             else if (subtask.status != daytaskVo.runingstatus){
@@ -438,33 +443,13 @@
             BeanUtils.copyProperties(daytaskVo, daytask)
             taskMapper.updateByPrimaryKeySelective(daytask)
             //****************************************************************************************
-            subtaskMapper.updateByPrimaryKeySelective(subtask)
+            res = subtaskMapper.updateByPrimaryKeySelective(subtask)
         }
+        return res
+    }
 
-        //鍒ゆ柇瀵瑰簲椤跺眰浠诲姟鐨勬墽琛岀姸鎬�
-        val daytaskVolist = taskService.getDayTaskByTaskID(toptaskVo.tguid!!)
-        val iterator: Iterator<TaskVo> = daytaskVolist.iterator()
-        if (daytaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS3.text
-                && toptaskVo.runingstatus == Constant.TaskProgress.RUNINGSTATUS2.text) {
-            var bool = false
-            while (iterator.hasNext()) {
-                val tmp = iterator.next()
-                if (tmp.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) {
-                    bool = true
-                    break
-                }
-            }
-            if (!bool){
-                toptaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS3.text
-            }
-        }
-        else if (daytaskVo.runingstatus != toptaskVo.runingstatus){
-            toptaskVo.runingstatus = Constant.TaskProgress.RUNINGSTATUS2.text
-        }
-        val toptask = Task()
-        BeanUtils.copyProperties(toptaskVo, toptask)
-        taskMapper.updateByPrimaryKeySelective(toptask)
-
+    override fun changeStatus(subtask: Subtask): Int {
+        val res = update(subtask)
         //瀵瑰凡缁撴潫鐨勫瓙浠诲姟杩涜鑷姩璇勫垎
         if (subtask.status == Constant.TaskProgress.RUNINGSTATUS3.text) {
             val example = Example(Evaluation::class.java)
@@ -472,23 +457,11 @@
             criteria.andEqualTo("stguid", subtask.stguid)
             val result = evaluationMapper.selectByExample(example)
             if (result.isEmpty()) {
-//                if (subtask.districtname == "寰愭眹鍖�") {
-//                    val autoScore = AutoScore2()
-//                    autoScore.subtask = subtask
-//                    autoScore.calculateScore()
-//                } else {
-//                    val autoScore = AutoScore()
-//                    autoScore.subtask = subtask
-//                    autoScore.calculateScore()
-//                }
-                val s = scenseMapper.selectByPrimaryKey(subtask.scenseid)
-                val autoScore = StAutoScore(scoreItem1, scoreItem2)
-                autoScore.sceneType = Constant.ScenseType.getByValue(s.typeid?.toString())
-                autoScore.sceneGrade(subtask)
+                aopEvaluation.executeBySubTask(subtask)
             }
         }
 
-        return 1
+        return res
     }
 
     override fun delete(id: String): Int{
@@ -509,15 +482,13 @@
             createCriteria().andEqualTo("tid", topTaskId).andEqualTo("sguid", sceneId)
         })
         mList.forEach {
-            if (it.monitornum == null) {
-                it.monitornum = 0
-            } else {
-                it.monitornum = it.monitornum!! - 1
-                if (it.monitornum!! < 0) {
-                    it.monitornum = 0
-                }
+            var count = it.extension1?.toIntOrNull() ?: 0
+            count--
+            if (count < 0) {
+                count = 0
             }
-            monitorobjectversionMapper.insert(it)
+            it.extension1 = count.toString()
+            monitorobjectversionMapper.updateByPrimaryKeySelective(it)
         }
 
         // 鍚屾椂鍒犻櫎瀵瑰簲闂鍜屽贰鏌ヨ褰�
@@ -538,7 +509,7 @@
             }
         }
 
-        val tempResult = BaseSearchResultVo()
+        val result = BaseSearchResultVo()
 
         val _sceneType = sceneType ?: 1
         val _districtCode = "310106"
@@ -550,7 +521,7 @@
             cal.set(Calendar.MILLISECOND, 0)
             cal.time
         } else {
-            DateUtil().StringToDate(startTime!!)
+            DateUtil.StringToDate(startTime!!)
         }
 
         val _endTime = if (endTime.isNullOrBlank()) {
@@ -561,113 +532,72 @@
             cal.set(Calendar.MILLISECOND, 999)
             cal.time
         } else {
-            DateUtil().StringToDate(endTime!!)?.apply {
+            DateUtil.StringToDate(endTime!!)?.apply {
                 time += 24 * 60 * 60 * 1000
             }
         }
 
-        val example = Example(Subtask::class.java).apply {
-            createCriteria().andEqualTo("districtcode", _districtCode)
-                    .andGreaterThanOrEqualTo("planstarttime", _startTime)
-                    .andLessThanOrEqualTo("planendtime", _endTime)
-        }
-
-        var counts = 0
-
-
-//        val offset = (perPage ?: 30).times((page ?: 1).minus(1))
-//        PageHelper.offsetPage<Subtask>(offset, perPage ?: 30)
-
-        subtaskMapper.selectByExample(example).forEach { s ->
-
-            val scene = scenseMapper.selectByPrimaryKey(s.scenseid)
-            val inspection = inspectionMapper.selectByExample(Example(Inspection::class.java).apply {
-                createCriteria().andEqualTo("stguid", s.stguid)
-            }).takeIf { it.isNotEmpty() }?.get(0)
-            val evaluation = evaluationMapper.selectByExample(Example(Evaluation::class.java).apply {
-                createCriteria().andEqualTo("stguid", s.stguid)
-            }).takeIf { it.isNotEmpty() }?.get(0)
-
-            if (scene.typeid != _sceneType.toByte()) {
-                return@forEach
+        val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>()
+        val problemMap = mutableMapOf<String?, ProblemDetail>()
+//        val  p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
+        subtaskMapper.getSubtask2(null, null, _districtCode, _sceneType.toByte(), _startTime, _endTime).forEach {
+            if (!subtaskMap.containsKey(it.subTaskId)) {
+                val vo =SubtaskSearchResultVo()
+                BeanUtils.copyProperties(it, vo)
+                subtaskMap[it.subTaskId] = vo
+            }
+            if (!problemMap.containsKey(it.problemId)) {
+                val problemDetail = ProblemDetail()
+                BeanUtils.copyProperties(it, problemDetail)
+                problemMap[it.problemId] = problemDetail
+                subtaskMap[it.subTaskId]?.problemList?.add(problemDetail)
+            }
+            val url = it.mExtension1 + it.mGuid+ ".jpg"
+            if (it.isChanged == true) {
+                problemMap[it.problemId]?.rectificationPics?.add(url)
             } else {
-                counts++
-            }
-
-
-            val subtaskSearchResultVo = SubtaskSearchResultVo().apply {
-                this.districtName = scene.districtname
-                this.townName = scene.townname
-                this.sceneName = scene.name
-                this.sceneAddress = scene.location
-                this.planStartTime = s.planstarttime
-                this.planEndTime = s.planendtime
-                this.status = s.status
-                this.path= inspection?.extension1
-                this.score = evaluation?.resultscorebef?.toIntOrNull()
-                this.level = when {
-                    score == null -> null
-                    score!! >= 54 -> "鍚堟牸"
-                    else -> "涓嶅悎鏍�"
-                }
-            }
-            tempResult.data.add(subtaskSearchResultVo)
-
-            problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
-                createCriteria().andEqualTo("stguid", s.stguid)
-            }).forEach { p ->
-                val problem = ProblemDetail().apply {
-                    this.problemName = p.problemname
-                    this.longitude = p.longitude?.toDouble()
-                    this.latitude = p.latitude?.toDouble()
-                    this.location = p.location
-                    this.rectification = p.ischanged
-                    this.rectificationTime = p.changedtime
-                }
-                subtaskSearchResultVo.problemList.add(problem)
-
-                mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
-                    createCriteria().andEqualTo("businessguid", p.guid)
-                }).forEach { m ->
-                    val url = m.extension1 + m.guid + ".jpg"
-                    if (m.ischanged == true) {
-                        problem.rectificationPics.add(url)
-                    } else {
-                        problem.problemPics.add(url)
-                    }
-                }
+                problemMap[it.problemId]?.problemPics?.add(url)
             }
         }
 
-        val totalPage = Math.ceil(counts.toDouble() / (perPage ?: 30).toDouble()).toInt()
-
-        val result = BaseSearchResultVo()
-
+        val totalPage = ceil(subtaskMap.size.toDouble() / (perPage ?: 30).toDouble()).toInt()
         result.head = DataHead().apply {
             this.page = page ?: 1
             this.totalPage = totalPage
+            this.totalCount = subtaskMap.size.toLong()
         }
-
-        val firstIndex = 0 + ((page ?: 1) - 1).times(perPage ?: 30)
-        val lastIndex = firstIndex + (perPage ?: 30) - 1
-
-        for (i in firstIndex until tempResult.data.size) {
-            if (i > lastIndex) {
-                break
+        var count = 0
+        val startIndex = ((page ?: 1) - 1) * (perPage ?: 30)
+        val endIndex = startIndex + (perPage ?: 30) - 1
+        with(subtaskMap) exit@{
+            subtaskMap.forEach {
+                if (count in startIndex..endIndex) {
+                    result.data.add(it.value)
+                }
+                count++
+                if (count > endIndex) return@exit
             }
-            result.data.add(tempResult.data[i])
         }
 
         return result
     }
 
-    override fun searchSubTask2(token: String, updateTime: String?, sceneType: Int?, districtCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<BaseSearchResultVo> {
+    override fun searchSubTask2(
+        token: String,
+        updateTime: String?,
+        sceneType: Int?,
+        districtCode: String?,
+        startTime: String?,
+        endTime: String?,
+        page: Int?,
+        perPage: Int?,
+    ): BaseResponse<BaseSearchResultVo> {
         if (token != "jinshan") {
             return BaseResponse(false, "璇锋眰token閿欒")
         }
 
         val time = if (updateTime != null) {
-            DateUtil().StringToDate(updateTime)
+            DateUtil.StringToDate(updateTime)
         } else {
             null
         }
@@ -686,7 +616,7 @@
                 cal.set(Calendar.MILLISECOND, 0)
                 cal.time
             } else {
-                DateUtil().StringToDate(startTime!!)
+                DateUtil.StringToDate(startTime!!)
             }
 
             val _endTime = if (endTime.isNullOrBlank()) {
@@ -697,7 +627,7 @@
                 cal.set(Calendar.MILLISECOND, 999)
                 cal.time
             } else {
-                DateUtil().StringToDate(endTime!!)?.apply {
+                DateUtil.StringToDate(endTime!!)?.apply {
                     this.time += 24 * 60 * 60 * 1000
                 }
             }
@@ -711,13 +641,13 @@
 
                 problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
                     createCriteria().andEqualTo("stguid", s.subTaskId)
-                            .andNotEqualTo("extension3", Constant.PROBLEM_UNCHECKED)
-                            .andNotEqualTo("extension3", Constant.PROBLEM_CHECK_FAIL)
-                            .andNotEqualTo("extension3", Constant.CHANGE_CHECK_FAIL)
-                            .andIsNotNull("extension3")
+                        .andNotEqualTo("extension3", Constant.PROBLEM_UNCHECKED)
+                        .andNotEqualTo("extension3", Constant.PROBLEM_CHECK_FAIL)
+                        .andNotEqualTo("extension3", Constant.CHANGE_CHECK_FAIL)
+                        .andIsNotNull("extension3")
                     time?.let {
                         and(createCriteria().orGreaterThan("time", it)
-                                .orGreaterThan("changedtime", it))
+                            .orGreaterThan("changedtime", it))
                     }
                 }).forEach { p ->
                     val problem = ProblemDetail().apply {
@@ -764,6 +694,7 @@
             result.head = DataHead().apply {
                 this.page = p.pageNum
                 this.totalPage = p.pages
+                this.totalCount = p.total
             }
 
             subtasklist.forEach {
@@ -777,9 +708,10 @@
             }
             val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>()
             val problemMap = mutableMapOf<String?, ProblemDetail>()
+//            val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
             subtaskMapper.getSubtask2(time, time2, _districtCode, _sceneType?.toByte(), null, null).forEach {
                 if (!subtaskMap.containsKey(it.subTaskId)) {
-                    val vo =SubtaskSearchResultVo()
+                    val vo = SubtaskSearchResultVo()
                     BeanUtils.copyProperties(it, vo)
                     subtaskMap[it.subTaskId] = vo
                 }
@@ -789,7 +721,7 @@
                     problemMap[it.problemId] = problemDetail
                     subtaskMap[it.subTaskId]?.problemList?.add(problemDetail)
                 }
-                val url = it.mExtension1 + it.mGuid+ ".jpg"
+                val url = it.mExtension1 + it.mGuid + ".jpg"
                 if (it.isChanged == true) {
                     problemMap[it.problemId]?.rectificationPics?.add(url)
                 } else {
@@ -799,6 +731,7 @@
             result.head = DataHead().apply {
                 this.page = 1
                 this.totalPage = 1
+                this.totalCount = subtaskMap.size.toLong()
             }
             subtaskMap.forEach {
                 result.data.add(it.value)
@@ -815,7 +748,7 @@
         }
 
         val time = if (updateTime != null) {
-            DateUtil().StringToDate(updateTime)
+            DateUtil.StringToDate(updateTime)
         } else {
             null
         }
@@ -834,7 +767,7 @@
                 cal.set(Calendar.MILLISECOND, 0)
                 cal.time
             } else {
-                DateUtil().StringToDate(startTime!!)
+                DateUtil.StringToDate(startTime!!)
             }
 
             val _endTime = if (endTime.isNullOrBlank()) {
@@ -845,7 +778,7 @@
                 cal.set(Calendar.MILLISECOND, 999)
                 cal.time
             } else {
-                DateUtil().StringToDate(endTime!!)?.apply {
+                DateUtil.StringToDate(endTime!!)?.apply {
                     this.time += 24 * 60 * 60 * 1000
                 }
             }
@@ -917,6 +850,7 @@
             result.head = DataHead().apply {
                 this.page = p.pageNum
                 this.totalPage = p.pages
+                this.totalCount = p.total
             }
 
             subtasklist.forEach {
@@ -930,6 +864,7 @@
             }
             val subtaskMap = mutableMapOf<String?, SubtaskSearchResultVo>()
             val problemMap = mutableMapOf<String?, ProblemDetail>()
+//            val p = PageHelper.startPage<Subtask>(page ?: 1, perPage ?: 30)
             subtaskMapper.getSubtask2(time, time2, _districtCode, _sceneType?.toByte(), null, null).forEach {
                 if (!subtaskMap.containsKey(it.subTaskId)) {
                     val vo =SubtaskSearchResultVo()
@@ -952,6 +887,7 @@
             result.head = DataHead().apply {
                 this.page = 1
                 this.totalPage = 1
+                this.totalCount = subtaskMap.size.toLong()
             }
             subtaskMap.forEach {
                 result.data.add(it.value)
@@ -963,7 +899,7 @@
     }
 
     override fun findByDate(date: String, userId: String): List<SubtaskVo> {
-        val time = DateUtil().StringToDate(date)
+        val time = DateUtil.StringToDate(date)
 
         val resultList = mutableListOf<SubtaskVo>()
 
@@ -979,67 +915,50 @@
         return resultList
     }
 
-    override fun getByTopTaskAndDate(topTaskId: String, startTime: String?, endTime: String?, sceneTypeId: Int?): List<Subtask> {
-//        val startDate = dateUtil.StringToDate(startTime)
-//        val endDate = dateUtil.StringToDate(endTime)
-//
-//        val cal = Calendar.getInstance().apply { time = startDate }
-//        val _startTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: startTime
-//
-//        if (endDate == null) {
-//            cal.add(Calendar.MONTH, 1)
-//            cal.add(Calendar.DAY_OF_MONTH, -1)
-//        } else {
-//            cal.time = endDate
-//        }
-//        cal.set(Calendar.HOUR_OF_DAY, 23)
-//        cal.set(Calendar.MINUTE, 59)
-//        cal.set(Calendar.SECOND, 59)
-//        val _endTime = dateUtil.DateToString(cal.time, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS) ?: endTime
+    override fun getByTopTaskAndDate(
+        topTaskId: String,
+        startTime: String?,
+        endTime: String?,
+        sceneTypeId: Int?
+    ): List<Subtask> {
 
-        val resultList = subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId)
-
-        return resultList
+        return subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId)
     }
 
     override fun getSummary(topTaskId: String, sceneTypeId: Int?): List<SubTaskSummary> {
-//        val result = mutableListOf<SubTaskSummary>()
-
-//        subtaskMapper.selectByTopTask2(topTaskId, sceneTypeId).forEach {
-//            val scene = scenseMapper.selectByPrimaryKey(it.scenseid)
-//            var p = 0
-//            var c = 0
-//            var pc = 0
-//            var cc = 0
-//            problemlistMapper.selectByExample(Example(Problemlist::class.java).apply {
-//                createCriteria().andEqualTo("stguid", it.stguid)
-//            }).forEach {pro ->
-//                p++
-//                if (pro.ischanged == true) c++
-//                if (pro.extension3 != Constant.PROBLEM_UNCHECKED) pc++
-//                if (pro.extension3 == Constant.CHANGE_CHECK_PASS || pro.extension3 == Constant.CHANGE_CHECK_FAIL) cc++
-//            }
-//            val ins = inspectionMapper.selectByExample(Example(Inspection::class.java).apply {
-//                createCriteria().andEqualTo("stguid", it.stguid)
-//            })
-//            result.add(SubTaskSummary().apply {
-//                stGuid = it.stguid
-//                stName = it.name
-//                if (ins.isNotEmpty()) insGuid = ins[0].guid
-//                sceneId = it.scenseid
-//                sceneName = scene.name
-//                sceneType = scene.type
-//                stPlanTime = it.planstarttime
-//                proNum = p
-//                changeNum = c
-//                proCheckedNum = pc
-//                changeCheckedNum = cc
-//            })
-//        }
-
-//        return result
-
         return subtaskMapper.getSummary(topTaskId, sceneTypeId)
+    }
 
+    override fun getTaskProgressByArea(areaVo: AreaVo): List<TaskProgressVo> {
+//        areaVo.scensetypeid ?: throw BizException("缂哄皯鍦烘櫙绫诲瀷鍙傛暟")
+        val res = mutableListOf<TaskProgressVo>()
+        taskRep.findTasks(areaVo).forEach {t->
+            if (t?.tguid == null) return@forEach
+            val pro = TaskProgressVo().apply {
+                tguid = t.tguid
+                name = t.name
+                levelnum = t.levelnum
+                provinceCode = t.provincecode
+                provinceName = t.provincename
+                cityCode = t.citycode
+                cityName = t.cityname
+                districtCode = t.districtcode
+                districtName = t.districtname
+                townCode = t.towncode
+                townName = t.townname
+                areaVo.topTaskId = t.tguid
+                subTaskSummary = subTaskRep.findSummary(areaVo)
+            }
+            res.add(pro)
+        }
+        return res
+    }
+
+    override fun getByScene(sceneId: String, startTime: LocalDateTime?, endTime: LocalDateTime?): List<SubTaskSummary> {
+        return subtaskMapper.getSummaryByScene(sceneId, startTime, endTime)
+    }
+
+    override fun getSummaryByArea(areaVo: AreaVo): List<SubTaskSummary> {
+        return subTaskRep.findSummary(areaVo)
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3