|
@@ -26,14 +26,18 @@
|
|
|
|
|
|
package com.persagy.server.syn.services.jms
|
|
|
|
|
|
+import com.persagy.base.extensions.toJson
|
|
|
import com.persagy.database.SFilter
|
|
|
import com.persagy.mybatis.SMybatisDao
|
|
|
import com.persagy.server.datacenter.models.entities.dictnew.DictProject
|
|
|
import com.persagy.server.datacenter.models.entities.objects.Equipment
|
|
|
import com.persagy.server.datacenter.models.jms.SynchronousMessage
|
|
|
import com.persagy.server.syn.Configure
|
|
|
+import com.persagy.server.syn.models.api.obj.BuildingApi
|
|
|
import com.persagy.server.syn.models.api.obj.EquipApi
|
|
|
import com.persagy.server.syn.models.tools.EquipUtil
|
|
|
+import com.persagy.server.syn.services.dict.DClassDefService
|
|
|
+import com.persagy.server.syn.utils.ParamTools
|
|
|
import com.persagy.service.SBaseService
|
|
|
import com.persagy.service.SObjectService
|
|
|
import org.springframework.stereotype.Service
|
|
@@ -72,10 +76,10 @@ class DataCenterEquipment {
|
|
|
if (equip!=null) {
|
|
|
val equipList = EquipUtil.equipTools(message.projectId!!, equip)
|
|
|
val sign = EquipApi.createObj(dictProject!!.groupCode!!,message.projectId!!, equipList)
|
|
|
- if (sign){
|
|
|
+ upDateMessage(message,equip)
|
|
|
+ if (sign!=null&& sign.result == "success"){
|
|
|
/** 成功 */
|
|
|
message.sign = 0
|
|
|
-
|
|
|
if (!equip.buildingId.isNullOrEmpty()&&!equip.floorId.isNullOrEmpty()){
|
|
|
try {
|
|
|
val toJsonObjArray =
|
|
@@ -88,6 +92,7 @@ class DataCenterEquipment {
|
|
|
val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
|
|
|
if (!createRel){
|
|
|
message.sign = 2
|
|
|
+ message.error = "设备和建筑楼层的关系存储失败"
|
|
|
message.count = message.count+1
|
|
|
}
|
|
|
} catch (e: Exception) {
|
|
@@ -101,22 +106,31 @@ class DataCenterEquipment {
|
|
|
val createRel = EquipApi.createRel(dictProject.groupCode!!, message.projectId!!, toJsonObjArray)
|
|
|
if (!createRel){
|
|
|
message.sign = 2
|
|
|
+ message.error = "设备和建筑的关系存储失败"
|
|
|
message.count = message.count+1
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
/** 失败 */
|
|
|
- message.sign = 2
|
|
|
- message.count = message.count+1
|
|
|
+ if (sign!=null){
|
|
|
+ message.error = sign.toJson()
|
|
|
+ } else {
|
|
|
+ message.error = "服务未连通"
|
|
|
+ }
|
|
|
+ /** 失败 */
|
|
|
+ message.sign = 2
|
|
|
+ message.count = message.count +1
|
|
|
}
|
|
|
}else {
|
|
|
/** 失败 */
|
|
|
message.sign = 2
|
|
|
+ message.error = "设备不存在可能已删除"
|
|
|
message.count = message.count+1
|
|
|
}
|
|
|
} else {
|
|
|
/** 失败 */
|
|
|
message.sign = 2
|
|
|
+ message.error = "集团信息为空"
|
|
|
message.count = message.count+1
|
|
|
}
|
|
|
/** 更改标记 */
|
|
@@ -134,20 +148,32 @@ class DataCenterEquipment {
|
|
|
if (equip != null) {
|
|
|
val equipList = EquipUtil.equipTools(message.projectId!!, equip)
|
|
|
val sign = EquipApi.updateObj(dictProject!!.groupCode!!, message.projectId!!, equipList)
|
|
|
- if (sign) {
|
|
|
+ upDateMessage(message,equip)
|
|
|
+ if (sign!=null&& sign.result == "success"){
|
|
|
/** 成功 */
|
|
|
message.sign = 0
|
|
|
} else {
|
|
|
/** 失败 */
|
|
|
+ if (sign != null) {
|
|
|
+ /** 失败 */
|
|
|
+ message.error = sign.toJson()
|
|
|
+ } else {
|
|
|
+ /** 失败 */
|
|
|
+ message.error = "服务未连通"
|
|
|
+ }
|
|
|
+ message.count +1
|
|
|
message.sign = 2
|
|
|
- message.count = message.count + 1
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- message.sign = 0
|
|
|
+ /** 失败 */
|
|
|
+ message.sign = 2
|
|
|
+ message.error = "设备不存在可能已删除"
|
|
|
+ message.count = message.count+1
|
|
|
}
|
|
|
} else {
|
|
|
message.sign = 2
|
|
|
+ message.error = "集团信息为空"
|
|
|
message.count = message.count + 1
|
|
|
}
|
|
|
/** 更改标记 */
|
|
@@ -155,19 +181,49 @@ class DataCenterEquipment {
|
|
|
}
|
|
|
Configure.DELETE -> {
|
|
|
if (dictProject!=null) {
|
|
|
- /** 删除 */
|
|
|
- val sign = EquipApi.deleteObj(dictProject!!.groupCode!!, message.projectId!!, message.objId!!)
|
|
|
- if (sign) {
|
|
|
- /** 成功 */
|
|
|
- message.sign = 0
|
|
|
+
|
|
|
+ val query = BuildingApi.queryIdTwo(dictProject!!.groupCode!!, message.projectId!!, message.objId!!)
|
|
|
+ if (query!=null&&query.result == "success"&&!query.data.isNullOrEmpty()) {
|
|
|
+
|
|
|
+ val equipment = EquipUtil.equipSyns(
|
|
|
+ message.projectId!!,
|
|
|
+ dictProject.groupCode!!,
|
|
|
+ query.data!![0]
|
|
|
+ )
|
|
|
+ /** 删除 */
|
|
|
+ val sign = EquipApi.deleteObj(dictProject!!.groupCode!!, message.projectId!!, message.objId!!)
|
|
|
+ upDateMessage(message,equipment)
|
|
|
+ if (sign!=null&&sign.result == "success"){
|
|
|
+ /** 成功 */
|
|
|
+ message.sign = 0
|
|
|
+ } else {
|
|
|
+ /** 失败 */
|
|
|
+ if (sign!=null){
|
|
|
+ message.error = sign.toJson()
|
|
|
+ } else {
|
|
|
+ message.error = "服务器未连通"
|
|
|
+ }
|
|
|
+ /** 失败 */
|
|
|
+ message.sign = 2
|
|
|
+ message.count +1
|
|
|
+ }
|
|
|
} else {
|
|
|
- /** 失败 */
|
|
|
- message.sign = 2
|
|
|
- message.count = message.count + 1
|
|
|
+ if (query!=null&&query.result == "success"&&query.data.isNullOrEmpty()) {
|
|
|
+ message.sign = 0
|
|
|
+ }else if (query!=null){
|
|
|
+ message.sign = 2
|
|
|
+ message.error = query.toJson()
|
|
|
+ message.count +1
|
|
|
+ }else {
|
|
|
+ message.sign = 2
|
|
|
+ message.error = "服务未连通"
|
|
|
+ message.count +1
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
/** 失败 */
|
|
|
message.sign = 2
|
|
|
+ message.error = "集团信息为空"
|
|
|
message.count = message.count + 1
|
|
|
}
|
|
|
/** 更改标记 */
|
|
@@ -239,5 +295,21 @@ class DataCenterEquipment {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 更新消息
|
|
|
+ */
|
|
|
+ fun upDateMessage(message: SynchronousMessage,equip: Equipment){
|
|
|
+ message.classCode = equip.classCode
|
|
|
+ message.localId = equip.localId
|
|
|
+ message.localName = equip.localName
|
|
|
+ message.name = equip.localName
|
|
|
+ message.objName = "设备"
|
|
|
+ message.opsName = ParamTools.operationType(message.ops!!)
|
|
|
+ val entity =
|
|
|
+ DClassDefService.select(SFilter.eq("projectId", equip.projectId!!), SFilter.eq("code", equip.classCode!!))
|
|
|
+ .entity()
|
|
|
+ if (entity!=null) {
|
|
|
+ message.classCodeName = entity.name
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|