From 46872a311da9480d3edb19223aca2e0833fb1e31 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 17 十二月 2024 11:41:00 +0800
Subject: [PATCH] 1. 完成数据产品中间结果基本信息和具体信息入库 2. 修改ColInspectionInfo.kt 监管时间格式修改为yyyy-mm-dd 3. 新增数据产品类型枚举类 DataProductType 4. 修改BaseTemplate实现类通过重写genData方法生成Template相关数据 5. TODO 其他未涉及到的产品对象的中间结果对象

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt |  143 +++++++++++++++++++++++++++++++----------------
 1 files changed, 94 insertions(+), 49 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
index 022941c..87908bb 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
@@ -1,5 +1,6 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.domain.ds1.entity.Problemlist
 import cn.flightfeather.supervision.domain.ds1.entity.Subtask
 import cn.flightfeather.supervision.domain.ds1.entity.Task
@@ -8,10 +9,10 @@
 import cn.flightfeather.supervision.domain.ds1.mapper.TaskMapper
 import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.common.utils.DateUtil
-import cn.flightfeather.supervision.lightshare.service.EvaluationService
-import cn.flightfeather.supervision.lightshare.service.SubtaskService
-import cn.flightfeather.supervision.lightshare.service.TaskService
-import cn.flightfeather.supervision.lightshare.service.UserinfoService
+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.*
 import cn.flightfeather.supervision.lightshare.vo.*
 import org.springframework.beans.BeanUtils
 import org.springframework.beans.factory.annotation.Autowired
@@ -21,7 +22,11 @@
 import kotlin.collections.ArrayList
 
 @Service
