From 39e208b6b0482a25c77e53590087c02d9d937563 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期三, 20 七月 2022 09:04:48 +0800
Subject: [PATCH] 1. 巡查汇总报告功能编写完成

---
 src/main/kotlin/cn/flightfeather/supervision/common/utils/DateUtil.kt                           |    2 
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt     |   34 +
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt               |    3 
 src/main/resources/mapper/ds1/DustDataResultMapper.xml                                          |    2 
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt     |    5 
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt       |    4 
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt   |    6 
 src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt                          |   55 +++-
 /dev/null                                                                                       |  111 --------
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt   |   30 +
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt     |   43 ++
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt                  |   15 +
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/entity/DustDataResult.java              |    6 
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt          |   84 ++++-
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColItemGrade.kt               |  111 ++++++++
 src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt                      |   78 +++++
 src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt                        |   33 +
 src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt              |   54 ++++
 src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt |   16 
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt       |   47 ++-
 20 files changed, 510 insertions(+), 229 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt
index c12a5cc..ae22382 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt
@@ -20,13 +20,14 @@
 
     //鐢熸垚涓�琛屽唴瀹�
     fun getOneRow(rowData: DataSource.RowData): List<Any> {
-        return if (rowData.noRecord()) {
-            val r = mutableListOf<String>()
-            repeat(heads.last().size) { r.add(("")) }
-            r
-        } else {
-            onOneRow(rowData)
-        }
+//        return if (rowData.noRecord()) {
+//            val r = mutableListOf<String>()
+//            repeat(heads.last().size) { r.add(("")) }
+//            r
+//        } else {
+//            onOneRow(rowData)
+//        }
+        return onOneRow(rowData)
     }
 
     abstract fun onOneRow(rowData: DataSource.RowData): List<Any>
@@ -57,7 +58,12 @@
                             oldHeads.first().forEach { it.rowSpan++ }
                         }
                         val h = mutableListOf<ExcelUtil.MyCell>()
-                        repeat(oldHeads.size) { h.add(ExcelUtil.MyCell("")) }
+
+                        var cols = 0
+                        oldHeads.last().forEach {
+                            cols += it.colSpan
+                        }
+                        repeat(cols) { h.add(ExcelUtil.MyCell("")) }
                         oldHeads.add(h)
                         h
                     }
@@ -70,12 +76,19 @@
                             newHeads.first().forEach { it.rowSpan++ }
                         }
                         val h = mutableListOf<ExcelUtil.MyCell>()
-                        repeat(newHeads.size) { h.add(ExcelUtil.MyCell("")) }
+
+                        var cols = 0
+                        newHeads.last().forEach {
+                            cols += it.colSpan
+                        }
+                        repeat(cols) { h.add(ExcelUtil.MyCell("")) }
                         newHeads.add(h)
                         h
                     }
+            }
 
-                oH.addAll(nH)
+            for (i in oldHeads.indices) {
+                oldHeads[i].addAll(newHeads[i])
             }
         }
     }
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
index 77154e7..cea8933 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt
@@ -4,10 +4,18 @@
 import cn.flightfeather.supervision.common.utils.DateUtil
 import cn.flightfeather.supervision.domain.ds1.entity.*
 import cn.flightfeather.supervision.domain.ds1.mapper.*
+import cn.flightfeather.supervision.domain.ds2.entity.LedgerRecord
+import cn.flightfeather.supervision.domain.ds2.entity.LedgerSubType
+import cn.flightfeather.supervision.domain.ds2.entity.UserMap
+import cn.flightfeather.supervision.domain.ds2.mapper.LedgerRecordMapper
+import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper
+import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper
 import cn.flightfeather.supervision.lightshare.vo.ExcelConfigVo
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.stereotype.Component
 import tk.mybatis.mapper.entity.Example
+import java.time.LocalDateTime
+import java.time.ZoneId
 import javax.annotation.PostConstruct
 
 /**
@@ -20,6 +28,12 @@
     private val dateUtil = DateUtil()
 
     private val sourceList = mutableListOf<Subtask>()
+
+    var year = 0
+
+    var month = 0
+
+    var area = ""
 
     val rowData = RowData()
 
@@ -36,6 +50,7 @@
     fun loop(callback: (index:Int, rowData: RowData) -> Unit) {
         reset()
         for (i in sourceList.indices) {
+            rowData.index = i
             rowData.clear()
             rowData.subTask = sourceList[i]
             callback(i, rowData)
@@ -46,6 +61,7 @@
      * 閲嶇疆
      */
     fun reset() {
+        rowData.index = 0
         rowData.subTask = sourceList.first()
         rowData.clear()
     }
@@ -55,7 +71,7 @@
      */
     fun areaName(): String {
         val t = dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid)
