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
|
}
|
}
|