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 | 484 +++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 356 insertions(+), 128 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 c9521ac..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
@@ -3,12 +3,15 @@
import cn.flightfeather.supervision.domain.entity.LedgerMediaFile
import cn.flightfeather.supervision.domain.entity.LedgerRecord
import cn.flightfeather.supervision.domain.entity.LedgerSubType
-import cn.flightfeather.supervision.domain.enumeration.LedgerCheckStatus
import cn.flightfeather.supervision.domain.enumeration.SceneType
import cn.flightfeather.supervision.domain.mapper.LedgerMediaFileMapper
import cn.flightfeather.supervision.domain.mapper.LedgerRecordMapper
import cn.flightfeather.supervision.domain.mapper.LedgerSubTypeMapper
import cn.flightfeather.supervision.domain.mapper.UserinfoMapper
+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
@@ -16,10 +19,19 @@
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
+import java.io.FileNotFoundException
+import java.time.LocalDate
+import java.time.LocalDateTime
+import java.time.ZoneId
+import java.time.format.DateTimeFormatter
import java.util.*
import javax.servlet.http.HttpServletResponse
import kotlin.collections.ArrayList
@@ -27,11 +39,20 @@
@Service
class LedgerServiceImpl(
- val ledgerSubTypeMapper: LedgerSubTypeMapper,
- val userinfoMapper: UserinfoMapper,
- val ledgerRecordMapper: LedgerRecordMapper,
- val ledgerMediaFileMapper: LedgerMediaFileMapper
-):LedgerService {
+ val ledgerSubTypeMapper: LedgerSubTypeMapper,
+ val userinfoMapper: UserinfoMapper,
+ val ledgerRecordMapper: LedgerRecordMapper,
+ val ledgerMediaFileMapper: LedgerMediaFileMapper,
+ private val ledgerMediaFileRep: LedgerMediaFileRep,
+ private val userInfoRep: UserInfoRep,
+ private val ledgerRep: LedgerRep,
+ private val userSettingRep: UserSettingRep,
+) : LedgerService {
+
+ @Value("\${imgPath}")
+ lateinit var imgPath: String
+
+ private val notInvolvedPath = "ledgerIcons/ledger_not_involved.jpg"
override fun getLedgerType(sceneType: Int): ArrayList<LedgerSubTypeVo> {
val ledgerSubTypes = ledgerSubTypeMapper.selectByExample(Example(LedgerSubType::class.java).apply {
@@ -42,13 +63,13 @@
val resultList = ArrayList<LedgerSubTypeVo>()
ledgerSubTypes.forEach {
val l = LedgerSubTypeVo(
- it.lsSubtypeid,
- it.lsName,
- it.getlTypeid(),
- it.getlTypename(),
- needUpdate = it.getlNeedupdate(),
- sceneType = it.getlScenetype(),
- iconUrl = it.getlIconurl()
+ it.lsSubtypeid,
+ it.lsName,
+ it.getlTypeid(),
+ it.getlTypename(),
+ needUpdate = it.getlNeedupdate(),
+ sceneType = it.getlScenetype(),
+ iconUrl = it.getlIconurl()
)
resultList.add(l)
}
@@ -56,6 +77,10 @@
}
override fun getUserLedgerSummary(userId: String, sceneType: Int, time: String): List<LedgerSubTypeVo> {
+ val c = Calendar.getInstance().apply { this.time = DateUtil.StringToDate(time) }
+ val year = c.get(Calendar.YEAR)
+ val month = c.get(Calendar.MONTH) + 1
+
val ledgerSubTypes = ledgerSubTypeMapper.selectByExample(Example(LedgerSubType::class.java).apply {
if (sceneType != SceneType.NoType.value) {
createCriteria().andEqualTo("lScenetype", sceneType)
@@ -73,17 +98,29 @@
needUpdate = it.getlNeedupdate(),
sceneType = it.getlScenetype(),
iconUrl = it.getlIconurl(),
- realTime = it.getlRealTime()
+ realTime = it.getlRealTime(),
+ copy = it.getlAutoCopy() ?: false,
+ description = it.getlDescription(),
+ notRelated = it.getlNotRelatedSwitch() ?: true,
+ multigroup = it.getlMultiGroup() ?: false
)
for (r in records) {
if (l.ledgerSubTypeId == r.lsSubtypeid) {
+ // FIXME: 2023/5/6 瑙勫垯鍙樺姩锛屼絾涓轰簡涓嶅奖鍝嶄箣鍓嶇殑璁板綍锛屾椂闂翠负2023骞�4鏈堝強涔嬪墠鐨勪笉閫傜敤鏂拌鍒�
+ if (year >= 2023 && month > 4) {
+ if (r.lrExtension2 == "notInvolved" && r.lrYear <= year && r.lrMonth < month.toByte()) {
+ continue
+ }
+ }
l.ledgerFinished = true
l.upLoad = true
// l.checkStatus = r.lrVerifyrst?.toIntOrNull() ?: LedgerCheckStatus.UnCheck.value
+ l.onTime = r.lrIssubmitontime
l.verified
l.verifierName = r.lrVerifierrealname
l.verified = r.lrIsverify
- l.verifyRst = l.verifyRst
+ l.verifyRst = r.lrVerifyrst
+ l.involved = r.lrExtension2 != "notInvolved"
break
}
}
@@ -93,9 +130,10 @@
return resultList
}
- override fun getLedgerDetail(userId: String, ledgerSubTypeId: Int?, sceneType: Int,
- startTime: String, endTime: String,
- page: Int?, perPage: Int, response: HttpServletResponse
+ override fun getLedgerDetail(
+ userId: String, ledgerSubTypeId: Int?, sceneType: Int,
+ startTime: String, endTime: String,
+ page: Int?, perPage: Int, response: HttpServletResponse,
): ArrayList<LedgerVo> {
val result = ArrayList<LedgerVo>()
@@ -118,32 +156,32 @@
val records = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
createCriteria().andEqualTo("lrSubmitid", userId)
- .andEqualTo("lrYear", year)
- .andEqualTo("lrMonth", month.toByte())
- .apply {
- ledgerSubTypeId?.let { andEqualTo("lsSubtypeid", it) }
- }
+ .andEqualTo("lrYear", year)
+ .andEqualTo("lrMonth", month.toByte())
+ .apply {
+ ledgerSubTypeId?.let { andEqualTo("lsSubtypeid", it) }
+ }
if (sceneType == SceneType.Restaurant.value) {
and(createCriteria().andIsNull("lrExtension1")
- .orEqualTo("lrExtension1", sceneType.toString()))
- }else if (sceneType != SceneType.NoType.value) {
+ .orEqualTo("lrExtension1", sceneType.toString()))
+ } else if (sceneType != SceneType.NoType.value) {
and(createCriteria().andEqualTo("lrExtension1", sceneType.toString()))
}
})
records.forEach {
val media = ledgerMediaFileMapper.selectByExample(
- Example(LedgerMediaFile::class.java).apply {
- createCriteria().andEqualTo("lrGuid", it.lrGuid)
- .andEqualTo("mfIsdelete", false)
- .andEqualTo("mfFiletype", it.lrEasubmitkind)
- orderBy("mfSavetime").desc()
- }
+ Example(LedgerMediaFile::class.java).apply {
+ createCriteria().andEqualTo("lrGuid", it.lrGuid)
+ .andEqualTo("mfIsdelete", false)
+ .andEqualTo("mfFiletype", it.lrEasubmitkind)
+ orderBy("mfSavetime").desc()
+ }
)
val type = ledgerSubTypeMapper.selectByExample(
- Example(LedgerSubType::class.java).apply {
- createCriteria().andEqualTo("lsSubtypeid", it.lsSubtypeid)
- }
+ Example(LedgerSubType::class.java).apply {
+ createCriteria().andEqualTo("lsSubtypeid", it.lsSubtypeid)
+ }
)
result.add(LedgerVo().apply {
id = it.lrGuid
@@ -153,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()
@@ -160,7 +201,7 @@
remark1 = media?.get(0)?.mfDescription1
path2 = media?.get(0)?.mfPath2
remark2 = media?.get(0)?.mfDescription2
- this.sceneType = if(it.lrExtension1 == null) SceneType.Restaurant.value else it.lrExtension1.toInt()
+ this.sceneType = if (it.lrExtension1 == null) SceneType.Restaurant.value else it.lrExtension1.toInt()
})
}
@@ -171,7 +212,12 @@
}
- override fun getLedgerDetail2(userId: String, ledgerSubTypeId: Int?, sceneType: Int, time: String?): List<LedgerVo> {
+ override fun getLedgerDetail2(
+ userId: String,
+ ledgerSubTypeId: Int?,
+ sceneType: Int,
+ time: String?,
+ ): List<LedgerVo> {
val records = if (time != null) {
getLedgerRecords(userId, ledgerSubTypeId, sceneType, time)
} else {
@@ -187,19 +233,20 @@
val result = ArrayList<LedgerVo>()
records.forEach {
val media = ledgerMediaFileMapper.selectByExample(
- Example(LedgerMediaFile::class.java).apply {
- createCriteria().andEqualTo("lrGuid", it.lrGuid)
- .andEqualTo("mfIsdelete", false)
- .andEqualTo("mfFiletype", it.lrEasubmitkind)
- orderBy("mfSavetime").desc()
- }
- )
+ Example(LedgerMediaFile::class.java).apply {
+ createCriteria().andEqualTo("lrGuid", it.lrGuid)
+ .andEqualTo("mfIsdelete", false)
+ .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)
- }
+ Example(LedgerSubType::class.java).apply {
+ createCriteria().andEqualTo("lsSubtypeid", it.lsSubtypeid)
+ }
)
result.add(LedgerVo().apply {
+
id = it.lrGuid
this.ledgerSubTypeId = it.lsSubtypeid
ledgerName = it.lsSubtypename
@@ -207,46 +254,139 @@
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
- this.sceneType = if(it.lrExtension1 == null) SceneType.Restaurant.value else it.lrExtension1.toInt()
+ 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()
})
}
return result
}
- override fun uploadLedger(userId: String, ledgerVoList: String, files: Array<MultipartFile>):Boolean {
+ override fun uploadLedger(userId: String, ledgerVo: LedgerVo, files: List<Pair<ByteArray, String>>): Boolean {
+ val user = userInfoRep.getUser(userId)
+ ledgerVo.apply {
+ if (fileType == null) fileType = 1
+ user?.extension2?.toInt()?.let { s -> sceneType = s }
+ }
+
+ val historyRecord = ledgerRep.selectRecord(userId, ledgerVo.ledgerSubTypeId, ledgerVo.updateDate)
+
+ var ledgerMedia: LedgerMediaFile? = null
+ if (historyRecord == null) {
+ //鐢熸垚鍙拌处鏇存柊璁板綍
+ val ledgerRecord = ledgerVo.toLedgerRecord(user)
+ ledgerVo.id = ledgerRecord.lrGuid
+ ledgerRep.insertRecord(ledgerRecord)
+ //鐢熸垚涓�鏉″濯掍綋鏂囦欢璁板綍
+ val filePath = ledgerMediaFileRep.saveFile(userId, ledgerVo, files)
+ ledgerMediaFileRep.insert(ledgerVo, filePath)
+ } else {
+ ledgerVo.id = historyRecord.lrGuid
+ ledgerMedia = deleteLedgerFile(historyRecord.lrGuid)
+ // 鍘婚櫎涓嶆秹鍙婃爣蹇楁垨澶嶅埗鏍囧織
+ historyRecord.lrSubmitdate = Date()
+ historyRecord.lrExtension2 = null
+ ledgerRep.updateRecord(historyRecord)
+ //鏇存柊鐨勫濯掍綋鏂囦欢璁板綍鏁版嵁
+ val filePath = ledgerMediaFileRep.saveFile(userId, ledgerVo, files)
+ ledgerMedia?.mfPath1 = filePath
+ ledgerMedia?.mfDescription1 = ledgerVo.remark1
+ ledgerMedia?.mfSavetime = Date()
+ ledgerMediaFileRep.update(ledgerMedia)
+ }
+
+ return true
+ }
+
+ @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()
it.fileType = it.fileType ?: 1
val userInfo = userinfoMapper.selectByPrimaryKey(userId)
- userInfo.extension2?.toInt()?.let {s-> it.sceneType = s }
+ userInfo?.extension2?.toInt()?.let { s -> it.sceneType = s }
val today = Calendar.getInstance().apply { time = Date() }
- .get(Calendar.DAY_OF_MONTH)
+ .get(Calendar.DAY_OF_MONTH)
val cal = Calendar.getInstance().apply { time = it.updateDate ?: Date() }
val updateYear = cal.get(Calendar.YEAR)
val updateMonth = cal.get(Calendar.MONTH) + 1
val updateDay = cal.get(Calendar.DAY_OF_MONTH)
+ //妫�鏌ユ暟鎹簱鏄惁宸叉湁璁板綍锛岄�夋嫨鎻掑叆鎴栨洿鏂�
+ val tmp = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
+ createCriteria().andEqualTo("lsSubtypeid", it.ledgerSubTypeId)
+ .andEqualTo("lrYear", updateYear)
+ .andEqualTo("lrMonth", updateMonth)
+ .andEqualTo("lrSubmitid", userId)
+ })
+ var ledgerMedia: LedgerMediaFile? = null
+ if (tmp.isEmpty()) {
+ //鐢熸垚鍙拌处鏇存柊璁板綍
+ val ledgerRecord = LedgerRecord().apply {
+ lrGuid = UUIDGenerator.generate16ShortUUID()
+ lsSubtypeid = it.ledgerSubTypeId
+ lsSubtypename = it.ledgerName
+ lrYear = updateYear
+ lrMonth = updateMonth.toByte()
+ lrDay = updateDay.toByte()
+ lrEasubmitkind = it.fileType?.toByte() ?: 1
+ lrSubmitid = userId
+ lrSubmitname = userInfo?.acountname ?: ""
+ lrIssubmitontime = today <= 10
+ lrSubmitdate = Date()
+ lrUpdatetype = it.updateType
+ lrExtension1 = it.sceneType.toString()
+ }
+ it.id = ledgerRecord.lrGuid
+ ledgerRecordMapper.insert(ledgerRecord)
+ } else {
+ val record = tmp[0]
+ it.id = record.lrGuid
+ ledgerMedia = deleteLedgerFile(record.lrGuid)
+ record.apply {
+ lrYear = updateYear
+ lrMonth = updateMonth.toByte()
+ lrDay = updateDay.toByte()
+ lrSubmitdate = Date()
+ // 鍘婚櫎涓嶆秹鍙婃爣蹇楁垨澶嶅埗鏍囧織
+ lrExtension2 = null
+ }
+ ledgerRecordMapper.updateByPrimaryKey(record)
+ }
+
//瀵规瘡寮犲浘鐗囩敓鎴愮浉搴旂殑璺緞骞朵繚瀛�
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/"
+ files.forEach { file ->
+ 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()) {
"$path$fileName"
@@ -256,59 +396,30 @@
try {
//璋冪敤鏂囦欢淇濆瓨鏂规硶
FileUtil.uploadFile(file.bytes, basePath + path, fileName!!)
- } catch (e: Exception) {
+ } catch (e: FileNotFoundException) {
e.printStackTrace()
}
}
//鐢熸垚涓�鏉″濯掍綋鏂囦欢璁板綍
- val ledgerMedia = LedgerMediaFile().apply {
- mfGuid = UUIDGenerator.generate16ShortUUID()
- lrGuid = it.id
- mfFiletype = it.fileType
- mfPath1 = picPath
- mfDescription1 = it.remark1
- mfSavetime = Date()
- mfIsdelete = false
- }
-
- //鏌ヨ鏄惁宸叉湁璁板綍锛屽宸叉湁璁板綍灏嗗叾鏍囪涓�"鍒犻櫎"
- val example = Example(LedgerMediaFile::class.java)
- val criteria = example.createCriteria()
- criteria.andEqualTo("lrGuid", it.id)
- .andEqualTo("mfIsdelete", false)
- val result = ledgerMediaFileMapper.selectByExample(example)
- result.forEach {mediaFile ->
- mediaFile.mfIsdelete = true
- ledgerMediaFileMapper.updateByPrimaryKey(mediaFile)
- }
-
- //鎻掑叆鏂扮殑澶氬獟浣撴枃浠惰褰曟暟鎹�
- ledgerMediaFileMapper.insert(ledgerMedia)
-
- //鐢熸垚鍙拌处鏇存柊璁板綍
- val ledgerRecord = LedgerRecord().apply {
- lrGuid = it.id
- lsSubtypeid = it.ledgerSubTypeId
- lsSubtypename = it.ledgerName
- lrYear = updateYear
- lrMonth = updateMonth.toByte()
- lrDay = updateDay.toByte()
- lrEasubmitkind = it.fileType?.toByte() ?: 1
- lrSubmitid = userId
- lrSubmitname = userInfo?.acountname ?: ""
- lrIssubmitontime = today <= 10
- lrSubmitdate = Date()
- lrUpdatetype = it.updateType
- lrExtension1 = it.sceneType.toString()
- }
-
- //妫�鏌ユ暟鎹簱鏄惁宸叉湁璁板綍锛岄�夋嫨鎻掑叆鎴栨洿鏂�
- val tmp = ledgerRecordMapper.selectByPrimaryKey(ledgerRecord.lrGuid)
- if (tmp == null || tmp.lrGuid == null) {
- ledgerRecordMapper.insert(ledgerRecord)
+ if (ledgerMedia == null) {
+ ledgerMedia = LedgerMediaFile().apply {
+ mfGuid = UUIDGenerator.generate16ShortUUID()
+ lrGuid = it.id
+ mfFiletype = it.fileType
+ mfPath1 = picPath
+ mfDescription1 = it.remark1
+ mfSavetime = Date()
+ mfIsdelete = false
+ }
+ //鎻掑叆鏂扮殑澶氬獟浣撴枃浠惰褰曟暟鎹�
+ ledgerMediaFileMapper.insert(ledgerMedia)
} else {
- ledgerRecordMapper.updateByPrimaryKey(ledgerRecord)
+ ledgerMedia.mfPath1 = picPath
+ ledgerMedia.mfDescription1 = it.remark1
+ ledgerMedia.mfSavetime = Date()
+ //鏇存柊鐨勫濯掍綋鏂囦欢璁板綍鏁版嵁
+ ledgerMediaFileMapper.updateByPrimaryKey(ledgerMedia)
}
return true
@@ -317,13 +428,79 @@
return false
}
+ override fun uploadNoLedger(
+ userId: String,
+ time: String,
+ remark: String?,
+ ledgerIdList: List<Int>,
+ ): BaseResponse<String> {
+ val date = LocalDate.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
+ val year = date.year
+ val month = date.monthValue
+ val day = date.dayOfMonth
+ val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return BaseResponse(false, "鐢ㄦ埛涓嶅瓨鍦�")
+ ledgerIdList.forEach {
+ //鍘婚噸鍒ゆ柇,褰撹绫诲瀷鍙拌处宸插瓨鍦ㄦ椂锛岄噰鐢ㄨ鐩栨洿鏂版搷浣�
+ val r = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
+ createCriteria().andEqualTo("lrSubmitid", userId)
+ .andEqualTo("lsSubtypeid", it)
+ .andEqualTo("lrYear", year)
+ .andEqualTo("lrMonth", month)
+ })
+ var record = if (r.size > 0) r[0] else null
+
+ //鐢熸垚鍙拌处鏇存柊璁板綍
+ if (record != null) {
+ record.lrExtension2 = "notInvolved"
+ ledgerRecordMapper.updateByPrimaryKey(record)
+ deleteLedgerFile(record.lrGuid)?.let { m ->
+ m.mfPath1 = notInvolvedPath
+ ledgerMediaFileMapper.updateByPrimaryKey(m)
+ }
+ } else {
+ //鑾峰彇鍙拌处绫诲瀷淇℃伅
+ val ledgerType = ledgerSubTypeMapper.selectByPrimaryKey(it) ?: return@forEach
+ record = LedgerRecord().apply {
+ lrGuid = record?.lrGuid ?: UUIDGenerator.generate16ShortUUID()
+ lsSubtypeid = ledgerType.lsSubtypeid
+ lsSubtypename = ledgerType.lsName
+ lrYear = year
+ lrMonth = month.toByte()
+ lrDay = day.toByte()
+ lrEasubmitkind = 1
+ lrSubmitid = userId
+ lrSubmitname = userInfo.acountname ?: ""
+ lrIssubmitontime = day <= 10
+ lrSubmitdate = Date()
+ lrUpdatetype
+ lrExtension1 = userInfo.extension2
+ lrExtension2 = "notInvolved"
+ }
+ ledgerRecordMapper.insert(record)
+ //鐢熸垚涓�鏉″濯掍綋鏂囦欢璁板綍
+ val ledgerMedia = LedgerMediaFile().apply {
+ mfGuid = UUIDGenerator.generate16ShortUUID()
+ lrGuid = record.lrGuid
+ mfFiletype = 1
+ mfPath1 = notInvolvedPath
+ mfDescription1 = remark
+ mfSavetime = Date()
+ mfIsdelete = false
+ }
+ ledgerMediaFileMapper.insert(ledgerMedia)
+ }
+ }
+
+ return BaseResponse(true)
+ }
+
override fun getLedgerImg(userId: String, ledgerType: Int): List<String> {
val result = mutableListOf<String>()
PageHelper.startPage<LedgerRecord>(1, 1)
val record = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
createCriteria().andEqualTo("lsSubtypeid", ledgerType)
- .andEqualTo("lrSubmitid", userId)
+ .andEqualTo("lrSubmitid", userId)
orderBy("lrYear").desc().orderBy("lrMonth").desc().orderBy("lrDay").desc()
}).takeIf { it.isNotEmpty() }?.get(0)
@@ -331,7 +508,7 @@
ledgerMediaFileMapper.selectByExample(Example(LedgerMediaFile::class.java).apply {
createCriteria().andEqualTo("lrGuid", it.lrGuid)
}).forEach {
- it.mfPath1?.split(";")?.let {list ->
+ it.mfPath1?.split(";")?.let { list ->
result.addAll(list)
}
}
@@ -346,14 +523,20 @@
PageHelper.startPage<LedgerRecord>(1, 1)
val record = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
createCriteria().andIn("lsSubtypeid", ledgerType)
- .andEqualTo("lrSubmitid", userId)
+ .andEqualTo("lrSubmitid", userId)
orderBy("lrYear").desc().orderBy("lrMonth").desc().orderBy("lrDay").desc()
})
return emptyList()
}
- override fun getLedgerRecords(userId: String, ledgerSubTypeId: Int?, sceneType: Int, time: String): List<LedgerRecord> {
+ override fun getLedgerRecords(
+ userId: String,
+ ledgerSubTypeId: Int?,
+ sceneType: Int,
+ time: String,
+ ): List<LedgerRecord> {
+ // 鏌ヨ鐩稿叧鐨勬墍鏈夊彴璐︾被鍨�
val ledgerSubTypes = ledgerSubTypeMapper.selectByExample(Example(LedgerSubType::class.java).apply {
if (ledgerSubTypeId != null) {
createCriteria().andEqualTo("lsSubtypeid", ledgerSubTypeId)
@@ -361,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
@@ -374,31 +568,41 @@
}
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)
- val endMon = startMon + p - 1
+ var endMon = startMon + p - 1
+// if (endMon > month) endMon = month
val r = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
createCriteria().andEqualTo("lrSubmitid", userId)
- .andEqualTo("lrYear", year)
- .andGreaterThanOrEqualTo("lrMonth", startMon.toByte())
- .andLessThanOrEqualTo("lrMonth", endMon.toByte())
- and(
- createCriteria().apply {
- v.forEach {
- orEqualTo("lsSubtypeid", it)
- }
- }
- )
+ .andEqualTo("lrYear", year)
+ .andGreaterThanOrEqualTo("lrMonth", startMon.toByte())
+ .andLessThanOrEqualTo("lrMonth", endMon.toByte())
+ .andIn("lsSubtypeid", v)
})
- records.addAll(r)
+ // 绛涢�夋瘡绉嶅彴璐﹁褰曚腑鐨勬渶鏂颁竴鏉�
+ val monMap = mutableMapOf<Int, LedgerRecord>()
+ r.forEach {
+ if (monMap.containsKey(it.lsSubtypeid)) {
+ val record = monMap[it.lsSubtypeid]!!
+ if (record.lrMonth < it.lrMonth) {
+ monMap[it.lsSubtypeid] = it
+ }
+ } else {
+ monMap[it.lsSubtypeid] = it
+ }
+ }
+ monMap.forEach { (_, u) ->
+ records.add(u)
+ }
}
return records
}
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 {
//鍘婚噸鍒ゆ柇
@@ -412,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)
@@ -449,7 +656,11 @@
return BaseResponse(true)
}
- override fun checkLedger(verifierId: String, remark: String?, recordList: List<LedgerCheckVo>): BaseResponse<Boolean> {
+ override fun checkLedger(
+ verifierId: String,
+ remark: String?,
+ recordList: List<LedgerCheckVo>,
+ ): BaseResponse<Boolean> {
val recordIdList = mutableListOf<String?>()
recordList.forEach { recordIdList.add(it.recordId) }
val records = ledgerRecordMapper.selectByExample(Example(LedgerRecord::class.java).apply {
@@ -478,4 +689,21 @@
BaseResponse(true)
}
}
+
+ /**
+ * 鍒犻櫎鍙拌处鐨勬枃浠惰褰�
+ * @param lrGuid 鍙拌处璁板綍id
+ */
+ private fun deleteLedgerFile(lrGuid: String): LedgerMediaFile? {
+ return ledgerMediaFileRep.select(lrGuid)?.apply {
+ if (this.mfPath1 != notInvolvedPath) {
+ this.mfPath1.split(";").forEach { p ->
+ val path = imgPath + p
+ FileUtil.deleteFile(path)
+ }
+// this.mfPath1 = notInvolvedPath
+// ledgerMediaFileMapper.updateByPrimaryKey(this)
+ }
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3