-        return "${dateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${Constant.ScenseType.getDes(config.sceneType)}"
+        return "${dateUtil.DateToString(t.starttime, DateUtil.DateStyle.YYYY_MM_CN)}${t.districtname}${if (area != t.districtname) area else ""}${Constant.ScenseType.getDes(config.sceneType)}"
     }
 
     /**
@@ -65,6 +81,19 @@
         if (config.sceneType == null) return
 
         val result = mutableListOf<Subtask>()
+
+        if (config.townCode != null) {
+            dbMapper.townMapper.selectByExample(Example(Town::class.java).apply {
+                createCriteria().andEqualTo("towncode", config.townCode)
+            })?.takeIf { it.isNotEmpty() }?.get(0)?.let { area = it.townname ?: "" }
+        }
+
+        dbMapper.taskMapper.selectByPrimaryKey(config.topTaskGuid).let {
+            val time = LocalDateTime.ofInstant(it.starttime?.toInstant(), ZoneId.systemDefault())
+            this.year = time.year
+            this.month = time.monthValue
+            if (area.isBlank()) area = it.districtname ?: ""
+        }
 
         //1. 鏌ユ壘鐗瑰畾鐨勫贰鏌ヤ换鍔℃垨鑰呮墍鏈夌殑璁″垝宸℃煡浠诲姟
         var taskSceneIdList = listOf<String>()
@@ -109,6 +138,8 @@
 
 
     inner class RowData(){
+        var index = 0
+
         var subTask: Subtask? = null
 
         //鍦烘櫙鍩烘湰淇℃伅
@@ -263,6 +294,43 @@
             }
         private var _rules = mutableListOf<Pair<Evaluationsubrule2, MutableList<Evaluationsubrule2>>>()
 
+        //蹇呭~鍙拌处鏁伴噺
+        val ledgerCount: Int
+            get() {
+                if (_ledgerCount == -1) {
+                    val tzSceneType = Constant.ScenseType.typeMap(config.sceneType?.toByte())
+                    _ledgerCount = dbMapper.ledgerSubTypeMapper.selectCountByExample(Example(LedgerSubType::class.java).apply {
+                        createCriteria().andEqualTo("lScenetype", tzSceneType).andEqualTo("lNeedupdate", true)
+                    })
+                }
+                return _ledgerCount
+            }
+        private var _ledgerCount = -1
+
+        //鐢ㄦ埛瀹為檯鎻愪氦鍙拌处鏁伴噺
+        val ledgerRecords: List<LedgerRecord>
+            get() {
+                if (_ledgerRecordNum == null) {
+                    val userInfo = dbMapper.userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
+                        createCriteria().andEqualTo("dGuid", subTask?.scenseid)
+                    })?.takeIf { l -> l.isNotEmpty() }?.get(0)
+
+                    val tzUserId = dbMapper.userMapMapper.selectByExample(Example(UserMap::class.java).apply {
+                        createCriteria().andEqualTo("svUserId", userInfo?.guid)
+                    })?.takeIf { m-> m.isNotEmpty() }?.get(0)?.tzUserId
+
+                    if (tzUserId != null) {
+                        _ledgerRecordNum = dbMapper.ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
+                            createCriteria().andEqualTo("lrYear", year)
+                                    .andEqualTo("lrMonth", month)
+                                    .andEqualTo("lrSubmitid", tzUserId)
+                        })
+                    }
+                }
+                return _ledgerRecordNum ?: emptyList()
+            }
+        private var _ledgerRecordNum: List<LedgerRecord>? = null
+
         /**
          * 娓呯┖褰撳墠澶勭悊鐨勫璞$殑鐩稿叧鏁版嵁婧�
          */
@@ -272,6 +340,7 @@
             _problems.clear()
             _evaluation = null
             _itemevaluationList.clear()
