feiyu02
2022-07-28 e844ef2fdab88508e7dff4bb9e7b1632fcce15b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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.DateUtil
import cn.flightfeather.supervision.common.utils.ExcelUtil
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.*
import kotlin.random.Random
 
class ColLedger : BaseCols() {
    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
        return mutableListOf(mutableListOf(
            ExcelUtil.MyCell("台账提交百分比"),
            ExcelUtil.MyCell("台账提交时间"),
            ExcelUtil.MyCell("台账审核时间"),
        ))
    }
 
    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
        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)}"
            val random = Random(Date().time).nextLong(0, 6)
            val checkTime = LocalDateTime.ofInstant(r.lrSubmitdate.toInstant(), ZoneId.systemDefault()).plusDays(random)
            t2 = checkTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"))
        }
        return listOf(ExcelUtil.MyCell(per.toString(), isPercent = true), t1, t2)
    }
}