package com.persagy.server.services.dict

import com.persagy.base.extensions.toJson
import com.persagy.base.utils.SJsonUtil
import com.persagy.database.SFilter
import com.persagy.database.functions.SLength
import com.persagy.mybatis.SMybatisDao
import com.persagy.server.datacenter.models.entities.dict.*
import com.persagy.server.datacenter.models.response.AllDictCategory
import com.persagy.server.services.base.Service
import com.persagy.server.utils.RecursiveQuery
import com.persagy.service.SBaseService
import com.persagy.service.SObjectService
import com.persagy.service.SPageContext
import com.persagy.service.models.enums.SResponseType
import com.persagy.service.models.requests.SQueryRequest
import com.persagy.service.models.responses.SQueryResponse

/**
 * 数据字典说明
 *
 * @author 张维新
 */
object PropertyDefService : Service<DPropertyDefML>(SMybatisDao(DPropertyDefML::class.java)) {

    /** 服务 */
    private val dictRentalservice = SBaseService(SMybatisDao(DictRental::class.java))

    /** 自定义信息点方案查询服务 */
    private val projectSchemeService = SBaseService(SMybatisDao(ProjectScheme::class.java))
    /** 自定义信息点方案内容 */
    var schemeInfoService = SObjectService(SMybatisDao(DataPlatformSchemeInfo::class.java))


    /**
     * 分页查询
     *
     * @param   request     查询条件
     * @return              查询结果
     */
    fun pageQuery(request: SQueryRequest): SQueryResponse<DPropertyDefML> {
        return try {
            val queryBuilder = select(request.filters)
            if (null != request.projection) {
                queryBuilder.projection(request.projection!!)
            }
            if (null != request.orders) {
                queryBuilder.order(request.orders!!)
            }
            val pageInfo = queryBuilder.pageQuery(request.pageNumber, request.pageSize)
            val contentList = pageInfo.content
            for (content in contentList!!) {
//                if (!"见《9租赁业态类型》".equals(content.dataSource, true)) continue
//                val service = SBaseService(SMybatisDao(DictRentalSyn::class.java))
//                content.dataSource = net.minidev.json.JSONArray.toJSONString(service.select(SFilter.notNull("id")).exec())

                if (!content.dataSource.isNullOrEmpty() && content.dataSource!!.contains("见《")) {
                    // TODO: 有时间转为when表达
                    if (content.dataSource!!.contains("省市区代码")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("气候区代码")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("发展水平代码")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("天气状态")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("空气风力等级")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("方向代码")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("建筑功能类型")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("空间功能类型")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("租赁业态类型")) {
                        val oneLevelList = dictRentalservice.select(SFilter.isNull("parent")).exec()
                        for (oneLevel in oneLevelList) {
                            oneLevel.parent = null
                            oneLevel.lastUpdate = null
                            oneLevel.createTime = null
                            val treeSpaceFunctional = RecursiveQuery.treeDictRental(oneLevel.id!!)
                            oneLevel.content = treeSpaceFunctional
                        }
                        content.dataSource = oneLevelList.toJson()
                    } else if (content.dataSource!!.contains("抗震设防烈度")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("污秽等级")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("污染等级")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("防护等级")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("地理分区")) {
                        content.dataSource = null
                    } else if (content.dataSource!!.contains("职业分类")) {
                        content.dataSource = null
                    }
                }
            }

            SQueryResponse(pageInfo)
        } catch (e: Exception) {
            e.printStackTrace()
            SQueryResponse(SResponseType.failure, e.message!!)
        }
    } // Function query()

    /**
     * 查询竖井类型范围
     */
    fun pageQueryShaftType(): SQueryResponse<DictClimate> {
        return try {
            val propertyDef = select(SFilter.eq("infoPointCode", "ShaftFuncType")).entity()

            val dictClimateList = SJsonUtil.fromJson<ArrayList<DictClimate>>(propertyDef!!.dataSource!!)
            val sQueryResponse = SQueryResponse<DictClimate>(SResponseType.success)
            sQueryResponse.content = dictClimateList
            sQueryResponse.total = dictClimateList.size.toLong()
            sQueryResponse
        } catch (e: Exception) {
            e.printStackTrace()
            SQueryResponse(SResponseType.failure, e.message!!)
        }
    } // Function pageQueryShaftType()


