feiyu02
2026-01-20 9558ad87cc950bd67306aa31e5f3b7de367258ae
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt
@@ -11,6 +11,7 @@
import cn.flightfeather.supervision.domain.repository.LedgerMediaFileRep
import cn.flightfeather.supervision.domain.repository.LedgerRep
import cn.flightfeather.supervision.domain.repository.UserInfoRep
import cn.flightfeather.supervision.domain.repository.UserSettingRep
import cn.flightfeather.supervision.infrastructure.utils.DateUtil
import cn.flightfeather.supervision.infrastructure.utils.FileUtil
import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator
@@ -43,6 +44,7 @@
    private val ledgerMediaFileRep: LedgerMediaFileRep,
    private val userInfoRep: UserInfoRep,
    private val ledgerRep: LedgerRep,
    private val userSettingRep: UserSettingRep,
) : LedgerService {
    @Value("\${imgPath}")
@@ -509,6 +511,7 @@
        sceneType: Int,
        time: String,
    ): List<LedgerRecord> {
        // 查询相关的所有台账类型
        val ledgerSubTypes = ledgerSubTypeMapper.selectByExample(Example(LedgerSubType::class.java).apply {
            if (ledgerSubTypeId != null) {
                createCriteria().andEqualTo("lsSubtypeid", ledgerSubTypeId)
@@ -516,6 +519,17 @@
                createCriteria().andEqualTo("lScenetype", sceneType)
            }
        })
        // 2026.1.20 新增自巡查承诺后,自巡查的有效周期延长至一年(当年内)
        val promised = userSettingRep.checkIsSelfPatrolPromised(userId)
        if (promised) {
            ledgerSubTypes.onEach {
                if (it.getlTypeid() == -1) {
                    it.setlPeriod(12)
                }
            }
        }
        val c = Calendar.getInstance().apply { this.time = DateUtil.StringToDate(time) }
        val year = c.get(Calendar.YEAR)
        val month = c.get(Calendar.MONTH) + 1
@@ -529,10 +543,11 @@
        }
        val records = mutableListOf<LedgerRecord>()
        map.forEach { (p, v) ->
            // 按照周期分组,统一查询相同周期的所有台账
            // FIXME: 2020/11/10  此处根据周期和当前月份计算得到当前月份所在周期的始末月,只适用于周期小于等于12个月的情况。后续待修改
            val startMon = ceil(month.toDouble() / p).toInt().minus(1).times(p).plus(1)
            var endMon = startMon + p - 1
            if (endMon > month) endMon = month
//            if (endMon > month) endMon = month
            val r = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
                createCriteria().andEqualTo("lrSubmitid", userId)
                    .andEqualTo("lrYear", year)
@@ -540,6 +555,7 @@
                    .andLessThanOrEqualTo("lrMonth", endMon.toByte())
                    .andIn("lsSubtypeid", v)
            })
            // 筛选每种台账记录中的最新一条
            val monMap = mutableMapOf<Int, LedgerRecord>()
            r.forEach {
                if (monMap.containsKey(it.lsSubtypeid)) {