Browse Source

优化:优化查询设备类型的代码
fix bug:/icon/query报错

lijie 3 years ago
parent
commit
703fb050cd

+ 5 - 3
meiku/build.gradle

@@ -89,16 +89,18 @@ dependencies {
     compile group: "cn.sagacloud", name: "saga-service-base", version: SYBOTAN_SERVICE_VERSION
     compile group: "cn.sagacloud", name: "saga-service-mybatis", version: SYBOTAN_SERVICE_VERSION
     compile group: "cn.sagacloud", name: "saga-service-mysql", version: SYBOTAN_SERVICE_VERSION
+    compile group: "com.persagy", name: "dmp-digital-starter", version: DIGITAL_START_VERSION
+
+    // compile project(":data-core")
 
     // TestNG 测试框架
     compile group: "org.testng", name: "testng", version: TESTNG_VERSION
     // Log 工具
     compile group: "org.projectlombok", name: "lombok", version: LOMBOK_VERSION
+    // spring cloud 依赖
+    // compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version:  SPRING_CLOUD_CONFIG_VERSION
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    //Gson
-    compile 'com.google.code.gson:gson:2.8.0'
-
 //    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //    // 二维码与条形码
 //    // https://mvnrepository.com/artifact/com.google.zxing/core

+ 110 - 0
meiku/src/main/kotlin/com/persagy/legend/Opts.kt

@@ -0,0 +1,110 @@
+/*
+ * *********************************************************************************************************************
+ *
+ *          !!
+ *        .F88X
+ *        X8888Y
+ *      .}888888N;
+ *        i888888N;        .:!              .I$WI:
+ *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
+ *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
+ *            +888888N;  .8888888Y                                  "&&8Y.}8,
+ *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
+ *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
+ *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
+ *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
+ *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
+ *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
+ *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
+ *      .:R888888I
+ *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *        ~8888'
+ *        .!88~                                                                     All rights reserved.
+ *
+ * *********************************************************************************************************************
+ */
+
+package com.persagy.server
+
+import com.sybotan.service.SPageContext
+
+/**
+ * 配置信息
+ *
+ * @author  PLX
+ */
+object Opts {
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // 测试环境
+    /** 数据平台地址 */
+//    const val dataPlatform = "http://api.sagacloud.cn/data-platform-3"
+    //const val dataPlatform = "http://192.168.20.225:8080/data-platform-3"
+//    //const val saasManage = "http://192.168.30.96:8080/saas-manage3"
+//
+//    /** 短信平台地址 */
+//    const val smsPlatform = "http://192.168.30.96:8080/sms-platform"
+//    /** 短信平台appCode */
+//    const val smsAppCode = "saga-test"
+//    /** 发送验证码地址 */
+//    const val smsSendCode = "${Opts.smsPlatform}/restSmsService/sendCode?appCode=${Opts.smsAppCode}"
+//    /** 检验验证码地址 */
+//    const val smsVerifyCode = "${Opts.smsPlatform}/restSmsService/verifyCode?appCode=${Opts.smsAppCode}"
+//
+//    /** 二维码服务器地址 */
+//    const val qrCodeServer = "http://192.168.30.96:8080/qrcode"
+
+    /** 项目 id */
+    val projectId: String?
+        get() = SPageContext.getHeader("projectId")
+    /** 数据来源 */
+    val coming: String?
+        get() = SPageContext.getHeader("appId")
+    /** 账号信息 */
+    val account: String?
+        get() = SPageContext.getHeader("userId")
+    /** 集团编码 */
+    val groupCode: String?
+        get() = SPageContext.getHeader("groupCode")
+
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+    // 线上环境
+    /** 数据平台地址 */
+    const val dataPlatform = "http://api.sagacloud.cn/data-platform-3"
+    //const val saasManage = "http://localhost:8080/saas-manage3"
+
+    /** 短信平台地址 */
+    const val smsPlatform = "http://api.sagacloud.cn/duoduo-service/scheduler-service/sms"
+//    const val smsPlatform = "api.sagacloud.cn/fm-service/sms-platform"
+//    const val smsPlatform = "http://localhost:8080/sms-platform"
+    /** 短信平台appCode */
+    const val smsAppCode = "saas"
+    /** 发送验证码地址 */
+    const val smsSendCode = "${Opts.smsPlatform}/sendCode"
+//    const val smsSendCode = "${Opts.smsPlatform}/restSmsService/sendCode?appCode=${Opts.smsAppCode}"
+    /** 检验验证码地址 */
+    const val smsVerifyCode = "${Opts.smsPlatform}/verifyCode"
+//    const val smsVerifyCode = "${Opts.smsPlatform}/restSmsService/verifyCode?appCode=${Opts.smsAppCode}"
+
+    /** 二维码服务器地址 */
+    const val qrCodeServer = "http://localhost:8080/qrcode"
+
+    /** 楼层平面图 */
+    const val FLOORMAP = "floorMap"
+    /**楼层标高 */
+    const val FLOORELEVATION = "floorElevation"
+    /** 高度 */
+    const val HEIGHt = "height"
+    /** 安装位置 */
+    const val INSTALLLOCATION = "installLocation"
+    /** 生产厂家名称 */
+    val MANUFACTURER = "manufacturer"
+    /** 设备型号 */
+    val SPECIFICATION = "specification"
+    /** 供应商单位名称 */
+    val SUPPLIER = "supplier"
+    /** 设备照片 */
+    val PIC = "pic"
+    /** 竖井类型 */
+    val SHAFTFUNCTYPE = "shaftFuncType"
+}

+ 30 - 0
meiku/src/main/kotlin/com/persagy/legend/client/DmpDicClient.kt

@@ -0,0 +1,30 @@
+package com.persagy.server.client
+
+import com.alibaba.fastjson.JSONArray
+import com.alibaba.fastjson.JSONObject
+import com.persagy.dmp.basic.config.DigitalFeignConfig
+import com.persagy.legend.constant.DmpUrlConstant
+import com.persagy.legend.models.request.InstanceUrlParam
+import com.persagy.legend.models.response.DmpResult
+import org.springframework.cloud.openfeign.FeignClient
+import org.springframework.cloud.openfeign.SpringQueryMap
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+
+/**
+ * @description:数据中台dmp-rwd 物理世界、数据字典、IOT 接口feign
+ * @author:lgy
+ * @data:2021/8/11 14:56
+ */
+@FeignClient(name = "dmp-rwd", configuration = [DigitalFeignConfig::class], url = "\${persagy.bdtp.rwd.service:}")
+interface DmpDicClient {
+    /**
+     * @description: 查询对象列表
+     * @param: objectUrlParam 对象请求url通用参数
+     * @param: criteria post请求参数
+     * @return: com.persagy.dmp.common.DmpResult
+     */
+    @PostMapping(DmpUrlConstant.DEF_CLASS)
+    fun queryDictObjectType(@SpringQueryMap objectUrlParam: InstanceUrlParam?, @RequestBody criteria: JSONObject?): DmpResult<JSONArray?>?
+
+ }

+ 47 - 0
meiku/src/main/kotlin/com/persagy/legend/constant/AdmMiddlewareUrlConstant.java

@@ -0,0 +1,47 @@
+package com.persagy.legend.constant;
+
+/**
+ * Description
+ *
+ * @author:linhuili
+ * @date:2021/10/25
+ */
+public class AdmMiddlewareUrlConstant {
+
+    /**
+     * 建筑查询
+     */
+    public final static String BUILDING_QUERY = "/object/building/query";
+
+
+    /**
+     * 设备查询
+     */
+    public final static String EQUIP_QUERY = "/object/equip/query";
+
+    /**
+     * 设备更新
+     */
+    public final static String EQUIP_UPDATE = "/object/equip/update";
+
+    /**
+     * 部件更新
+     */
+    public final static String COMPONENT_UPDATE = "/object/component/update";
+
+
+    /**
+     * 资产查询
+     */
+    public final static String PROPERTY_QUERY = "/object/property/query";
+
+    /**
+     * 资产更新
+     */
+    public final static String PROPERTY_UPDATE = "/object/property/update";
+
+    /**
+     * 元空间查询
+     */
+    public final static String ISPACE_QUERY = "/object/ispace/query";
+}

+ 162 - 0
meiku/src/main/kotlin/com/persagy/legend/constant/DmpUrlConstant.java

@@ -0,0 +1,162 @@
+package com.persagy.legend.constant;
+
+
+/**
+ *@description:dmp服务请求url常量
+ *@author:lgy
+ *@data:2021/8/11 15:00
+ */
+public class DmpUrlConstant {
+
+    /**
+     * 创建对象
+     */
+    public final static String OBJECT_CREATE = "/rwd/instance/object/create";
+
+    /**
+     * 更新对象
+     */
+    public final static String OBJECT_UPDATE = "/rwd/instance/object/update";
+
+    /**
+     * 删除对象
+     */
+    public final static String OBJECT_DELETE = "/rwd/instance/object/delete";
+
+    /**
+     * 查询对象
+     */
+    public final static String OBJECT_QUERY = "/rwd/instance/object/query";
+
+    /**
+     * 查询实时数据
+     */
+    public final static String OBJECT_CURRENT_DATA = "/rwd/iot/data/current";
+
+    /**
+     * 查询历史数据/分精度数据
+     */
+    public final static String OBJECT_HISTORY_DATA = "/rwd/iot/data/history";
+
+    /**
+     * 查询图实例
+     */
+    public final static String GRAPH_QUERY = "/rwd/graph/query";
+
+    /**
+     * 创建关系
+     */
+    public final static String RELATION_CREATE = "/rwd/instance/relation/create";
+
+    /**
+     * 删除关系
+     */
+    public final static String RELATION_DELETE = "/rwd/instance/relation/delete";
+
+    /**
+     * 查询关系
+     */
+    public final static String RELATION_QUERY = "/rwd/instance/relation/query";
+
+    /**
+     * 查询关系对象
+     */
+    public final static String RELATION_OBJECT_QUERY = "/rwd/instance/relation/object/query";
+
+
+
+    /**
+     * 查询信息点描述信息
+     */
+    public final static String DEF_FUNCID = "/rwd/def/funcid";
+
+    /**
+     * 创建信息点
+     */
+    public final static String DEF_FUNCID_CREATE = "/rwd/def/funcid/create";
+
+    /**
+     * 批量修改信息点
+     */
+    public final static String DEF_FUNCID_UPDATE_BATCH = "/rwd/def/funcid/updateBatch";
+
+
+    /**
+     * 批量删除信息点
+     */
+    public final static String DEF_FUNCID_DEL_BATCH = "/rwd/def/funcid/deleteBatch";
+
+    /**
+     * 类型查询
+     */
+    public final static String DEF_CLASS = "/rwd/def/class";
+
+    // ==================中台组织结构=========================================================================
+
+    /**
+     * 中台人员组织权限服务--查询用户
+     */
+    public static final String ORG_USER_QUERY = "/org/user/query";
+
+    /**
+     * 集团查询
+     */
+    public static final String ORG_GROUP_QUERY = "/org/group/query";
+
+    /**
+     * 项目查询
+     */
+    public static final String ORG_PROJECT_QUERY = "/org/project/query";
+
+    /**批量查询项目接口URI*/
+    public static final  String OBJECT_BATCH_QUERY_PROJECT_BY_IDS = "/rwd/instance/object/batchQueryProjectByIds";
+
+    // ==================中台知识库=========================================================================
+
+    /**
+     * 字典数据查询
+     */
+    public static final String DIC_DATA_QUERY = "/dic/dt/data/query";
+
+    // ==================中台关系计算入口=========================================================================
+    /**
+     * 关系计算创建
+     */
+    public static final String OBJECT_COMPATIBLE_CREATE = "rwd/instance/object/compatible/createObjRelationsByKeywordAndObjType";
+
+    /**
+     * 关系计算删除
+     */
+    public static final String OBJECT_COMPATIBLE_DELETE = "rwd/instance/object/compatible/deleteObjRelationsByRelId";
+
+
+    /**
+     * 查询
+     */
+    public static final String RELATION_PROJECT_CAL_QUERY = "/rwd/instance/relation/project/cal/query";
+    /**
+     * 字典数据查询
+     */
+    public static final String RELATION_PROJECT_CAL_CREATE = "/rwd/instance/relation/project/cal/create";
+    /**
+     * 更新
+     */
+    public static final String RELATION_PROJECT_CAL_UPDATE = "/rwd/instance/relation/project/cal/update";
+
+    /**
+     * 删除
+     */
+    public static final String RELATION_PROJECT_CAL_DELETE = "/rwd/instance/relation/project/cal/delete";
+
+    /**
+     * 查询采集信息点
+     */
+    public final static String DEF_FUNCID_COLLECT = "/rwd/def/funcid/collect/query";
+
+    /**
+     * 批量设置采集信息点
+     */
+    public final static String DEF_FUNCID_COLLECT_SET = "/rwd/def/funcid/collect/updateBatch";
+
+
+}

+ 1 - 1
meiku/src/main/kotlin/com/persagy/legend/controller/LegendIconController.kt

@@ -68,7 +68,7 @@ class LegendIconController {
     @Operation(summary = "查询图标图例-批量", description = " 级联:类型信息(classInfo) 状态信息(stateList)")
     @PostMapping(value = ["/query"])
     fun queryState(@RequestBody request: SQueryRequest): SQueryResponse<LegendIcon> {
-        return LegendIconService.pageQuery(request)
+        return LegendIconService.pageQuerys(request)
     }
 
     /**

+ 1 - 1
meiku/src/main/kotlin/com/persagy/legend/controller/LegendOutlineController.kt

@@ -68,7 +68,7 @@ class LegendOutlineController {
     @Operation(summary = "查询轮廓图例-批量", description = " 级联:类型信息(classInfo)")
     @PostMapping(value = ["/query"])
     fun query(@RequestBody request: SQueryRequest): SQueryResponse<LegendOutline> {
-        return LegendOutlineService.pageQuery(request)
+        return LegendOutlineService.pageQuerys(request)
     }
 
     /**

+ 2 - 2
meiku/src/main/kotlin/com/persagy/legend/models/entities/LegendIcon.kt

@@ -60,12 +60,12 @@ class LegendIcon: Legend() {
 
     /** 状态信息 */
     @Schema(description = "状态信息")
-    @SCascade(table="legend.state", idColumn="legend_id", childIdColumn="id")
+    @SCascade(table="labsl_meiku.state", idColumn="legend_id", childIdColumn="id")
     var stateList: ArrayList<State>? = null
 
     /** 类型信息 */
     @Schema(description = "类型信息")
-    @SCascade(table="legend.legend_icon", idColumn="id", childIdColumn="class_code")
+    // @SCascade(table="labsl_meiku.legend_icon", idColumn="id", childIdColumn="class_code")
     var classInfo: DefClass? = null
 
 } // Class LegendIcon

+ 2 - 2
meiku/src/main/kotlin/com/persagy/legend/models/entities/LegendOutline.kt

@@ -34,12 +34,12 @@ class LegendOutline: Legend() {
 
     /** 状态信息 */
     @Schema(description = "状态信息")
-    @SCascade(table="legend.state", idColumn="legend_id", childIdColumn="id")
+    @SCascade(table="labsl_meiku.state", idColumn="legend_id", childIdColumn="id")
     var stateList: ArrayList<State>? = null
 
     /** 类型信息 */
     @Schema(description = "类型信息")
-    @SCascade(table="dict.def_class", idColumn="class_code", childIdColumn="code")
+    // @SCascade(table="dict.def_class", idColumn="class_code", childIdColumn="code")
     var classInfo: DefClass? = null
 
 } // Class LegendPipe

+ 2 - 2
meiku/src/main/kotlin/com/persagy/legend/models/entities/LegendPipe.kt

@@ -44,12 +44,12 @@ class LegendPipe: Legend() {
 
     /** 状态信息 */
     @Schema(description = "状态信息")
-    @SCascade(table="legend.state", idColumn="legend_id", childIdColumn="id")
+    @SCascade(table="labsl_meiku.state", idColumn="legend_id", childIdColumn="id")
     var stateList: ArrayList<State>? = null
 
     /** 类型信息 */
     @Schema(description = "类型信息")
-    @SCascade(table="legend.legend_pipe", idColumn="id", childIdColumn="class_code")
+    @SCascade(table="labsl_meiku.legend_pipe", idColumn="id", childIdColumn="class_code")
     var classInfo: PipelineCategory? = null
 
 } // Class LegendPipe

+ 30 - 0
meiku/src/main/kotlin/com/persagy/legend/models/request/InstanceUrlParam.kt

@@ -0,0 +1,30 @@
+package com.persagy.legend.models.request
+
+import com.fasterxml.jackson.annotation.JsonInclude
+import lombok.AllArgsConstructor
+import lombok.Builder
+import lombok.Data
+import lombok.NoArgsConstructor
+
+/**
+ * @description: 对象、关系请求url通用参数
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonInclude(JsonInclude.Include.NON_NULL)
+class InstanceUrlParam {
+        /**
+         * 集团编码
+         */
+        var groupCode: String? = null
+        /**
+         * 项目id
+         */
+        var projectId: String? = null
+
+
+        val serialVersionUID : Long? = -994117732505752231L
+
+}