    /**
     * 查询 字典全集信息
     */
    fun pageQueryAllDict(dictTypeList: ArrayList<String>): AllDictCategory {

        val allDictCategory = AllDictCategory()
        val projectId = SPageContext.getHeader("ProjectId")
        val projectScheme = projectSchemeService.select(SFilter.eq("projectId", projectId!!)).entity()

        try {
            var list = ArrayList<DPropertyDefML>()
            if (!dictTypeList.isNullOrEmpty() && dictTypeList.size > 0) {


                for (dictType in dictTypeList) {

                    if (dictType == "Project") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "项目"
                        dPropertyDef.infoPointCode = "Project"

                        val projectList = select(SFilter.eq("type", "Project"), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                        if (projectScheme!=null){
                            val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", "project"),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                            if (!schemeInfoList.isNullOrEmpty()){
                                for (schemeInfo in schemeInfoList){
                                    val dPropertyDefML = DPropertyDefML()
                                    dPropertyDefML.dataSource = schemeInfo.dataSource
                                    dPropertyDefML.dataType = schemeInfo.dataType
                                    dPropertyDefML.firstName = schemeInfo.firstName
                                    dPropertyDefML.firstTag = schemeInfo.firstTag
                                    dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                    dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                    dPropertyDefML.inputMode = schemeInfo.inputMode
                                    dPropertyDefML.note = schemeInfo.note
                                    dPropertyDefML.priority = schemeInfo.priority
                                    dPropertyDefML.secondName = schemeInfo.secondName
                                    dPropertyDefML.secondTag = schemeInfo.secondTag
                                    dPropertyDefML.unit = schemeInfo.unit
                                    projectList.add(dPropertyDefML)
                                }
                            }
                        }
                        dPropertyDef.content = projectList
                        list.add(dPropertyDef)

                    } else if (dictType == "Building") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "建筑"
                        dPropertyDef.infoPointCode = "Building"
                        val buildingList = select(SFilter.eq("type", "Building"), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                        if (projectScheme!=null){
                            val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", "building"),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                            if (!schemeInfoList.isNullOrEmpty()){
                                for (schemeInfo in schemeInfoList){
                                    val dPropertyDefML = DPropertyDefML()
                                    dPropertyDefML.dataSource = schemeInfo.dataSource
                                    dPropertyDefML.dataType = schemeInfo.dataType
                                    dPropertyDefML.firstName = schemeInfo.firstName
                                    dPropertyDefML.firstTag = schemeInfo.firstTag
                                    dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                    dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                    dPropertyDefML.inputMode = schemeInfo.inputMode
                                    dPropertyDefML.note = schemeInfo.note
                                    dPropertyDefML.priority = schemeInfo.priority
                                    dPropertyDefML.secondName = schemeInfo.secondName
                                    dPropertyDefML.secondTag = schemeInfo.secondTag
                                    dPropertyDefML.unit = schemeInfo.unit
                                    buildingList.add(dPropertyDefML)
                                }
                            }
                        }

                        dPropertyDef.content = buildingList
                        list.add(dPropertyDef)
                    } else if (dictType == "Floor") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "楼层"
                        dPropertyDef.infoPointCode = "Floor"
                        val floorList = select(SFilter.eq("type", "Floor"), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                        if (projectScheme!=null){
                            val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", "floor"),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                            if (!schemeInfoList.isNullOrEmpty()){
                                for (schemeInfo in schemeInfoList){
                                    val dPropertyDefML = DPropertyDefML()
                                    dPropertyDefML.dataSource = schemeInfo.dataSource
                                    dPropertyDefML.dataType = schemeInfo.dataType
                                    dPropertyDefML.firstName = schemeInfo.firstName
                                    dPropertyDefML.firstTag = schemeInfo.firstTag
                                    dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                    dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                    dPropertyDefML.inputMode = schemeInfo.inputMode
                                    dPropertyDefML.note = schemeInfo.note
                                    dPropertyDefML.priority = schemeInfo.priority
                                    dPropertyDefML.secondName = schemeInfo.secondName
                                    dPropertyDefML.secondTag = schemeInfo.secondTag
                                    dPropertyDefML.unit = schemeInfo.unit
                                    floorList.add(dPropertyDefML)
                                }
                            }
                        }

                        dPropertyDef.content = floorList
                        list.add(dPropertyDef)
                    } else if (dictType == "Equipment") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "设备"
                        dPropertyDef.infoPointCode = "Equipment"
                        val equipmentCategoryList = DClassDefService.select(SFilter.eq(SLength("id"), 4), SFilter.not(SFilter.isNull("parentId"))).exec()
                        var listEquip = ArrayList<DPropertyDefML>()
                        if (!equipmentCategoryList.isNullOrEmpty() && equipmentCategoryList.size > 0) {
                            for (equipmentCategory in equipmentCategoryList) {
                                val dPropertyDef = DPropertyDefML()
                                dPropertyDef.infoPointCode = equipmentCategory.id
                                dPropertyDef.infoPointName = equipmentCategory.name
                                val exec = select(SFilter.eq("type", equipmentCategory.id!!), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                                if (projectScheme!=null){
                                    val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", equipmentCategory.id!!),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                                    if (!schemeInfoList.isNullOrEmpty()){
                                        for (schemeInfo in schemeInfoList){
                                            val dPropertyDefML = DPropertyDefML()
                                            dPropertyDefML.dataSource = schemeInfo.dataSource
                                            dPropertyDefML.dataType = schemeInfo.dataType
                                            dPropertyDefML.firstName = schemeInfo.firstName
                                            dPropertyDefML.firstTag = schemeInfo.firstTag
                                            dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                            dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                            dPropertyDefML.inputMode = schemeInfo.inputMode
                                            dPropertyDefML.note = schemeInfo.note
                                            dPropertyDefML.priority = schemeInfo.priority
                                            dPropertyDefML.secondName = schemeInfo.secondName
                                            dPropertyDefML.secondTag = schemeInfo.secondTag
                                            dPropertyDefML.unit = schemeInfo.unit
                                            exec.add(dPropertyDefML)
                                        }
                                    }
                                }


                                dPropertyDef.content = exec
                                listEquip.add(dPropertyDef)
                            }
                        }
                        dPropertyDef.content = listEquip
                        list.add(dPropertyDef)
                    } else if (dictType == "Component") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "部件"
                        dPropertyDef.infoPointCode = "Component"
                        var listComponent = ArrayList<DPropertyDefML>()
                        val execComponentList = DClassDefService.select(SFilter.eq(SLength("id"), 6), SFilter.not(SFilter.isNull("parentId")),
                                SFilter.not(SFilter.eq("parentId", "Space")), SFilter.not(SFilter.eq("name", "租户"))).exec()
                        if (!execComponentList.isNullOrEmpty() && execComponentList.size > 0) {
                            for (execComponent in execComponentList) {
                                val dPropertyDef = DPropertyDefML()
                                dPropertyDef.infoPointCode = execComponent.id
                                dPropertyDef.infoPointName = execComponent.name
                                val exec = select(SFilter.eq("type", execComponent.id!!), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                                if (projectScheme!=null){
                                    val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", execComponent.id!!),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                                    if (!schemeInfoList.isNullOrEmpty()){
                                        for (schemeInfo in schemeInfoList){
                                            val dPropertyDefML = DPropertyDefML()
                                            dPropertyDefML.dataSource = schemeInfo.dataSource
                                            dPropertyDefML.dataType = schemeInfo.dataType
                                            dPropertyDefML.firstName = schemeInfo.firstName
                                            dPropertyDefML.firstTag = schemeInfo.firstTag
                                            dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                            dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                            dPropertyDefML.inputMode = schemeInfo.inputMode
                                            dPropertyDefML.note = schemeInfo.note
                                            dPropertyDefML.priority = schemeInfo.priority
                                            dPropertyDefML.secondName = schemeInfo.secondName
                                            dPropertyDefML.secondTag = schemeInfo.secondTag
                                            dPropertyDefML.unit = schemeInfo.unit
                                            exec.add(dPropertyDefML)
                                        }
                                    }
                                }

                                dPropertyDef.content = exec
                                listComponent.add(dPropertyDef)
                            }
                            dPropertyDef.content = listComponent
                            list.add(dPropertyDef)
                        }
                    }else if (dictType == "Shaft") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "竖井"
                        dPropertyDef.infoPointCode = "Shaft"
                        val shaftList = select(SFilter.eq("type", "Shaft"), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                        if (projectScheme!=null){
                            val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", "shaft"),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                            if (!schemeInfoList.isNullOrEmpty()){
                                for (schemeInfo in schemeInfoList){
                                    val dPropertyDefML = DPropertyDefML()
                                    dPropertyDefML.dataSource = schemeInfo.dataSource
                                    dPropertyDefML.dataType = schemeInfo.dataType
                                    dPropertyDefML.firstName = schemeInfo.firstName
                                    dPropertyDefML.firstTag = schemeInfo.firstTag
                                    dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                    dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                    dPropertyDefML.inputMode = schemeInfo.inputMode
                                    dPropertyDefML.note = schemeInfo.note
                                    dPropertyDefML.priority = schemeInfo.priority
                                    dPropertyDefML.secondName = schemeInfo.secondName
                                    dPropertyDefML.secondTag = schemeInfo.secondTag
                                    dPropertyDefML.unit = schemeInfo.unit
                                    shaftList.add(dPropertyDefML)
                                }
                            }
                        }

                        dPropertyDef.content = shaftList
                        list.add(dPropertyDef)
                    } else if (dictType == "GeneralSystem") {


                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "系统"
                        dPropertyDef.infoPointCode = "GeneralSystem"
                        /** 专业 */
                        val execGeneralSystemList = DClassDefService.select(SFilter.eq(SLength("id"), 2), SFilter.eq("parentId", "AllProfessionalSystemEquipment")).exec()
                        var listSy = ArrayList<DPropertyDefML>()
                        if (!execGeneralSystemList.isNullOrEmpty() && execGeneralSystemList.size > 0) {
                            for (execGeneralSystem in execGeneralSystemList) {
                                /** 专业 */
                                val dPropertyDef = DPropertyDefML()
                                dPropertyDef.infoPointCode = execGeneralSystem.id
                                dPropertyDef.infoPointName = execGeneralSystem.name

                                val generalSystemList = DClassDefService.select(SFilter.eq("parentId", execGeneralSystem.id!!)).exec()
                                val listsys = ArrayList<DPropertyDefML>()
                                for (generalSystem in generalSystemList){
                                    /** 系统 */
                                    val dPropertyDef = DPropertyDefML()
                                    dPropertyDef.infoPointCode = generalSystem.id
                                    dPropertyDef.infoPointName = generalSystem.name
                                    val general = select(SFilter.eq("type", generalSystem.id!!), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                                    if (projectScheme!=null){
                                        val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", generalSystem.id!!),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                                        if (!schemeInfoList.isNullOrEmpty()){
                                            for (schemeInfo in schemeInfoList){
                                                val dPropertyDefML = DPropertyDefML()
                                                dPropertyDefML.dataSource = schemeInfo.dataSource
                                                dPropertyDefML.dataType = schemeInfo.dataType
                                                dPropertyDefML.firstName = schemeInfo.firstName
                                                dPropertyDefML.firstTag = schemeInfo.firstTag
                                                dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                                dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                                dPropertyDefML.inputMode = schemeInfo.inputMode
                                                dPropertyDefML.note = schemeInfo.note
                                                dPropertyDefML.priority = schemeInfo.priority
                                                dPropertyDefML.secondName = schemeInfo.secondName
                                                dPropertyDefML.secondTag = schemeInfo.secondTag
                                                dPropertyDefML.unit = schemeInfo.unit
                                                general.add(dPropertyDefML)
                                            }
                                        }
                                    }

                                    dPropertyDef.content = general
                                    listsys.add(dPropertyDef)
                                }
                                dPropertyDef.content = listsys
                                listSy.add(dPropertyDef)
                            }
                        }
                        dPropertyDef.content = listSy
                        list.add(dPropertyDef)
                    } else if (dictType == "Tenant") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "租户"
                        dPropertyDef.infoPointCode = "Tenant"
                        val tenantList = select(SFilter.eq("type", "Tenant"), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                        if (projectScheme!=null){
                            val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", "Tenant"),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                            if (!schemeInfoList.isNullOrEmpty()){
                                for (schemeInfo in schemeInfoList){
                                    val dPropertyDefML = DPropertyDefML()
                                    dPropertyDefML.dataSource = schemeInfo.dataSource
                                    dPropertyDefML.dataType = schemeInfo.dataType
                                    dPropertyDefML.firstName = schemeInfo.firstName
                                    dPropertyDefML.firstTag = schemeInfo.firstTag
                                    dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                    dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                    dPropertyDefML.inputMode = schemeInfo.inputMode
                                    dPropertyDefML.note = schemeInfo.note
                                    dPropertyDefML.priority = schemeInfo.priority
                                    dPropertyDefML.secondName = schemeInfo.secondName
                                    dPropertyDefML.secondTag = schemeInfo.secondTag
                                    dPropertyDefML.unit = schemeInfo.unit
                                    tenantList.add(dPropertyDefML)
                                }
                            }
                        }

                        dPropertyDef.content = tenantList
                        list.add(dPropertyDef)
                    }  else if (dictType == "Space") {
                        val dPropertyDef = DPropertyDefML()
                        dPropertyDef.infoPointName = "空间"
                        dPropertyDef.infoPointCode = "Space"
                        var listSpace = ArrayList<DPropertyDefML>()
                        val execSpaceList = DClassDefService.select(SFilter.eq("parentId", "Space"), SFilter.not(SFilter.isNull("parentId")), SFilter.not(SFilter.eq("id", "Ispace"))).exec()
                        if (!execSpaceList.isNullOrEmpty() && execSpaceList.size > 0) {
                            for (execSpace in execSpaceList) {
                                val dPropertyDef = DPropertyDefML()
                                dPropertyDef.infoPointCode = execSpace.id
                                dPropertyDef.infoPointName = execSpace.name
                                val exec = select(SFilter.eq("type", execSpace.id!!), SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()

                                if (projectScheme!=null){
                                    val schemeInfoList = schemeInfoService.select(SFilter.eq("schemeId", projectScheme.schemeId!!), SFilter.eq("type", execSpace.id!!),SFilter.or(SFilter.eq("inputMode", "L"),SFilter.eq("inputMode", "M"))).exec()
                                    if (!schemeInfoList.isNullOrEmpty()){
                                        for (schemeInfo in schemeInfoList){
                                            val dPropertyDefML = DPropertyDefML()
                                            dPropertyDefML.dataSource = schemeInfo.dataSource
                                            dPropertyDefML.dataType = schemeInfo.dataType
                                            dPropertyDefML.firstName = schemeInfo.firstName
                                            dPropertyDefML.firstTag = schemeInfo.firstTag
                                            dPropertyDefML.infoPointCode = schemeInfo.infoPointCode
                                            dPropertyDefML.infoPointName = schemeInfo.infoPointName
                                            dPropertyDefML.inputMode = schemeInfo.inputMode
                                            dPropertyDefML.note = schemeInfo.note
                                            dPropertyDefML.priority = schemeInfo.priority
                                            dPropertyDefML.secondName = schemeInfo.secondName
                                            dPropertyDefML.secondTag = schemeInfo.secondTag
                                            dPropertyDefML.unit = schemeInfo.unit
                                            exec.add(dPropertyDefML)
                                        }
                                    }
                                }

                                dPropertyDef.content = exec
                                listSpace.add(dPropertyDef)
                            }
                            dPropertyDef.content = listSpace
                            list.add(dPropertyDef)
                        }
                    }
                }
            }
            allDictCategory.content = list
            allDictCategory.result = SResponseType.success
            return allDictCategory
        } catch (e: Exception) {
            e.printStackTrace()
            allDictCategory.result = SResponseType.failure
            return allDictCategory
        }

    } // Function pageQueryAllDict()

} // object PropertyDefService