+            _ledgerRecordNum = null
         }
 
         /**
@@ -295,5 +364,10 @@
     val evaluationruleMapper: EvaluationruleMapper,
     val evaluationsubruleMapper: EvaluationsubruleMapper2,
     val evaluationMapper: EvaluationMapper,
-    val itemevaluationMapper: ItemevaluationMapper
+    val itemevaluationMapper: ItemevaluationMapper,
+    val ledgerSubTypeMapper: LedgerSubTypeMapper,
+    val ledgerRecordMapper: LedgerRecordMapper,
+    val userinfoMapper: UserinfoMapper,
+    val userMapMapper: UserMapMapper,
+    val townMapper: TownMapper,
 )
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt
deleted file mode 100644
index 271e082..0000000
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt
+++ /dev/null
@@ -1,111 +0,0 @@
-package cn.flightfeather.supervision.business.report.cols
-
-import cn.flightfeather.supervision.business.report.BaseCols
-import cn.flightfeather.supervision.business.report.DataSource
-import cn.flightfeather.supervision.common.utils.ExcelUtil
-import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
-import org.apache.poi.hssf.util.HSSFColor
-
-class ColGrade(private val hasHead3: Boolean = true) : BaseCols() {
-
-    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
-        val h1 = mutableListOf<ExcelUtil.MyCell>()
-        h1.add(ExcelUtil.MyCell("鐜俊鐮�", 3, 1))
-        h1.add(ExcelUtil.MyCell("闃叉不瑙勮寖鎬�", 3, 1))
-        h1.add(ExcelUtil.MyCell("鎬诲垎", 3, 1))
-        val h2 = mutableListOf<ExcelUtil.MyCell>()
-        h2.add(ExcelUtil.MyCell(""))
-        h2.add(ExcelUtil.MyCell(""))
-        h2.add(ExcelUtil.MyCell(""))
-        val h3 = mutableListOf<ExcelUtil.MyCell>()
-        h3.add(ExcelUtil.MyCell(""))
-        h3.add(ExcelUtil.MyCell(""))
-        h3.add(ExcelUtil.MyCell(""))
-        dataSource.rowData.topItems.forEach {
-            h1.add(ExcelUtil.MyCell(it.itemname ?: "", 1, 0))
-            for (r in dataSource.rowData.rules) {
-                if (r.first.fatherid == it.guid || r.first.guid == it.guid) {
-                    h2.add(ExcelUtil.MyCell(r.first.itemname ?: "", 1, 0))
-                    if (hasHead3) {
-                        r.second.forEach { s ->
-                            h3.add(ExcelUtil.MyCell(s.itemname ?: ""))
-                            h2.last().colSpan++
-                            h1.last().colSpan++
-                        }
-                    } else {
-                        h2.last().colSpan++
-                        h1.last().colSpan++
-                    }
-                }
-            }
-        }
-
-        return mutableListOf(h1, h2, h3)
-    }
-
-    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
-        val row = mutableListOf<Any>()
-
-        if (rowData.noRecord()) {
-            repeat(heads.last().size) { row.add(("")) }
-        } else {
-            row.apply {
-                //鎬诲垎鍜岀幆淇$爜
-                rowData.evaluation.let { e ->
-                    val s = e?.resultscorebef?.toIntOrNull() ?: ""
-                    val code = when (s) {
-                        in 0..59 -> ExcelUtil.MyCell("绾㈢爜", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
-                        in 60..89 -> ExcelUtil.MyCell("榛勭爜", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
-                        in 90..100 -> ExcelUtil.MyCell("缁跨爜", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
-                        "" -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
-                        else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
-                    }
-                    val normalization = when (s) {
-                        in 0..59 -> ExcelUtil.MyCell("涓ラ噸涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.ROSE.index)
-                        in 60..89 -> ExcelUtil.MyCell("涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
-                        in 90..99 -> ExcelUtil.MyCell("鍩烘湰瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
-                        100 -> ExcelUtil.MyCell("瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
-                        "" -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
-                        else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
-                    }
-                    add(code)
-                    add(normalization)
-                    add(s)
-                }
-
-
-                //姣忎竴椤瑰叿浣撳緱鍒�
-                rowData.topItems.forEach {
-                    for (r in rowData.rules) {
-                        if (r.first.fatherid == it.guid || r.first.guid == it.guid) {
-                            // FIXME: 2021/4/25 鍐冲畾鏄惁鍐檋3
-                            if (hasHead3) {
-                                r.second.forEach { s ->
-                                    val v = searchScore(s.guid, rowData.itemevaluationList)
-                                    add(v.toIntOrNull() ?: "")
-                                }
-                            } else {
-                                val v = searchScore(r.first.guid, rowData.itemevaluationList)
-                                add(v.toIntOrNull() ?: "")
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        return row
-    }
-
-    //鏌ユ壘寰楀垎璁板綍鍐呭搴旇鍒欑殑寰楀垎
-    private fun searchScore(ruleId: String?, itemevaluations: List<Itemevaluation>): String {
-        var score = ""
-        for (e in itemevaluations) {
-            if (ruleId == e.esrguid) {
-                score = e.value ?: ""
-                break
-            }
-        }
-        return score
-    }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt
index da2bfe8..0da1231 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt
@@ -10,22 +10,26 @@
 class ColInspectionInfo() : BaseCols() {
     override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
         return mutableListOf(mutableListOf(
-            ExcelUtil.MyCell("鐩戠鏃堕棿"),
-            ExcelUtil.MyCell("宸℃煡浜哄憳"),
-            ExcelUtil.MyCell("闂绫诲瀷"),
-            ExcelUtil.MyCell("闂鎻忚堪"),
-            ExcelUtil.MyCell("闂浣嶇疆"),
-            ExcelUtil.MyCell("闂鏁�"),
-            ExcelUtil.MyCell("鏁存敼鏃堕棿"),
-            ExcelUtil.MyCell("鏁存敼鎯呭喌"),
-            ExcelUtil.MyCell("鏁存敼闂"),
-            ExcelUtil.MyCell("鏁存敼鏁�"),
-            ExcelUtil.MyCell("鏈暣鏀归棶棰�"),
-            ExcelUtil.MyCell("鏈暣鏀规暟"),
-            ExcelUtil.MyCell("瀹℃牳鎯呭喌"),
-            ExcelUtil.MyCell("闂瀹℃牳鏃堕棿"),
-            ExcelUtil.MyCell("鏁存敼瀹℃牳鏃堕棿"),
-            ExcelUtil.MyCell("闂鏁存敼鐜�"),
+                ExcelUtil.MyCell("鐩戠鏃堕棿"),
+                ExcelUtil.MyCell("宸℃煡浜哄憳"),
+                ExcelUtil.MyCell("闂绫诲瀷"),
+                ExcelUtil.MyCell("闂鎻忚堪"),
+                ExcelUtil.MyCell("闂浣嶇疆"),
+                ExcelUtil.MyCell("闂鏁�"),
+                ExcelUtil.MyCell("鏁存敼鏃堕棿"),
+                ExcelUtil.MyCell("鏁存敼鎯呭喌"),
+                ExcelUtil.MyCell("鏁存敼闂"),
+                ExcelUtil.MyCell("鏁存敼鏁�"),
+                ExcelUtil.MyCell("鏈暣鏀归棶棰�"),
+                ExcelUtil.MyCell("鏈暣鏀规暟"),
+                ExcelUtil.MyCell("闂鏁存敼鐜�"),
+                ExcelUtil.MyCell("瀹℃牳鎯呭喌"),
+                ExcelUtil.MyCell("闂瀹℃牳鏃堕棿"),
+                ExcelUtil.MyCell("鏁存敼瀹℃牳鏃堕棿"),
+                ExcelUtil.MyCell("闂瀹℃牳鏁�"),
+                ExcelUtil.MyCell("闂瀹℃牳鍗犳瘮"),
+                ExcelUtil.MyCell("鏁存敼瀹℃牳鏁�"),
+                ExcelUtil.MyCell("鏁存敼瀹℃牳鍗犳瘮"),
         ))
     }
 
@@ -53,10 +57,15 @@
                 var cNum = 0//鏁存敼鏁�
                 var unChangedProblem = ""//鏈暣鏀归棶棰�
                 var unChangeNum = 0//鏈暣鏀规暟
+                var changePercent: Any = ""//闂鏁存敼鐜�
+
                 var checkStatus = ""//瀹℃牳鎯呭喌
                 var pCheckTime = ""//闂瀹℃牳鏃堕棿
                 var cCheckTime = ""//鏁存敼瀹℃牳鏃堕棿
-                var changePercent = ""//闂鏁存敼鐜�
+                var pCheckNum = 0//闂瀹℃牳鏁�
+                var pCheckPer: Any = ""//闂瀹℃牳鍗犳瘮
+                var cCheckNum = 0//鏁存敼瀹℃牳鏁�
+                var cCheckPer: Any = ""//鏁存敼瀹℃牳鍗犳瘮F
                 rowData.problems.forEach { p ->
                     var typeName = ""
                     for (t in rowData.problemTypes) {
@@ -71,7 +80,7 @@
                     pDes += "${lr}$y銆�${p.problemname}"
                     pLoc += "${lr}$y銆�${p.location}"
                     pNum++
-                    changeTime = "${lr}$y銆�${dateUtil.DateToString(p.changedtime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_CN)}"
+                    changeTime += "${lr}$y銆�${dateUtil.DateToString(p.changedtime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_CN)}"
                     pChanged += "${lr}$y銆�${if (p.ischanged == true) "鉁�" else "脳"}"
                     if (p.ischanged == true) {
                         if (changedProblem.isNotBlank()) {
@@ -86,23 +95,48 @@
                         unChangedProblem += "$y銆�${p.problemname}"
                         unChangeNum++
                     }
+                    changePercent = if (pNum == 0) "" else ExcelUtil.MyCell((cNum.toDouble() / pNum).toString(), isPercent = true)
+
                     val status = when (p.extension3) {
-                        Constant.PROBLEM_CHECK_PASS -> "闂瀹℃牳閫氳繃"//
-                        Constant.PROBLEM_CHECK_FAIL -> "闂瀹℃牳鏈�氳繃"//
                         Constant.PROBLEM_UNCHECKED -> "闂鏈鏍�"//
-                        Constant.CHANGE_UNCHECKED -> "鏁存敼鏈鏍�"//
-                        Constant.CHANGE_CHECK_PASS -> "鏁存敼瀹℃牳閫氳繃"//
-                        Constant.CHANGE_CHECK_FAIL -> "鏁存敼瀹℃牳鏈�氳繃"//
+                        Constant.PROBLEM_CHECK_PASS -> {
+                            pCheckNum++
+                            "闂瀹℃牳閫氳繃"
+                        }//
+                        Constant.PROBLEM_CHECK_FAIL -> {
+                            pCheckNum++
+                            "闂瀹℃牳鏈�氳繃"
+                        }//
+                        Constant.CHANGE_UNCHECKED -> {
+                            pCheckNum++
+                            "鏁存敼鏈鏍�"
+                        }//
+                        Constant.CHANGE_CHECK_PASS -> {
+                            pCheckNum++
+                            cCheckNum++
+                            "鏁存敼瀹℃牳閫氳繃"
+                        }//
+                        Constant.CHANGE_CHECK_FAIL -> {
+                            pCheckNum++
+                            cCheckNum++
+                            "鏁存敼瀹℃牳鏈�氳繃"
+                        }//
                         else -> "闂鏈鏍�"
                     }
                     checkStatus += "${lr}$y銆�${status}"
-                    changePercent = if (pNum == 0) "" else "${(cNum * 100 / pNum)}%"
+                    pCheckTime += "${lr}$y銆�/"
+                    cCheckTime += "${lr}$y銆�/"
+                    pCheckPer = if (pNum == 0) "" else ExcelUtil.MyCell((pCheckNum.toDouble() / pNum).toString(), isPercent = true)
+                    cCheckPer = if (cNum == 0) "" else ExcelUtil.MyCell((cCheckNum.toDouble() / cNum).toString(), isPercent = true)
+
+
                     y++
                 }
                 addAll(
                     listOf(
                         pType, pDes, pLoc, pNum, changeTime, pChanged, changedProblem, cNum,
-                        unChangedProblem, unChangeNum, checkStatus, pCheckTime, cCheckTime, changePercent
+                        unChangedProblem, unChangeNum, changePercent, checkStatus, pCheckTime, cCheckTime,
+                            pCheckNum, pCheckPer, cCheckNum, cCheckPer
                     )
                 )
             }
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColItemGrade.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColItemGrade.kt
new file mode 100644
index 0000000..757019b
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColItemGrade.kt
@@ -0,0 +1,111 @@
+package cn.flightfeather.supervision.business.report.cols
+
+import cn.flightfeather.supervision.business.report.BaseCols
+import cn.flightfeather.supervision.business.report.DataSource
+import cn.flightfeather.supervision.common.utils.ExcelUtil
+import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
+import org.apache.poi.hssf.util.HSSFColor
+
+class ColItemGrade(private val hasHead3: Boolean = true) : BaseCols() {
+
+    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
+        val h1 = mutableListOf<ExcelUtil.MyCell>()
+//        h1.add(ExcelUtil.MyCell("鐜俊鐮�", 3, 1))
+//        h1.add(ExcelUtil.MyCell("闃叉不瑙勮寖鎬�", 3, 1))
+//        h1.add(ExcelUtil.MyCell("鎬诲垎", 3, 1))
+        val h2 = mutableListOf<ExcelUtil.MyCell>()
+//        h2.add(ExcelUtil.MyCell(""))
+//        h2.add(ExcelUtil.MyCell(""))
+//        h2.add(ExcelUtil.MyCell(""))
+        val h3 = mutableListOf<ExcelUtil.MyCell>()
+//        h3.add(ExcelUtil.MyCell(""))
+//        h3.add(ExcelUtil.MyCell(""))
+//        h3.add(ExcelUtil.MyCell(""))
+        dataSource.rowData.topItems.forEach {
+            h1.add(ExcelUtil.MyCell(it.itemname ?: "", 1, 0))
+            for (r in dataSource.rowData.rules) {
+                if (r.first.fatherid == it.guid || r.first.guid == it.guid) {
+                    h2.add(ExcelUtil.MyCell(r.first.itemname ?: "", 1, 0))
+                    if (hasHead3) {
+                        r.second.forEach { s ->
+                            h3.add(ExcelUtil.MyCell(s.itemname ?: ""))
+                            h2.last().colSpan++
+                            h1.last().colSpan++
+                        }
+                    } else {
+                        h2.last().colSpan++
+                        h1.last().colSpan++
+                    }
+                }
+            }
+        }
+
+        return mutableListOf(h1, h2, h3)
+    }
+
+    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
+        val row = mutableListOf<Any>()
+
+        if (rowData.noRecord()) {
+            repeat(heads.last().size) { row.add(("")) }
+        } else {
+            row.apply {
+                //鎬诲垎鍜岀幆淇$爜
+//                rowData.evaluation.let { e ->
+//                    val s = e?.resultscorebef?.toIntOrNull() ?: ""
+//                    val code = when (s) {
+//                        in 0..59 -> ExcelUtil.MyCell("绾㈢爜", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
+//                        in 60..89 -> ExcelUtil.MyCell("榛勭爜", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
+//                        in 90..100 -> ExcelUtil.MyCell("缁跨爜", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
+//                        "" -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+//                        else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+//                    }
+//                    val normalization = when (s) {
+//                        in 0..59 -> ExcelUtil.MyCell("涓ラ噸涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.ROSE.index)
+//                        in 60..89 -> ExcelUtil.MyCell("涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
+//                        in 90..99 -> ExcelUtil.MyCell("鍩烘湰瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
+//                        100 -> ExcelUtil.MyCell("瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
+//                        "" -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+//                        else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+//                    }
+//                    add(code)
+//                    add(normalization)
+//                    add(s)
+//                }
+
+
+                //姣忎竴椤瑰叿浣撳緱鍒�
+                rowData.topItems.forEach {
+                    for (r in rowData.rules) {
+                        if (r.first.fatherid == it.guid || r.first.guid == it.guid) {
+                            // FIXME: 2021/4/25 鍐冲畾鏄惁鍐檋3
+                            if (hasHead3) {
+                                r.second.forEach { s ->
+                                    val v = searchScore(s.guid, rowData.itemevaluationList)
+                                    add(v.toIntOrNull() ?: "")
+                                }
+                            } else {
+                                val v = searchScore(r.first.guid, rowData.itemevaluationList)
+                                add(v.toIntOrNull() ?: "")
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return row
+    }
+
+    //鏌ユ壘寰楀垎璁板綍鍐呭搴旇鍒欑殑寰楀垎
+    private fun searchScore(ruleId: String?, itemevaluations: List<Itemevaluation>): String {
+        var score = ""
+        for (e in itemevaluations) {
+            if (ruleId == e.esrguid) {
+                score = e.value ?: ""
+                break
+            }
+        }
+        return if (score == "0") "" else score
+    }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt
index 9f2b23f..bbb0751 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt
@@ -2,7 +2,9 @@
 
 import cn.flightfeather.supervision.business.report.BaseCols
 import cn.flightfeather.supervision.business.report.DataSource
+import cn.flightfeather.supervision.common.utils.DateUtil
 import cn.flightfeather.supervision.common.utils.ExcelUtil
+import kotlin.math.round
 
 class ColLedger : BaseCols() {
     override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
@@ -14,6 +16,17 @@
     }
 
     override fun onOneRow(rowData: DataSource.RowData): List<Any> {
-        return listOf("", "", "")
+        val dateUtil = DateUtil()
+        rowData.ledgerRecords.sortedByDescending {
+            it.lrSubmitdate
+        }
+        val per = rowData.ledgerRecords.size.toDouble() / rowData.ledgerCount
+        var t1 = ""
+        var t2 = "/"
+        if (rowData.ledgerRecords.isNotEmpty()) {
+            val r = rowData.ledgerRecords[0]
+            t1 = "${dateUtil.DateToString(r.lrSubmitdate, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_CN)}"
+        }
+        return listOf(ExcelUtil.MyCell(per.toString(), isPercent = true), t1, t2)
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt
index 7e2cc48..979b066 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt
@@ -13,6 +13,7 @@
     }
 
     override fun onOneRow(rowData: DataSource.RowData): List<Any> {
-        return listOf(rowData.scene?.index ?: -99, rowData.scene?.extension2 ?: "", rowData.scene?.name ?: "")
+//        return listOf(rowData.scene?.index ?: -99, rowData.scene?.extension2 ?: "", rowData.scene?.name ?: "")
+        return listOf(rowData.index + 1, rowData.scene?.index ?: -99, rowData.scene?.name ?: "")
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt
new file mode 100644
index 0000000..4efda09
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt
@@ -0,0 +1,54 @@
+package cn.flightfeather.supervision.business.report.cols
+
+import cn.flightfeather.supervision.business.report.BaseCols
+import cn.flightfeather.supervision.business.report.DataSource
+import cn.flightfeather.supervision.common.utils.ExcelUtil
+import cn.flightfeather.supervision.domain.ds1.entity.Itemevaluation
+import org.apache.poi.hssf.util.HSSFColor
+
+class ColTotalGrade() : BaseCols() {
+
+    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
+        val h1 = mutableListOf<ExcelUtil.MyCell>()
+        h1.add(ExcelUtil.MyCell("鐜俊鐮�"))
+        h1.add(ExcelUtil.MyCell("闃叉不瑙勮寖鎬�"))
+        h1.add(ExcelUtil.MyCell("鎬诲垎"))
+
+        return mutableListOf(h1)
+    }
+
+    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
+        val row = mutableListOf<Any>()
+
+        if (rowData.noRecord()) {
+            repeat(heads.last().size) { row.add(("")) }
+        } else {
+            row.apply {
+                //鎬诲垎鍜岀幆淇$爜
+                rowData.evaluation.let { e ->
+                    val s = e?.resultscorebef?.toIntOrNull() ?: -1
+                    val code = when (s) {
+                        in 0..59 -> ExcelUtil.MyCell("绾㈢爜", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
+                        in 60..89 -> ExcelUtil.MyCell("榛勭爜", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
+                        in 90..100 -> ExcelUtil.MyCell("缁跨爜", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
+                        -1 -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+                        else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+                    }
+                    val normalization = when (s) {
+                        in 0..59 -> ExcelUtil.MyCell("涓ラ噸涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.RED.index)
+                        in 60..89 -> ExcelUtil.MyCell("涓嶈鑼�", fontColor = HSSFColor.HSSFColorPredefined.ROSE.index)
+                        in 90..99 -> ExcelUtil.MyCell("鍩烘湰瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.GOLD.index)
+                        100 -> ExcelUtil.MyCell("瑙勮寖", fontColor = HSSFColor.HSSFColorPredefined.BRIGHT_GREEN.index)
+                        -1 -> ExcelUtil.MyCell("", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+                        else -> ExcelUtil.MyCell("瓒呭嚭鑼冨洿锛�${s}", fontColor = HSSFColor.HSSFColorPredefined.BLACK.index)
+                    }
+                    add(code)
+                    add(normalization)
+                    add(s)
+                }
+            }
+        }
+
+        return row
+    }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt
index 8317647..7a62467 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt
@@ -4,6 +4,7 @@
 import cn.flightfeather.supervision.business.report.BaseTemplate
 import cn.flightfeather.supervision.business.report.DataSource
 import cn.flightfeather.supervision.business.report.cols.ColInspectionInfo
+import cn.flightfeather.supervision.business.report.cols.ColTotalGrade
 import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.common.utils.ExcelUtil
 import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite
@@ -16,7 +17,7 @@
  * 鍒嗚闀囬棶棰樻暣鏀瑰垎鏋愭眹鎬昏〃
  */
 class ProAnalysisSummary(dataSource: DataSource) : BaseTemplate(dataSource) {
-    override val cols: List<BaseCols> = listOf(ColInspectionInfo())
+    override val cols: List<BaseCols> = listOf(ColInspectionInfo(), ColTotalGrade())
 
     override val templateName: String = "鍒嗚闀囬棶棰樻暣鏀瑰垎鏋愭眹鎬昏〃"
 
@@ -31,6 +32,7 @@
             if (rowData.noRecord()) return@loop
 
             val r = cols[0].getOneRow(rowData)
+            val r1 = cols[1].getOneRow(rowData)
 
             val k = rowData.scene?.townname
             if (!districtMap.containsKey(k)) {
@@ -70,6 +72,12 @@
                 if (pNum > 0 && cNum > 0) changeScenes++
                 proNum += pNum
                 changeNum += cNum
+
+
+                val standard = r1[1] as ExcelUtil.MyCell
+                if (standard.text.contains("涓嶈鑼�")) {
+                    focusSceneNum++
+                }
             }
         }
 