+ 73 - 0
meiku/src/main/kotlin/com/persagy/legend/models/response/DmpResult.kt

@@ -0,0 +1,73 @@
+package com.persagy.legend.models.response
+
+import lombok.Data
+import lombok.NoArgsConstructor
+import lombok.extern.slf4j.Slf4j
+import java.io.Serializable
+import java.lang.reflect.*
+import java.lang.reflect.Array
+
+/**
+ * @description: 数据中台返回值通用类
+ * @author: lgy
+ * @since: 2021/08/11 15:40
+ * @version: V1.0
+ */
+@Data
+@NoArgsConstructor
+@Slf4j
+class DmpResult<T> : Serializable {
+    val result: String? = null
+    val data: T? = null
+    val count: Int? = null
+    val message: String? = null
+    fun getData(clazz: Class<T>): T? {
+        if (data == null) {
+            var t: T? = null
+            try {
+                t = clazz.newInstance()
+            } catch (e: Exception) {
+                //DmpResult.log.error(e.message, e)
+            }
+            return t
+        }
+        return data
+    }
+
+    fun getData(t: T): T {
+        return data ?: t
+    }
+
+    companion object {
+        /**
+         * 成功
+         */
+        const val SUCCESS = "success"
+
+        /**
+         * 失败
+         */
+        const val FAILURE = "failure"
+        private const val serialVersionUID = 1L
+
+        // type不能直接实例化对象,通过type获取class的类型,然后实例化对象
+        fun getRawType(type: Type?): Class<*> {
+            return if (type is Class<*>) {
+                type
+            } else if (type is ParameterizedType) {
+                val rawType = type.rawType
+                rawType as Class<*>
+            } else if (type is GenericArrayType) {
+                val componentType = type.genericComponentType
+                Array.newInstance(getRawType(componentType), 0).javaClass
+            } else if (type is TypeVariable<*>) {
+                Any::class.java
+            } else if (type is WildcardType) {
+                getRawType(type.upperBounds[0])
+            } else {
+                val className = if (type == null) "null" else type.javaClass.name
+                throw IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <$type> is of type $className")
+            }
+        }
+    }
+}

