Browse Source

****************************************提交分类************************************

weixinVSjinlai 4 years ago
parent
commit
39e56be571

+ 51 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/dict/DictInfosWanDa.kt

@@ -0,0 +1,51 @@
+package com.persagy.server.datacenter.wanda.dict
+
+import io.swagger.v3.oas.annotations.media.Schema
+import javax.persistence.Column
+import javax.persistence.Id
+import javax.persistence.Table
+
+/**
+ * 万达对照表
+ *
+ * @author wx
+ */
+@Schema(description = "字典万达对照表")
+@Table(name = "dict.dict_info_wanda")
+class DictInfosWanDa {
+
+    /** id */
+    @Schema(description = "id")
+    @Column(name = "id")
+    var id: String? = null
+    /** 集团编码 */
+    @Schema(description = "集团编码")
+    @Id
+    @Column(name = "group_code")
+    var groupCode: String? = null
+    /** 项目 id */
+    @Schema(description = "项目id")
+    @Id
+    @Column(name = "project_id")
+    var projectId: String? = null
+    /** 类型 */
+    @Schema(description = "类型")
+    @Id
+    @Column(name = "class_code")
+    var classCode: String? = null
+    /** 信息点编码 */
+    @Schema(description = "信息点编码")
+    @Id
+    @Column(name = "code")
+    var code: String? = null
+    /** 信息点名称 */
+    @Schema(description = "信息点名称")
+    @Column(name = "name")
+    var name: String? = null
+    /** 阶段 */
+    @Schema(description = "阶段")
+    @Id
+    @Column(name = "stage")
+    var stage: String? = null
+
+}

+ 31 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/dict/DictStage.kt

@@ -0,0 +1,31 @@
+package com.persagy.server.datacenter.wanda.dict
+
+import com.persagy.server.datacenter.models.entities.dictnew.DefFuncId
+import io.swagger.v3.oas.annotations.media.Schema
+import javax.persistence.Column
+import javax.persistence.Id
+import javax.persistence.Table
+
+/**
+ * 阶段
+ *
+ * @author wx
+ */
+@Schema(description = "字典万达阶段")
+@Table(name = "dict.dict_stage")
+class DictStage {
+
+    @Schema(description = "信息点编码")
+    @Id
+    @Column(name = "code")
+    var code: String? = null
+
+    /** 信息点名称 */
+    @Schema(description = "信息点名称")
+    @Column(name = "name")
+    var name: String? = null
+
+    @Schema(description = "信息点")
+    var infos: ArrayList<DefFuncId>? = null
+
+}

+ 22 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/response/DictInfoResponse.kt

@@ -0,0 +1,22 @@
+package com.persagy.server.datacenter.wanda.response
+
+import com.persagy.server.datacenter.models.entities.dictnew.DefFuncId
+import com.persagy.server.datacenter.wanda.dict.DictStage
+import io.swagger.v3.oas.annotations.media.Schema
+
+/**
+ * 设备字典应答类
+ *
+ * @author wx
+ */
+@Schema(description = "设备字典应答类")
+class DictInfoResponse {
+
+    /** 基础信息点 */
+    @Schema(description = "基础信息点")
+    var basicInfos: ArrayList<DefFuncId>? = null
+    /** 阶段 */
+    var dictStages: ArrayList<DictStage>? = null
+
+
+}

+ 4 - 0
data-core/src/main/kotlin/com/persagy/server/datacenter/wanda/test.java

@@ -0,0 +1,4 @@
+package com.persagy.server.datacenter.wanda;
+
+public class test {
+}

+ 4 - 1
equip-component/src/main/kotlin/com/persagy/server/Opt.kt

