feiyu02
2022-07-20 39e208b6b0482a25c77e53590087c02d9d937563
1. 巡查汇总报告功能编写完成
已修改17个文件
已删除1个文件
已添加2个文件
645 ■■■■ 文件已修改
src/main/kotlin/cn/flightfeather/supervision/business/report/BaseCols.kt 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/DataSource.kt 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColItemGrade.kt 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColLedger.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColSceneName.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColTotalGrade.kt 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProAnalysisSummary.kt 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProDetailSummary.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankMainSummary.kt 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeRankSummary.kt 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ProTypeStatusSummary.kt 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreAnalysisSummary.kt 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/business/report/template/ScoreDetailSummary.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/utils/DateUtil.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/common/utils/ExcelUtil.kt 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/domain/ds1/entity/DustDataResult.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/SearchServiceImpl.kt 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ds1/DustDataResultMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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])
            }
        }
    }
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,
)
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColGrade.kt
ÎļþÒÑɾ³ý
src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColInspectionInfo.kt
@@ -22,10 +22,14 @@
            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
                    )
                )
            }
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 å†³å®šæ˜¯å¦å†™h3
                            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
    }
}
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)
    }
}
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 ?: "")
    }
}
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
    }
}
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
    }
}
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 = "问题与整改跟踪汇总表"
}
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)
                )
            )
        }
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
            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]
            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,12 +102,20 @@
        )
        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 ?: "", "",
                            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
                            s.count, ExcelUtil.MyCell(s.countPer.toString(), isPercent = true), s.countRank,
                            s.changeNum, ExcelUtil.MyCell(s.changePer.toString(), isPercent = true), s.changeRank
                )
            )
        }
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),
                )
            )
        }
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
            //规范占比排名
            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
                )
            )
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 = "规范性评估详情表"
}
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)
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,6 +89,16 @@
                when (c) {
                    is MyCell -> {
                        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()
@@ -97,6 +108,7 @@
                                setCellStyle(cellStyle)
                            }
                            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 {
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;
    }
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
@@ -46,7 +49,10 @@
    val evaluationruleMapper: EvaluationruleMapper,
    val evaluationsubruleMapper: EvaluationsubruleMapper2,
    val evaluationMapper: EvaluationMapper,
    val itemevaluationMapper: ItemevaluationMapper
        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) {
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" />