src/main/kotlin/cn/flightfeather/supervision/business/report/cols/ColStrategy.kt
@@ -7,8 +7,9 @@
import java.time.Duration
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.temporal.ChronoUnit
class ColStrategy : BaseCols() {
class ColStrategy(chooseIndexList: List<Int> = emptyList()) : BaseCols(chooseIndexList) {
    override fun onHeads(dataSource: DataSource): MutableList<MutableList<ExcelUtil.MyCell>> {
        return mutableListOf(mutableListOf(
            ExcelUtil.MyCell("整改跟踪提醒")
@@ -16,7 +17,7 @@
    }
    override fun onOneRow(rowData: DataSource.RowData): List<Any> {
        if (rowData.problems.isEmpty()) return listOf("")
        if (rowData.noRecord()) return listOf("")
        val strategyList = listOf(
            "1、存在问题超期3天不满7天未整改,由系统推送整改提醒;",
@@ -40,29 +41,32 @@
                continue
            }
            val pTime = LocalDateTime.ofInstant(p.time?.toInstant(), ZoneId.systemDefault())
            val duration = Duration.between(pTime.toLocalDate(), now)
            val day = duration.toDays()
            val day = pTime.toLocalDate().until(now.toLocalDate(), ChronoUnit.DAYS)
            when {
                //1、存在问题超期3天不满7天未整改,由系统推送整改提醒;
                day in 3..6 -> {
                    result += strategyList[0] + "\n"
                    break
                }
                //2、存在问题超期7天未整改,由技术服务部线上督促;
                day > 6 -> {
                    result += strategyList[1] + "\n"
                    break
                }
            }
        }
        //3、巡查后10天或月末前3天,问题整改率低于50%,由数据应用部一对一督促,并于主管部门联动;
        //整改率
        val cPer = cPros.toDouble() / rowData.problems.size
        //巡查时间
        val sTime = LocalDateTime.ofInstant(rowData.subTask?.planstarttime?.toInstant(), ZoneId.systemDefault())
        val day1 = Duration.between(sTime.toLocalDate(), now).toDays()
        val day1 = sTime.toLocalDate().until(now.toLocalDate(), ChronoUnit.DAYS)
        val lastDayOfMon = now.plusMonths(1).withDayOfMonth(1).minusDays(1)
        val day2 = Duration.between(lastDayOfMon.toLocalDate(), now.toLocalDate()).toDays()
        val day2 = lastDayOfMon.toLocalDate().until(now.toLocalDate(), ChronoUnit.DAYS)
        if (cPer < .5 && (day1 >= 10 || day2 <= 3)) result += strategyList[2] + "\n"
        //4、问题审核或整改审核未开展或问题审核较巡查时间延后24小时以上或问题与整改时间间隔超过一周,项目管理人员应及时开展审核或后续应提升审核时效性;
        //审核
        for (p in rowData.problems) {
            //问题审核或整改审核未开展
@@ -80,7 +84,7 @@
            if (p.changedtime != null) {
                val ct = LocalDateTime.ofInstant(p.changedtime?.toInstant(), ZoneId.systemDefault())
                val pt = LocalDateTime.ofInstant(p.time?.toInstant(), ZoneId.systemDefault())
                if (Duration.between(pt.toLocalDate(), ct.toLocalDate()).toDays() > 7) {
                if (pt.toLocalDate().until(ct.toLocalDate(), ChronoUnit.DAYS) > 7) {
                    result += strategyList[3] + "\n"
                    break
                }
@@ -89,18 +93,46 @@
        }
        //5、台账未按时提交,由技术服务部一对一督促;
        //台账
        val rNum = rowData.ledgerRecords.size
        if (rNum == 0) result += strategyList[4] + "\n"
        //6、台账已部分提交,提交比例不足100%的,由数据应用部一对一督促;
        if (rNum != 0 && rNum < rowData.ledgerCount) result += strategyList[5] + "\n"
        //7、当月问题数超3个且全部未整改或连续两月问题整改率低于50%的场景,列为重点监管,由技术服务部当月增加不少于一次现场复核;
        val lastMonData = rowData.lastOne()
        if (rowData.problems.size > 3 && cPros == 0) {
            result += strategyList[6] + "\n"
        } else if (cPer < .5) {
            if (!lastMonData.noRecord()) {
                var lastCPer = 0
                lastMonData.problems.forEach {
                    if (it.ischanged == true) {
                        lastCPer++
                    }
                }
                if (lastMonData.problems.size != 0 && (lastCPer.toDouble() / lastMonData.problems.size > .5)) {
                    result += strategyList[6] + "\n"
                }
            }
        }
        //8、连续两月台账提交比例低于50%的,由技术服务部当月增加一次现场或线上操作指导;
        val thisMonLedgerPer = rowData.ledgerRecords.size.toDouble() / rowData.ledgerCount
        if (thisMonLedgerPer < .5) {
            val lastMonLedgerPer = lastMonData.ledgerRecords.size.toDouble() / lastMonData.ledgerCount
            if (lastMonLedgerPer < .5) {
                result += strategyList[7] + "\n"
            }
        }
        //9、台账审核较提交时间延后5日以上或月末前3日仍未审核的,由数据应用部及时开展;
        // TODO: 2022/7/26
        return strategyList
        if (result.isNotEmpty()) {
            result = result.substring(0, result.length - 2)
        }
        return listOf(result)
    }
}