@@ -81,23 +89,32 @@
         }
         districtMap.forEach {
             val v = it.value
-            v.changeScenePer = round(v.changeScenes.toDouble() / v.sceneCount * 1000) / 1000
-            v.proPer = round(v.proNum.toDouble() / totalPro * 1000) / 1000
-            v.changePer = round(v.changeNum.toDouble() / v.proNum * 1000) / 1000
+            v.changeScenePer = v.changeScenes.toDouble() / v.sceneCount
+            v.proPer = v.proNum.toDouble() / totalPro
+            v.changePer = v.changeNum.toDouble() / v.proNum
+            v.focusScenePer = v.focusSceneNum.toDouble() / v.sceneCount
         }
         //鏁存敼鍗曚綅姣旀帓鍚�
         summarys.sortByDescending {
             it.changeScenePer
         }
         for (i in summarys.indices) {
-            summarys[i].changeSceneRank = i + 1
+            if (i > 0 && summarys[i - 1].changeScenePer == summarys[i].changeScenePer) {
+                summarys[i].changeSceneRank = summarys[i - 1].changeSceneRank
+            } else {
+                summarys[i].changeSceneRank = i + 1
+            }
         }
         //闂鏁存敼鐜囨帓鍚�
         summarys.sortByDescending {
             it.changePer
         }
         for (i in summarys.indices) {
-            summarys[i].proChangeRank = i + 1
+            if (i > 0 && summarys[i - 1].changePer == summarys[i].changePer) {
+                summarys[i].proChangeRank = summarys[i - 1].proChangeRank
+            } else {
+                summarys[i].proChangeRank = i + 1
+            }
         }
 
         //鏇存柊琛ㄥご
