|
@@ -26,6 +26,7 @@
|
|
|
|
|
|
package com.persagy.server.syn.controllers.obj
|
|
package com.persagy.server.syn.controllers.obj
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
import com.google.gson.reflect.TypeToken
|
|
import com.google.gson.reflect.TypeToken
|
|
import com.persagy.base.extensions.toJson
|
|
import com.persagy.base.extensions.toJson
|
|
@@ -270,7 +271,7 @@ class ObjectFromToControllers {
|
|
var num = page
|
|
var num = page
|
|
if (switch) {
|
|
if (switch) {
|
|
val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", projectId)).entity()
|
|
val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", projectId)).entity()
|
|
- val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page)
|
|
|
|
|
|
+ val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page,"equipment")
|
|
val equipDataList = equipSynApi.data
|
|
val equipDataList = equipSynApi.data
|
|
for (equipData in equipDataList!!){
|
|
for (equipData in equipDataList!!){
|
|
val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
|
|
val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
|
|
@@ -287,6 +288,7 @@ class ObjectFromToControllers {
|
|
/** 查询楼层 */
|
|
/** 查询楼层 */
|
|
val equipInFloorList = EquipApi.equipInFloor(dictProject!!.groupCode!!,projectId, equipSyn.id!!)
|
|
val equipInFloorList = EquipApi.equipInFloor(dictProject!!.groupCode!!,projectId, equipSyn.id!!)
|
|
if (equipInFloorList.size>0){
|
|
if (equipInFloorList.size>0){
|
|
|
|
+
|
|
val hashMap = equipInFloorList[0]
|
|
val hashMap = equipInFloorList[0]
|
|
if (hashMap.containsKey("objTo")){
|
|
if (hashMap.containsKey("objTo")){
|
|
equipSyn.floorId = hashMap["objTo"].toString()
|
|
equipSyn.floorId = hashMap["objTo"].toString()
|
|
@@ -302,6 +304,7 @@ class ObjectFromToControllers {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
BaseDataService.equipmentService.replace(equipSyn)
|
|
BaseDataService.equipmentService.replace(equipSyn)
|
|
|
|
+
|
|
}
|
|
}
|
|
if (equipSynApi.data!!.size>= 1000){
|
|
if (equipSynApi.data!!.size>= 1000){
|
|
num ++
|
|
num ++
|
|
@@ -311,7 +314,7 @@ class ObjectFromToControllers {
|
|
val projectList = BaseDataService.projectService.selectAll().exec()
|
|
val projectList = BaseDataService.projectService.selectAll().exec()
|
|
for (project in projectList){
|
|
for (project in projectList){
|
|
val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", project.id!!)).entity()
|
|
val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", project.id!!)).entity()
|
|
- val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,project.id!!, page)
|
|
|
|
|
|
+ val equipSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,project.id!!, page,"equipment")
|
|
val equipDataList = equipSynApi.data
|
|
val equipDataList = equipSynApi.data
|
|
for (equipData in equipDataList!!){
|
|
for (equipData in equipDataList!!){
|
|
val equipSyn = EquipUtil.equipSyns(project.id!!, dictProject.groupCode!!, equipData)
|
|
val equipSyn = EquipUtil.equipSyns(project.id!!, dictProject.groupCode!!, equipData)
|
|
@@ -445,8 +448,108 @@ class ObjectFromToControllers {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 部件
|
|
|
|
+ */
|
|
|
|
+ @Operation(summary = "部件信息-数据中台存储到数据中心 ", description = "switch true 根据输入的项目 id 同步楼层,false 同步所有项目的 楼层")
|
|
|
|
+ @PostMapping(value = ["/component-syn"])
|
|
|
|
+ fun componentSyn(@RequestParam projectId: String,@RequestParam switch: Boolean = true,@RequestParam isBuildingFloor: Boolean = true,@RequestParam page: Int = 1){
|
|
|
|
+
|
|
|
|
+ var num = page
|
|
|
|
+ if (switch) {
|
|
|
|
+ val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", projectId)).entity()
|
|
|
|
+ val componentSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page,"component")
|
|
|
|
+ val equipDataList = componentSynApi.data
|
|
|
|
+ for (equipData in equipDataList!!){
|
|
|
|
+ val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
|
|
|
|
+ logger.debug("设备=${equipSyn.toJson()}")
|
|
|
|
+ if (isBuildingFloor){
|
|
|
|
+ logger.debug("***************************************************")
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ val jsonObject = JSONObject()
|
|
|
|
+ /** 部件和设备的关系 */
|
|
|
|
+ val jsonObject2 = JSONObject()
|
|
|
|
+ jsonObject2["graphCode"] = "MechSubset"
|
|
|
|
+ jsonObject2["relCode"] = "Eq2Ec"
|
|
|
|
+ jsonObject2["objTo"] = equipSyn.id
|
|
|
|
+ jsonObject["criteria"] = jsonObject2
|
|
|
|
+ logger.debug("3333333333333333333333333333333333333333333333")
|
|
|
|
+ val queryRelationList =
|
|
|
|
+ EquipApi.queryRelation(dictProject.groupCode!!, projectId!!, jsonObject)
|
|
|
|
+ if (queryRelationList.size>0){
|
|
|
|
+ logger.debug("44444444444444444444444444444444444444444444")
|
|
|
|
+ val hashMap = queryRelationList[0]
|
|
|
|
+ if (hashMap.containsKey("objFrom")){
|
|
|
|
+ equipSyn.parentId = hashMap["objFrom"].toString()
|
|
|
|
|
|
|
|
+ val entity = BaseDataService.equipmentService.select(
|
|
|
|
+ SFilter.eq("projectId", projectId),
|
|
|
|
+ SFilter.eq("id", equipSyn.parentId!!)
|
|
|
|
+ ).entity()
|
|
|
|
+ if (entity !=null ) {
|
|
|
|
+ equipSyn.buildingId = entity.buildingId
|
|
|
|
+ equipSyn.floorId = entity.floorId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ logger.debug("222222222222222222222222222222222222222")
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
+ e.printStackTrace()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ logger.debug("//////////////////////////////////////////////////")
|
|
|
|
+ BaseDataService.equipmentService.replace(equipSyn)
|
|
|
|
+ }
|
|
|
|
+ if (componentSynApi.data!!.size>= 1000){
|
|
|
|
+ num ++
|
|
|
|
+ componentSyn(projectId,switch,isBuildingFloor,num)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ val projectList = BaseDataService.projectService.selectAll().exec()
|
|
|
|
+ for (project in projectList){
|
|
|
|
|
|
|
|
+ val dictProject = BaseDataService.dictProjectService.select(SFilter.eq("id", project.id!!)).entity()
|
|
|
|
+ val componentSynApi = EquipApi.equipSynApi(dictProject!!.groupCode!!,projectId, page,"component")
|
|
|
|
+ val equipDataList = componentSynApi.data
|
|
|
|
+ for (equipData in equipDataList!!){
|
|
|
|
+ val equipSyn = EquipUtil.equipSyns(projectId, dictProject!!.groupCode!!, equipData)
|
|
|
|
+ logger.debug("设备=${equipSyn.toJson()}")
|
|
|
|
+ if (isBuildingFloor){
|
|
|
|
+ /** 部件和设备的关系 */
|
|
|
|
+ val jsonObject2 = JSONObject()
|
|
|
|
+ jsonObject2["graphCode"] = "MechSubset"
|
|
|
|
+ jsonObject2["relCode"] = "Eq2Ec"
|
|
|
|
+ jsonObject2["objTo"] = equipSyn.id
|
|
|
|
+ val queryRelationList =
|
|
|
|
+ EquipApi.queryRelation(dictProject.groupCode!!, projectId!!, jsonObject2)
|
|
|
|
+ if (queryRelationList.size>0){
|
|
|
|
+ val hashMap = queryRelationList[0]
|
|
|
|
+ if (hashMap.containsKey("objFrom")){
|
|
|
|
+ equipSyn.parentId = hashMap["objFrom"].toString()
|
|
|
|
+
|
|
|
|
+ val entity = BaseDataService.equipmentService.select(
|
|
|
|
+ SFilter.eq("projectId", projectId),
|
|
|
|
+ SFilter.eq("id", equipSyn.parentId!!)
|
|
|
|
+ ).entity()
|
|
|
|
+ if (entity !=null ) {
|
|
|
|
+ equipSyn.buildingId = entity.buildingId
|
|
|
|
+ equipSyn.floorId = entity.floorId
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BaseDataService.equipmentService.replace(equipSyn)
|
|
|
|
+ }
|
|
|
|
+ if (componentSynApi.data!!.size>= 1000){
|
|
|
|
+ num ++
|
|
|
|
+ componentSyn(projectId,switch,isBuildingFloor,num)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|