|
@@ -39,6 +39,7 @@ import com.persagy.server.services.DmpBaseService
|
|
|
import com.persagy.server.services.base.RService
|
|
|
import com.persagy.service.SBaseService
|
|
|
import com.persagy.service.SPageContext
|
|
|
+import com.persagy.service.models.SCascadeQuery
|
|
|
import com.persagy.service.models.enums.SResponseType
|
|
|
import com.persagy.service.models.requests.SQueryRequest
|
|
|
import com.persagy.service.models.responses.SQueryResponse
|
|
@@ -96,29 +97,62 @@ object ScanTaskBaseService : RService<ScanTaskBase>(SMybatisDao(ScanTaskBase::cl
|
|
|
* 查询所有建筑和楼层
|
|
|
*/
|
|
|
fun buildingQuery(type: String): SQueryResponse<BuildingDic> {
|
|
|
- val pageQuery: SPageQueryInfo<BuildingDic>
|
|
|
- val gson = Gson()
|
|
|
+ val pageQuery = SPageQueryInfo<BuildingDic>(1, 1000)
|
|
|
return try {
|
|
|
val projectId = SPageContext.getHeader("projectId").toString()
|
|
|
var request = SQueryRequest()
|
|
|
- val service = SBaseService(SMybatisDao(BuildingDic::class.java))
|
|
|
- val queryBuilder = service.select(request.filters)
|
|
|
- queryBuilder.tableName = "scantask.f_get_building_dic('$type','$projectId')"
|
|
|
- pageQuery = queryBuilder.pageQuery(1, 1000)
|
|
|
-
|
|
|
- if (pageQuery.content!=null&&pageQuery.content!!.size>0){
|
|
|
- for(floor in pageQuery.content!!){
|
|
|
- if(floor.floorListStr != null){
|
|
|
- val listStr = floor.floorListStr!!.replace("/\\","")
|
|
|
- val newStr = "["+listStr.substring(1,listStr.length-1)+"]"
|
|
|
- val type = object : TypeToken<ArrayList<FloorDic>>() {
|
|
|
- }.type
|
|
|
- val siInSpList = gson.fromJson<ArrayList<FloorDic>>(newStr, type)
|
|
|
- floor.floor = siInSpList
|
|
|
- floor.floorListStr = null
|
|
|
- }
|
|
|
- }
|
|
|
+ request.filters = " buildingId is not null and floorId is not null ";
|
|
|
+ request.projection = arrayListOf("buildingId", "floorId")
|
|
|
+ request.distinct = true
|
|
|
+ val tasks = ArrayList<ScanTaskBase>()
|
|
|
+ if(type == "equip") {
|
|
|
+ // 如果是equip
|
|
|
+ val response = EquipScanTaskService.pageQuery(request, null)
|
|
|
+ tasks.addAll(response.content!!)
|
|
|
+ } else if(type == "property") {
|
|
|
+ // 如果是property
|
|
|
+ val response = PropertyScanTaskService.pageQuery(request, null)
|
|
|
+ tasks.addAll(response.content!!)
|
|
|
+ } else if(type == "model") {
|
|
|
+ // 如果是model
|
|
|
+ val response = ModelScanTaskService.pageQuery(request, null)
|
|
|
+ tasks.addAll(response.content!!)
|
|
|
+ }
|
|
|
+ val resultList = ArrayList<BuildingDic>()
|
|
|
+ pageQuery.content = resultList
|
|
|
+ if(tasks!!.isNotEmpty()) {
|
|
|
+ // 转换为<buildId, List<floorId>>
|
|
|
+ val builds = tasks.map { it.buildingId }
|
|
|
+ val floors = tasks.map { it.floorId }
|
|
|
+ var buildingRequest = SQueryRequest()
|
|
|
+ buildingRequest.filters = "id in (" +builds!!.joinToString(",", ",", "'") + ")"
|
|
|
+ buildingRequest.pageSize = 1000
|
|
|
+ buildingRequest.pageNumber = 1
|
|
|
+ var cascade = SCascadeQuery()
|
|
|
+ cascade.name = "floor"
|
|
|
+ cascade.filters = "id in (" +floors!!.joinToString(",", ",", "'") + ")"
|
|
|
+ buildingRequest.cascade = arrayListOf(cascade)
|
|
|
+ // TODO 调用adm-middleware建筑查询接口
|
|
|
+ // ...
|
|
|
+ // TODO 转换为BuildingDic
|
|
|
+ // ...
|
|
|
+ }
|
|
|
+// val queryBuilder = service.select(request.filters)
|
|
|
+// queryBuilder.tableName = "scantask.f_get_building_dic('$type','$projectId')"
|
|
|
+// pageQuery = queryBuilder.pageQuery(1, 1000)
|
|
|
|
|
|
+ if (resultList!!.size>0){
|
|
|
+// for(floor in resultList!!){
|
|
|
+// if(floor.floorListStr != null){
|
|
|
+// val listStr = floor.floorListStr!!.replace("/\\","")
|
|
|
+// val newStr = "["+listStr.substring(1,listStr.length-1)+"]"
|
|
|
+// val type = object : TypeToken<ArrayList<FloorDic>>() {
|
|
|
+// }.type
|
|
|
+// val siInSpList = gson.fromJson<ArrayList<FloorDic>>(newStr, type)
|
|
|
+// floor.floor = siInSpList
|
|
|
+// floor.floorListStr = null
|
|
|
+// }
|
|
|
+// }
|
|
|
if (type == "equip"||type == "property"){
|
|
|
var taskSource: String
|
|
|
if (type == "equip"){
|
|
@@ -159,8 +193,6 @@ object ScanTaskBaseService : RService<ScanTaskBase>(SMybatisDao(ScanTaskBase::cl
|
|
|
pageQuery.content!!.add(0,buildingDic)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}else{
|
|
|
if (type == "equip"||type == "property") {
|
|
|
var taskSource: String
|