package cn.flightfeather.supervision.business.report.template
|
|
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.ColInspectionInfo
|
import cn.flightfeather.supervision.common.utils.Constant
|
import cn.flightfeather.supervision.common.utils.ExcelUtil
|
import cn.flightfeather.supervision.domain.ds1.entity.SceneConstructionSite
|
import cn.flightfeather.supervision.domain.ds1.entity.SceneMixingPlant
|
import cn.flightfeather.supervision.domain.ds1.entity.SceneStorageYard
|
import cn.flightfeather.supervision.domain.ds1.entity.SceneWharf
|
import kotlin.math.round
|
|
/**
|
* 分街镇问题整改分析汇总表
|
*/
|
class ProAnalysisSummary(dataSource: DataSource) : BaseTemplate(dataSource) {
|
override val cols: List<BaseCols> = listOf(ColInspectionInfo())
|
|
override val templateName: String = "分街镇问题整改分析汇总表"
|
|
override fun execute() {
|
//数据源重置
|
dataSource.reset()
|
|
cols.forEach { it.combineHead(head,dataSource) }
|
|
val districtMap = mutableMapOf<String?, Summary>()
|
dataSource.loop { _, rowData ->
|
if (rowData.noRecord()) return@loop
|
|
val r = cols[0].getOneRow(rowData)
|
|
val k = rowData.scene?.townname
|
if (!districtMap.containsKey(k)) {
|
districtMap[k] = Summary().apply {
|
townCode = rowData.scene?.towncode ?: ""
|
townName = rowData.scene?.townname ?: ""
|
type = rowData.scene?.type ?: ""
|
}
|
}
|
districtMap[k]?.apply {
|
sceneCount++
|
val status = when (dataSource.config.sceneType.toString()) {
|
Constant.ScenseType.TYPE1.value -> {
|
(rowData.baseScene as SceneConstructionSite?)?.csStatus
|
}
|
Constant.ScenseType.TYPE2.value -> {
|
(rowData.baseScene as SceneWharf?)?.getwStatus()
|
}
|
Constant.ScenseType.TYPE3.value -> {
|
(rowData.baseScene as SceneMixingPlant?)?.mpStatus
|
}
|
Constant.ScenseType.TYPE14.value -> {
|
(rowData.baseScene as SceneStorageYard?)?.syStatus
|
}
|
else -> ""
|
}
|
// FIXME: 2022/7/18 后续场景的施工状态改为布尔值存储
|
if ((status?.contains("完工") == true) || (status?.contains("未施工") == true) || (status?.contains("停") == true)
|
|| (status?.contains("关") == true)
|
) {
|
inactiveScenes++
|
} else {
|
activeScenes++
|
}
|
val pNum = r[5] as Int
|
val cNum = r[9] as Int
|
if (pNum > 0 && cNum > 0) changeScenes++
|
proNum += pNum
|
changeNum += cNum
|
}
|
}
|
|
val summarys = mutableListOf<Summary>()
|
var totalPro = 0
|
districtMap.forEach {
|
summarys.add(it.value)
|
totalPro += it.value.proNum
|
}
|
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
|
}
|
//整改单位比排名
|
summarys.sortByDescending {
|
it.changeScenePer
|
}
|
for (i in summarys.indices) {
|
summarys[i].changeSceneRank = i + 1
|
}
|
//问题整改率排名
|
summarys.sortByDescending {
|
it.changePer
|
}
|
for (i in summarys.indices) {
|
summarys[i].proChangeRank = i + 1
|
}
|
|
//更新表头
|
head.clear()
|
head.add(mutableListOf(
|
ExcelUtil.MyCell("街镇序号", rowSpan = 2),
|
ExcelUtil.MyCell("区域"),
|
ExcelUtil.MyCell("场景类别", rowSpan = 2),
|
ExcelUtil.MyCell("场景状态", colSpan = 3),
|
ExcelUtil.MyCell("整改单位", colSpan = 2),
|
ExcelUtil.MyCell("问题与整改", colSpan = 4),
|
ExcelUtil.MyCell("排名", colSpan = 2),
|
ExcelUtil.MyCell("区域监管策略", colSpan = 2),
|
))
|
head.add(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("拟列入重点监管占比"),
|
))
|
//更新内容
|
summarys.forEach {
|
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
|
)
|
)
|
}
|
}
|
|
inner class Summary(){
|
var townCode = ""
|
var townName = ""
|
var type = ""
|
var sceneCount = 0
|
//停运的场景数
|
var inactiveScenes = 0
|
var activeScenes = 0
|
|
var changeScenes = 0
|
var changeScenePer = .0
|
set(value) { field = if (value.isNaN()) .0 else value }
|
|
var proNum = 0
|
var proPer = .0
|
set(value) { field = if (value.isNaN()) .0 else value }
|
|
var changeNum = 0
|
var changePer = .0
|
set(value) { field = if (value.isNaN()) .0 else value }
|
|
var changeSceneRank = 0
|
var proChangeRank = 0
|
}
|
}
|