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/SelfPatrolService.kt | 2
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt | 18 +++++
src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSettingRecord.java | 25 ++++++++
src/main/kotlin/cn/flightfeather/supervision/domain/repository/UserSettingRep.kt | 32 ++++++++++
src/main/resources/mapper/UserSettingRecordMapper.xml | 3
src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SelfPatrolController.kt | 4
src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSetting.java | 24 ++++++++
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/SelfPatrolServiceImpl.kt | 18 +++++
src/main/resources/mapper/UserSettingMapper.xml | 12 ++++
9 files changed, 131 insertions(+), 7 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSetting.java b/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSetting.java
index bfb6eab..f26f087 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSetting.java
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSetting.java
@@ -74,6 +74,12 @@
private Boolean selfPatrolPromise;
/**
+ * 鑷贰鏌ユ壙璇轰功鍐呭
+ */
+ @Column(name = "sp_promise_content")
+ private String spPromiseContent;
+
+ /**
* @return id
*/
public Integer getId() {
@@ -364,4 +370,22 @@
public void setSelfPatrolPromise(Boolean selfPatrolPromise) {
this.selfPatrolPromise = selfPatrolPromise;
}
+
+ /**
+ * 鑾峰彇鑷贰鏌ユ壙璇轰功鍐呭
+ *
+ * @return sp_promise_content - 鑷贰鏌ユ壙璇轰功鍐呭
+ */
+ public String getSpPromiseContent() {
+ return spPromiseContent;
+ }
+
+ /**
+ * 璁剧疆鑷贰鏌ユ壙璇轰功鍐呭
+ *
+ * @param spPromiseContent 鑷贰鏌ユ壙璇轰功鍐呭
+ */
+ public void setSpPromiseContent(String spPromiseContent) {
+ this.spPromiseContent = spPromiseContent == null ? null : spPromiseContent.trim();
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSettingRecord.java b/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSettingRecord.java
index 41db457..bfcf613 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSettingRecord.java
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/entity/UserSettingRecord.java
@@ -1,5 +1,6 @@
package cn.flightfeather.supervision.domain.entity;
+import java.util.Date;
import javax.persistence.*;
@Table(name = "sm_t_setting_record")
@@ -16,6 +17,12 @@
*/
@Column(name = "self_patrol_promised")
private Boolean selfPatrolPromised;
+
+ /**
+ * 涓婁竴娆℃壙璇烘椂闂�
+ */
+ @Column(name = "last_promised_time")
+ private Date lastPromisedTime;
/**
* 鑾峰彇鐢ㄦ埛id
@@ -52,4 +59,22 @@
public void setSelfPatrolPromised(Boolean selfPatrolPromised) {
this.selfPatrolPromised = selfPatrolPromised;
}
+
+ /**
+ * 鑾峰彇涓婁竴娆℃壙璇烘椂闂�
+ *
+ * @return last_promised_time - 涓婁竴娆℃壙璇烘椂闂�
+ */
+ public Date getLastPromisedTime() {
+ return lastPromisedTime;
+ }
+
+ /**
+ * 璁剧疆涓婁竴娆℃壙璇烘椂闂�
+ *
+ * @param lastPromisedTime 涓婁竴娆℃壙璇烘椂闂�
+ */
+ public void setLastPromisedTime(Date lastPromisedTime) {
+ this.lastPromisedTime = lastPromisedTime;
+ }
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/repository/UserSettingRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/repository/UserSettingRep.kt
new file mode 100644
index 0000000..5261c3c
--- /dev/null
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/repository/UserSettingRep.kt
@@ -0,0 +1,32 @@
+package cn.flightfeather.supervision.domain.repository
+
+import cn.flightfeather.supervision.domain.mapper.UserSettingMapper
+import cn.flightfeather.supervision.domain.mapper.UserSettingRecordMapper
+import org.springframework.stereotype.Repository
+import java.time.LocalDate
+import java.time.LocalDateTime
+import java.time.ZoneId
+
+/**
+ *
+ * @date 2026/1/20
+ * @author feiyu02
+ */
+@Repository
+class UserSettingRep(
+ private val userSettingMapper: UserSettingMapper,
+ private val userSettingRecordMapper: UserSettingRecordMapper,
+) {
+
+ /**
+ * 鏌ヨ鐢ㄦ埛鑷贰鏌ユ壙璇烘槸鍚︽湁鏁�
+ * 绛剧讲鏃堕棿鐨勫綋骞村唴涓烘湁鏁�
+ */
+ fun checkIsSelfPatrolPromised(userId: String): Boolean {
+ val record = userSettingRecordMapper.selectByPrimaryKey(userId) ?: return false
+ record.lastPromisedTime ?: return false
+ val now = LocalDate.now().year
+ val recordYear = LocalDateTime.ofInstant(record.lastPromisedTime.toInstant(), ZoneId.systemDefault()).year
+ return record.selfPatrolPromised && (now == recordYear)
+ }
+}
\ No newline at end of file
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 d761887..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}")
@@ -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)) {
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/SelfPatrolServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/SelfPatrolServiceImpl.kt
index e505fe4..ce1b327 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/SelfPatrolServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/SelfPatrolServiceImpl.kt
@@ -30,6 +30,7 @@
private val selfPatrolMediaFileMapper: SelfPatrolMediaFileMapper,
private val userinfoMapper: UserinfoMapper,
private val ledgerSubTypeMapper: LedgerSubTypeMapper,
+ private val userSettingRecordMapper: UserSettingRecordMapper,
) : SelfPatrolService {
@Value("\${imgPath}")
@@ -463,7 +464,20 @@
* 鑷鏌ユ壙璇�
* 鎵胯瀹屾垚鍚庯紝鍦ㄤ竴涓嚜鐒跺勾鍐呰褰曢兘鏈夋晥锛屼篃鍙互瑕嗙洊涓婁紶
*/
- override fun promiseSelfPatrol(record: UserSettingRecord): UserSettingRecord? {
- TODO("Not yet implemented")
+ override fun promiseSelfPatrol(userId: String): UserSettingRecord? {
+ var record = userSettingRecordMapper.selectByPrimaryKey(userId)
+ if (record == null) {
+ record = UserSettingRecord().apply {
+ this.userId = userId
+ this.selfPatrolPromised = true
+ this.lastPromisedTime = Date()
+ }
+ userSettingRecordMapper.insert(record)
+ } else {
+ record.selfPatrolPromised = true
+ record.lastPromisedTime = Date()
+ userSettingRecordMapper.updateByPrimaryKey(record)
+ }
+ return record
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SelfPatrolService.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SelfPatrolService.kt
index b9b7d71..b9fd2bc 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SelfPatrolService.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/SelfPatrolService.kt
@@ -58,5 +58,5 @@
*/
fun checkSelfPatrolFinished(taskId: String?, justFinishedNum: Int)
- fun promiseSelfPatrol(record: UserSettingRecord): UserSettingRecord?
+ fun promiseSelfPatrol(userId: String): UserSettingRecord?
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SelfPatrolController.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SelfPatrolController.kt
index dfb0bf2..eedee59 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SelfPatrolController.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/web/SelfPatrolController.kt
@@ -88,8 +88,8 @@
@ApiOperation("鑷贰鏌ユ壙璇�")
@PostMapping("/promise")
fun promiseSelfPatrol(
- @RequestBody record: UserSettingRecord,
- ) = resPack { selfPatrolService.promiseSelfPatrol(record) }
+ @ApiParam(value = "鐢ㄦ埛id") @RequestParam userId: String,
+ ) = resPack { selfPatrolService.promiseSelfPatrol(userId) }
}
\ No newline at end of file
diff --git a/src/main/resources/mapper/UserSettingMapper.xml b/src/main/resources/mapper/UserSettingMapper.xml
index 12f6d80..8c70f93 100644
--- a/src/main/resources/mapper/UserSettingMapper.xml
+++ b/src/main/resources/mapper/UserSettingMapper.xml
@@ -26,6 +26,12 @@
<result column="ledger_deadline" property="ledgerDeadline" jdbcType="INTEGER" />
<result column="self_patrol_promise" property="selfPatrolPromise" jdbcType="BIT" />
</resultMap>
+ <resultMap id="ResultMapWithBLOBs" type="cn.flightfeather.supervision.domain.entity.UserSetting" extends="BaseResultMap" >
+ <!--
+ WARNING - @mbg.generated
+ -->
+ <result column="sp_promise_content" property="spPromiseContent" jdbcType="LONGVARCHAR" />
+ </resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
@@ -35,4 +41,10 @@
Area, Management_Company_Id, Management_Company, scene_type_id, ledger_deadline,
self_patrol_promise
</sql>
+ <sql id="Blob_Column_List" >
+ <!--
+ WARNING - @mbg.generated
+ -->
+ sp_promise_content
+ </sql>
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/UserSettingRecordMapper.xml b/src/main/resources/mapper/UserSettingRecordMapper.xml
index b22812f..799ba18 100644
--- a/src/main/resources/mapper/UserSettingRecordMapper.xml
+++ b/src/main/resources/mapper/UserSettingRecordMapper.xml
@@ -7,11 +7,12 @@
-->
<id column="user_id" property="userId" jdbcType="VARCHAR" />
<result column="self_patrol_promised" property="selfPatrolPromised" jdbcType="BIT" />
+ <result column="last_promised_time" property="lastPromisedTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
- user_id, self_patrol_promised
+ user_id, self_patrol_promised, last_promised_time
</sql>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3