| | |
| | | package cn.flightfeather.supervision.lightshare.service.impl |
| | | |
| | | import cn.flightfeather.supervision.business.import.SceneImport |
| | | import cn.flightfeather.supervision.business.location.LocationRoadNearby |
| | | import cn.flightfeather.supervision.common.exception.BizException |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | | import cn.flightfeather.supervision.domain.ds1.entity.* |
| | | import cn.flightfeather.supervision.domain.ds1.mapper.* |
| | | import cn.flightfeather.supervision.common.utils.Constant |
| | | import cn.flightfeather.supervision.domain.ds1.repository.SceneRep |
| | | import cn.flightfeather.supervision.domain.ds2.entity.UserMap |
| | | import cn.flightfeather.supervision.domain.ds2.repository.BaseInfoRep |
| | | import cn.flightfeather.supervision.domain.ds2.repository.UserMapRep |
| | | import cn.flightfeather.supervision.lightshare.service.* |
| | | import cn.flightfeather.supervision.lightshare.vo.* |
| | | import com.github.pagehelper.PageHelper |
| | | import com.google.gson.Gson |
| | | import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.beans.factory.annotation.Autowired |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.transaction.annotation.Transactional |
| | | import org.springframework.web.multipart.MultipartFile |
| | | import tk.mybatis.mapper.entity.Example |
| | | import tk.mybatis.mapper.util.StringUtil |
| | | import java.io.ByteArrayInputStream |
| | | import java.util.* |
| | | import kotlin.collections.ArrayList |
| | | |
| | | @Service |
| | | class ScenseServiceImpl( |
| | | val scenseMapper: ScenseMapper, |
| | | val sceneConstructionSiteMapper: SceneConstructionSiteMapper, |
| | | val sceneDeviceMapper: SceneDeviceMapper, |
| | | val sceneMixingPlantMapper: SceneMixingPlantMapper, |
| | | val sceneStorageYardMapper: SceneStorageYardMapper, |
| | | val sceneWharfMapper: SceneWharfMapper, |
| | | val userinfoService: UserinfoService |
| | | val scenseMapper: ScenseMapper, |
| | | val sceneConstructionSiteMapper: SceneConstructionSiteMapper, |
| | | val sceneDeviceMapper: SceneDeviceMapper, |
| | | val sceneMixingPlantMapper: SceneMixingPlantMapper, |
| | | val sceneStorageYardMapper: SceneStorageYardMapper, |
| | | val sceneWharfMapper: SceneWharfMapper, |
| | | val userinfoService: UserinfoService, |
| | | private val locationRoadNearby: LocationRoadNearby, |
| | | private val sceneImport: SceneImport, |
| | | private val sceneRep: SceneRep, |
| | | private val baseInfoRep: BaseInfoRep, |
| | | private val userMapRep: UserMapRep, |
| | | ) : ScenseService { |
| | | |
| | | @Autowired |
| | |
| | | } |
| | | |
| | | override fun save(scense: Scense): Int { |
| | | // TODO: 2021/7/20 新增场景的同时生成账户 |
| | | val r = scenseMapper.insert(scense) |
| | | if (r == 1) { |
| | | scense.guid?.let { userinfoService.createAccount(it) } |
| | | return try { |
| | | createScene(scense) |
| | | 1 |
| | | } catch (e: BizException) { |
| | | println(e.message) |
| | | 0 |
| | | } |
| | | return r |
| | | } |
| | | |
| | | override fun update(scense: Scense): Int = scenseMapper.updateByPrimaryKeySelective(scense) |
| | |
| | | areaVo.towncode?.let { andEqualTo("towncode", it) } |
| | | areaVo.scensetypeid?.let { andEqualTo("typeid", it) } |
| | | areaVo.sceneName?.let { andLike("name", "%${it}%") } |
| | | |
| | | } |
| | | areaVo.online?.let { |
| | | and(createCriteria().apply { |
| | |
| | | }) |
| | | return BaseResponse(true, head = DataHead(p.pageNum, p.pages, p.total), data = list) |
| | | } |
| | | |
| | | override fun searchByCoordinate(lng: Double, lat: Double, radius: Double): List<Scense> { |
| | | return locationRoadNearby.searchByRadius(Pair(lng, lat), radius) |
| | | } |
| | | |
| | | override fun importSceneInfo(file: MultipartFile): Boolean { |
| | | val f = ByteArrayInputStream(file.bytes) |
| | | val scenes = sceneImport.readFromFile(f) |
| | | // 查找场景名称是否重复 |
| | | val names = scenes.map { it.name } |
| | | sceneRep.findScenes(names).map { it?.name }.ifNotEmpty { |
| | | val str = this.joinToString(",") |
| | | throw BizException("存在重复场景,如下:${str}") |
| | | } |
| | | scenes.forEach { |
| | | createOneScene(it) |
| | | } |
| | | return true |
| | | } |
| | | |
| | | override fun createScene(scense: Scense): Scense { |
| | | val names = listOf(scense.name) |
| | | sceneRep.findScenes(names).map { it?.name }.ifNotEmpty { |
| | | val str = this.joinToString(",") |
| | | throw BizException("存在重复场景,如下:${str}") |
| | | } |
| | | createOneScene(scense) |
| | | return scense |
| | | } |
| | | |
| | | |
| | | override fun createOneScene(scense: Scense) { |
| | | //1. 插入场景表 |
| | | sceneRep.insert(scense) |
| | | //2. 生成对应账户信息 |
| | | val userInfo = userinfoService.createAccount(scense) |
| | | createTZUserInfo(userInfo, scense) |
| | | } |
| | | |
| | | override fun createTZUserInfo(userInfo: Userinfo, scense: Scense) { |
| | | //1. 生成飞羽环境系统对应账户和基础信息 |
| | | val userInfoTZ = userinfoService.createAccountTZ(userInfo, scense) |
| | | val baseInfo = baseInfoRep.create(userInfoTZ, scense) |
| | | //2. 生成用户匹配信息 |
| | | userMapRep.insert(UserMap().apply { |
| | | tzUserId = userInfoTZ.guid |
| | | tzUserName = userInfoTZ.realname |
| | | svUserId = userInfo.guid |
| | | svUserName = userInfo.realname |
| | | umCreateTime = Date() |
| | | }) |
| | | } |
| | | |
| | | } |