-class TaskServiceImpl(val taskMapper: TaskMapper) : TaskService {
+class TaskServiceImpl(
+    val taskMapper: TaskMapper,
+    private val taskRep: TaskRep,
+    private val subTaskRep: SubTaskRep,
+) : TaskService {
 
     @Autowired
     lateinit var subtaskService: SubtaskService
@@ -101,7 +106,7 @@
                     townRank.standardRate = it.get("standardRate").toString().toFloat()
                 } catch (e: Exception) {
                 }
-                val s =it.get("hasScoredNum").toString()
+                val s = it.get("hasScoredNum").toString()
                 try {
                     townRank.hasScoredNum = it.get("hasScoredNum").toString().toInt()
                 } catch (e: Exception) {
@@ -161,7 +166,7 @@
         if (type == 0)
             return getAllTop()
         //鑾峰彇鏈畬鎴愰《灞備换鍔″強瀵瑰簲鏃ヤ换鍔″垪琛�
-        else if (type == 1){
+        else if (type == 1) {
             val tmp = getAllTop()
             tmp.forEach {
                 if (it.runingstatus != Constant.TaskProgress.RUNINGSTATUS3.text) {
@@ -175,13 +180,13 @@
     }
 
     //鏍规嵁鏃ユ湡鑾峰彇鏃ヤ换鍔�
-    override fun findByDate(date: String): TaskVo {
+    override fun findByDate(topTaskId: String, date: String): TaskVo {
         val taskVo = TaskVo()
         val example = Example(Task::class.java)
         val criteria = example.createCriteria()
         //gsguid涓嶄负绌轰负鏃ヤ换鍔�,鏃ヤ换鍔″紑濮嬫椂闂村拰缁撴潫鏃堕棿鍦ㄥ悓涓�澶�,杩囨护寮�濮嬫椂闂村氨ok
-        criteria.andEqualTo("starttime", dateUtil.StringToDate(date.substring(0, 10)))
-        criteria.andIsNotNull("tsguid")
+        criteria.andEqualTo("starttime", DateUtil.StringToDate(date.substring(0, 10)))
+        criteria.andEqualTo("tsguid", topTaskId)
         val tasklist = taskMapper.selectByExample(example)
         if (tasklist.isNotEmpty()) {
             BeanUtils.copyProperties(tasklist[0], taskVo)
@@ -220,10 +225,10 @@
 //                .andEqualTo("districtcode", districtCode)
 //                .andLessThanOrEqualTo("endtime", date)
 //        example.or(
-                example.createCriteria().andIsNull("tsguid")
-                        .andEqualTo("districtcode", districtCode)
-                        .andLessThan("starttime", date)
-                        .andGreaterThanOrEqualTo("endtime", date)
+        example.createCriteria().andIsNull("tsguid")
+            .andEqualTo("districtcode", districtCode)
+            .andLessThanOrEqualTo("starttime", date)
+            .andGreaterThanOrEqualTo("endtime", date)
 //        )
         example.orderBy("starttime").desc()
         val tasklist = taskMapper.selectByExample(example)
@@ -286,8 +291,6 @@
         return if (tasks.isEmpty()) Task() else tasks[0]
     }
 
-    val dateUtil = DateUtil()
-
     //鏍规嵁椤跺眰鍒楄〃,鏃ユ湡,鍜屾墽琛屼汉鍛業D锛岀敤鎴风被鍨嬭幏鍙栨棩浠诲姟
     override fun getDayTaskList(taskVoList: List<TaskVo>, date: String, guid: String, userType: String): List<TaskVo> {
         if (taskVoList.isEmpty()) return taskVoList
@@ -296,9 +299,9 @@
             val criteria = example.createCriteria()
             //鏋勯�犳煡璇㈡潯浠�
             criteria.andEqualTo("tsguid", it.tguid)
-            val dateTemo = dateUtil.StringToDate(date)
+            val dateTemo = DateUtil.StringToDate(date)
             //鏉′欢杩囨护
-            criteria.andBetween("starttime", dateTemo, dateUtil.addSecond(dateUtil.addMonth(dateTemo!!, 1)!!, 1))
+            criteria.andBetween("starttime", dateTemo, DateUtil.addSecond(DateUtil.addMonth(dateTemo!!, 1)!!, 1))
             if (userType == "1") {
                 criteria.andLike("executorguids", "%$guid%")
             }
@@ -340,7 +343,7 @@
             val complete = subtaskMapper.selectCountByExample(exampleComplete)
 
             var changed = 0
-            problemListMapper.findUnchangedCount(it.tguid ?: "").forEach {i ->
+            problemListMapper.findUnchangedCount(it.tguid ?: "").forEach { i ->
                 //缁撴灉琛ㄧず璇ュ瓙浠诲姟鏈暣鏀归棶棰樻暟
                 if (i == 0) {
                     changed++
@@ -353,7 +356,7 @@
                 forEach {
                     problemListMapper.selectByExample(Example(Problemlist::class.java).apply {
                         createCriteria().andEqualTo("stguid", it.stguid)
-                    }).forEach {problem ->
+                    }).forEach { problem ->
                         if (problem.extension3 == Constant.PROBLEM_UNCHECKED) {
                             check = true
                             return@breaking
@@ -362,8 +365,8 @@
                 }
             }
 
-           resultList.add(DayTaskProgressVo(
-                    it.tguid, it.starttime, taskId, complete, changed, total, check
+            resultList.add(DayTaskProgressVo(
+                it.tguid, it.starttime, taskId, complete, changed, total, check
             ))
         }
 
@@ -378,9 +381,9 @@
             val criteria = example.createCriteria()
             //鏋勯�犳煡璇㈡潯浠�
             criteria.andEqualTo("tsguid", it.tguid)
-            val dateTemo = dateUtil.StringToDate(date)
+            val dateTemo = DateUtil.StringToDate(date)
             //鏉′欢杩囨护
-            criteria.andBetween("starttime", dateTemo, dateUtil.addSecond(dateUtil.addMonth(dateTemo!!, 1)!!, 1))
+            criteria.andBetween("starttime", dateTemo, DateUtil.addSecond(DateUtil.addMonth(dateTemo!!, 1)!!, 1))
             criteria.andLike("executorguids", "%$guid%")
             //鏍规嵁sql鏉′欢鏌ヨ
             val taskList = taskMapper.selectByExample(example)
@@ -401,10 +404,10 @@
         if (date.length < 7) {
             return taskVoList
         }
-        val startDate = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList
+        val startDate = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList
         //鏌ヨ涓�涓湀浠诲姟
-        var endDate = DateUtil().addMonth(startDate, 1) ?: return taskVoList
-        endDate = DateUtil().addSecond(endDate, -1)!!
+        var endDate = DateUtil.addMonth(startDate, 1) ?: return taskVoList
+        endDate = DateUtil.addSecond(endDate, -1)!!
         //鏋勯�犳煡璇㈡潯浠�
         val example = Example(Task::class.java)
         val criteria = example.createCriteria()
@@ -453,22 +456,22 @@
 //            return taskVoList
 //        }
 //        //鏃堕棿杞崲
-//        val d1 = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList
+//        val d1 = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList
 //        var startDate: Date? = null
 //        var endDate: Date? = null
 //        //鏍规嵁type绫诲瀷,寰楀埌瑕佹煡璇㈢殑鑼冨洿
 //        when (type) {
 //            "Middle" -> {
-//                startDate = DateUtil().addMonth(d1, -1);endDate = DateUtil().addMonth(d1, 2)
+//                startDate = DateUtil.addMonth(d1, -1);endDate = DateUtil.addMonth(d1, 2)
 //            }
 //            "Left" -> {
-//                startDate = DateUtil().addMonth(d1, -3);endDate = d1
+//                startDate = DateUtil.addMonth(d1, -3);endDate = d1
 //            }
 //            "Right" -> {
-//                startDate = DateUtil().addMonth(d1, 1);endDate = DateUtil().addMonth(d1, 4)
+//                startDate = DateUtil.addMonth(d1, 1);endDate = DateUtil.addMonth(d1, 4)
 //            }
 //            else -> {
-//                startDate = d1;endDate = DateUtil().addMonth(d1, 1)
+//                startDate = d1;endDate = DateUtil.addMonth(d1, 1)
 //            }
 //        }
 //
@@ -497,16 +500,16 @@
         if (date.length < 7) {
             return taskVoList
         }
-        val startDate = DateUtil().StringToDate(date.substring(0, 7)) ?: return taskVoList
+        val startDate = DateUtil.StringToDate(date.substring(0, 7)) ?: return taskVoList
         //鏌ヨ涓�涓湀浠诲姟
-        var endDate = DateUtil().addMonth(startDate, 1) ?: return taskVoList
-        endDate = DateUtil().addSecond(endDate, -1)!!
+        var endDate = DateUtil.addMonth(startDate, 1) ?: return taskVoList
+        endDate = DateUtil.addSecond(endDate, -1)!!
         //鏋勯�犳煡璇㈡潯浠�
         val example = Example(Task::class.java)
         val criteria = example.createCriteria()
         //鑾峰彇鐢ㄦ埛淇℃伅
         val userInfo = userinfoMapper.findOne(guid)
-        val districtCode = userInfo.dGuid
+        val districtCode = userInfo?.dGuid
 
         //娣诲姞鏃ユ湡杩囨护
 
@@ -521,25 +524,25 @@
 
         val criteria2 = example.createCriteria()
         criteria2.orBetween(
-                "endtime",
-                startDate,
-                endDate
+            "endtime",
+            startDate,
+            endDate
         ).andIsNull("tsguid");
         if (userType == "1") {
             criteria2.andLike("executorguids", "%$guid%")
-        } else if (userType == "2"){
+        } else if (userType == "2") {
             criteria2.andEqualTo("districtcode", districtCode)
         }
         example.or(criteria2)
 
         val criteria3 = example.createCriteria()
         criteria3.orLessThan("starttime", startDate).andGreaterThan(
-                "endtime",
-                endDate
+            "endtime",
+            endDate
         ).andIsNull("tsguid");
         if (userType == "1") {
             criteria3.andLike("executorguids", "%$guid%")
-        } else if (userType == "2"){
+        } else if (userType == "2") {
             criteria3.andEqualTo("districtcode", districtCode)
         }
         example.or(criteria3)
@@ -586,7 +589,7 @@
         }
         return taskVoList
     }
-    
+
     override fun save(task: Task): Int {
         // FIXME: 2021/10/9 鎸夌収褰撳墠鐨勯�昏緫锛屾鍑芥暟涓昏鐢ㄤ簬鏂板缓椤跺眰浠诲姟浠ュ強鏃ヤ换鍔★紝浣嗘槸鏃ヤ换鍔″唴瀹圭殑鐢熸垚閫昏緫鐩墠鐢卞墠绔痑pp瀹屾垚锛屽洜姝や細鍑虹幇涓�涓猙ug锛�
         // FIXME: 2021/10/9 褰撳墠绔涓敤鎴峰悓鏃跺湪鍚屼竴涓《灞備换鍔′笅鐨勬柊鐨勪竴澶╁垱寤轰换鍔℃椂锛屼細鍑虹幇鍚屼竴澶╂湁澶氫釜鏃ヤ换鍔★紝姝ゆ椂鍓嶇鍚庣画鏌ョ湅鍙兘鐪嬪埌鍏朵腑涓�涓棩浠诲姟涓嬬殑瀛愪换鍔�
@@ -594,6 +597,7 @@
         // FIXME: 2021/10/9 鍙﹀瀵逛簬椤跺眰浠诲姟涔熸坊鍔犵被浼奸�昏緫锛岀敱浜庨《灞備换鍔$殑浠诲姟鍚嶇О榛樿绯荤粺鑷姩鐢熸垚锛屽洜姝ゆ殏鏃跺彧鍒ゆ柇鍚屽悕鐨勯《灞備换鍔★紝褰撳瓨鍦ㄥ悓鍚嶉《灞備换鍔℃椂锛屼笉鍋氫繚瀛樻搷浣�
 
         var result = 0
+        if (task.tguid == null) task.tguid = UUIDGenerator.generate16ShortUUID()
         // 1銆侀鍏堝垽鏂槸椤跺眰浠诲姟杩樻槸鏃ヤ换鍔�
         if (task.levelnum == 2) {
             //2.1銆� 鏄《灞備换鍔℃椂锛屽垽鏂槸鍚﹀凡鏈夊悓鍚嶄换鍔�
@@ -607,7 +611,7 @@
             }
         } else {
             //3.1銆� 褰撴槸鏃ヤ换鍔℃椂锛屽垽鏂湪鍚屼竴涓《灞備换鍔′笅锛屾槸鍚︽湁鍚屽悕鐨勬棩浠诲姟
-            val r  =taskMapper.selectByExample(Example(Task::class.java).apply {
+            val r = taskMapper.selectByExample(Example(Task::class.java).apply {
                 createCriteria().andEqualTo("tsguid", task.tsguid)
                     .andEqualTo("name", task.name)
             })
@@ -633,6 +637,14 @@
         return result
     }
 
+    override fun create(task: Task): Task {
+        val res = save(task)
+        if (res < 1)
+            throw BizException("浠诲姟鍒涘缓澶辫触")
+        else
+            return task
+    }
+
     //淇敼鏃ヤ换鍔′俊鎭�,鑻ユ湁瀛愪换鍔�,瀛愪换鍔′篃淇敼
     override fun update(task: Task): Int {
         var re = 1
@@ -645,7 +657,7 @@
                 BeanUtils.copyProperties(it, subtask)
                 subtask.planstarttime = task.starttime
                 subtask.planendtime = task.endtime
-                subtaskService.update(subtask)
+                subtaskService.changeStatus(subtask)
             }
         }
         return re
@@ -664,7 +676,7 @@
         criteria.andIsNull("tsguid")
         example.orderBy("starttime").asc()
         val result = taskMapper.selectByExample(example)
-        if (result.isNotEmpty()){
+        if (result.isNotEmpty()) {
             result.forEach {
                 var mytotalcount = 0
                 var mycompletecount = 0
@@ -691,7 +703,7 @@
                     taskProgressVo.mycompletetask = mycompletecount
                     val daytaskVolist = getDayTaskByTaskID(it.tguid!!)
                     val daytasklist = mutableListOf<TaskVo>()
-                    if (daytaskVolist.isNotEmpty()){
+                    if (daytaskVolist.isNotEmpty()) {
                         daytaskVolist.forEach {
                             var mytotalcount1 = 0
                             var mycompletecount1 = 0
@@ -703,7 +715,7 @@
                                     if (Objects.equals(it.status!!, Constant.TaskProgress.RUNINGSTATUS3.text))
                                         mycompletecount1++
                                 }
-                                if(Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text))
+                                if (Objects.equals(it.status, Constant.TaskProgress.RUNINGSTATUS3.text))
                                     completecount1++
                             }
                             val daytaskProgressVo = TaskVo()
@@ -725,4 +737,37 @@
         return taskProgressVolist
     }
 
+    override fun findTask(areaVo: AreaVo): List<Task?> {
+        return taskRep.findTasks(areaVo)
+    }
+
+    override fun findTaskProgress(areaVo: AreaVo): List<TaskProgressVo?> {
+        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
+                var count = 0
+                taskRep.findMonitorList(t.tguid!!, areaVo.scensetypeid).forEach {
+                    val c = if (it.extension1 != null) it.extension1!!.toInt() else 1
+                    count += c
+                }
+                totaltask = count
+                subTaskSummary = subTaskRep.findSummary(areaVo)
+                completetask = this.subTaskSummary?.size
+            }
+            res.add(pro)
+        }
+        return res
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3