src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/TaskServiceImpl.kt
@@ -21,6 +21,8 @@
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
import java.time.ZoneId
import java.util.*
import kotlin.collections.ArrayList
@@ -405,20 +407,34 @@
                        this.totalProblemNum += proList.size.toDouble() / ids.size
                        this.changedProblemNum += proList.filter { it.ischanged == true }.size.toDouble() / ids.size
                        this.changedProblemNumOnTime += proList.filter {
                            // 是否在同一天内整改
                            val _changedDate = it.changedtime?.let { c->
                                LocalDateTime.ofInstant(c.toInstant(), ZoneId.systemDefault()).toLocalDate()
                            }
                            val _proDate = it.time?.let { t->
                                LocalDateTime.ofInstant(t.toInstant(), ZoneId.systemDefault()).toLocalDate()
                            }
                            val isSameDay = _changedDate?.equals(_proDate)
                            it.ischanged == true && (isSameDay ?: false)
                        }.size.toDouble() / ids.size
                        this.efficientChangedProNum += proList.filter {
                            // 整改耗时(天)
                            val day = ((it.changedtime?.time ?: 0L) - (it?.time?.time ?: 0L)).div(1000 * 60 * 60 * 24)
                            it.ischanged == true && day <= 1
                            it.ischanged == true && day <= 2
                        }.size.toDouble() / ids.size
                        // 此处先累计巡查时长,最后再根据任务数量平均
                        this.avgInspectionTime +=
                            ((fst.executionendtime?.time ?: 0L) - (fst.executionstarttime?.time ?: 0L)).div(1000).div(ids.size)
                        this.avgInspectionTime += if (fst.executionendtime == null || fst.executionstarttime == null) {
                            0
                        } else {
                            (fst.executionendtime!!.time - fst.executionstarttime!!.time).div(1000).div(ids.size)
                        }
                    }
                }
            }
            // 统一计算平均巡查时长(秒)
            userProgressMap.forEach { (t, u) ->
                u.avgInspectionTime = (u.avgInspectionTime / u.completeTaskNum).toLong()
                u.avgInspectionTime = if (u.completeTaskNum == .0 ) 0 else (u.avgInspectionTime / u.completeTaskNum).toLong()
                u.formatParam()
            }