feiyu02
2025-09-17 8c15c9cc0d6474ed77e313258f9b09f7f2d6366e
src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/ScenseServiceImpl.kt
@@ -83,6 +83,7 @@
        val name = scense.name ?: ""
        val example = Example(Scense::class.java)
        val criteria = example.createCriteria()
        criteria.andEqualTo("typeid", scense.typeid)
        //如果有type信息,就构建type查询
        if (StringUtil.isNotEmpty(scense.type)) {
            criteria.andEqualTo("type", scense.type)
@@ -99,6 +100,10 @@
        if (StringUtil.isNotEmpty(scense.towncode)) {
            criteria.andEqualTo("towncode", scense.towncode)
        }
        if (StringUtil.isNotEmpty(scense.extension1)) {
            criteria.andEqualTo("extension1", scense.extension1)
        }
        criteria.andEqualTo("index", scense.index)
        //name查询
        criteria.andLike("name", "%$name%")
        val re = scenseMapper.selectByExample(example)
@@ -278,10 +283,10 @@
    override fun getSceneDetail(sceneId: String): BaseResponse<SceneDetail> {
        val sceneDetail = SceneDetail()
        val scene = scenseMapper.selectByPrimaryKey(sceneId)
        val scene = sceneRep.findScene(sceneId = sceneId)
        sceneDetail.scense = scene
        val mapper = when (scene.typeid.toString()) {
        val mapper = when (scene?.typeid.toString()) {
            Constant.SceneType.TYPE1.value -> sceneConstructionSiteMapper
            Constant.SceneType.TYPE2.value -> sceneWharfMapper
            Constant.SceneType.TYPE3.value -> sceneMixingPlantMapper
@@ -324,6 +329,7 @@
            when (typeId.toString()) {
                Constant.SceneType.TYPE1.value -> {
                    val subScene = Gson().fromJson(sceneDetailStr.subScene, SceneConstructionSite::class.java)
                    subScene.csUpdateTime = Date()
                    if (subScene.getsGuid() != null) {
                        val record = sceneConstructionSiteMapper.selectByPrimaryKey(subScene.getsGuid())
                        isUpdate = record != null
@@ -406,24 +412,29 @@
        return locationRoadNearby.searchByRadius(Pair(lng, lat), radius)
    }
    override fun importSceneInfo(file: MultipartFile): Boolean {
        val f = ByteArrayInputStream(file.bytes)
    override fun importSceneInfo(files: Array<MultipartFile>): Boolean {
        if (files.isEmpty()) throw BizException("未正确上传文件,接口调用错误")
        val f = ByteArrayInputStream(files[0].bytes)
        val scenes = sceneImport.readFromFile(f)
        if (scenes.isEmpty()) throw BizException("文件内容为空")
        // 查找场景名称是否重复
        val names = scenes.map { it.name }
        sceneRep.findScenes(names).map { it?.name }.ifNotEmpty {
        val names = scenes.map { it.scense?.name }
        sceneRep.findSceneList(names).map { it?.name }.ifNotEmpty {
            val str = this.joinToString(",")
            throw BizException("存在重复场景,如下:${str}")
        }
        scenes.forEach {
            createOneScene(it)
            it.scense ?: return@forEach
            createOneScene(it.scense!!)
            sceneRep.insertOrUpdateSubScene(it.scense!!.typeid?.toInt(), it.scense!!.guid, it.subScene)
        }
        return true
    }
    override fun createScene(scense: Scense): Scense {
        val names = listOf(scense.name)
        sceneRep.findScenes(names).map { it?.name }.ifNotEmpty {
        sceneRep.findSceneList(names).map { it?.name }.ifNotEmpty {
            val str = this.joinToString(",")
            throw BizException("存在重复场景,如下:${str}")
        }