From ae04c5d925b0094e1a1ba1f2ce0bf6da0a6fee04 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 22 一月 2026 17:27:55 +0800
Subject: [PATCH] 2026.1.22 1. 新增台账上传office文档功能; 2. 新增office文档存储原始文档名字功能
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/LedgerServiceImpl.kt | 83 ++++++++++++++++++++++++++++++++---------
1 files changed, 64 insertions(+), 19 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..3c3fed5 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
@@ -18,9 +19,11 @@
import cn.flightfeather.supervision.lightshare.vo.*
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.module.kotlin.readValue
import com.github.pagehelper.PageHelper
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
+import org.springframework.transaction.annotation.Transactional
import org.springframework.web.multipart.MultipartFile
import tk.mybatis.mapper.entity.Example
import java.io.File
@@ -43,6 +46,7 @@
private val ledgerMediaFileRep: LedgerMediaFileRep,
private val userInfoRep: UserInfoRep,
private val ledgerRep: LedgerRep,
+ private val userSettingRep: UserSettingRep,
) : LedgerService {
@Value("\${imgPath}")
@@ -95,6 +99,7 @@
sceneType = it.getlScenetype(),
iconUrl = it.getlIconurl(),
realTime = it.getlRealTime(),
+ copy = it.getlAutoCopy() ?: false,
description = it.getlDescription(),
notRelated = it.getlNotRelatedSwitch() ?: true,
multigroup = it.getlMultiGroup() ?: false
@@ -186,6 +191,9 @@
ledgerType = type?.get(0)?.getlTypename()
ledgerFinished = true
isUpLoad = true
+ this.year = it.lrYear
+ this.month = it.lrMonth
+ this.day = it.lrDay
updateDate = it.lrSubmitdate
updateType = it.lrUpdatetype
fileType = it.lrEasubmitkind.toInt()
@@ -231,13 +239,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
@@ -245,13 +254,16 @@
ledgerType = type?.get(0)?.getlTypename()
ledgerFinished = true
isUpLoad = true
+ this.year = it.lrYear
+ this.month = it.lrMonth
+ this.day = it.lrDay
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()
})
}
@@ -295,11 +307,21 @@
return true
}
- override fun uploadLedger(userId: String, ledgerVoList: String, files: Array<MultipartFile>): Boolean {
-
+ @Transactional
+ override fun uploadLedger(
+ userId: String, ledgerVoList: String,
+ fileNames: String?, files: Array<MultipartFile>,
+ ): Boolean {
val mapper = ObjectMapper()
- val ledgerVos = mapper.readValue<List<LedgerVo>>(ledgerVoList, object : TypeReference<List<LedgerVo>>() {})
+ val ledgerVos = mapper.readValue(ledgerVoList, object : TypeReference<List<LedgerVo>>() {})
+ val fileNamePair = if (fileNames.isNullOrBlank()) {
+ emptyList()
+ } else {
+ mapper.readValue(fileNames, object : TypeReference<List<Map<String, String>>>() {})?.map {
+ it["first"] to it["second"]
+ }
+ }
ledgerVos.forEach {
it.id = it.id ?: UUIDGenerator.generate16ShortUUID()
@@ -346,8 +368,14 @@
val record = tmp[0]
it.id = record.lrGuid
ledgerMedia = deleteLedgerFile(record.lrGuid)
- // 鍘婚櫎涓嶆秹鍙婃爣蹇楁垨澶嶅埗鏍囧織
- record.lrExtension2 = null
+ record.apply {
+ lrYear = updateYear
+ lrMonth = updateMonth.toByte()
+ lrDay = updateDay.toByte()
+ lrSubmitdate = Date()
+ // 鍘婚櫎涓嶆秹鍙婃爣蹇楁垨澶嶅埗鏍囧織
+ lrExtension2 = null
+ }
ledgerRecordMapper.updateByPrimaryKey(record)
}
@@ -355,9 +383,9 @@
var picPath = ""
val time = DateUtil.DateToString(Date(), DateUtil.DateStyle.YYYY_MM)
files.forEach { file ->
- val fileName = file.originalFilename
- //TODO 姝ゅ鐨勬枃浠惰矾寰勯渶瑕佷慨鏀逛负鍔ㄦ�侀厤缃�
-// val basePath = "D:/02product/05ledger/images/"
+ var fileName = file.originalFilename
+ // 鏍规嵁浼犲叆鐨勬枃浠堕厤闃熶俊鎭幏鍙栧師濮嬫枃浠跺悕
+ fileNamePair?.find { p-> p.first == file.originalFilename }?.let { p-> fileName = p.second }
val basePath = imgPath
val path = "$time/$userId/${it.ledgerName}/"
picPath += if (picPath.isEmpty()) {
@@ -508,6 +536,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 +544,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 +568,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 +580,7 @@
.andLessThanOrEqualTo("lrMonth", endMon.toByte())
.andIn("lsSubtypeid", v)
})
+ // 绛涢�夋瘡绉嶅彴璐﹁褰曚腑鐨勬渶鏂颁竴鏉�
val monMap = mutableMapOf<Int, LedgerRecord>()
r.forEach {
if (monMap.containsKey(it.lsSubtypeid)) {
@@ -559,8 +601,8 @@
}
override fun copyLedger(userId: String, time: String, copyLedgerList: List<CopyLedgerVo>): BaseResponse<String> {
- val year = time.split("-")[0]
- val month = time.split("-")[1]
+ val year = time.split("-")[0].toIntOrNull() ?: return BaseResponse(false, "骞翠唤鏍煎紡閿欒")
+ val month = time.split("-")[1].toIntOrNull() ?: return BaseResponse(false, "鏈堜唤鏍煎紡閿欒")
val date = DateUtil.StringToDate(time, DateUtil.DateStyle.YYYY_MM)
copyLedgerList.forEach {
//鍘婚噸鍒ゆ柇
@@ -574,14 +616,17 @@
return@forEach
}
- val y = it.time?.split("-")?.get(0) ?: return@forEach
- val m = it.time?.split("-")?.get(1) ?: return@forEach
+ val y = it.time?.split("-")?.get(0)
+ val m = it.time?.split("-")?.get(1)
ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
createCriteria().andEqualTo("lrSubmitid", userId)
.andEqualTo("lsSubtypeid", it.subTypeId)
.andEqualTo("lrYear", y)
.andEqualTo("lrMonth", m)
- }).forEach record@{ lr ->
+ orderBy("lrYear").desc()
+ .orderBy("lrMonth").desc()
+ .orderBy("lrSubmitdate").desc()
+ }).takeIf { list-> list.isNotEmpty() }?.get(0)?.let record@{ lr ->
//鑾峰彇璁板綍瀵瑰簲鐨勬枃浠朵俊鎭�
val fileList = ledgerMediaFileMapper.selectByExample(Example(LedgerMediaFile::class.java).apply {
createCriteria().andEqualTo("lrGuid", lr.lrGuid)
--
Gitblit v1.9.3