|
@@ -26,6 +26,7 @@
|
|
|
|
|
|
package com.persagy.server.services.task
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil
|
|
|
import cn.sagacloud.server.scanbuilding.User
|
|
|
import com.alibaba.fastjson.JSONObject
|
|
|
import com.google.gson.Gson
|
|
@@ -33,23 +34,35 @@ import com.google.gson.reflect.TypeToken
|
|
|
import com.persagy.base.extensions.toJson
|
|
|
import com.persagy.database.SFilter
|
|
|
import com.persagy.database.SPageQueryInfo
|
|
|
+import com.persagy.database.functions.SLength
|
|
|
import com.persagy.mybatis.SMybatisDao
|
|
|
import com.persagy.server.Opts
|
|
|
import com.persagy.server.datacenter.models.entities.assistant.TaskPic
|
|
|
import com.persagy.server.datacenter.models.entities.dict.EquipFamilyCategory
|
|
|
+import com.persagy.server.datacenter.models.entities.dictnew.DefClass
|
|
|
+import com.persagy.server.datacenter.models.entities.objects.Equipment
|
|
|
import com.persagy.server.datacenter.models.entities.objects.Property
|
|
|
+import com.persagy.server.datacenter.models.entities.task.EquipScanTaskQuery
|
|
|
import com.persagy.server.datacenter.models.entities.task.PropertyScanTask
|
|
|
import com.persagy.server.datacenter.models.entities.task.SchemeUtils
|
|
|
import com.persagy.server.scanbuilding.UserLog
|
|
|
+import com.persagy.server.services.AdmBaseService
|
|
|
+import com.persagy.server.services.DmpBaseService
|
|
|
import com.persagy.server.services.base.RService
|
|
|
+import com.persagy.server.util.AdmEntityTransferUtil
|
|
|
import com.persagy.server.util.IdUtils
|
|
|
import com.persagy.service.SBaseService
|
|
|
import com.persagy.service.SObjectService
|
|
|
import com.persagy.service.SPageContext
|
|
|
+import com.persagy.service.models.SCascadeQuery
|
|
|
import com.persagy.service.models.requests.SCreateRequest
|
|
|
+import com.persagy.service.models.requests.SQueryRequest
|
|
|
+import com.persagy.service.models.responses.SQueryResponse
|
|
|
import org.slf4j.LoggerFactory
|
|
|
+import org.springframework.beans.factory.annotation.Autowired
|
|
|
import org.springframework.web.bind.annotation.RequestBody
|
|
|
import java.util.*
|
|
|
+import java.util.stream.Collectors
|
|
|
import kotlin.collections.ArrayList
|
|
|
|
|
|
/**
|
|
@@ -66,8 +79,113 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
var userLogService = SObjectService(SMybatisDao(UserLog::class.java))
|
|
|
/** 用户 */
|
|
|
var userService = SObjectService(SMybatisDao(User::class.java))
|
|
|
+
|
|
|
/** 用户 */
|
|
|
- var equipFamilyCategoryService = SObjectService(SMybatisDao(EquipFamilyCategory::class.java))
|
|
|
+ //var equipFamilyCategoryService = SObjectService(SMybatisDao(EquipFamilyCategory::class.java))
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private val admBaseService: AdmBaseService? = AdmBaseService()
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private val dmpBaseService: DmpBaseService? = DmpBaseService()
|
|
|
+
|
|
|
+
|
|
|
+ fun pageQuerys(request: SQueryRequest): SQueryResponse<PropertyScanTask> {
|
|
|
+ //查询设备台账任务
|
|
|
+ val projectId = SPageContext.getHeader("projectId").toString()
|
|
|
+ val withFilterList = ArrayList<SFilter>()
|
|
|
+ withFilterList.add(SFilter.eq("projectId", SPageContext.getHeader("projectId").toString()))
|
|
|
+ //withFilterList.add(SFilter.lt(SLength("classCode"), 7))
|
|
|
+ val pageQuery = PropertyScanTaskService.pageQuery(request, withFilterList)
|
|
|
+ if (!pageQuery.content.isNullOrEmpty()&&pageQuery.content!!.size>0){
|
|
|
+
|
|
|
+ //级联查询设备相关信息:建筑,楼层,空间等
|
|
|
+ val equipScanTaskList = pageQuery.content
|
|
|
+ var cascadeQueryAdmEquip = arrayListOf<Property>()
|
|
|
+ if (equipScanTaskList != null) {
|
|
|
+
|
|
|
+ val cascades = ArrayList<SCascadeQuery>()
|
|
|
+ //级联查询建筑
|
|
|
+ val buildCacade = SCascadeQuery()
|
|
|
+ buildCacade.name = "building"
|
|
|
+ cascades.add(buildCacade)
|
|
|
+ //级联查询楼层
|
|
|
+ val floorCacade = SCascadeQuery()
|
|
|
+ floorCacade.name="floor"
|
|
|
+ cascades.add(floorCacade)
|
|
|
+
|
|
|
+ val cascade = request.cascade
|
|
|
+ if (cascade != null) {
|
|
|
+ cascade.addAll(cascades)
|
|
|
+ request.cascade= cascade
|
|
|
+ }else{
|
|
|
+ request.cascade= cascades
|
|
|
+ }
|
|
|
+ cascadeQueryAdmEquip = cascadeQueryAdmProperty(equipScanTaskList, request) as ArrayList<Property>
|
|
|
+ }
|
|
|
+ val equipMap = cascadeQueryAdmEquip?.stream()?.collect(Collectors.groupingBy { item: Property -> item.id })
|
|
|
+ for (content in pageQuery.content!!){
|
|
|
+ //设置级联查询结果
|
|
|
+ val caseNodes = equipMap.get(content.equipId)
|
|
|
+ if(CollUtil.isNotEmpty(caseNodes)){
|
|
|
+ val equip = caseNodes?.get(0)
|
|
|
+ if (equip != null) {
|
|
|
+ content.building = equip.building
|
|
|
+ content.floor = equip.floor
|
|
|
+ /*val component = equip.component
|
|
|
+ val toAdmMultiEntity = AdmEntityTransferUtil.toAdmMultiEntity(component, null, EquipScanTaskQuery::class.java)
|
|
|
+ content.component = toAdmMultiEntity*/
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询组件
|
|
|
+ /* val exec = EquipScanTaskQueryService.select(SFilter.eq("parentId", content.equipId!!), SFilter.eq("taskParentId", content.id!!)).exec()
|
|
|
+ if (exec.size>0){
|
|
|
+ content.component = exec
|
|
|
+ }*/
|
|
|
+ //查询中台类型数据,2021.10.25日中心中台整合调整
|
|
|
+ val param = JSONObject()
|
|
|
+ val criteria = JSONObject()
|
|
|
+ criteria["code"] = content.classCode!!
|
|
|
+ param["criteria"] = criteria
|
|
|
+ val dictTypes = dmpBaseService?.queryDictType(param)
|
|
|
+ val entity = AdmEntityTransferUtil.toAdmMultiEntity(dictTypes, null, EquipFamilyCategory::class.java)?.get(0)
|
|
|
+ if (entity!=null) {
|
|
|
+ content.equipFamily = entity
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pageQuery
|
|
|
+ } // Fun
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 级联查询资产相关信息:建筑,楼层,空间等
|
|
|
+ */
|
|
|
+ fun cascadeQueryAdmProperty(equipScanTaskList: List<PropertyScanTask>?, request: SQueryRequest): List<Property>? {
|
|
|
+ //级联查询设备相关信息:建筑,楼层,空间等
|
|
|
+ if(CollUtil.isEmpty(equipScanTaskList)){
|
|
|
+ return ArrayList<Property>()
|
|
|
+ }
|
|
|
+ val equipIds = equipScanTaskList?.stream()?.map(PropertyScanTask::equipId)?.collect(Collectors.toList<String>())
|
|
|
+ var equipRequest = SQueryRequest()
|
|
|
+ equipRequest.filters = "id in "+"(\'" + java.lang.String.join("\',\'", equipIds) + "\')"
|
|
|
+
|
|
|
+ val requestCascade = request.cascade
|
|
|
+ //查询级联关系
|
|
|
+ val cascadeList = arrayListOf<SCascadeQuery>()
|
|
|
+ if (requestCascade != null) {
|
|
|
+ for(cascade in requestCascade){
|
|
|
+ if("scanScheme".equals(cascade.name)){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ cascadeList.add(cascade)
|
|
|
+ }
|
|
|
+ equipRequest.cascade = cascadeList;
|
|
|
+ return admBaseService?.queryProperty(equipRequest)
|
|
|
+ }
|
|
|
+ return ArrayList<Property>()
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 插入之前先过滤已经存在未验证任务的对象,返回新列表
|
|
|
*/
|
|
@@ -75,7 +193,7 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
val propertyTaskList = request.content;
|
|
|
var newList = arrayListOf<PropertyScanTask>()
|
|
|
for(property in propertyTaskList){
|
|
|
- val propertyTask = PropertyScanTaskService.select("equipId" to property.equipId!!,"taskState" to 1).entity()
|
|
|
+ val propertyTask = PropertyScanTaskService.select(SFilter.eq("equipId", property.equipId!!),SFilter.eq("taskState", 1)).entity()
|
|
|
if(propertyTask==null){//表示当前设备已经存在未验证的任务
|
|
|
newList.add(property)
|
|
|
}
|
|
@@ -97,7 +215,9 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
flag = true
|
|
|
|
|
|
val propertyScanTaskService = SBaseService(SMybatisDao(PropertyScanTask::class.java))
|
|
|
- val resetTask = propertyScanTaskService.select("equipId" to propertyScanTask.equipId!!,"taskState" to -1).entity()
|
|
|
+ val resetTask = propertyScanTaskService.select(SFilter.eq("equipId", propertyScanTask.equipId!!),SFilter.eq("taskState", -1)
|
|
|
+ ).entity()
|
|
|
+
|
|
|
if( resetTask!=null ){
|
|
|
resetTask.taskState = 0
|
|
|
propertyScanTaskService.update(resetTask)
|
|
@@ -114,8 +234,10 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
propertyScanTask.taskState = 1//任务状态为待验证
|
|
|
propertyScanTask.taskType = "1"
|
|
|
if (!propertyScanTask.equipId.isNullOrEmpty()) {//当设备id不为空时,去设备表查询对应的详细信息
|
|
|
- val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
- val property = propertyService.select("id" to propertyScanTask.equipId!!).entity()
|
|
|
+ // val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
+ // val property = propertyService.select(SFilter.eq("id", propertyScanTask.equipId!!)
|
|
|
+ //).entity()
|
|
|
+ val property = admBaseService?.queryPropertyById(propertyScanTask.equipId!!)?.get(0)
|
|
|
if (propertyScanTask.schemeId.isNullOrEmpty()){
|
|
|
propertyScanTask.schemeId = SchemeUtils.setScheme(property!!.family!!)
|
|
|
}
|
|
@@ -234,13 +356,28 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
|
|
|
|
|
|
override fun onDeleteBefore(entity: PropertyScanTask): Boolean {
|
|
|
- val entity1 = select(SFilter.eq("id", entity.id!!)).entity()
|
|
|
- val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
- val property = propertyService.select(SFilter.eq("id", entity1!!.equipId!!)).entity()
|
|
|
- val list = ArrayList<String>()
|
|
|
- list.add("TaskState")
|
|
|
- property!!.taskState = null
|
|
|
- propertyService.update(property,list)
|
|
|
+ /* val entity1 = select(SFilter.eq("id", entity.id!!)).entity()
|
|
|
+ val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
+ val property = propertyService.select(SFilter.eq("id", entity1!!.equipId!!)).entity()
|
|
|
+
|
|
|
+ val list = ArrayList<String>()
|
|
|
+ list.add("TaskState")
|
|
|
+ property!!.taskState = null
|
|
|
+ propertyService.update(property,list)*/
|
|
|
+
|
|
|
+ val property = admBaseService?.queryPropertyById(entity!!.equipId!!)?.get(0)
|
|
|
+ val infos = HashMap<String, Any?>()
|
|
|
+ infos.put("taskState",null)
|
|
|
+ if (property != null) {
|
|
|
+ property.infos = infos
|
|
|
+ }
|
|
|
+
|
|
|
+ val list = ArrayList<Property>()
|
|
|
+ if (property != null) {
|
|
|
+ list.add(property)
|
|
|
+ }
|
|
|
+ admBaseService?.updateProperty(list)
|
|
|
+
|
|
|
return super.onDeleteBefore(entity)
|
|
|
}
|
|
|
|
|
@@ -250,11 +387,21 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
*/
|
|
|
override fun onCreateSuccess(propertyScanTaskList: ArrayList<PropertyScanTask>) {
|
|
|
for(task in propertyScanTaskList){
|
|
|
- val property = Property()
|
|
|
+ /*val property = Property()
|
|
|
val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
property.id = task.equipId!!
|
|
|
property.taskState = 1
|
|
|
- propertyService.update(property)
|
|
|
+ propertyService.update(property)*/
|
|
|
+
|
|
|
+ val property = Property()
|
|
|
+ property.id = task.equipId!!
|
|
|
+ val infos = HashMap<String, Any?>()
|
|
|
+ infos.put("taskState",1)
|
|
|
+ if (property != null) {
|
|
|
+ property.infos = infos
|
|
|
+ }
|
|
|
+ admBaseService?.updateProperty(arrayListOf(property))
|
|
|
+
|
|
|
}
|
|
|
} // Fun onCreateSuccess
|
|
|
|
|
@@ -264,18 +411,28 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
override fun onUpdateSuccess(list: ArrayList<PropertyScanTask>) {
|
|
|
val projectId = SPageContext.getHeader("projectId")
|
|
|
for (task in list) {
|
|
|
- val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
+ // val propertyService = SBaseService(SMybatisDao(Property::class.java))
|
|
|
if(task.equipId == null ){
|
|
|
- val propertyScanTask = PropertyScanTaskService.select("id" to task.id!!).entity()
|
|
|
+ val propertyScanTask = PropertyScanTaskService.select(SFilter.eq("id", task.id!!)).entity()
|
|
|
task.equipId = propertyScanTask!!.equipId
|
|
|
}
|
|
|
//更改设备对象的状态
|
|
|
- val propertyOld = propertyService.select("id" to task.equipId!!).entity()
|
|
|
+ //val propertyOld = propertyService.select(SFilter.eq("id", task.equipId!!)).entity()
|
|
|
+ val propertyOld = admBaseService?.queryPropertyById(task!!.equipId!!)?.get(0)
|
|
|
if(propertyOld!!.taskState != -1) {//未找到
|
|
|
- val property = Property()
|
|
|
+ /* val property = Property()
|
|
|
property.id = task.equipId!!
|
|
|
property.taskState = task.taskState
|
|
|
- propertyService.update(property)
|
|
|
+ propertyService.update(property)*/
|
|
|
+
|
|
|
+ val property = Property()
|
|
|
+ property.id = task.equipId!!
|
|
|
+ val infos = HashMap<String, Any?>()
|
|
|
+ infos.put("taskState",task.taskState!!)
|
|
|
+ if (property != null) {
|
|
|
+ property.infos = infos
|
|
|
+ }
|
|
|
+ admBaseService?.updateProperty(arrayListOf(property))
|
|
|
}
|
|
|
try {
|
|
|
if (!Opts.coming.isNullOrEmpty()&&Opts.coming == "app"){
|
|
@@ -300,17 +457,26 @@ object PropertyScanTaskService : RService<PropertyScanTask>(SMybatisDao(Property
|
|
|
} // Fun onUpdateSuccess
|
|
|
|
|
|
override fun onQuerySuccess(pageInfo: SPageQueryInfo<PropertyScanTask>) {
|
|
|
- if (!pageInfo.content.isNullOrEmpty()){
|
|
|
+ /* if (!pageInfo.content.isNullOrEmpty()){
|
|
|
for (content in pageInfo.content!!){
|
|
|
- val entity = equipFamilyCategoryService.select(SFilter.eq("family", content.classCode!!)).entity()
|
|
|
+ // val entity = equipFamilyCategoryService.select(SFilter.eq("family", content.classCode!!)).entity()
|
|
|
+ //查询中台类型数据,2021.10.25日中心中台整合调整
|
|
|
+ val param = JSONObject()
|
|
|
+ val criteria = JSONObject()
|
|
|
+ criteria["code"] = content.classCode!!
|
|
|
+ param["criteria"] = criteria
|
|
|
+ val dictTypes = dmpBaseService?.queryDictType(param)
|
|
|
+ val entity = AdmEntityTransferUtil.toAdmMultiEntity(dictTypes, null, EquipFamilyCategory::class.java)?.get(0)
|
|
|
if (entity!=null) {
|
|
|
content.equipFamily = entity
|
|
|
}else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
super.onQuerySuccess(pageInfo)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
} // Class PropertyScanTaskService
|