+ 47 - 0
meiku/src/main/kotlin/com/persagy/legend/services/DmpBaseService.kt

@@ -0,0 +1,47 @@
+package com.persagy.server.services
+
+import cn.hutool.core.collection.CollUtil
+import com.alibaba.fastjson.JSONObject
+import com.persagy.legend.models.entities.DefClass
+import com.persagy.legend.models.request.InstanceUrlParam
+import com.persagy.server.Opts
+import com.persagy.server.client.DmpDicClient
+import com.persagy.server.util.AdmEntityTransferUtil
+import com.sybotan.service.utils.SSpringContextUtil
+import org.springframework.stereotype.Service
+
+/**
+ * 物理世界对象查询
+ * @author:linhuili
+ * @date:2021/10/19
+ */
+@Service
+class DmpBaseService {
+
+    /** 自定义 sql */
+    private val rwdClient by lazy {
+        SSpringContextUtil.getBean(DmpDicClient::class.java) as DmpDicClient
+    }
+
+    /**
+     * 查询字典类型
+     * @param params
+     * @return
+     */
+    fun queryDictType(params: JSONObject?): List<DefClass>? {
+        //封装基础查询参数
+        val instanceUrlParam = InstanceUrlParam()
+        instanceUrlParam.groupCode = Opts.groupCode
+        instanceUrlParam.projectId = Opts.projectId
+        //查询对象信息
+        val dmpResult = rwdClient!!.queryDictObjectType(instanceUrlParam, params) ?: return ArrayList()
+        if(CollUtil.isEmpty(dmpResult.data)){
+            return ArrayList<DefClass>()
+        }
+        return AdmEntityTransferUtil.toAdmMultiEntity(dmpResult.data, null, DefClass::class.java)
+    }
+
+
+
+
+}