@@ -131,12 +148,15 @@
             ExcelUtil.MyCell("鎷熷垪鍏ラ噸鐐圭洃绠″崰姣�"),
         ))
         //鏇存柊鍐呭
-        summarys.forEach {
+        summarys.sortBy { it.townCode }
+        for (i in summarys.indices) {
+            val it = summarys[i]
             contents.add(
                 mutableListOf(
-                    it.townCode, it.townName, it.type, it.sceneCount, it.inactiveScenes, it.activeScenes, it.changeScenes,
-                    "${round(it.changeScenePer * 1000) / 10}%",
-                    it.proNum, "${round(it.proPer * 1000) / 10}%", it.changeNum, "${round(it.changePer * 1000) / 10}%", it.changeSceneRank, it.proChangeRank
+                    i+1, it.townName, it.type, it.sceneCount, it.inactiveScenes, it.activeScenes, it.changeScenes,
+                        ExcelUtil.MyCell(it.changeScenePer.toString(), isPercent = true),
+                    it.proNum, ExcelUtil.MyCell(it.proPer.toString(), isPercent = true), it.changeNum, ExcelUtil.MyCell(it.changePer.toString(), isPercent = true), it.changeSceneRank, it.proChangeRank,
+                        it.focusSceneNum, ExcelUtil.MyCell(it.focusScenePer.toString(), isPercent = true)
                 )
             )
         }
@@ -165,5 +185,8 @@
 
         var changeSceneRank = 0
         var proChangeRank = 0
+
+        var focusSceneNum = 0
+        var focusScenePer = .0
     }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt
