From 9558ad87cc950bd67306aa31e5f3b7de367258ae Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 20 一月 2026 17:29:23 +0800
Subject: [PATCH] 2026.1.20 1. 新增自巡查承诺功能接口

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt
index 96ca914..6e3f009 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt
+++ b/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}")
@@ -231,13 +233,14 @@
                         .andEqualTo("mfFiletype", it.lrEasubmitkind)
                     orderBy("mfSavetime").desc()
                 }
-            )
+            )?.takeIf { it.isNotEmpty() }?.get(0)
             val type = ledgerSubTypeMapper.selectByExample(
                 Example(LedgerSubType::class.java).apply {
                     createCriteria().andEqualTo("lsSubtypeid", it.lsSubtypeid)
                 }
             )
             result.add(LedgerVo().apply {
+
                 id = it.lrGuid
                 this.ledgerSubTypeId = it.lsSubtypeid
                 ledgerName = it.lsSubtypename
@@ -248,10 +251,10 @@
                 updateDate = it.lrSubmitdate
                 updateType = it.lrUpdatetype
                 fileType = it.lrEasubmitkind.toInt()
-                path1 = media?.get(0)?.mfPath1
-                remark1 = media?.get(0)?.mfDescription1
-                path2 = media?.get(0)?.mfPath2
-                remark2 = media?.get(0)?.mfDescription2
+                path1 = media?.mfPath1
+                remark1 = media?.mfDescription1
+                path2 = media?.mfPath2
+                remark2 = media?.mfDescription2
                 this.sceneType = if (it.lrExtension1 == null) SceneType.Restaurant.value else it.lrExtension1.toInt()
             })
         }
@@ -508,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)
@@ -515,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
@@ -528,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)
@@ -539,6 +555,7 @@
                     .andLessThanOrEqualTo("lrMonth", endMon.toByte())
                     .andIn("lsSubtypeid", v)
             })
+            // 绛涢�夋瘡绉嶅彴璐﹁褰曚腑鐨勬渶鏂颁竴鏉�
             val monMap = mutableMapOf<Int, LedgerRecord>()
             r.forEach {
                 if (monMap.containsKey(it.lsSubtypeid)) {

--
Gitblit v1.9.3