From 53ce8de426561e7a43847afda23b5e24e6f76c4e Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 19 一月 2026 17:29:55 +0800
Subject: [PATCH] 2026.1.19 1. 新增可配置的台账提交期限 2. 新增可配置的自巡查承诺
---
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt | 214 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 169 insertions(+), 45 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt
index 47d73ed..4e3b176 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt
@@ -1,17 +1,20 @@
package cn.flightfeather.supervision.lightshare.service.Impl
-import cn.flightfeather.supervision.domain.entity.BaseInfo
-import cn.flightfeather.supervision.domain.entity.Company
-import cn.flightfeather.supervision.domain.entity.Userinfo
+import cn.flightfeather.supervision.domain.entity.*
import cn.flightfeather.supervision.domain.enumeration.SceneType
+import cn.flightfeather.supervision.domain.enumeration.UserType
import cn.flightfeather.supervision.domain.mapper.*
+import cn.flightfeather.supervision.domain.repository.UserInfoRep
import cn.flightfeather.supervision.infrastructure.utils.FileUtil
import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator
+import cn.flightfeather.supervision.domain.repository.UserConfigRep
import cn.flightfeather.supervision.lightshare.service.UserinfoService
import cn.flightfeather.supervision.lightshare.vo.*
import com.github.pagehelper.PageHelper
+import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.springframework.beans.BeanUtils
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.math.BigDecimal
@@ -25,7 +28,12 @@
val companyMapper: CompanyMapper,
val restaurantBaseInfoMapper: RestaurantBaseInfoMapper,
val vehicleBaseInfoMapper: VehicleBaseInfoMapper,
- val userMapMapper: UserMapMapper
+ val industrialBaseInfoMapper: IndustrialBaseInfoMapper,
+ val userMapMapper: UserMapMapper,
+ val personalInfoMapper: PersonalInfoMapper,
+ val userInfoWxMapper: UserInfoWxMapper,
+ val userInfoRep: UserInfoRep,
+ val userConfigRep: UserConfigRep,
) : UserinfoService {
//鏍规嵁userinfo鏉′欢鏌ヨ
@@ -35,25 +43,87 @@
criteria.andEqualTo("acountname", userinfo.acountname)
val result = userinfoMapper.selectByExample(example)
return if (result.isNotEmpty()) {
- result[0]
+ result?.get(0) ?: Userinfo()
} else {
Userinfo()
}
}
- override fun findOne(id: String): Userinfo{
+ override fun findOne(id: String): Userinfo {
val userInfo = userinfoMapper.selectByPrimaryKey(id)
+// userInfo?.password = null
userMapMapper.selectByPrimaryKey(id)?.let {
userInfo?.extension3 = it.svUserId
}
return userInfo ?: Userinfo()
}
- override fun findAll(): MutableList<Userinfo> = userinfoMapper.selectAll()
+ override fun findAll(): MutableList<Userinfo?> = userinfoMapper.selectAll()
- override fun save(userinfo: Userinfo): Int = userinfoMapper.insert(userinfo)
+ override fun save(userinfo: Userinfo): BaseResponse<Int> {
+ userinfoMapper.selectByPrimaryKey(userinfo.guid)?.run { return BaseResponse(false, "鐢ㄦ埛宸插瓨鍦�", data = 0) }
+ userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
+ createCriteria().andEqualTo("acountname", userinfo.acountname)
+ }).run { if (isNotEmpty()) return BaseResponse(false, "鐢ㄦ埛鐧诲綍璐︽埛鍚嶇О宸插瓨鍦�", data = 0) }
+ userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
+ createCriteria().andEqualTo("realname", userinfo.realname)
+ }).run { if (isNotEmpty()) return BaseResponse(false, "鐢ㄦ埛鏄电О宸插瓨鍦�", data = 0) }
- override fun update(userinfo: Userinfo): Int = userinfoMapper.updateByPrimaryKeySelective(userinfo)
+ userinfo.apply {
+ guid = UUIDGenerator.generate16ShortUUID()
+ headIconUrl = ""
+ password = "123456"
+ if (isenable == null) isenable = true
+ uiCreateTime = Date()
+ }
+ val res = userinfoMapper.insert(userinfo)
+ return if (res == 1) {
+ BaseResponse(true, data = res)
+ } else {
+ BaseResponse(false, "鎻掑叆鏁版嵁搴撳け璐�", data = res)
+ }
+ }
+
+ @Transactional
+ override fun save2(info: UserBaseInfo): BaseResponse<Int> {
+ info.userInfo ?: return BaseResponse(false, "鐢ㄦ埛淇℃伅缂哄け锛屾棤娉曟柊寤虹敤鎴�")
+ info.baseInfo ?: return BaseResponse(false, "鐢ㄦ埛淇℃伅缂哄け锛屾棤娉曟柊寤虹敤鎴�")
+ val repeatRes = userInfoRep.checkIsRepeat(info.userInfo)
+ if (repeatRes.first) return BaseResponse(false, repeatRes.second)
+
+ info.userInfo.apply {
+ guid = UUIDGenerator.generate16ShortUUID()
+ headIconUrl = ""
+ password = "123456"
+ if (isenable == null) isenable = true
+ uiCreateTime = Date()
+ }
+ info.baseInfo.apply {
+ biGuid = info.userInfo.guid
+ biName = info.userInfo.realname
+ biCreateTime = info.userInfo.uiCreateTime
+ biExtension1 = info.userInfo.acountname
+ }
+ userinfoMapper.insert(info.userInfo)
+ baseInfoMapper.insert(info.baseInfo)
+ return BaseResponse(true)
+ }
+
+ override fun resetPassword(userId: String): BaseResponse<Boolean> {
+ val info = userinfoMapper.selectByPrimaryKey(userId) ?: return BaseResponse(false, "鐢ㄦ埛涓嶅瓨鍦�")
+ info.password = "123456"
+ val r = userinfoMapper.updateByPrimaryKeySelective(info)
+ return BaseResponse(r == 1)
+ }
+
+ override fun update(userinfo: Userinfo): BaseResponse<Int> {
+ val res = userinfoMapper.updateByPrimaryKeySelective(userinfo)
+ return if (res == 1) {
+ BaseResponse(true, data = res)
+ } else {
+ BaseResponse(false, "鎻掑叆鏁版嵁搴撳け璐�", data = res)
+ }
+ }
override fun delete(id: String): Int = userinfoMapper.deleteByPrimaryKey(id)
@@ -62,11 +132,15 @@
val example = Example(Userinfo::class.java)
val criteria = example.createCriteria()
criteria.andEqualTo("acountname", loginRequestVo.userName)
- .andEqualTo("password",loginRequestVo.password)
+ .andEqualTo("password", loginRequestVo.password)
val result = userinfoMapper.selectByExample(example)
return AccessToken().apply {
if (result.isNotEmpty()) {
- userId = result[0].guid
+ val u = result?.get(0)
+ u?.uiLoginTime = Date()
+ userinfoMapper.updateByPrimaryKeySelective(u)
+ userInfoRep.loginLog(u?.guid)
+ userId = u?.guid
val sUser = userMapMapper.selectByPrimaryKey(userId)
sUserId = sUser?.svUserId
success = true
@@ -157,24 +231,24 @@
createCriteria().andEqualTo("extension1", userInfo.extension1)
.andGreaterThanOrEqualTo("usertypeid", userInfo.usertypeid)
})
- .forEach {
- val groupName = if (it.extension1.isNullOrEmpty()){
- "鏈垎缁�"
- } else {
- "${it.extension1!!}-${it.usertype}-${SceneType.getNameByValue(it.extension2?.toInt() ?: -1)}"
+ .forEach {
+ val groupName = if (it?.extension1.isNullOrEmpty()) {
+ "鏈垎缁�"
+ } else {
+ "${it?.extension1!!}-${it.usertype}-${SceneType.getByValue(it.extension2?.toInt() ?: -1).des}"
+ }
+ val friend = if (it?.guid != userId) {
+ FriendVo(groupName)
+ } else {
+ FriendVo("鎴�")
+ }
+ BeanUtils.copyProperties(it, friend)
+ if (it?.guid == userId) {
+ resultList.add(0, friend)
+ } else {
+ resultList.add(friend)
+ }
}
- val friend = if (it.guid != userId) {
- FriendVo(groupName)
- } else {
- FriendVo("鎴�")
- }
- BeanUtils.copyProperties(it, friend)
- if (it.guid == userId) {
- resultList.add(0, friend)
- } else {
- resultList.add(friend)
- }
- }
return resultList
}
@@ -202,29 +276,38 @@
}
}
- override fun changePassword(userId: String, oldPassword: String, newPassword: String): Int {
+ override fun changePassword(userId: String, oldPassword: String, newPassword: String): BaseResponse<String> {
+ if (newPassword.trim() == "") return BaseResponse(false, "鏂板瘑鐮佷笉鑳戒负绌�")
+ if (oldPassword == newPassword) return BaseResponse(false, "鏂板瘑鐮佷笉鑳藉拰鍘熷瘑鐮佺浉鍚�")
+
val userInfo = findOne(userId)
return if (oldPassword != userInfo.password) {
- 0
+ BaseResponse(false, "鍘熷瘑鐮侀敊璇�")
} else {
val newUserInfo = Userinfo().apply {
guid = userInfo.guid
password = newPassword
+ remark = "pwChanged"
}
update(newUserInfo)
+ BaseResponse(true, "瀵嗙爜淇敼鎴愬姛")
}
}
- override fun searchUser(userId: String, condition: UserSearchCondition, page: Int, perPage: Int, response: HttpServletResponse): List<Userinfo> {
+ override fun searchUser(
+ userId: String, condition: UserSearchCondition, page: Int, perPage: Int,
+ response:
+ HttpServletResponse,
+ ): List<Userinfo?> {
val user = userinfoMapper.selectByPrimaryKey(userId)
- val districtName = condition.districtName ?: user.extension1
+ val districtName = condition.districtName ?: user?.extension1
val p = PageHelper.startPage<Userinfo>(page, perPage)
- val result = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
- if (condition.searchText.isNotBlank()) {
+ val userInfoList = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
+ if (condition.searchText?.isNotBlank() == true) {
and(createCriteria()
- .orLike("acountname", "%${condition.searchText}%")
- .orLike("realname", "%${condition.searchText}%")
+ .orLike("acountname", "%${condition.searchText}%")
+ .orLike("realname", "%${condition.searchText}%")
)
}
if (condition.sceneTypes.isNotEmpty()) {
@@ -235,33 +318,49 @@
})
}
and(createCriteria().andEqualTo("extension1", districtName)
- .andEqualTo("isenable", true))
- //todo 2020.8.19 琛楅晣鐨勬潯浠舵煡璇㈤渶瑕佹墿鍏匓aseInfo鏁版嵁琛ㄥ瓧娈靛悗鍐嶅疄鐜�
+ .andEqualTo("isenable", true).apply {
+ condition.userTypeId?.let { andEqualTo("usertypeid", it) }
+ })
})
+ //2025.11.28 閫氳繃BaseInfo琛ㄤ腑鐨刡iTownCode瀛楁鏉ョ瓫閫夊嚭绗﹀悎鏉′欢鐨勭敤鎴�
+ val baseInfoList = baseInfoMapper.selectByExample(Example(BaseInfo::class.java).apply {
+ createCriteria().andIn("biGuid", userInfoList.map { it?.guid })
+ }).filter { it.biTownCode == condition.townCode }
+
+ val result = userInfoList.filter { u-> baseInfoList.any { b-> b.biGuid == u?.guid } }
response.setIntHeader("totalPage", p.pages)
response.setIntHeader("currentPage", p.pageNum)
+ response.setIntHeader("totalCount", p.total.toInt())
return result
}
- override fun getBaseInfo(userId: String): UserBaseInfo {
+ override fun getBaseInfo(userId: String, wxUserId: String?): UserBaseInfo {
val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return UserBaseInfo(userId)
- val baseInfo = baseInfoMapper.selectByPrimaryKey(userId) ?: return UserBaseInfo(userId)
+ userInfo.password = null
+ val baseInfo = baseInfoMapper.selectByPrimaryKey(userId)
+ val wxUser = if (wxUserId != null) userInfoWxMapper.selectByPrimaryKey(wxUserId) else null
val mapper = when (userInfo.extension2) {
SceneType.Restaurant.value.toString() -> restaurantBaseInfoMapper
SceneType.VehicleRepair.value.toString() -> vehicleBaseInfoMapper
- else -> restaurantBaseInfoMapper
+ SceneType.Industrial.value.toString() -> industrialBaseInfoMapper
+ else -> null
}
- val specialInfo = mapper.selectByPrimaryKey(baseInfo.biGuid)
- val companyInfo = companyMapper.selectByPrimaryKey(baseInfo.ciGuid)
+ val specialInfo = mapper?.selectByPrimaryKey(baseInfo?.biGuid)
+ val companyInfo =
+ companyMapper.selectByPrimaryKey(if (baseInfo?.ciGuid != null) baseInfo.ciGuid else wxUser?.ciGuid)
+ val personalInfo = personalInfoMapper.selectByExample(Example(PersonalInfo::class.java).apply {
+ createCriteria().andEqualTo("piSceneId", userId).andEqualTo("piWxId", wxUser?.uiOpenId)
+ }).takeIf { it.isNotEmpty() }?.get(0)
- return UserBaseInfo(userId, userInfo.realname, baseInfo, companyInfo, specialInfo)
+ return UserBaseInfo(userId, userInfo.realname, userInfo, baseInfo, companyInfo, specialInfo, personalInfo)
}
- override fun search(district: String?, sceneType: Int?, userType: Int?, page: Int, perPage: Int): BaseResponse<List<Userinfo>> {
+ override fun search(district: String?, sceneType: Int?, userType: Int?, page: Int, perPage: Int):
+ BaseResponse<List<Userinfo?>> {
val result = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
createCriteria().apply {
district?.let { andEqualTo("extension1", it) }
@@ -272,4 +371,29 @@
return BaseResponse(true, data = result)
}
+
+ override fun getSceneCount(userId: String, condition: UserSearchCondition): BaseResponse<Triple<Int, Int, Int>> {
+// val user = userinfoMapper.selectByPrimaryKey(userId)
+// val baseInfo = baseInfoMapper.selectByPrimaryKey(userId)
+// condition.districtName = condition.districtName ?: user?.extension1
+
+ val config = userConfigRep.getUserConfigBySubType(userId)
+ val c = UserSearchCondition.fromUserConfig(config, condition).apply {
+ userTypeId = UserType.Enterprise.value.toByte()
+// sceneTypes = condition.sceneTypes
+ }
+
+ val result = userinfoMapper.searchUser(c)
+ val total = result.size
+ val enabled = result.filter { u ->
+ return@filter u.isenable == true
+ }.size
+ val disabled = total - enabled
+
+ return BaseResponse(true, data = Triple(total, enabled, disabled))
+ }
+
+ override fun createUsers(workbook: HSSFWorkbook) {
+ TODO("Not yet implemented")
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3