index edc0440..7435e3d 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt
@@ -4,9 +4,11 @@
 import cn.flightfeather.supervision.business.report.BaseTemplate
 import cn.flightfeather.supervision.business.report.DataSource
 import cn.flightfeather.supervision.business.report.cols.ColInspectionInfo
+import cn.flightfeather.supervision.business.report.cols.ColLedger
 import cn.flightfeather.supervision.business.report.cols.ColSceneName
 
 class ProDetailSummary(dataSource: DataSource) : BaseTemplate(dataSource) {
-    override val cols: List<BaseCols> = listOf(ColSceneName(), ColInspectionInfo())
+    override val cols: List<BaseCols> = listOf(ColSceneName(), ColInspectionInfo(), ColLedger())
+
     override val templateName: String = "闂涓庢暣鏀硅窡韪眹鎬昏〃"
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
index 688d2e2..1eec3c3 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt
@@ -1,14 +1,20 @@
 package cn.flightfeather.supervision.business.report.template
 
 import cn.flightfeather.supervision.business.report.DataSource
+import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.common.utils.ExcelUtil
 import kotlin.math.round
 
 class ProTypeRankMainSummary(dataSource: DataSource) : ProTypeRankSummary(dataSource) {
     override val templateName: String = "鏈堝害涓昏鎴栧吀鍨嬮棶棰樺垎鏋愯〃"
 
-    override fun formatTable(summarys: List<Summary>) {
-        summarys.sortedByDescending { it.count }
+    override fun formatTable(summarys: MutableList<Summary>) {
+        val max = when (dataSource.config.sceneType.toString()) {
+            Constant.ScenseType.TYPE1.value -> 5
+            else -> 4
+        }
+
+        summarys.sortByDescending { it.count }
 
         head.clear()
         head.add(
@@ -36,11 +42,13 @@
             )
         )
         for (i in summarys.indices) {
+            if (i >= max) break
+
             val s = summarys[i]
             contents.add(
                 mutableListOf(
-                    i + 1, "", "", dataSource.rowData.scene?.type ?: "", "", s.count,
-                    s.proDes, s.count, "${round(s.countPer * 1000) / 10}%"
+                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.count,
+                    s.proDes, s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true)
                 )
             )
         }
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt
index 0eec5f3..04aef32 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt
@@ -48,19 +48,27 @@
         for (i in summarys.indices) {
             val it = summarys[i]
             it.countPer = it.count.toDouble() / tPros
-            it.countRank = i + 1
+            if (i > 0 && summarys[i - 1].countPer == it.countPer) {
+                it.countRank = summarys[i - 1].countRank
+            } else {
+                it.countRank = i + 1
+            }
             it.changePer = it.changeNum.toDouble() / it.count
         }
         summarys.sortByDescending { it.changePer }
         for (i in summarys.indices) {
             val it = summarys[i]
-            it.changeRank = i + 1
+            if (i > 0 && summarys[i - 1].changePer == it.changePer) {
+                it.changeRank = summarys[i - 1].changeRank
+            } else {
+                it.changeRank = i + 1
+            }
         }
 
         formatTable(summarys)
     }
 
-    open fun formatTable(summarys: List<Summary>) {
+    open fun formatTable(summarys: MutableList<Summary>) {
         head.clear()
         head.add(
             mutableListOf(
@@ -94,13 +102,21 @@
         )
         for (i in summarys.indices) {
             val s = summarys[i]
+//            contents.add(
+//                mutableListOf(
+//                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area,
+//                    s.proType, s.proDes,
+//                    s.count, "${round(s.countPer * 1000) / 10}%", s.countRank,
+//                    s.changeNum, "${round(s.changePer * 1000) / 10}%", s.changeRank
+//                )
+//            )
             contents.add(
-                mutableListOf(
-                    i + 1, "", "", dataSource.rowData.scene?.type ?: "", "",
-                    s.proType, s.proDes,
-                    s.count, "${round(s.countPer * 1000) / 10}%", s.countRank,
-                    s.changeNum, "${round(s.changePer * 1000) / 10}%", s.changeRank
-                )
+                    mutableListOf(
+                            i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area,
+                            s.proType, s.proDes,
+                            s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true), s.countRank,
+                            s.changeNum, ExcelUtil.MyCell(s.changePer.toString(), isPercent = true), s.changeRank
+                    )
             )
         }
     }
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt
index b63af99..aa6e38a 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt
@@ -100,10 +100,10 @@
             val s = summarys[i]
             contents.add(
                 mutableListOf(
-                    i + 1, "", "", dataSource.rowData.scene?.type ?: "", "", s.status, s.status,
+                    i + 1, dataSource.year, dataSource.month, dataSource.rowData.scene?.type ?: "", dataSource.area, s.status, s.status,
                     s.proType, s.proDes,
-                    s.count, "${round(s.countPer * 1000) / 10}%",
-                    s.changeNum, "${round(s.changePer * 1000) / 10}%",
+                    s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true),
+                    s.changeNum, ExcelUtil.MyCell(s.changePer.toString(), isPercent = true),
                 )
             )
         }
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt
index e6bf6cb..1dce64b 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt
@@ -3,12 +3,12 @@
 import cn.flightfeather.supervision.business.report.BaseCols
 import cn.flightfeather.supervision.business.report.BaseTemplate
 import cn.flightfeather.supervision.business.report.DataSource
