123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750 |
- /*
- * *********************************************************************************************************************
- *
- * !!
- * .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.service
- import com.persagy.base.extensions.rootCause
- import com.persagy.base.extensions.toJson
- import com.persagy.database.SFilter
- import com.persagy.database.SQueryBuilder
- import com.persagy.mybatis.SMybatisDao
- import com.persagy.server.datacenter.models.entities.dict.EquipCategory
- import com.persagy.server.datacenter.models.entities.dict.EquipFamily
- import com.persagy.server.datacenter.models.entities.dict.Family
- import com.persagy.server.datacenter.models.entities.dictnew.DefClass
- import com.persagy.server.datacenter.models.entities.graphtype.RelationTypeProject
- import com.persagy.server.datacenter.models.entities.objects.*
- import com.persagy.server.datacenter.models.entities.rel.REq2Sp
- import com.persagy.server.models.planar.PlanarEquip
- import com.persagy.server.models.requests.PlanarEquipRequests
- import com.persagy.server.service.base.Service
- import com.persagy.server.service.labsl.CustomSqlLabslService
- import com.persagy.server.service.objects.PropertyService
- import com.persagy.server.utils.IdUtils
- import com.persagy.server.utils.MatchingProperty
- 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.requests.SUpdateRequest
- import com.persagy.service.models.responses.SBaseResponse
- import com.persagy.service.models.responses.SQueryResponse
- import com.persagy.service.utils.SSpringContextUtil
- import org.slf4j.LoggerFactory
- import java.util.*
- import kotlin.collections.ArrayList
- /**
- * 设备和部件信息服务
- *
- * @author 张维新
- */
- object EquipmentComService : Service<Equipment>(SMybatisDao(Equipment::class.java)) {
- /** 日志 */
- private val logger = LoggerFactory.getLogger(EquipmentComService::class.java)
- /** MQ消息对象 */
- val customSqlLabslService by lazy {
- SSpringContextUtil.getBean(CustomSqlLabslService::class.java) as CustomSqlLabslService
- }
- /** 建筑服务 */
- val buildingService = SObjectService(SMybatisDao(Building::class.java))
- /** 楼层服务 */
- val floorService = SObjectService(SMybatisDao(Floor::class.java))
- /** 关系总览服务 */
- val relationTypeProjectservice = SBaseService(SMybatisDao(RelationTypeProject::class.java))
- /** 字典对象类型 */
- private val defClassService = SBaseService(SMybatisDao(DefClass::class.java))
- /** 平面图访问设备服务 */
- private val planarEquipService = SObjectService(SMybatisDao(PlanarEquip::class.java))
- /** 空间服务 */
- val spaceService = SObjectService(SMybatisDao(ZoneSpace::class.java))
- /**
- * 查询之前操作
- */
- override fun onQueryBefore(queryBuilder: SQueryBuilder<Equipment>) {
- queryBuilder.tableName = "v_equip_property_component"
- return
- }
- /**
- * 批量处理设备关联资产、 查询接口
- *
- * @param category 设备或部件类型
- * @param request 条件
- * @param spaceIdList 空间id列表
- * @param spacrType 空间类型
- * */
- fun equipProperty(category:String, request: SQueryRequest, spaceIdList: ArrayList<String>?, spacrType: String?):SQueryResponse<Equipment> {
- return try {
- /** 设备类型或设备族类型 */
- val rEq2SpService = SBaseService(SMybatisDao(REq2Sp::class.java))
- val equipFamilyService = SBaseService(SMybatisDao(EquipFamily::class.java))
- val projectId = SPageContext.getHeader("projectId")
- if (spaceIdList!=null&&spaceIdList.size>0){
- logger.debug("空间*************** ")
- /** 获取到空间关联的设备 */
- val rEqInSpBaseList = rEq2SpService.select(SFilter.inList("id2", spaceIdList), SFilter.eq("type","eq2sp_in")).exec()
- if ( !rEqInSpBaseList.isEmpty()){
- val setId = HashSet<String>()
- for (rEqInSpBase in rEqInSpBaseList){
- setId.add(rEqInSpBase.id1!!)
- }
- val sQueryResponse = SQueryResponse<Equipment>()
- val equipList = select(SFilter.inList("id", setId.toList())).exec()
- sQueryResponse.total = equipList.size.toLong()
- val iterator = equipList.iterator()
- while (iterator.hasNext()) {
- var equipment = iterator.next()
- if (category != equipment.classCode){
- iterator.remove()
- }
- }
- if (equipList.size>0){
- val iterator = equipList.iterator()
- while (iterator.hasNext()) {
- var equipment = iterator.next()
- val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equipment.classCode!!)).entity()
- var propertyList = ArrayList<Property>()
- // if (!equipment.buildingId.isNullOrEmpty()&&!equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("floorId", equipment.floorId!!), SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else if (!equipment.buildingId.isNullOrEmpty()&&equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!),SFilter.eq("buildingId", equipment.buildingId!!),SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else{
- propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("family", equipFamily!!.family!!),SFilter.isNull("equipId")).exec()
- // }
- logger.debug("category = ${equipment.classCode}")
- logger.debug("Family = ${equipFamily.family}")
- logger.debug("匹配长度 = ${propertyList.size}")
- if (propertyList.size>0){
- /** 计算匹配资产 */
- val equipMatchingProperty = MatchingProperty.equipMatchingProperty(equipment, propertyList)
- if (equipMatchingProperty.size>0){
- equipment.propertyList = equipMatchingProperty
- }else{
- iterator.remove()
- }
- }
- /** 编码审查 */
- IdUtils.codeExanine()
- }
- }
- sQueryResponse.result= SResponseType.success
- sQueryResponse.content = equipList
- sQueryResponse
- }else{
- val sQueryResponse = SQueryResponse<Equipment>()
- sQueryResponse.total = 0
- sQueryResponse.result=SResponseType.success
- sQueryResponse.content = ArrayList<Equipment>()
- sQueryResponse
- }
- }else if(!spacrType.isNullOrEmpty()&&spacrType == "noKnow"){
- logger.debug("空间类型*************** ")
- var floorId: String? = null
- var buildingId: String? = null
- val queryBuilder = select(request.filters)
- val filterList = queryBuilder.filterList
- for (filter in filterList){
- if (filter.first.toString() == "buildingId"){
- buildingId = filter.second.toString()
- }else if (filter.first.toString() == "floorId"){
- floorId = filter.second.toString()
- }
- }
- val rEqInSpBaseList =rEq2SpService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("type","eq2sp_in")).exec()
- // val rEqInSpBaseList = REqInSpBaseService.select(SFilter.eq("projectId", projectId!!)).exec()
- val setId = HashSet<String>()
- for (rEqInSpBase in rEqInSpBaseList){
- setId.add(rEqInSpBase.id1!!)
- }
- val equipList = select(SFilter.eq("projectId", projectId!!), SFilter.eq("classCode", category), SFilter.eq("buildingId", buildingId!!),
- SFilter.eq("floorId", floorId!!), SFilter.not(SFilter.inList("id", setId.toList()))).exec()
- if (!equipList.isEmpty()){
- val sQueryResponse = SQueryResponse<Equipment>()
- sQueryResponse.total = equipList.size.toLong()
- val iterator = equipList.iterator()
- while (iterator.hasNext()) {
- var equipment = iterator.next()
- val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equipment.classCode!!)).entity()
- var propertyList = ArrayList<Property>()
- // if (!equipment.buildingId.isNullOrEmpty()&&!equipment.floorId.isNullOrEmpty()){
- propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("floorId", equipment.floorId!!), SFilter.isNull("equipId"), SFilter.eq("family", equipFamily!!.family!!)).exec()
- // }else if (!equipment.buildingId.isNullOrEmpty()&&equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!),SFilter.eq("buildingId", equipment.buildingId!!),SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else{
- propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("family", equipFamily!!.family!!),SFilter.isNull("equipId")).exec()
- // }
- if (propertyList.size>0){
- /** 计算匹配资产 */
- val equipMatchingProperty = MatchingProperty.equipMatchingProperty(equipment, propertyList)
- if (equipMatchingProperty.size>0){
- equipment.propertyList = equipMatchingProperty
- }else{
- iterator.remove()
- }
- }
- /** 编码审查 */
- IdUtils.codeExanine()
- }
- if (!equipList.isEmpty()){
- for (equip in equipList){
- if (!equip.buildingId.isNullOrEmpty()){
- val building = buildingService.select(SFilter.eq("id", equip.buildingId!!)).entity()
- if (building!=null){
- equip.building = building
- }
- }
- if (!equip.floorId.isNullOrEmpty()){
- val floor = floorService.select(SFilter.eq("id", equip.floorId!!)).entity()
- if (floor!=null){
- equip.floor = floor
- }
- }
- if (!equip.classCode.isNullOrEmpty()){
- val equipFamily = defClassService.select(SFilter.eq("projectId", projectId!!),SFilter.eq("code", equip.classCode!!)).entity()
- if (equipFamily!=null){
- val equipCategory = EquipCategory()
- equipCategory.code = equipFamily.code
- equipCategory.name = equipFamily.name
- equip.equipCategory = equipCategory
- }
- }
- if (!equip.propertyList!!.isEmpty()){
- for ( property in equip.propertyList!!){
- if (!property.buildingId.isNullOrEmpty()){
- val building = buildingService.select(SFilter.eq("id", property.buildingId!!)).entity()
- if (building!=null){
- property.building = building
- }
- }
- if (!property.floorId.isNullOrEmpty()){
- val floor = floorService.select(SFilter.eq("id", property.floorId!!)).entity()
- if (floor!=null){
- property.floor = floor
- }
- }
- if (!property.family.isNullOrEmpty()){
- val equipFamily = equipFamilyService.select(SFilter.eq("family", property.family!!)).entity()
- if (equipFamily!=null){
- val family = Family()
- family.code = equipFamily.family
- family.name = equipFamily.familyName
- property.familyName = family
- }
- }
- }
- }
- }
- }
- sQueryResponse.result=SResponseType.success
- sQueryResponse.content = equipList
- sQueryResponse
- }else{
- val sQueryResponse = SQueryResponse<Equipment>()
- sQueryResponse.total = 0
- sQueryResponse.result=SResponseType.success
- sQueryResponse.content = ArrayList<Equipment>()
- sQueryResponse
- }
- }else if (!spacrType.isNullOrEmpty()){
- // logger.debug("空间类型2*************** ")
- var floorId: String? = null
- var buildingId: String? = null
- val zoneSpaceBaseTable = SObjectService(SMybatisDao(ZoneSpace::class.java))
- val queryBuilder = select(request.filters)
- val filterList = queryBuilder.filterList
- for (filter in filterList){
- if (filter.first.toString() == "buildingId"){
- buildingId = filter.second.toString()
- }else if (filter.first.toString() == "floorId"){
- floorId = filter.second.toString()
- }
- }
- /** 查询空间数据 */
- val zoneSpaceBaseList = zoneSpaceBaseTable.select(SFilter.eq("objectType", spacrType), SFilter.eq("projectId", projectId!!),
- SFilter.eq("buildingId", buildingId!!), SFilter.eq("floorId", floorId!!)).exec()
- if (!zoneSpaceBaseList.isEmpty()){
- val listId = ArrayList<String>()
- for (zoneSpaceBase in zoneSpaceBaseList){
- listId.add(zoneSpaceBase.id!!)
- }
- /** 获取到空间关联的设备 */
- val rEqInSpBaseList = rEq2SpService.select(SFilter.inList("id2", listId), SFilter.eq("type","eq2sp_in")).exec()
- // val rEqInSpBaseList = REqInSpBaseService.select(SFilter.inList("spaceId", listId)).exec()
- if ( !rEqInSpBaseList.isEmpty()){
- val setId = HashSet<String>()
- for (rEqInSpBase in rEqInSpBaseList){
- setId.add(rEqInSpBase.id1!!)
- }
- val sQueryResponse = SQueryResponse<Equipment>()
- val equipList = select(SFilter.inList("id", setId.toList())).exec()
- sQueryResponse.total = equipList.size.toLong()
- val iterator = equipList.iterator()
- while (iterator.hasNext()) {
- var equipment = iterator.next()
- if (category != equipment.classCode){
- iterator.remove()
- }
- }
- if (equipList.size>0){
- val iterator = equipList.iterator()
- while (iterator.hasNext()) {
- var equipment = iterator.next()
- val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equipment.classCode!!)).entity()
- var propertyList = ArrayList<Property>()
- // if (!equipment.buildingId.isNullOrEmpty()&&!equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("floorId", equipment.floorId!!), SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else if (!equipment.buildingId.isNullOrEmpty()&&equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!),SFilter.eq("buildingId", equipment.buildingId!!),SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else{
- propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("family", equipFamily!!.family!!),SFilter.isNull("equipId")).exec()
- // }
- if (propertyList.size>0){
- /** 计算匹配资产 */
- val equipMatchingProperty = MatchingProperty.equipMatchingProperty(equipment, propertyList)
- if (equipMatchingProperty.size>0){
- equipment.propertyList = equipMatchingProperty
- }else{
- iterator.remove()
- }
- }
- /** 编码审查 */
- IdUtils.codeExanine()
- }
- }
- if (!equipList.isEmpty()){
- for (equip in equipList){
- if (!equip.buildingId.isNullOrEmpty()){
- val building = buildingService.select(SFilter.eq("id", equip.buildingId!!)).entity()
- if (building!=null){
- equip.building = building
- }
- }
- if (!equip.floorId.isNullOrEmpty()){
- val floor = floorService.select(SFilter.eq("id", equip.floorId!!)).entity()
- if (floor!=null){
- equip.floor = floor
- }
- }
- if (!equip.classCode.isNullOrEmpty()){
- val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equip.classCode!!)).entity()
- if (equipFamily!=null){
- val equipCategory = EquipCategory()
- equipCategory.code = equipFamily.equipCode
- equipCategory.name = equipFamily.equipName
- equip.equipCategory = equipCategory
- }
- }
- if (!equip.propertyList!!.isEmpty()){
- for ( property in equip.propertyList!!){
- if (!property.buildingId.isNullOrEmpty()){
- val building = buildingService.select(SFilter.eq("id", property.buildingId!!)).entity()
- if (building!=null){
- property.building = building
- }
- }
- if (!property.floorId.isNullOrEmpty()){
- val floor = floorService.select(SFilter.eq("id", property.floorId!!)).entity()
- if (floor!=null){
- property.floor = floor
- }
- }
- if (!property.family.isNullOrEmpty()){
- val equipFamily = equipFamilyService.select(SFilter.eq("family", property.family!!)).entity()
- if (equipFamily!=null){
- val family = Family()
- family.code = equipFamily.family
- family.name = equipFamily.familyName
- property.familyName = family
- }
- }
- }
- }
- }
- }
- sQueryResponse.result=SResponseType.success
- sQueryResponse.content = equipList
- sQueryResponse
- }else{
- val sQueryResponse = SQueryResponse<Equipment>()
- sQueryResponse.total = 0
- sQueryResponse.result=SResponseType.success
- sQueryResponse.content = ArrayList<Equipment>()
- sQueryResponse
- }
- }else{
- val sQueryResponse = SQueryResponse<Equipment>()
- sQueryResponse.total = 0
- sQueryResponse.result=SResponseType.success
- sQueryResponse.content = ArrayList<Equipment>()
- sQueryResponse
- }
- }else{
- logger.debug("设备*************** ")
- request.pageSize = 100000
- SQueryRequest.maxRow = 100000
- val pageQuery = pageQuery(request, arrayListOf(SFilter.eq("classCode", category),
- SFilter.isNull("propertyId"),SFilter.eq("projectId", projectId!!)))
- var contentList :ArrayList<Equipment>? = null
- logger.debug("设备***************${pageQuery.toJson()} ")
- if (pageQuery.content!=null&&!pageQuery.content!!.isNullOrEmpty()){
- contentList = pageQuery.content as ArrayList<Equipment>
- }else{
- contentList = ArrayList<Equipment>()
- }
- if (contentList!=null&&!contentList.isEmpty()){
- try {
- // logger.debug("设备***************11111111111111111111111111")
- val iterator = contentList.iterator()
- while (iterator.hasNext()){
- var equipment = iterator.next()
- val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equipment.classCode!!)).entity()
- var propertyList = ArrayList<Property>()
- // if (!equipment.buildingId.isNullOrEmpty()&&!equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("floorId", equipment.floorId!!), SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else if (!equipment.buildingId.isNullOrEmpty()&&equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!),SFilter.eq("buildingId", equipment.buildingId!!),SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else{
- propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("family", equipFamily!!.family!!),SFilter.isNull("equipId")).exec()
- // }
- // logger.debug("category = ${equipment.category}")
- // logger.debug("Family = ${equipFamily.family}")
- // logger.debug("匹配长度 = ${propertyList.size}")
- if (propertyList.size>0){
- /** 计算匹配资产 */
- val equipMatchingProperty = MatchingProperty.equipMatchingProperty(equipment, propertyList)
- logger.debug("匹配到的数据 = ${equipMatchingProperty.size}")
- if (equipMatchingProperty.size>0){
- equipment.propertyList = equipMatchingProperty
- }else{
- iterator.remove()
- }
- /** 编码审查 */
- IdUtils.codeExanine()
- }else{
- iterator.remove()
- }
- }
- // for (equipment in contentList){
- // val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equipment.category!!)).entity()
- // var propertyList = ArrayList<Property>()
- // if (!equipment.buildingId.isNullOrEmpty()&&!equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("floorId", equipment.floorId!!), SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else if (!equipment.buildingId.isNullOrEmpty()&&equipment.floorId.isNullOrEmpty()){
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!),SFilter.eq("buildingId", equipment.buildingId!!),SFilter.isNull("EquipmentId"), SFilter.eq("Family", equipFamily!!.family!!)).exec()
- // }else{
- // propertyList = PropertyService.select(SFilter.eq("projectId", projectId!!), SFilter.eq("Family", equipFamily!!.family!!),SFilter.isNull("EquipmentId")).exec()
- // }
- // logger.debug("资产个数 =${propertyList.size}")
- // if (propertyList.size>0){
- // /** 计算匹配资产 */
- // val equipMatchingProperty = MatchingProperty.equipMatchingProperty(equipment, propertyList)
- //
- // if (equipMatchingProperty.size>0){
- // equipment.propertyList = equipMatchingProperty
- // }else{
- // contentList.remove(equipment)
- // }
- // try {
- // Thread.sleep(500)
- // } catch (e: InterruptedException) {
- // e.printStackTrace()
- // }
- // }else{
- // contentList.remove(equipment)
- // }
- // }
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
- if (!contentList.isEmpty()){
- for (equip in contentList){
- if (!equip.buildingId.isNullOrEmpty()){
- val building = buildingService.select(SFilter.eq("id", equip.buildingId!!)).entity()
- if (building!=null){
- equip.building = building
- }
- }
- if (!equip.floorId.isNullOrEmpty()){
- try {
- val floor = floorService.select(SFilter.eq("id", equip.floorId!!)).entity()
- if (floor!= null){
- equip.floor = floor
- }
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
- if (!equip.classCode.isNullOrEmpty()){
- val equipFamily = equipFamilyService.select(SFilter.eq("equipCode", equip.classCode!!)).entity()
- if (equipFamily!=null){
- val equipCategory = EquipCategory()
- equipCategory.code = equipFamily.equipCode
- equipCategory.name = equipFamily.equipName
- equip.equipCategory = equipCategory
- }
- }
- if (!equip.propertyList!!.isEmpty()){
- for ( property in equip.propertyList!!){
- if (!property.buildingId.isNullOrEmpty()){
- val building = buildingService.select(SFilter.eq("id", property.buildingId!!)).entity()
- if (building!=null){
- property.building = building
- }
- }
- if (!property.floorId.isNullOrEmpty()){
- val floor = floorService.select(SFilter.eq("id", property.floorId!!)).entity()
- if (floor!=null){
- property.floor = floor
- }
- }
- if (!property.family.isNullOrEmpty()){
- val equipFamily = equipFamilyService.select(SFilter.eq("family", property.family!!)).entity()
- if (equipFamily!=null){
- val family = Family()
- family.code = equipFamily.family
- family.name = equipFamily.familyName
- property.familyName = family
- }
- }
- }
- }
- }
- }
- pageQuery.content = contentList
- pageQuery
- }
- } catch (e : Exception){
- e.printStackTrace()
- SQueryResponse(SResponseType.failure, e.rootCause()?.message ?: e.message ?: "未知异常!")
- }
- }
- /**
- * 创建设备和资产的关系
- */
- fun equipPro(request: SUpdateRequest<Property>): SBaseResponse {
- return try {
- val projectId = SPageContext.getHeader("projectId")
- var projection = request.projection
- if (projection == null ){
- projection = ArrayList()
- projection.add("equipId")
- }
- if (projection!=null&&projection!!.isEmpty()){
- projection.add("equipId")
- }
- if (projection!=null&&!projection.isEmpty()){
- projection.clear()
- projection.add("equipId")
- }
- val updateList = PropertyService.updateList(request)
- try {
- /** 处理关系标记 */
- val listtype = ArrayList<String>()
- listtype.add("pe2bd")
- listtype.add("pe2fl")
- listtype.add("pe2sh")
- listtype.add("pe2sp")
- for (type in listtype){
- val entity = relationTypeProjectservice.select(SFilter.eq("projectId", projectId!!), SFilter.eq("relationType", type)).entity()
- if (entity!=null){
- entity.computationalState = 2
- relationTypeProjectservice.update(entity)
- }
- }
- } catch (e: Exception) {
- e.printStackTrace()
- }
- updateList
- } catch (e: Exception) {
- e.printStackTrace()
- SBaseResponse(SResponseType.failure, e.message.toString())
- }
- }
- /**
- * 查询设备
- *
- * @param request 请求条件
- */
- fun equipQuery(request: PlanarEquipRequests): SQueryResponse<PlanarEquip> {
- val sQueryResponse = SQueryResponse<PlanarEquip>()
- try {
- sQueryResponse.result = SResponseType.success
- if (!request.equipTypes.isNullOrEmpty()&&!request.zoneTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()) {
- /** 先查询空间数据 */
- if (!request.spaceIds.isNullOrEmpty()) {
- // spaceService.select(SFilter.eq())
- } else {
- }
- } else if (!request.equipTypes.isNullOrEmpty()&&!request.zoneTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()){
- } else if (!request.equipTypes.isNullOrEmpty()&&!request.zoneTypes.isNullOrEmpty()){
- } else if (!request.equipTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()){
- }else if (!request.equipTypes.isNullOrEmpty()){
- val planarEquipList = planarEquipService.select(
- SFilter.eq("buildingId", request.buildingId!!), SFilter.eq("floorId", request.floorId!!),
- SFilter.Companion.inList("classCode", request.equipTypes!!)
- ).exec()
- sQueryResponse.content = planarEquipList
- }else {
- sQueryResponse.result = SResponseType.failure
- }
- return sQueryResponse
- } catch (e: Exception) {
- return SQueryResponse(SResponseType.failure,e.message!!)
- }
- }
- /**
- * 查询设备类型统计数量
- *
- * @param request 请求条件
- */
- // fun equipQueryCount(request: PlanarEquipRequests): SQueryResponse<EquipQueryCount> {
- //
- // val sQueryResponse = SQueryResponse<EquipQueryCount>()
- // try {
- // sQueryResponse.result = SResponseType.success
- // if (!request.equipTypes.isNullOrEmpty()&&!request.zoneTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()) {
- //
- // } else if (!request.equipTypes.isNullOrEmpty()&&!request.zoneTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()){
- // /** 空间类型 和功能区类型组合查询 */
- //
- // if (!request.spaceIds.isNullOrEmpty()) {
- //
- //
- //
- // } else {
- //
- // }
- //
- //
- //
- // } else if (!request.equipTypes.isNullOrEmpty()&&!request.zoneTypes.isNullOrEmpty()){
- //
- // } else if (!request.equipTypes.isNullOrEmpty()&&!request.funcTypes.isNullOrEmpty()){
- //
- //
- // }else if (!request.equipTypes.isNullOrEmpty()){
- //
- //// val planarEquipList = planarEquipService.select(
- //// SFilter.eq("buildingId", request.buildingId!!), SFilter.eq("floorId", request.floorId!!),
- //// SFilter.inList("classCode", request.equipTypes!!)
- //// ).exec()
- // val equipTypeCounts = customSqlLabslService.equipTypeCounts(
- // Opt.projectId!!,
- // request.buildingId!!,
- // request.floorId!!,
- // request.equipTypes!!
- // )
- // sQueryResponse.content = equipTypeCounts
- // }else {
- //
- // sQueryResponse.result = SResponseType.failure
- // }
- // return sQueryResponse
- // } catch (e: Exception) {
- // return SQueryResponse(SResponseType.failure,e.message!!)
- // }
- // }
- } // Object EquipmentService
|