+ 58 - 0
meiku/src/main/kotlin/com/persagy/legend/services/LegendIconService.kt

@@ -1,6 +1,9 @@
 package com.persagy.legend.services
 
+import com.alibaba.fastjson.JSONObject
+import com.persagy.legend.models.entities.DefClass
 import com.persagy.legend.models.entities.LegendIcon
+import com.persagy.server.services.DmpBaseService
 import com.sybotan.database.SFilter
 import com.sybotan.mybatis.SMybatisDao
 import com.sybotan.service.SObjectService
@@ -8,12 +11,19 @@ import com.sybotan.service.models.enums.SResponseType
 import com.sybotan.service.models.requests.SQueryRequest
 import com.sybotan.service.models.responses.SCreateResponse
 import com.sybotan.service.models.responses.SQueryResponse
+import org.springframework.beans.factory.annotation.Autowired
 import java.util.*
+import kotlin.collections.HashMap
+import kotlin.collections.HashSet
 
 /**
  * @author  zy
  */
 object LegendIconService : SObjectService<LegendIcon>(SMybatisDao(LegendIcon::class.java)) {
+
+    @Autowired
+    private val dmpBaseService: DmpBaseService? = DmpBaseService()
+
     /**
      * 保存
      *
@@ -93,6 +103,54 @@ object LegendIconService : SObjectService<LegendIcon>(SMybatisDao(LegendIcon::cl
             }
           }
         }
+        queryDefClass(pageQuery)
+        return pageQuery
+    }
+
+    fun queryDefClass(pageQuery: SQueryResponse<LegendIcon>) {
+        if (pageQuery.result != SResponseType.success) {
+            return
+        }
+        if (pageQuery.content.isNullOrEmpty()) {
+            return
+        }
+        var classCodes:HashSet<String> = HashSet<String>()
+        for (content in pageQuery.content!!) {
+            //查询中台类型数据,2021.10.25日中心中台整合调整
+            if (content.classCode.isNullOrBlank()){
+                continue
+            }
+            classCodes.add(content.classCode!!)
+        }
+        var classCodeMap:HashMap<String, DefClass> = HashMap<String, DefClass>()
+        if (!classCodes.isNullOrEmpty()){
+            val param = JSONObject()
+            val criteria = JSONObject()
+            criteria["code"] = classCodes
+            param["criteria"] = criteria
+            val dictTypes =dmpBaseService!!.queryDictType(param)
+            /*   val defClass =
+                   defClassService.select(SFilter.eq("projectId", projectId), SFilter.eq("code", content.classCode!!)).entity()*/
+            if (dictTypes!=null && dictTypes.size>0) {
+                for (dictType in dictTypes){
+                    classCodeMap.put(dictType.code!!,dictType)
+                }
+            }
+        }
+        for (content in pageQuery.content!!) {
+            content.classInfo=classCodeMap.get(content.classCode)
+        }
+    }
+
+    /**
+     * 查询默认状态的图例
+     *
+     * @param  request  查询条件
+     * @return 返回结果
+     */
+    fun pageQuerys(request: SQueryRequest): SQueryResponse<LegendIcon> {
+        val pageQuery = pageQuery(request)
+        queryDefClass(pageQuery)
         return pageQuery
     }
 }