-import cn.flightfeather.supervision.business.report.cols.ColGrade
+import cn.flightfeather.supervision.business.report.cols.ColTotalGrade
 import cn.flightfeather.supervision.common.utils.ExcelUtil
 import kotlin.math.round
 
 class ScoreAnalysisSummary(dataSource: DataSource) : BaseTemplate(dataSource) {
-    override val cols: List<BaseCols> = listOf(ColGrade())
+    override val cols: List<BaseCols> = listOf(ColTotalGrade())
 
     override val templateName: String = "鍒嗚闀囪鑼冩�у垎鏋愯〃"
 
@@ -75,7 +75,7 @@
             tNonstandard += v.nonstandard
             tStandard += v.standard
         }
-        summarys.sortByDescending { it.standardPer }
+        summarys.sortByDescending { it.standard }
         for (i in summarys.indices) {
             val it = summarys[i]
             //鍙傝瘎鐧惧垎姣�
@@ -90,7 +90,11 @@
             //瑙勮寖鍖哄煙鍗犳瘮
             it.standardPer = it.standard.toDouble() / tStandard
             //瑙勮寖鍗犳瘮鎺掑悕
-            it.rank = i + 1
+            if (i > 0 && summarys[i - 1].standard == it.standard) {
+                it.rank = summarys[i - 1].rank
+            } else {
+                it.rank = i + 1
+            }
         }
 
         head.clear()
@@ -124,16 +128,18 @@
             ExcelUtil.MyCell("瑙勮寖鎬ф帓鍚�"),
         ))
 
