feiyu02
2022-07-20 39e208b6b0482a25c77e53590087c02d9d937563
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) {
            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) {
            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
    }
}