+ 58 - 0
meiku/src/main/kotlin/com/persagy/legend/services/LegendOutlineService.kt

@@ -1,17 +1,27 @@
 package com.persagy.legend.services
 
+import com.alibaba.fastjson.JSONObject
+import com.persagy.legend.models.entities.DefClass
 import com.persagy.legend.models.entities.LegendOutline
+import com.persagy.server.services.DmpBaseService
 import com.sybotan.database.SFilter
 import com.sybotan.mybatis.SMybatisDao
 import com.sybotan.service.SObjectService
 import com.sybotan.service.models.enums.SResponseType
+import com.sybotan.service.models.requests.SQueryRequest
 import com.sybotan.service.models.responses.SCreateResponse
+import com.sybotan.service.models.responses.SQueryResponse
+import org.springframework.beans.factory.annotation.Autowired
 import java.util.*
 
 /**
  * @author  zy
  */
 object LegendOutlineService : SObjectService<LegendOutline>(SMybatisDao(LegendOutline::class.java)) {
+
+    @Autowired
+    private val dmpBaseService: DmpBaseService? = DmpBaseService()
+
     /**
      * 保存
      *
@@ -63,4 +73,52 @@ object LegendOutlineService : SObjectService<LegendOutline>(SMybatisDao(LegendOu
             sCreateResponse
         }
     }
+
+    /**
+     * 查询默认状态的图例
+     *
+     * @param  request  查询条件
+     * @return 返回结果
+     */
+    fun pageQuerys(request: SQueryRequest): SQueryResponse<LegendOutline> {
+        val pageQuery = pageQuery(request)
+        queryDefClass(pageQuery)
+        return pageQuery
+    }
+
+    fun queryDefClass(pageQuery: SQueryResponse<LegendOutline>) {
+        if (pageQuery.result != SResponseType.success) {
+            return
+        }
+        if (pageQuery.content.isNullOrEmpty()) {
+            return
+        }
+        var classCodes:HashSet<String> = HashSet<String>()
+        for (content in pageQuery.content!!) {
+            //查询中台类型数据,2021.10.25日中心中台整合调整
+            if (content.classCode.isNullOrBlank()){
+                continue
+            }
+            classCodes.add(content.classCode!!)
+        }
+        var classCodeMap:HashMap<String, DefClass> = HashMap<String, DefClass>()
+        if (!classCodes.isNullOrEmpty()){
+            val param = JSONObject()
+            val criteria = JSONObject()
+            criteria["code"] = classCodes
+            param["criteria"] = criteria
+            val dictTypes = dmpBaseService!!.queryDictType(param)
+            /*   val defClass =
+                   defClassService.select(SFilter.eq("projectId", projectId), SFilter.eq("code", content.classCode!!)).entity()*/
+            if (dictTypes!=null && dictTypes.size>0) {
+                for (dictType in dictTypes){
+                    classCodeMap.put(dictType.code!!,dictType)
+                }
+            }
+        }
+        for (content in pageQuery.content!!) {
+            content.classInfo=classCodeMap.get(content.classCode)
+        }
+    }
+
 }

