From a5cdbf569067822e3232d2177b8a9aac1ed95b69 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期三, 29 五月 2024 17:32:00 +0800
Subject: [PATCH] 1. 修改自评逻辑中,问题整改的判断方式为已整改并且整改审核通过; 2. 新增评估详情获取接口;

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SubtaskServiceImpl.kt |  230 ++++++++++++++------------------------------------------
 1 files changed, 59 insertions(+), 171 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 1cebbb9..dafb0c5 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,13 +1,13 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
-import cn.flightfeather.supervision.business.storage.JinAnScore
-import cn.flightfeather.supervision.business.storage.StAutoScore
-import cn.flightfeather.supervision.business.storage.item.*
+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.TaskRep
 import cn.flightfeather.supervision.lightshare.service.SubtaskService
 import cn.flightfeather.supervision.lightshare.service.TaskService
 import cn.flightfeather.supervision.lightshare.vo.*
@@ -18,26 +18,19 @@
 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(
     private val subtaskMapper: SubtaskMapper,
-    private val mpScoreItem_1: MpScoreItem_1,
-    private val mpScoreItem_2: MpScoreItem_2,
-    private val stScoreItem_1: StScoreItem_1,
-    private val whScoreItem_1: WhScoreItem_1,
-    private val whScoreItem_2: WhScoreItem_2,
-    private val jinAnScore: JinAnScore,
+    private val aopEvaluation: AopEvaluation,
+    private val taskRep: TaskRep,
 ) : SubtaskService {
 
     val dateUtil = DateUtil()
 
-    @Autowired
-    lateinit var scoreItem1: CsScoreItem_1
-    @Autowired
-    lateinit var scoreItem2: CsScoreItem_2
     @Autowired
     lateinit var taskService: TaskService
     @Autowired
@@ -71,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)
@@ -479,20 +472,7 @@
             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, mpScoreItem_1, mpScoreItem_2, stScoreItem_1,
-                    whScoreItem_1, whScoreItem_2, jinAnScore)
-                autoScore.sceneType = Constant.ScenseType.getByValue(s.typeid?.toString())
-                autoScore.sceneGrade(subtask)
+                aopEvaluation.executeBySubTask(subtask)
             }
         }
 
@@ -616,89 +596,19 @@
             }
         }
 
-
-//        val example = Example(Subtask::class.java).apply {
-//            createCriteria().andEqualTo("districtcode", _districtCode)
-//                    .andGreaterThanOrEqualTo("planstarttime", _startTime)
-//                    .andLessThanOrEqualTo("planendtime", _endTime)
-//        }
-//
-//        var counts = 0
-//
-//        val  p = PageHelper.startPage<Subtask>(page ?: 1, 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
-//            } else {
-//                counts++
-//            }
-//
-//
-//            val subtaskSearchResultVo = SubtaskSearchResultVo().apply {
-//                this.subTaskId = s.stguid
-//                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.problemId = p.guid
-//                    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)
-//                    }
-//                }
-//            }
-//        }
-//
-//        tempResult.head = DataHead().apply {
-//            this.page = p.pageNum
-//            this.totalPage = p.pages
-//        }
-
         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閿欒")
         }
@@ -748,13 +658,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 {
@@ -818,7 +728,7 @@
 //            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
                 }
@@ -828,7 +738,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 {
@@ -1022,67 +932,45 @@
         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 getSummaryByArea(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
+                subTaskSummary = subtaskMapper.getSummary(t.tguid!!, areaVo.scensetypeid?.toIntOrNull())
+            }
+            res.add(pro)
+        }
+        return res
+    }
+
+    override fun getByScene(sceneId: String, startTime: LocalDateTime?, endTime: LocalDateTime?): List<SubTaskSummary> {
+        return subtaskMapper.getSummaryByScene(sceneId, startTime, endTime)
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3