| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | | import cn.flightfeather.supervision.common.utils.PinYin |
| | | import cn.flightfeather.supervision.common.utils.UUIDGenerator |
| | | import cn.flightfeather.supervision.domain.ds1.entity.Scense |
| | |
| | | import cn.flightfeather.supervision.domain.ds1.repository.SceneRep |
| | | import cn.flightfeather.supervision.domain.ds1.repository.TaskRep |
| | | import cn.flightfeather.supervision.domain.ds1.repository.UserInfoSVRep |
| | | import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ |
| | | import cn.flightfeather.supervision.domain.ds2.repository.UserInfoTZRep |
| | | import cn.flightfeather.supervision.lightshare.service.UserinfoService |
| | | import cn.flightfeather.supervision.lightshare.vo.AreaVo |
| | | import cn.flightfeather.supervision.lightshare.vo.DataHead |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | import kotlin.random.Random |
| | |
| | | class UserinfoServiceImpl( |
| | | val userinfoMapper: UserinfoMapper, |
| | | private val scenseMapper: ScenseMapper, |
| | | private val userInfoSVRep: UserInfoSVRep, |
| | | private val userInfoTZRep: UserInfoTZRep, |
| | | ) : UserinfoService { |
| | | |
| | | //根据userinfo条件查询 |
| | |
| | | |
| | | override fun delete(id: String): Int = userinfoMapper.deleteByPrimaryKey(id) |
| | | |
| | | override fun search(areaVo: AreaVo, keyword: String, userType: Int?, page: Int?, perPage: Int?) |
| | | : Pair<DataHead, List<Userinfo?>> { |
| | | val p = PageHelper.startPage<Userinfo>(page ?: 1, perPage ?: 30) |
| | | val result = userInfoSVRep.searchUser(areaVo, keyword.trim(), Constant.UserType.fromValue(userType)) |
| | | result.forEach { it?.password = null } |
| | | return DataHead(p.pageNum, p.pages, p.total) to result |
| | | } |
| | | |
| | | override fun createAccount(sceneId: String): Userinfo { |
| | | findByScene(sceneId)?.let { return it } |
| | | |
| | | scenseMapper.selectByPrimaryKey(sceneId)?.let { |
| | | val sceneName = it.name ?: return Userinfo() |
| | | val uName = getUName(sceneName) |
| | | |
| | | val userInfo = Userinfo().apply { |
| | | guid = UUIDGenerator.generate16ShortUUID() |
| | | acountname = uName |
| | | realname = sceneName |
| | | password = "123456" |
| | | usertypeid = 3 |
| | | usertype = "企业" |
| | | dGuid = it.guid |
| | | departmentname = sceneName |
| | | isenable = true |
| | | remark = it.districtname |
| | | } |
| | | |
| | | val r = userinfoMapper.insert(userInfo) |
| | | if (r == 1) { |
| | | return userInfo |
| | | } |
| | | createAccount(it) |
| | | } |
| | | return Userinfo() |
| | | } |
| | |
| | | return null |
| | | } |
| | | |
| | | private fun getUName(sceneName: String): String { |
| | | override fun getUName(sceneName: String): String { |
| | | var uName = PinYin.getPinYinHeader(sceneName) |
| | | var suffix = "" |
| | | var repeated: Boolean |
| | |
| | | } |
| | | } |
| | | |
| | | private fun createAccount(scence: Scense) { |
| | | override fun createAccount(scence: Scense):Userinfo { |
| | | scence.let { |
| | | val sceneName = it.name ?: return |
| | | val uName = getUName(sceneName) |
| | | // 判断该场景是否已有对应账户 |
| | | val user = userInfoSVRep.findUser(it.guid) |
| | | if (user != null) return user |
| | | |
| | | val sceneName = it.name ?: return Userinfo() |
| | | val uName = getUName(sceneName) |
| | | val userInfo = Userinfo().apply { |
| | | guid = UUIDGenerator.generate16ShortUUID() |
| | | acountname = uName |
| | |
| | | |
| | | val r = userinfoMapper.insert(userInfo) |
| | | if (r == 1) { |
| | | println("${userInfo.guid}--${userInfo.acountname}--${userInfo.realname}") |
| | | return userInfo |
| | | } else { |
| | | return Userinfo() |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun createAccountTZ(userinfo: Userinfo, scence: Scense): UserinfoTZ { |
| | | val userinfoTZ = UserinfoTZ() |
| | | BeanUtils.copyProperties(userinfo, userinfoTZ) |
| | | // 使用新的id |
| | | userinfoTZ.guid = UUIDGenerator.generate16ShortUUID() |
| | | // 添加区县描述 |
| | | // FIXME: 2024/4/23 目前在BaseInfo基础信息中已存储完整的行政区划,后续应将此处记录去除 |
| | | userinfoTZ.extension1 = userinfoTZ.remark |
| | | userinfoTZ.remark = null |
| | | // 场景类型转换 |
| | | userinfoTZ.extension2 = Constant.SceneType.typeMap(scence.typeid)?.toString() |
| | | // 根据acountname和realname进行重复判断 |
| | | userInfoTZRep.findOne(UserinfoTZ().apply { |
| | | acountname = userinfoTZ.acountname |
| | | realname = userinfoTZ.realname |
| | | }).takeIf { it == null }.run { |
| | | // 当没有查询结果时,插入新账户信息 |
| | | userInfoTZRep.insert(userinfoTZ) |
| | | } |
| | | return userinfoTZ |
| | | } |
| | | } |