+ 141 - 0
meiku/src/main/kotlin/com/persagy/legend/util/AdmEntityTransferUtil.kt

@@ -0,0 +1,141 @@
+package com.persagy.server.util
+
+import com.persagy.dmp.basic.utils.JsonNodeUtils
+import cn.hutool.core.collection.CollUtil
+import cn.hutool.core.util.ArrayUtil
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+
+/**
+ * ADM通用查询条件
+ * @author Charlie Yu
+ * @date 2021-08-16
+ */
+object AdmEntityTransferUtil {
+    /**
+     * 转换为数据中台对象
+     * @param objList
+     * @return
+     */
+    fun toDmpMultiEntity(objList: List<*>?): ArrayNode {
+        return JsonNodeUtils.toArrayNode(objList, "infos", null)
+    }
+
+    /**
+     * 转换为数据中台对象
+     * @param obj
+     * @return
+     */
+    fun toDmpSingleEntity(obj: Any?): JsonNode {
+        return JsonNodeUtils.toObjectNode(obj, "infos", null)
+    }
+
+    /**
+     * 转换为数据中心对象
+     * @param array 数据中台对象
+     * @param clazz 数据中心对象class
+     * @param <T>
+     * @return
+    </T> */
+    fun <T> toAdmMultiEntity(array: List<*>?, projection: List<String?>?, clazz: Class<T>?): List<T>? {
+        if(CollUtil.isEmpty(array)){
+            return null;
+        }
+        val dataNode = JsonNodeUtils.toArrayNode(array, null, null)
+        return toAdmMultiEntity(dataNode, projection, clazz)
+    }
+
+    /**
+     * 转换为数据中心对象
+     * @param clazz
+     * @param <T>
+     * @return
+     * @param array
+    </T> */
+    fun <T> toAdmMultiEntity(array: ArrayNode, projection: List<String?>?, clazz: Class<T>?): List<T>? {
+        if (ArrayUtil.isEmpty(array)) {
+            return null
+        }
+        // 转换属性名
+        var i = 0
+        val j = array.size()
+        while (i < j) {
+            val node = array[i]
+            if (node != null && node.isObject) {
+                resetAdmProperty(node as ObjectNode, projection)
+            }
+            i++
+        }
+        return JsonNodeUtils.toEntity(array, clazz, "infos")
+    }
+
+    /**
+     * 转换为数据中心对象
+     * @param node
+     * @param clazz
+     * @param <T>
+     * @return
+    </T> */
+    fun <T> toAdmSingleEntity(node: ObjectNode, projection: List<String?>?, clazz: Class<T>?): T {
+        resetAdmProperty(node, projection)
+        return JsonNodeUtils.toEntity(node, clazz, "infos")
+    }
+
+    /**
+     * 处理dmp转adm对象的属性名
+     * @param node
+     */
+    private fun resetAdmProperty(node: ObjectNode, projection: List<String?>?) {
+        // 转换属性名 TODO 目前只有创建时间和修改时间需要转换,后续有其他时通过建立映射在此转换即可
+        copyProperty(node, "creationTime", "createTime")
+        copyProperty(node, "modifiedTime", "lastUpdate")
+        copyProperty(node, "objType", "objectType")
+        removeProperty(node, projection)
+    }
+
+    /**
+     * 拷贝属性
+     * @param dmpData 数据中台对象
+     * @param srcProp 数据中台属性名
+     * @param desProp 对应的数据中心属性名
+     */
+    private fun copyProperty(dmpData: ObjectNode?, srcProp: String, desProp: String) {
+        if (dmpData == null) {
+            return
+        }
+        val value = dmpData[srcProp]
+        if (value == null || value.isNull) {
+            return
+        }
+        dmpData.set<JsonNode>(desProp, value)
+        dmpData.remove(srcProp)
+    }
+
+    /**
+     * 删除掉数据中心不需要的属性
+     * @param dmpData
+     */
+    private fun removeProperty(dmpData: ObjectNode, projection: List<String?>?) {
+        if (CollUtil.isNotEmpty(projection)) {
+            // 转换为Set,提供遍历效率
+            val fieldSet: Set<String?> = CollUtil.newHashSet(projection)
+            val fields = dmpData.fieldNames()
+            while (fields.hasNext()) {
+                val field = fields.next()
+                // 返回结果中包含的不处理
+                if (fieldSet.contains(field)) {
+                    continue
+                }
+                // 去掉不包含的属性
+                fields.remove()
+            }
+        } else {
+            // 返回全部时,去掉不需要属性
+            val removeList: List<String> = CollUtil.newArrayList("creator", "valid", "createApp", "virtualCodes", "updateApp", "grouping", "modifier")
+            for (removeField in removeList) {
+                dmpData.remove(removeField)
+            }
+        }
+    }
+}