-        summarys.forEach {
+        summarys.sortBy { it.townCode }
+        for (i in summarys.indices) {
+            val it = summarys[i]
             contents.add(
                 mutableListOf(
-                    it.townCode, it.townName, it.type, it.sceneCount, it.gradeCount, "${round(it.gradePer * 1000) / 10}%",
-                    it.level1, "${round(it.level1Per * 1000) / 10}%",
-                    it.level2, "${round(it.level2Per * 1000) / 10}%",
-                    it.level3, "${round(it.level3Per * 1000) / 10}%",
-                    it.level4, "${round(it.level4Per * 1000) / 10}%",
-                    it.nonstandard, "${round(it.nonstandardPer * 1000) / 10}%",
-                    it.standard, "${round(it.standardPer * 1000) / 10}%",
+                    i + 1, it.townName, it.type, it.sceneCount, it.gradeCount, ExcelUtil.MyCell(it.gradePer.toString(), isPercent = true),
+                    it.level1, ExcelUtil.MyCell(it.level1Per.toString(), isPercent = true),
+                    it.level2, ExcelUtil.MyCell(it.level2Per.toString(), isPercent = true),
+                    it.level3, ExcelUtil.MyCell(it.level3Per.toString(), isPercent = true),
+                    it.level4, ExcelUtil.MyCell(it.level4Per.toString(), isPercent = true),
+                    it.nonstandard, ExcelUtil.MyCell(it.nonstandardPer.toString(), isPercent = true),
+                    it.standard, ExcelUtil.MyCell(it.standardPer.toString(), isPercent = true),
                     it.rank
                 )
             )
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt
index 25b3c7a..0669097 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt
@@ -3,11 +3,12 @@
 import cn.flightfeather.supervision.business.report.BaseCols
 import cn.flightfeather.supervision.business.report.BaseTemplate
 import cn.flightfeather.supervision.business.report.DataSource
-import cn.flightfeather.supervision.business.report.cols.ColGrade
+import cn.flightfeather.supervision.business.report.cols.ColItemGrade
 import cn.flightfeather.supervision.business.report.cols.ColSceneName
+import cn.flightfeather.supervision.business.report.cols.ColTotalGrade
 import cn.flightfeather.supervision.business.report.cols.ColTown
 
 class ScoreDetailSummary(dataSource: DataSource) : BaseTemplate(dataSource) {
-    override val cols: List<BaseCols> = listOf(ColSceneName(), ColTown(), ColGrade())
+    override val cols: List<BaseCols> = listOf(ColSceneName(), ColTown(), ColTotalGrade(), ColItemGrade())
     override val templateName: String = "瑙勮寖鎬ц瘎浼拌鎯呰〃"
 }
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/DateUtil.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/DateUtil.kt
index 455e29f..2584613 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/DateUtil.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/DateUtil.kt
@@ -271,7 +271,7 @@
      * @return 鏃ユ湡瀛楃涓�
      */
     fun DateToString(date: Date?, pattern: String): String? {
-        var dateString: String? = null
+        var dateString: String? = ""
         if (date != null) {
             try {
                 dateString = getDateFormat(pattern).format(date)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt b/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
index 3bd21a9..f69a607 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt
@@ -2,11 +2,11 @@
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook
 import org.apache.poi.ss.util.CellRangeAddress
-import java.io.File
 import java.io.OutputStream
 import java.time.LocalDate
 import java.util.*
 import kotlin.math.max
+
 
 /**
  * @author riku
@@ -18,7 +18,8 @@
         var text: String,
         var rowSpan: Int = 1,
         var colSpan: Int = 1,
-        var fontColor: Short? = null
+        var fontColor: Short? = null,
+        var isPercent:Boolean = false
     )
 
     /**
@@ -88,15 +89,26 @@
                 when (c) {
                     is MyCell -> {
                         rows.createCell(col).apply {
-                            c.fontColor?.let {fC ->
-                                val font = workbook.createFont()
+                            if (c.isPercent) {
                                 val cellStyle = workbook.createCellStyle()
-
-                                font.color = fC
-                                cellStyle.setFont(font)
+                                val format = workbook.createDataFormat()
+                                cellStyle.dataFormat = format.getFormat("0.0%")
                                 setCellStyle(cellStyle)
+                                val v = c.text.toDoubleOrNull()
+                                if (v != null) {
+                                    setCellValue(v)
+                                }
+                            } else {
+                                c.fontColor?.let {fC ->
+                                    val font = workbook.createFont()
+                                    val cellStyle = workbook.createCellStyle()
+
+                                    font.color = fC
+                                    cellStyle.setFont(font)
+                                    setCellStyle(cellStyle)
+                                }
+                                setCellValue(c.text)
                             }
-                            setCellValue(c.text)
                         }
                         println("write1-1: ${c.text};($rowIndex, ${col})")
                     }
@@ -150,7 +162,28 @@
 
                         when (c) {
                             is MyCell -> {
-                                rows.createCell(map.key).setCellValue(c.text)
+                                rows.createCell(col).apply {
+                                    if (c.isPercent) {
+                                        val cellStyle = workbook.createCellStyle()
+                                        val format = workbook.createDataFormat()
+                                        cellStyle.dataFormat = format.getFormat("0.0%")
+                                        setCellStyle(cellStyle)
+                                        val v = c.text.toDoubleOrNull()
+                                        if (v != null) {
+                                            setCellValue(v)
+                                        }
+                                    } else {
+                                        c.fontColor?.let {fC ->
+                                            val font = workbook.createFont()
+                                            val cellStyle = workbook.createCellStyle()
+
+                                            font.color = fC
+                                            cellStyle.setFont(font)
+                                            setCellStyle(cellStyle)
+                                        }
+                                        setCellValue(c.text)
+                                    }
+                                }
                                 println("write2-1: ${c.text};($_rowIndex, ${map.key})")
                             }
                             is String -> {
@@ -191,10 +224,6 @@
         workbook.close()
         out.flush()
         out.close()
-    }
-
-    fun write3() {
-
     }
 
     private fun getMaxRows(rowArray: Array<Any>): Int {
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/entity/DustDataResult.java b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/entity/DustDataResult.java
index e3e174d..0418c15 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/entity/DustDataResult.java
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/entity/DustDataResult.java
@@ -19,7 +19,7 @@
      * 鍦烘櫙鍚嶇О
      */
     @Column(name = "DR_Scene_Name")
-    private Integer drSceneName;
+    private String drSceneName;
 
     /**
      * 璁板綍鏈堜唤
@@ -106,7 +106,7 @@
      *
      * @return DR_Scene_Name - 鍦烘櫙鍚嶇О
      */
-    public Integer getDrSceneName() {
+    public String getDrSceneName() {
         return drSceneName;
     }
 
@@ -115,7 +115,7 @@
      *
      * @param drSceneName 鍦烘櫙鍚嶇О
      */
-    public void setDrSceneName(Integer drSceneName) {
+    public void setDrSceneName(String drSceneName) {
         this.drSceneName = drSceneName;
     }
 
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 647b09e..1025cf9 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
@@ -9,6 +9,9 @@
 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.ds2.mapper.LedgerRecordMapper
+import cn.flightfeather.supervision.domain.ds2.mapper.LedgerSubTypeMapper
+import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper
 import cn.flightfeather.supervision.lightshare.service.SearchService
 import cn.flightfeather.supervision.lightshare.vo.*
 import com.github.pagehelper.PageHelper
@@ -28,25 +31,28 @@
  */
 @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 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,
 ) : SearchService {
 
     private val dateUtil = DateUtil()
@@ -63,7 +69,8 @@
             sceneStorageYardMapper,
             sceneWharfMapper,
             taskMapper,
-            evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper
+            evaluationruleMapper, evaluationsubruleMapper, evaluationMapper, itemevaluationMapper,
+                ledgerSubTypeMapper, ledgerRecordMapper, userinfoMapper, userMapMapper, townMapper
         )
         val dataSource = DataSource(config, dbMapper)
         val t = when (mode) {
diff --git a/src/main/resources/mapper/ds1/DustDataResultMapper.xml b/src/main/resources/mapper/ds1/DustDataResultMapper.xml
index 07b6df5..d96848f 100644
--- a/src/main/resources/mapper/ds1/DustDataResultMapper.xml
+++ b/src/main/resources/mapper/ds1/DustDataResultMapper.xml
@@ -7,7 +7,7 @@
     -->
     <id column="DR_Id" property="drId" jdbcType="INTEGER" />
     <result column="DR_Scene_Id" property="drSceneId" jdbcType="VARCHAR" />
-    <result column="DR_Scene_Name" property="drSceneName" jdbcType="INTEGER" />
+    <result column="DR_Scene_Name" property="drSceneName" jdbcType="VARCHAR" />
     <result column="DR_Time" property="drTime" jdbcType="DATE" />
     <result column="DR_Exceed_Times" property="drExceedTimes" jdbcType="INTEGER" />
     <result column="DR_Avg" property="drAvg" jdbcType="DOUBLE" />

--
Gitblit v1.9.3