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/NotificationServiceImpl.kt | 237 ++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 155 insertions(+), 82 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/NotificationServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/NotificationServiceImpl.kt
index be4bb2b..baffd61 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/NotificationServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/NotificationServiceImpl.kt
@@ -1,9 +1,6 @@
package cn.flightfeather.supervision.lightshare.service.Impl
-import cn.flightfeather.supervision.common.net.WXHttpService
-import cn.flightfeather.supervision.common.wx.MessageWxVo
import cn.flightfeather.supervision.common.wx.TemplateManager
-import cn.flightfeather.supervision.common.wx.WxTokenManager
import cn.flightfeather.supervision.domain.entity.*
import cn.flightfeather.supervision.domain.enumeration.DistrictType
import cn.flightfeather.supervision.domain.enumeration.UserType
@@ -11,12 +8,13 @@
import cn.flightfeather.supervision.lightshare.service.NotificationService
import cn.flightfeather.supervision.lightshare.vo.NoticeReadStateVo
import cn.flightfeather.supervision.lightshare.vo.NotificationVo
-import cn.flightfeather.supervision.push.PushService
+import cn.flightfeather.supervision.common.push.PushService
import cn.flightfeather.supervision.domain.enumeration.ParticipantType
import cn.flightfeather.supervision.domain.enumeration.SceneType
import cn.flightfeather.supervision.domain.mapper.*
import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator
-import com.alibaba.fastjson.JSON
+import cn.flightfeather.supervision.lightshare.vo.BaseResponse
+import cn.flightfeather.supervision.lightshare.vo.DataHead
import com.flightfeather.taizhang.model.enumeration.NotificationType
import com.flightfeather.taizhang.model.enumeration.WorkSubType
import com.github.pagehelper.PageHelper
@@ -29,24 +27,55 @@
@Service
class NotificationServiceImpl(
- val notificationMapper: NotificationMapper,
- val noticeMapper: NoticeMapper,
- val noticeReadStateMapper: NoticeReadStateMapper,
- val userinfoMapper: UserinfoMapper,
- val meetingParticipantRepository: MeetingParticipantRepository,
- val templateManager: TemplateManager
+ val notificationMapper: NotificationMapper,
+ val noticeMapper: NoticeMapper,
+ val noticeReadStateMapper: NoticeReadStateMapper,
+ val noticeTemplateMapper: NoticeTemplateMapper,
+ val userinfoMapper: UserinfoMapper,
+ val baseInfoMapper: BaseInfoMapper,
+ val meetingParticipantRepository: MeetingParticipantRepository,
+ val templateManager: TemplateManager,
) : NotificationService {
- override fun getNotificationUnRead(userId: String, page: Int, per_page: Int, response: HttpServletResponse): List<NotificationVo> {
+ override fun getAllNotices(
+ userId: String,
+ noticeConfig: NoticeConfig,
+ page: Int,
+ perPage: Int,
+ ): BaseResponse<List<Notice>> {
+// val userInfo = userinfoMapper.selectByPrimaryKey(userId)
+ val p = PageHelper.startPage<Notice>(page, perPage)
+ val nList = noticeMapper.selectByExample(Example(Notice::class.java).apply {
+ createCriteria().apply {
+ if (noticeConfig.ecNoticetype != null && noticeConfig.ecNoticetype != 0) {
+ andEqualTo("ecNoticetype", noticeConfig.ecNoticetype)
+ }
+ if (noticeConfig.ecNoticesubtype != null && noticeConfig.ecNoticesubtype != 0) {
+ andEqualTo("ecNoticesubtype", noticeConfig.ecNoticesubtype)
+ }
+ }
+ orderBy("ecUpdatedate").desc()
+ })
+ return BaseResponse(true, head = DataHead(p.pageNum, p.pages, p.total), data = nList)
+ }
+
+ override fun getNotificationUnRead(
+ userId: String,
+ page: Int,
+ per_page: Int,
+ response: HttpServletResponse,
+ ): List<NotificationVo> {
val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return emptyList()
+ val baseInfo = baseInfoMapper.selectByPrimaryKey(userId)
val userTypeId = userInfo.usertypeid
val district = userInfo.extension1
- var districtCode = DistrictType.getCode(district)
+ var districtCode = DistrictType.getCode(district) ?: baseInfo?.biDistrictCode
var sceneTypeId = userInfo.extension2
when (userTypeId?.toInt()) {
UserType.Admin.value,
- UserType.Insider.value -> {
+ UserType.Insider.value,
+ -> {
districtCode = null
sceneTypeId = null
}
@@ -61,17 +90,15 @@
val myPage = PageHelper.startPage<Notice>(page, per_page)
val noticeIdList = mutableListOf<String?>()
- val resultList = noticeMapper.getUnReadNotification(userId, districtCode, sceneTypeId).also {
- it.forEach {vo->
- noticeIdList.add(vo.id)
- }
+ val resultList = noticeMapper.getUnReadNotification(userId, districtCode, sceneTypeId, userTypeId).onEach { vo ->
+ noticeIdList.add(vo.id)
}
if (noticeIdList.isEmpty()) {
return resultList
}
val readStateList = noticeReadStateMapper.selectByExample(Example(NoticeReadState::class.java).apply {
createCriteria().andEqualTo("nrUserid", userId)
- .andIn("ecGuid", noticeIdList)
+ .andIn("ecGuid", noticeIdList)
})
resultList.forEach {
@@ -100,7 +127,7 @@
nrSignstate = it.hasSigned
val example = Example(NoticeReadState::class.java)
example.createCriteria().andEqualTo("nrUserid", nrUserid)
- .andEqualTo("ecGuid", ecGuid)
+ .andEqualTo("ecGuid", ecGuid)
val result = noticeReadStateMapper.selectByExample(example)
if (result.isEmpty()) {
noticeReadStateMapper.insert(this)
@@ -137,14 +164,16 @@
override fun getUnReadNoticeNum(userId: String): Int {
val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return 0
+ val baseInfo = baseInfoMapper.selectByPrimaryKey(userId)
val userTypeId = userInfo.usertypeid
val district = userInfo.extension1
- var districtCode = DistrictType.getCode(district)
+ var districtCode = DistrictType.getCode(district) ?: baseInfo?.biDistrictCode
var sceneTypeId = userInfo.extension2
when (userTypeId?.toInt()) {
UserType.Admin.value,
- UserType.Insider.value -> {
+ UserType.Insider.value,
+ -> {
districtCode = null
sceneTypeId = null
}
@@ -157,8 +186,8 @@
}
val noticeIdList = mutableListOf<String?>()
- val resultList = noticeMapper.getUnReadNotification(userId, districtCode, sceneTypeId).also {
- it.forEach {vo->
+ val resultList = noticeMapper.getUnReadNotification(userId, districtCode, sceneTypeId, userTypeId).also {
+ it.forEach { vo ->
noticeIdList.add(vo.id)
}
}
@@ -182,10 +211,16 @@
return totalCount
}
- override fun pushMeetingReleaseNotification(meetingVo: MeetingInfo, roomVo: VMRoom?, userId: String, title: String, body: String) {
+ override fun pushMeetingReleaseNotification(
+ meetingVo: MeetingInfo,
+ roomVo: VMRoom?,
+ userId: String,
+ title: String,
+ body: String,
+ ) {
val accountList = mutableListOf<String>()
meetingParticipantRepository.getParticipantByType(meetingVo.miGuid
- ?: "", roomVo?.vmrGuid, ParticipantType.All.value).forEach {
+ ?: "", roomVo?.vmrGuid, ParticipantType.All.value).forEach {
if (it.mpParticipantid != userId) {
accountList.add(it.mpParticipantid)
}
@@ -205,19 +240,19 @@
val user = userinfoMapper.selectByPrimaryKey(userId)
val notificationVo = NotificationVo(
- UUIDGenerator.generate16ShortUUID(),
- user.guid,
- user.realname,
- user.headIconUrl,
- NotificationType.Work.value.toString(),
- NotificationType.Work.des,
- WorkSubType.Meeting.value.toString(),
- WorkSubType.Meeting.des,
- meetingVo.miTitle ?: title,
- body,
- receiverType = "-1",
- receiverId = receiverId.toString(),
- district = "-1"
+ UUIDGenerator.generate16ShortUUID(),
+ user?.guid,
+ user?.realname,
+ user?.headIconUrl,
+ NotificationType.Work.value.toString(),
+ NotificationType.Work.des,
+ WorkSubType.Meeting.value.toString(),
+ WorkSubType.Meeting.des,
+ meetingVo.miTitle ?: title,
+ body,
+ receiverType = "-1",
+ receiverId = receiverId.toString(),
+ district = "-1"
)
releaseNotice(userId, notificationVo)
@@ -226,7 +261,7 @@
override fun releaseNotice(userId: String, noticeVo: NotificationVo): Boolean {
val notice = Notice().apply {
noticeVo.let {
- ecGuid = it.id
+ ecGuid = if (it.id == null) UUIDGenerator.generate16ShortUUID() else it.id
ecNoticetype = it.typeId?.toInt()
ecNoticetypename = it.typeName
ecNoticesubtype = it.subTypeId?.toInt()
@@ -248,52 +283,90 @@
ecExtension1 = it.district
}
}
- Executors.newSingleThreadExecutor().execute {
- PushService().run {
- if (noticeVo.receiverId?.isNotBlank() == true) {
- val accountList = noticeVo.receiverId!!.split(";")
- pushByAccount(accountList)
- } else {
- val accountList = mutableListOf<String>()
- val districts = mutableListOf<String>()
- val sceneTypes = mutableListOf<String>()
- noticeVo.district?.split(";")?.forEach {
- if (it.isNotBlank()) {
- districts.add(it)
- }
- }
- noticeVo.receiverType.split(";")?.forEach {
- if (it.isNotBlank()) {
- sceneTypes.add(it)
- }
- }
- val districtCodeList = mutableListOf<String>()
- districts.forEach {
- DistrictType.getDes(it)?.let { d-> districtCodeList.add(d)}
- }
- userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
- createCriteria()
- .apply {
- if (districts.isNotEmpty()) {
- andIn("extension1", districtCodeList)
- }
- if (noticeVo.receiverType != SceneType.NoType.value.toString()) {
- andIn("extension2", sceneTypes)
- }
- }
- }).forEach {
- accountList.add(it.guid ?: "")
- }
- pushByAccount(accountList)
- }
- push(noticeVo.title?:"鏂伴�氱煡", noticeVo.content?:"鏂伴�氱煡")
- }
- }
+// Executors.newSingleThreadExecutor().execute {
+// PushService().run {
+// if (noticeVo.receiverId?.isNotBlank() == true) {
+// val accountList = noticeVo.receiverId!!.split(";")
+// pushByAccount(accountList)
+// } else {
+// val accountList = mutableListOf<String>()
+// val districts = mutableListOf<String>()
+// val sceneTypes = mutableListOf<String>()
+// noticeVo.district?.split(";")?.forEach {
+// if (it.isNotBlank()) {
+// districts.add(it)
+// }
+// }
+// noticeVo.receiverType.split(";")?.forEach {
+// if (it.isNotBlank()) {
+// sceneTypes.add(it)
+// }
+// }
+// val districtCodeList = mutableListOf<String>()
+// districts.forEach {
+// DistrictType.getDes(it)?.let { d-> districtCodeList.add(d)}
+// }
+// userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
+// createCriteria()
+// .apply {
+// if (districts.isNotEmpty()) {
+// andIn("extension1", districtCodeList)
+// }
+// if (noticeVo.receiverType != SceneType.NoType.value.toString()) {
+// andIn("extension2", sceneTypes)
+// }
+// }
+// }).forEach {
+// accountList.add(it.guid ?: "")
+// }
+// pushByAccount(accountList)
+// }
+// push(noticeVo.title?:"鏂伴�氱煡", noticeVo.content?:"鏂伴�氱煡")
+// }
+// }
return noticeMapper.insert(notice) == 1
}
+ override fun releaseNotice2(userId: String, noticeVo: NotificationVo): Notice {
+ val notice = Notice().apply {
+ noticeVo.let {
+ ecGuid = if (it.id == null) UUIDGenerator.generate16ShortUUID() else it.id
+ ecNoticetype = it.typeId?.toInt()
+ ecNoticetypename = NotificationType.getByValue(ecNoticetype)
+ ecNoticesubtype = it.subTypeId?.toInt()
+ ecNoticesubtypename = WorkSubType.getByValue(ecNoticetype, ecNoticesubtype)
+ ecNoticetitle = it.title
+ ecNoticecontent = it.content
+ ecIsinuse = true
+ ecCreatedate = Date()
+ ecCreatorid = it.authorId
+ ecCreator = it.authorName
+ ecUpdatedate = Date()
+ ecModifierid = it.authorId
+ ecModifier = it.authorName
+ ecReceivertype = if (it.receiverType != "-1") it.receiverType + ";" else "-1"
+ ecReceiverid = it.receiverId
+ ecPicurl = it.picUrl
+ ecBodyurl = it.bodyUrl
+ ecNeedsign = it.needSigned
+ ecExtension1 = if (it.district != "-1") it.district + ";" else "-1"
+ }
+ }
+ noticeMapper.insert(notice)
+ return notice
+ }
+
override fun pushMsgWx(templateId: Int): String {
- val res = templateManager.sendMsg(templateId, "otZkc5VRlwauEMPqMluQYdVa4zuE", listOf("鍙拌处涓婁紶", "2022骞�10鏈�10鏃�", "3", "璇烽噸鐐瑰叧娉ㄧ幇鍦鸿嚜瀵绘煡閮ㄥ垎"))
+ val res = templateManager.sendMsg(templateId,
+ "otZkc5VRlwauEMPqMluQYdVa4zuE",
+ listOf("鍙拌处涓婁紶", "2022骞�10鏈�10鏃�", "3", "璇烽噸鐐瑰叧娉ㄧ幇鍦鸿嚜瀵绘煡閮ㄥ垎"))
return if (res) "success" else "fail"
}
+
+ override fun getTemplate(typeId: Int, subTypeId: Int): BaseResponse<List<NoticeTemplate?>> {
+ val res = noticeTemplateMapper.selectByExample(Example(NoticeTemplate::class.java).apply {
+ createCriteria().andEqualTo("ntNoticeType", typeId).andEqualTo("ntNoticeSubType", subTypeId)
+ })
+ return BaseResponse(true, data = res)
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3