+ 262 - 0
meiku/src/main/kotlin/com/persagy/legend/util/IdUtils.kt

@@ -0,0 +1,262 @@
+/*
+ * *********************************************************************************************************************
+ *
+ *          !!
+ *        .F88X
+ *        X8888Y
+ *      .}888888N;
+ *        i888888N;        .:!              .I$WI:
+ *          R888888I      .'N88~            i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
+ *          .R888888I    .;N8888~          .X8'  "8I.!,/8"  !%NY8`"8I8~~8>,88I
+ *            +888888N;  .8888888Y                                  "&&8Y.}8,
+ *            ./888888N;  .R888888Y        .'}~    .>}'.`+>  i}!    "i'  +/'  .'i~  !11,.:">,  .~]!  .i}i
+ *              ~888888%:  .I888888l      .]88~`1/iY88Ii+1'.R$8$8]"888888888>  Y8$  W8E  X8E  W8888'188Il}Y88$*
+ *              18888888    E8888881    .]W%8$`R8X'&8%++N8i,8N%N8+l8%`  .}8N:.R$RE%N88N%N$K$R  188,FE$8%~Y88I
+ *            .E888888I  .i8888888'      .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
+ *            8888888I  .,N888888~        ~88i"8W,!N8*.I88.}888%F,i$88"F88"  888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
+ *          i888888N'      I888Y          ]88;/EX*IFKFK88X  K8R  .l8W  88Y  ~88}'88E&%8W.X8N``]88!.$8K  .:W8I
+ *        .i888888N;        I8Y          .&8$  .X88!  i881.:%888>I88  ;88]  +88+.';;;;:.Y88X  18N.,88l  .+88/
+ *      .:R888888I
+ *      .&888888I                                          Copyright (c) 2009-2020.  博锐尚格科技股份有限公司
+ *        ~8888'
+ *        .!88~                                                                     All rights reserved.
+ *
+ * *********************************************************************************************************************
+ */
+
+package com.persagy.server.util
+
+import java.text.SimpleDateFormat
+import java.util.*
+
+
+/**
+ * id生成帮助类
+ *
+ * @author 张维新
+ */
+object IdUtils {
+
+    /**
+     * 生成项目id
+     *
+     * @param   code    城市六位编码
+     * @param   num     城市存在建筑的数量
+     * @return          返回项目id
+     */
+    fun projectIdCreate(code: String, num: Int): String {
+        try {
+            if (num + 1 > 9999) {
+                throw  SecurityException("建筑数量已超出最大值")
+            }
+            val nums = num + 1
+            val genId = String.format("%1$4s", nums).replace(' ', '0')
+            val sb = StringBuilder()
+            val appendId = sb.append("Pj").append(code).append(genId)
+
+            return appendId.toString()
+        } catch (e: Throwable) {
+            e.printStackTrace()
+        }
+        throw  SecurityException("id生成失败")
+    } // Function ProjectId
+
+    /**
+     * 生成建筑Id
+     *
+     * @param   projectId   项目id
+     * @return              建筑id
+     */
+    fun buildIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Bd")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val buildId = sb.append(bdid).append(uuId)
+        return buildId.toString()
+    } // Function buildIdCreate
+
+    /**
+     * 生成楼层Id
+     *
+     * @param   projectId   项目id
+     * @return              楼层id
+     */
+    fun floorIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Fl")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val floorId = sb.append(bdid).append(uuId)
+        return floorId.toString()
+    } // Function floorIdCreate
+
+    /**
+     * 生成空间Id
+     *
+     * @param   projectId   项目id
+     * @return              空间id
+     */
+    fun spaceIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Sp")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val spaceId = sb.append(bdid).append(uuId)
+        return spaceId.toString()
+    } // Function spaceIdCreate
+
+    /**
+     * 生成元空间Id
+     *
+     * @param   projectId   项目id
+     * @return              元空间id
+     */
+    fun iSpaceIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Si")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val siId = sb.append(bdid).append(uuId)
+        return siId.toString()
+    } // Function iSpaceIdCreate
+
+    /**
+     * 生成系统Id
+     *
+     * @param   projectId   项目id
+     * @return              系统id
+     */
+    fun systemIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Sy")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val systemId = sb.append(bdid).append(uuId)
+        return systemId.toString()
+    } // Function systemIdCreate
+
+    /**
+     * 生成设备Id
+     *
+     * @param   projectId   项目id
+     * @return              设备id
+     */
+    fun equipmentIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Eq")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val eqId = sb.append(bdid).append(uuId)
+        return eqId.toString()
+    } // Function equipmentIdCreate
+
+    /**
+     * 生成设备部件Id
+     *
+     * @param   projectId   项目id
+     * @return              设备部件id
+     */
+    fun equipmentComponentIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Ec")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val ecId = sb.append(bdid).append(uuId)
+        return ecId.toString()
+    } // Function equipmentComponentIdCreate
+
+    /**
+     * 生成设施Id
+     *
+     * @param   projectId   项目id
+     * @return              设施id
+     */
+    fun structureIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "St")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val stId = sb.append(bdid).append(uuId)
+        return stId.toString()
+    } // Function structureIdCreate
+
+    /**
+     * 生成设施部件Id
+     *
+     * @param   projectId   项目id
+     * @return              设施部件id
+     */
+    fun structureComponentIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Sc")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val scId = sb.append(bdid).append(uuId)
+        return scId.toString()
+    } // Function structureComponentIdCreate
+
+    /**
+     * 生成资产编码Id
+     *
+     * @param   projectId   项目id
+     * @return              设备资产编码id
+     */
+    fun peIdCreate(projectId: String): String {
+        val bdid = "Pe"
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val peId = sb.append(bdid).append(uuId)
+        return peId.toString()
+    } // Function peIdCreate
+
+    /**
+     * 生成竖井Id
+     *
+     * @param   projectId   项目id
+     * @return              竖井id
+     */
+    fun shaftIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "Sh")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val shId = sb.append(bdid).append(uuId)
+        return shId.toString()
+    } // Function shaftIdCreate
+
+    /**
+     * 生成租户Id
+     *
+     * @param   projectId   项目id
+     * @return              租户id
+     */
+    fun tenantIdCreate(projectId: String): String {
+        val bdid = projectId.replace("Pj", "VOTn")
+        val sb = StringBuilder()
+        val uuid = UUID.randomUUID().toString()
+        val uuId = uuid.replace("-", "")
+        val shId = sb.append(bdid).append(uuId)
+        return shId.toString()
+    } // Function shaftIdCreate
+
+    /**
+     * 生成uuid
+     *
+     * @return              uuid
+     */
+    fun uuidCreate(): String {
+        val uuid = UUID.randomUUID().toString()
+        return uuid.replace("-", "")
+    } // Function uuidCreate
+
+
+    fun time():String {
+        val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") //设置日期格式
+        println(df.format(Date())) // new Date()为获取当前系统时间
+        return df.format(Date())
+    }
+
+
+} // Object IdUtils

+ 3 - 0
meiku/src/main/resources/application.yml

@@ -16,6 +16,9 @@ spring:
   jmx:
     default-domain:                     meiku
 
+  main:
+    allow-bean-definition-overriding: true
+
   datasource:
     name: labsl
     type: com.alibaba.druid.pool.DruidDataSource