@@ -35,10 +35,13 @@ import com.persagy.service.SPageContext
  */
 object Opt {
 
-
     /** 项目 id */
     val projectId: String?
         get() = SPageContext.getHeader("projectId")
+    /** 集团编码 */
+    val groupCode: String?
+        get() = SPageContext.getHeader("groupCode")
+
     /** 数据来源 */
     val coming: String?
         get() = SPageContext.getHeader("coming")

+ 0 - 25
equip-component/src/main/kotlin/com/persagy/server/ShiroConfig.kt

@@ -1,25 +0,0 @@
-/*
- * *********************************************************************************************************************
- *
- *          !!
- *        .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.
- *
- * *********************************************************************************************************************
- */

+ 2 - 0
equip-component/src/main/kotlin/com/persagy/server/Swagger3Config.kt

@@ -123,6 +123,7 @@ open class Swagger3Config {
      * @author  庞利祥 <sybotan@126.com>
      */
     class GlobalHeaderOperationCustomizer : OperationCustomizer {
+
         /**
          * 接口定义器
          *
@@ -133,6 +134,7 @@ open class Swagger3Config {
         override fun customize(operation: Operation, handlerMethod: HandlerMethod): Operation {
             val projectId = Parameter().`in`(ParameterIn.HEADER.toString())
                 .name("projectId").description("项目 id")
+                    .name("groupCode").description("集团编码")
                 .schema(StringSchema()).required(false)
             operation.addParametersItem(projectId)
             return operation

+ 14 - 85
equip-component/src/main/kotlin/com/persagy/server/controllers/dict/DictCustomController.kt

@@ -26,23 +26,12 @@
 
 package com.persagy.server.controllers.dict
 
-
-import com.persagy.database.SFilter
-import com.persagy.mybatis.SMybatisDao
-import com.persagy.server.Opt
-import com.persagy.server.datacenter.models.entities.dictnew.DefFuncId
-import com.persagy.server.datacenter.models.jms.SynchronousMessage
-import com.persagy.server.service.dict.DictDefClassService
-import com.persagy.service.SObjectService
-import com.persagy.service.models.requests.SCountRequest
-import com.persagy.service.models.responses.SCountResponse
+import com.persagy.server.datacenter.models.entities.dictnew.DefClass
+import com.persagy.server.service.dict.DefFuncIdService
 import com.persagy.service.models.responses.SQueryResponse
 import io.swagger.v3.oas.annotations.Operation
 import io.swagger.v3.oas.annotations.tags.Tag
-import org.springframework.web.bind.annotation.PostMapping
-import org.springframework.web.bind.annotation.RequestBody
-import org.springframework.web.bind.annotation.RequestMapping
-import org.springframework.web.bind.annotation.RestController
+import org.springframework.web.bind.annotation.*
 
 /**
  * 项目化字典
@@ -54,81 +43,21 @@ import org.springframework.web.bind.annotation.RestController
 @RequestMapping("/dict")
 class DictCustomController {
 
-    /** 缓存对象数据服务 - 数据中心到数据中台  */
-    var synchronousMessageObjService = SObjectService(SMybatisDao(SynchronousMessage::class.java))
-    /**
-     * 项目化字典类型
-     */
-//   @Operation(summary = "项目化字典 - 统计数量", description = "")
-//    @PostMapping(value = ["/project-dict-count"])
-//    fun  projectDictCount(@RequestBody request: SCountRequest): SCountResponse {
-//        return DictDatacenterProjectcustomService.counts(request)
-//    } // Function  projectDictCount
-
-    /**
-     * 需补充转换规则数量
-     */
-//   @Operation(summary = "项目化字典 - 需补充转换规则数量", description = "")
-//    @PostMapping(value = ["/project-dict-switch-count"])
-//    fun  projectDictSwitchRuleCount(): SCountResponse{
-//        return DictDatacenterProjectcustomService.projectDictSwitchRuleCounts()
-//    } // Function  projectDictSwitchRuleCount
-
-
-    /**
-     * 项目化字典类型
-     */
-//   @Operation(summary = "项目化字典 - 内容", description = "")
-//    @PostMapping(value = ["/project-dict-info"])
-//    fun  projectDictInfo(@RequestBody request: SQueryRequest): SQueryResponse<DictDatacenterProjectcustom> {
-//        return DictDatacenterProjectcustomService.queryDict(request)
-//    } // Function  projectDictCount()
-
     /**
-     * 数据中心-物理世界数据转换
+     * 设备类型
      */
-//   @Operation(summary = "数据中心-物理世界数据转换 ", description = "")
-//    @PostMapping(value = ["/project-dict-datacenter"])
-//    fun dataCenterDataPlatform(): SQueryResponse<EquipDictStatistics>{
-//       return DictDatacenterProjectcustomService.equipStatisticsDataCenter()
-//    } // Function dataCenterDataPlatform ()
-
-    /**
-     * 物理世界 - 数据中心数据转换
-     */
-//   @Operation(summary = "物理世界-数据中心数据转换 ", description = "")
-//    @PostMapping(value = ["/project-dict-dataplatfrom"])
-//    fun dataPlatformdataCenter(): SQueryResponse<EquipDictStatistics>{
-//        return DictDatacenterProjectcustomService.equipStatisticsDataPlatfrom()
-//    } // Function dataCenterDataPlatform ()
-
-
-//   @Operation(summary = "更新自定义自定脚本", description = "")
-//    @PostMapping(value = ["/update"])
-//    fun update(@RequestBody request: ArrayList<DictDatacenterProjectcustom>): SBaseResponse {
-//
-//        return DictDatacenterProjectcustomService.updateDictSwitchRule(request)
-//    } // Function upDate
-
-    /**
-     * 查询 M 和 L 类型的信息点
-     */
-    @Operation(summary = "字典-查询所有字典信息 M 和 L 类型,包括自定义信息点", description = "project (项目),building (建筑),floor (楼层),equipment (设备),system(系统),component (部件),space (空间)")
-    @PostMapping(value = ["/morl/query"])
-    fun queryMOrL(@RequestBody dictTypeList: ArrayList<String>): SQueryResponse<DefFuncId> {
-        return DictDefClassService.queryMOrL(dictTypeList)
+    @Operation(summary = "所有设备类型", description = "")
+    @GetMapping(value = ["/equip/type"])
+    fun dictTypeEquipQuery(): SQueryResponse<DefClass>{
+        return DefFuncIdService.dictTypeEquipQuery()
     }
 
     /**
-     * 获取不能同步到物理世界对象的数量
+     * 类型下信息点
      */
-    @Operation(summary = "获取不能同步到物理世界对象的数量", description = "")
-    @PostMapping(value = ["/data-count"])
-    fun objectCounts(@RequestBody request: SCountRequest): SCountResponse {
-        val messageList =
-            synchronousMessageObjService.select(SFilter.eq("projectId", Opt.projectId!!),SFilter.not(SFilter.eq("sign", 2))).order("createTime").exec()
-        return SCountResponse(messageList.size.toLong())
-    }  // Function objectCounts()
+    @Operation(summary = "类型下信息点", description = "")
+    @GetMapping(value = ["/equip/info"])
+    fun dictEquipInfoQuer(@RequestParam category: String){
 
-
-} //
+    }
+}

+ 96 - 112
equip-component/src/main/kotlin/com/persagy/server/service/dict/DictDefClassService.kt

@@ -31,6 +31,9 @@ import com.persagy.mybatis.SMybatisDao
 import com.persagy.server.Opt
 import com.persagy.server.datacenter.models.entities.dictnew.DefClass
 import com.persagy.server.datacenter.models.entities.dictnew.DefFuncId
+import com.persagy.server.datacenter.wanda.dict.DictInfosWanDa
+import com.persagy.server.datacenter.wanda.dict.DictStage
+import com.persagy.server.datacenter.wanda.response.DictInfoResponse
 import com.persagy.service.SObjectService
 import com.persagy.service.models.enums.SResponseType
 import com.persagy.service.models.responses.SQueryResponse
@@ -41,137 +44,118 @@ import com.persagy.service.models.responses.SQueryResponse
  * @author wx  <zhangweixin@sagacloud.com>
  * @date  2020/11/17 17:28
  */
-object DictDefClassService: SObjectService<DefFuncId>(SMybatisDao(DefFuncId::class.java)) {
+object DefFuncIdService: SObjectService<DefFuncId>(SMybatisDao(DefFuncId::class.java)) {
 
     /** 平台集团对象类型 */
     private val defClassService = SObjectService(SMybatisDao(DefClass::class.java))
+    /** 对照表 */
+    private val dictInfosWanDaService = SObjectService(SMybatisDao(DictInfosWanDa::class.java))
+    /** 阶段 */
+    private val dictStageService = SObjectService(SMybatisDao(DictStage::class.java))
+
     /**
-     * 查询 M 和 L 类型的信息点
+     * 查询设备类型
      */
-    fun queryMOrL(dictTypeList: ArrayList<String>): SQueryResponse<DefFuncId> {
-        /** 返回对象 */
-        val sQueryResponse = SQueryResponse<DefFuncId>(SResponseType.success)
-        /** 对象列表 */
-        var list = ArrayList<DefFuncId>()
-        /** 入参不为空 */
-        if (!dictTypeList.isNullOrEmpty()){
-            /** 遍历入参列表 */
-            for (dictType in dictTypeList){
-                /** 类型筛选 */
-                when(dictType){
-                    "project" -> {
-                        /** 项目 */
-                        list.add(typeStatisticsOne("project","项目"))
-                    }
-                    "building" -> {
-                        /** 建筑 */
-                        list.add(typeStatisticsOne("building","建筑"))
-                    }
-                    "floor" -> {
-                        /** 楼层 */
-                        list.add(typeStatisticsOne("floor","楼层"))
-                    }
-                    "equipment" -> {
-                        /** 设备 */
-                        list.add(typeStatisticsTwo("equipment","设备"))
-                    }
-                    "component" -> {
-                        /** 部件 */
-                        list.add(typeStatisticsTwo("component","部件"))
-                    }
-                    "system" -> {
-                        /** 系统 */
-                        list.add(typeStatisticsTwo("system","系统"))
-                    }
-                    "space" -> {
-                        /** 空间 */
-                        list.add(typeStatisticsTwo("space","空间"))
-                    }
+    fun dictTypeEquipQuery(): SQueryResponse<DefClass>{
+        return try {
+            val sQueryResponse = SQueryResponse<DefClass>(SResponseType.success)
+            val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")).exec()
+            val dictInfosWanDaProjectList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", Opt.projectId!!)).exec()
+            val setCode = HashSet<String>()
+            for (dictInfosWanDaGroup in dictInfosWanDaGroupList){
+                setCode.add(dictInfosWanDaGroup.classCode!!)
+            }
+            if (dictInfosWanDaProjectList.size>0){
+                for (dictInfosWanDaProject in dictInfosWanDaProjectList){
+                    setCode.add(dictInfosWanDaProject.classCode!!)
                 }
             }
-
-            /** 列表赋值 */
-            sQueryResponse.content = list
-        }else {
-            /** 返回状态 */
-            sQueryResponse.result = SResponseType.failure
+            var defClassList = defClassService.select(SFilter.eq("projectId", Opt.projectId!!), SFilter.inList("code", setCode.toList())).order("code").exec()
+            if (defClassList.size == 0){
+                defClassList = defClassService.select(SFilter.eq("type","group"), SFilter.inList("code", setCode.toList())).order("code").exec()
+                if (defClassList.size == 0){
+                    defClassList = defClassService.select(SFilter.eq("type", "common"), SFilter.inList("code", setCode.toList())).order("code").exec()
+                }
+            }
+            sQueryResponse.content = defClassList
+            sQueryResponse.total = defClassList.size.toLong()
+            sQueryResponse
+        } catch (e: Exception) {
+            e.printStackTrace()
+            SQueryResponse(SResponseType.failure)
         }
 
-        /** 返回对象 */
-        return sQueryResponse
     }
 
     /**
-     * 项目、建筑、楼层 M 或 L 信息点统计
+     * 类型下信息点查询
      *
-     * @param code  编码
-     * @param name  名称
-     * @return 信息点对象
+     * @param category    分类
      */
-    private fun typeStatisticsOne(code: String,name:String): DefFuncId {
-        /** 实例化对象 */
-        val defFuncId = DefFuncId()
-        /** 查询 M 或 L 信息点 */
-        val infosList = select(
-            SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("classCode", code),
-           SFilter.not(SFilter.eq("category","STATIC"))
-        ).exec()
-        /** 编码赋值 */
-        defFuncId.code = code
-        /** 名称赋值 */
-        defFuncId.name = name
-        /** 列表赋值 */
-        defFuncId.content = infosList
-        /** 返回对象 */
-        return defFuncId
-    }
+    fun dictEquipInfoQuery(category: String): DictInfoResponse {
+        val dictInfoResponse = DictInfoResponse()
+        val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")
+                ,SFilter.eq("classCode", category)).exec()
+        val dictInfosWanDaProjectList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", Opt.projectId!!)
+                ,SFilter.eq("classCode", category)).exec()
+        var defFuncIdList = DefFuncIdService.select(SFilter.eq("projectId", Opt.projectId!!),
+                SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
+        if (defFuncIdList.size == 0 ) {
+            defFuncIdList = DefFuncIdService.select(SFilter.eq("type","group"),
+                    SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
+            if (defFuncIdList.size == 0) {
+                defFuncIdList = DefFuncIdService.select(SFilter.eq("type","common"),
+                        SFilter.inList("code", arrayListOf("bimTypeId","name","localName","localId"))).exec()
+            }
+        }
+        for (defFuncId in defFuncIdList) {
+            if (defFuncId.code == "name"){
+                defFuncId.code = "systemCategory"
+                defFuncId.name = "系统分类"
+                defFuncId.aliasCode = "systemCategory"
+                defFuncId.aliasName = "系统分类"
+            } else if (defFuncId.code == "localName"){
+                defFuncId.code = "codeName"
+                defFuncId.name = "设备类型名称"
+                defFuncId.aliasCode = "codeName"
+                defFuncId.aliasName = "设备类型名称"
+            }
+        }
 
-    /**
-     * 设备、部件、系统、空间 M 或 L 信息点统计
-     *
-     * @param code  编码
-     * @param name  名称
-     * @return 信息点对象
-     */
-    private fun typeStatisticsTwo(code: String,name:String): DefFuncId {
-        /** 返回对象 */
-        val defFuncId = DefFuncId()
-        /** 名称 */
-        defFuncId.name = name
-        /** 编码 */
-        defFuncId.code = code
-        /** 对象列表 */
-        var equipList = ArrayList<DefFuncId>()
-        /** 查询  */
-        val typeList = defClassService.select(
-            SFilter.eq("parentCode", code),
-            SFilter.eq("projectId", Opt.projectId!!)
-        ).exec()
-        /** 遍历列表 */
-        for (type in typeList){
-            /** 实例化对象 */
-            val defFuncId = DefFuncId()
-            /** 名称 */
-            defFuncId.name = type.name
-            /** 编码 */
-            defFuncId.code = type.code
-            /** 查询 */
-            val equipInfosList = select(
-                SFilter.eq("projectId", Opt.projectId!!), SFilter.eq("classCode", type.code!!),
-                SFilter.not(SFilter.eq("category","STATIC"))
-            ).exec()
-            /** 列表赋值 */
-            defFuncId.content = equipInfosList
-            /** 添加到列表 */
-            equipList.add(defFuncId)
+        val dictStageList = dictStageService.selectAll().exec()
+        for (dictStage in dictStageList) {
+            val dictInfosWanDaGroupList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", "0")
+                    ,SFilter.eq("classCode", category),SFilter.eq("stage", dictStage.code!!)).exec()
+            val dictInfosWanDaProjectList = dictInfosWanDaService.select(SFilter.eq("groupCode", Opt.groupCode!!), SFilter.eq("projectId", Opt.projectId!!)
+                    ,SFilter.eq("classCode", category),SFilter.eq("stage", dictStage.code!!)).exec()
+            if (dictInfosWanDaProjectList.size>0){
+                dictInfosWanDaGroupList.addAll(dictInfosWanDaProjectList)
+            }
+            var setCode = HashSet<String>()
+            for (dictInfosWanDaGroup in dictInfosWanDaGroupList){
+                setCode.add(dictInfosWanDaGroup.code!!)
+            }
+            var funcIdList = DefFuncIdService.select(SFilter.eq("projectId", Opt.projectId!!),
+                    SFilter.inList("code", setCode.toList())).order("code").exec()
+            if (funcIdList.size == 0 ) {
+                funcIdList = DefFuncIdService.select(SFilter.eq("type","group"),
+                        SFilter.inList("code", setCode.toList())).order("code").exec()
+                if (funcIdList.size == 0) {
+                    funcIdList = DefFuncIdService.select(SFilter.eq("type","common"),
+                            SFilter.inList("code",  setCode.toList())).order("code").exec()
+                }
+            }
+            dictStage.infos = funcIdList
         }
 
-        /** 列表赋值 */
-        defFuncId.content = equipList
-        /** 返回对象 */
-        return defFuncId
+        dictInfoResponse.basicInfos = defFuncIdList
+        dictInfoResponse.dictStages = dictStageList
+        return dictInfoResponse
+
     }
 
 
 
+
+
 }