From 6c7f45871b93ef26d353a5a3596701ac2f39ed9c Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 10 九月 2024 17:48:27 +0800
Subject: [PATCH] 1. 新增问题更新接口

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt |  124 ++++++++++++++++++++++++++++-------------
 1 files changed, 85 insertions(+), 39 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt
index 8b0e284..b6b57b7 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt
@@ -6,9 +6,13 @@
 import cn.flightfeather.supervision.business.report.file.ReportThree
 import cn.flightfeather.supervision.business.report.file.ReportTwo
 import cn.flightfeather.supervision.business.report.template.*
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.common.utils.*
 import cn.flightfeather.supervision.domain.ds1.entity.*
 import cn.flightfeather.supervision.domain.ds1.mapper.*
+import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRep
+import cn.flightfeather.supervision.domain.ds1.repository.EvaluationRuleRep
+import cn.flightfeather.supervision.domain.ds1.repository.SceneRep
 import cn.flightfeather.supervision.domain.ds2.mapper.LedgerRecordMapper
 import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper
 import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper
@@ -34,36 +38,37 @@
  */
 @Service
 class SearchServiceImpl(
-        val userinfoMapper: UserinfoMapper,
-        val subtaskMapper: SubtaskMapper,
-        val scenseMapper: ScenseMapper,
-        val sceneConstructionSiteMapper: SceneConstructionSiteMapper,
-        val sceneMixingPlantMapper: SceneMixingPlantMapper,
-        val sceneStorageYardMapper: SceneStorageYardMapper,
-        val sceneWharfMapper: SceneWharfMapper,
-        val problemlistMapper: ProblemlistMapper,
-        val problemtypeMapper: ProblemtypeMapper,
-        val townMapper: TownMapper,
-        val mediafileMapper: MediafileMapper,
-        val scoreMapper: ScoreMapper,
-        val inspectionMapper: InspectionMapper,
-        val taskMapper: TaskMapper,
-        val monitorobjectversionMapper: MonitorobjectversionMapper,
-        val evaluationruleMapper: EvaluationruleMapper,
-        val evaluationsubruleMapper: EvaluationsubruleMapper2,
-        val evaluationMapper: EvaluationMapper,
-        val itemevaluationMapper: ItemevaluationMapper,
-        val ledgerSubTypeMapper: LedgerSubTypeMapper,
-        val ledgerRecordMapper: LedgerRecordMapper,
-        val userMapMapper: UserMapMapper,
-        val taskService: TaskService,
-        @Value("\${filePath}") var filePath: String,
-        @Value("\${imgPath}") var imgPath: String
+    val userinfoMapper: UserinfoMapper,
+    val subtaskMapper: SubtaskMapper,
+    val scenseMapper: ScenseMapper,
+    val sceneConstructionSiteMapper: SceneConstructionSiteMapper,
+    val sceneMixingPlantMapper: SceneMixingPlantMapper,
+    val sceneStorageYardMapper: SceneStorageYardMapper,
+    val sceneWharfMapper: SceneWharfMapper,
+    val problemlistMapper: ProblemlistMapper,
+    val problemtypeMapper: ProblemtypeMapper,
+    val townMapper: TownMapper,
+    val mediafileMapper: MediafileMapper,
+    val scoreMapper: ScoreMapper,
+    val inspectionMapper: InspectionMapper,
+    val taskMapper: TaskMapper,
+    val monitorobjectversionMapper: MonitorobjectversionMapper,
+    val evaluationruleMapper: EvaluationruleMapper,
+    val evaluationsubruleMapper: EvaluationsubruleMapper2,
+    val evaluationMapper: EvaluationMapper,
+    val itemevaluationMapper: ItemevaluationMapper,
+    val ledgerSubTypeMapper: LedgerSubTypeMapper,
+    val ledgerRecordMapper: LedgerRecordMapper,
+    val userMapMapper: UserMapMapper,
+    val taskService: TaskService,
+    private val evaluationRep: EvaluationRep,
+    private val evaluationRuleRep: EvaluationRuleRep,
+    private val sceneRep: SceneRep,
+    @Value("\${filePath}") var filePath: String,
+    @Value("\${imgPath}") var imgPath: String,
 ) : SearchService {
 
-    private val dateUtil = DateUtil()
-
-    override fun writeToFile(config: ExcelConfigVo, mode:Int) {
+    override fun writeToFile(config: ExcelConfigVo, mode: Int) {
         val dbMapper = DbMapper(
             scenseMapper,
             problemlistMapper,
@@ -76,7 +81,7 @@
             sceneWharfMapper,
             taskMapper,
             evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper,
-                ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper
+            ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper
         )
         val dataSource = DataSource(config, dbMapper)
         val t = when (mode) {
@@ -251,8 +256,9 @@
         }
 
         //寤虹珛绗竴灞傜洰褰曪紝鍖呭惈鎵�鏈夌殑浠诲姟
-        val time = dateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss")
-        var basePath = Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + time
+        val time = DateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss")
+        var basePath =
+            imgPath + File.separator + "temp" + File.separator + time
         var file = File(basePath)
         var i = 1
         while (file.exists() && i <= 100) {
@@ -303,7 +309,8 @@
                 mediafileMapper.selectByExample(Example(Mediafile::class.java).apply {
                     createCriteria().andEqualTo("businessguid", p.guid)
                 }).forEach { m ->
-                    val picPath = Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + m.extension1 + m.guid + ".jpg"
+                    val picPath =
+                        imgPath + File.separator + m.extension1 + m.guid + ".jpg"
                     val fromFile = File(picPath)
                     val picName = p.problemname + "_" + p.location + "($y).jpg"
                     val toFile = File(pPath + File.separator + picName)
@@ -342,8 +349,9 @@
     override fun downloadPic2(sceneType: Int, topTaskId: String, response: HttpServletResponse): HttpServletResponse {
         //寤虹珛绗竴灞傜洰褰曪紝鍖呭惈鎵�鏈夌殑浠诲姟
         val topTask = taskMapper.selectByPrimaryKey(topTaskId)
-        val time = dateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss")
-        val basePath = Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + "temp" + File.separator + topTask.name
+        val time = DateUtil.DateToString(Date(), "yyyy-MM-dd_HH-mm-ss")
+        val basePath =
+            imgPath + File.separator + "temp" + File.separator + topTask.name
         val file = File(basePath)
         if (!file.exists()) {
             file.mkdirs()
@@ -362,7 +370,7 @@
 
                 //寤虹珛涓�涓瓙浠诲姟鏂囦欢澶�
                 var subTaskFilePath = "${basePath}${File.separator}(${
-                    dateUtil.DateToString(
+                    DateUtil.DateToString(
                         it.planstarttime,
                         DateUtil.DateStyle.YYYY_MM_DD_CN
                     )
@@ -412,7 +420,7 @@
 
                         u.forEach { f ->
                             val picPath =
-                                Constant.DEFAULT_FILE_PATH + File.separator + "images" + File.separator + f.extension1 + f.guid + ".jpg"
+                                imgPath + File.separator + f.extension1 + f.guid + ".jpg"
                             val fromFile = File(picPath)
                             val picName = f.description
                             val toFile = File(pPath + File.separator + picName)
@@ -452,7 +460,13 @@
         return response
     }
 
-    override fun searchScore4JingAn(token: String, year: Int, month: Int, page: Int?, perPage: Int?): BaseResponse<List<ScoreVo>> {
+    override fun searchScore4JingAn(
+        token: String,
+        year: Int,
+        month: Int,
+        page: Int?,
+        perPage: Int?,
+    ): BaseResponse<List<ScoreVo>> {
         if (token != "jingan") {
             return BaseResponse(false)
         }
@@ -475,7 +489,12 @@
         return BaseResponse(true, head = DataHead(p.pageNum, p.pages), data = result)
     }
 
-    override fun searchSubTaskByKeyword(userId: String, keyword: String, page: Int, perPage: Int): BaseResponse<List<SubtaskVo>> {
+    override fun searchSubTaskByKeyword(
+        userId: String,
+        keyword: String,
+        page: Int,
+        perPage: Int,
+    ): BaseResponse<List<SubtaskVo>> {
         val userInfo = userinfoMapper.selectByPrimaryKey(userId)
         if (userInfo.usertypeid?.toInt() == 3) return BaseResponse(false, "浼佷笟鐢ㄦ埛鏃犳煡璇㈡潈闄�")//浼佷笟鐢ㄦ埛鏃犳硶鏌ヨ
         val result = mutableListOf<SubtaskVo>()
@@ -517,7 +536,8 @@
             evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper,
             ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper
         )
-        val task = taskService.getByDistrictCode(config.districtCode, config.startTime)?.takeIf { it.isNotEmpty() }?.get(0)
+        val task =
+            taskService.getByDistrictCode(config.districtCode, config.startTime)?.takeIf { it.isNotEmpty() }?.get(0)
         config.topTaskGuid = task?.tguid ?: ""
         val dataSource = mutableListOf<DataSource>()
         config.sceneType = Constant.SceneType.TYPE1.value.toInt()
@@ -538,4 +558,30 @@
 
         return BaseTableVo(result.first, result.second)
     }
+
+    override fun getScoreDetail(subTaskId: String): ScoreDetail {
+        //鍦烘櫙淇℃伅
+        val scene = sceneRep.findBySubTask(subTaskId)
+        //鎬诲垎
+        val evaluation = evaluationRep.findBySubtask(subTaskId)
+        //瀛愯鍒欓�愭潯寰楀垎
+        val subRuleScores = evaluationRep.findItemEvaluation(subTaskId)
+        if (subRuleScores.isEmpty()) throw BizException("鏃犺瘎浼拌褰�")
+        //璇勫垎鎬昏鍒�
+        val rule = evaluationRuleRep.findAutoEvaluationRule(subTaskId) ?: throw BizException("鏈壘鍒扮浉鍏宠嚜鍔ㄨ瘎浼拌鍒�")
+        //鎬昏鍒欏搴旂殑璇勫垎瀛愯鍒�
+        val subRules = evaluationRuleRep.findSubRule(rule.guid)
+        //鏌ヨ缁撴灉
+        val result = ScoreDetail()
+        result.status = if (scene?.extension1.equals("1")) "鍦ㄥ缓" else "瀹屽伐"
+
+        result.updateTime = evaluation?.updatedate
+        subRules.forEach {
+            it.ertype ?: return@forEach
+            result.addDetail(result.details, it, it.ertype!! - 1, subRuleScores, true)
+        }
+        result.calScore()
+
+        return result
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3