Browse Source

需求:实现根据revit.project来查询集团编码

lijie 3 years ago
parent
commit
b88a921885

+ 1 - 3
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/backstage/BackMainThread.kt

@@ -4,7 +4,6 @@ import cn.sagacloud.server.algorithm.backstage.state.*
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.scheduling.annotation.EnableScheduling
-import org.springframework.scheduling.annotation.Scheduled
 import org.springframework.stereotype.Component
 
 /**
@@ -54,7 +53,7 @@ class BackMainThread {
      * 定时任务, 处理它们的状态, 当前未完成时, 不会执行下一个scheduled
      */
     //@Scheduled(cron = "0 0/1 * * * ?")
-    @Scheduled(fixedRate = 1000 * 60 * 3, initialDelay = 1000)
+    //@Scheduled(fixedRate = 1000 * 60 * 3, initialDelay = 1000)
     fun run() {
         if(states.isEmpty()) {
 //            states.addAll(arrayListOf(state31, state3))
@@ -62,7 +61,6 @@ class BackMainThread {
             states.addAll(arrayListOf(state0, state1, state10, state11, state2, state20, state21, state31, state3, state4))
         }
         states.forEach { modelState ->
-            modelState.prepareModel()
             modelState.handle()
         }
     }

+ 50 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/controllers/modelEntity/GroupProjectController.kt

@@ -0,0 +1,50 @@
+package cn.sagacloud.server.algorithm.controllers.modelEntity
+
+import cn.sagacloud.server.algorithm.models.entities.Project
+import cn.sagacloud.server.algorithm.models.group.GroupProjectDTO
+import cn.sagacloud.server.algorithm.models.request.BaseProjectRequest
+import cn.sagacloud.server.algorithm.services.group.GroupProjectService
+import com.sybotan.mybatis.SMybatisDao
+import com.sybotan.service.SObjectService
+import com.sybotan.service.models.responses.SQueryResponse
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestBody
+import org.springframework.web.bind.annotation.RestController
+
+/**
+ *
+ * @author  Cainga
+ * @date  2021/1/26 16:39
+ */
+@Api(tags = ["集团项目配置接口"])
+@RestController
+class GroupProjectController {
+
+    companion object {
+        // 日志
+        private val logger = LoggerFactory.getLogger(GroupProjectController::class.java)
+    } // Companion object
+    
+    val projectService = SObjectService(SMybatisDao(Project::class.java))  // 项目
+    @Autowired
+    lateinit var groupProjectService:GroupProjectService  // 项目
+
+    /**
+     * 查询集团拥有的项目
+     *
+     * @param   request     查询请求
+     * @return  查询结果应答信息
+     */
+    @ApiOperation(value = "查询集团拥有的项目", notes = "")
+    @PostMapping(value = ["/rwd/groupAndSchema/admin/queryGroupProjectList"])
+    fun queryGroupProjectList(@RequestBody request: BaseProjectRequest): SQueryResponse<GroupProjectDTO> {
+        val list:List<GroupProjectDTO> = groupProjectService.queryGroupProjectList(request)
+        val response = SQueryResponse<GroupProjectDTO>()
+        response.content=list
+        return response
+    } // Function queryGroupProjectList()
+}

+ 4 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/controllers/modelEntity/ProjectController.kt

@@ -1,6 +1,7 @@
 package cn.sagacloud.server.algorithm.controllers.modelEntity
 
 import cn.sagacloud.server.algorithm.models.entities.Project
+import cn.sagacloud.server.algorithm.services.group.GroupProjectService
 import com.sybotan.mybatis.SMybatisDao
 import com.sybotan.service.SObjectService
 import com.sybotan.service.models.requests.SCountRequest
@@ -14,6 +15,7 @@ import com.sybotan.service.models.responses.SQueryResponse
 import io.swagger.annotations.Api
 import io.swagger.annotations.ApiOperation
 import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.web.bind.annotation.PostMapping
 import org.springframework.web.bind.annotation.RequestBody
 import org.springframework.web.bind.annotation.RequestMapping
@@ -35,6 +37,8 @@ class ProjectController {
     } // Companion object
     
     val projectService = SObjectService(SMybatisDao(Project::class.java))  // 项目
+    @Autowired
+    lateinit var groupProjectService:GroupProjectService  // 项目
 
     /**
      * 创建项目

+ 19 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/models/group/GroupProjectDTO.kt

@@ -0,0 +1,19 @@
+package cn.sagacloud.server.algorithm.models.group
+
+import cn.sagacloud.server.algorithm.models.project.ProjectDTO
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonProperty
+import io.swagger.annotations.ApiModel
+import io.swagger.annotations.ApiModelProperty
+
+/**
+ * 项目
+ * @author  Cainga
+ * @date  2020/12/3 15:50
+ */
+@ApiModel(description = "集团")
+@JsonIgnoreProperties(ignoreUnknown = true)
+open class GroupProjectDTO(/** 集团id */ @ApiModelProperty(value = "集团id") @JsonProperty("groupCode") var groupCode: String?,
+                           /** 集团名称 */ @ApiModelProperty(value = "集团名称") @JsonProperty("groupName") var groupName: String?,
+                           /** 项目列表 */ @ApiModelProperty(value = "项目列表") @JsonProperty("projects") var projects: List<ProjectDTO>?) {
+}

+ 16 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/models/project/ProjectDTO.kt

@@ -0,0 +1,16 @@
+package cn.sagacloud.server.algorithm.models.project
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import io.swagger.annotations.ApiModel
+import io.swagger.annotations.ApiModelProperty
+
+/**
+ * 项目
+ * @author  Cainga
+ * @date  2020/12/3 15:50
+ */
+@ApiModel(description = "项目")
+@JsonIgnoreProperties(ignoreUnknown = true)
+open class ProjectDTO(/** 项目id */ @ApiModelProperty(value = "项目id") val projectId:String?,
+                      /** 项目名称 */ @ApiModelProperty(value = "项目名称")val projectName:String?) {
+}

+ 18 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/models/request/BaseProjectRequest.kt

@@ -0,0 +1,18 @@
+package cn.sagacloud.server.algorithm.models.request
+
+import com.alibaba.fastjson.annotation.JSONField
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties
+import com.fasterxml.jackson.annotation.JsonProperty
+
+/**
+ *
+ *
+ * @author jxing
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+class BaseProjectRequest {
+    @JSONField(name = "projectIds")
+    @JsonProperty("projectIds")
+    // 接收的值为数据中心楼层上的model_id
+    var projectIds : Set<String>? = null
+}

+ 33 - 0
revit-algorithm/src/main/kotlin/cn/sagacloud/server/algorithm/services/group/GroupProjectService.kt

@@ -0,0 +1,33 @@
+package cn.sagacloud.server.algorithm.services.group
+
+import cn.sagacloud.server.algorithm.models.entities.Project
+import cn.sagacloud.server.algorithm.models.group.GroupProjectDTO
+import cn.sagacloud.server.algorithm.models.project.ProjectDTO
+import cn.sagacloud.server.algorithm.models.request.BaseProjectRequest
+import com.sybotan.database.SFilter
+import com.sybotan.mybatis.SMybatisDao
+import com.sybotan.service.SObjectService
+import org.springframework.stereotype.Service
+
+@Service
+class GroupProjectService {
+
+    val projectService = SObjectService(SMybatisDao(Project::class.java))
+
+    /**
+     * 查询集团项目列表
+     */
+    fun queryGroupProjectList(request: BaseProjectRequest):List<GroupProjectDTO> {
+        val projectList:ArrayList<Project>
+        if (!request.projectIds.isNullOrEmpty()){
+            projectList = projectService.select(SFilter.Companion.inList("id", ArrayList(request.projectIds!!))).exec()
+        }else{
+            projectList = projectService.selectAll().exec()
+        }
+        val list:ArrayList<GroupProjectDTO> = ArrayList<GroupProjectDTO>()
+        val map = projectList.groupBy { project: Project -> project.groupCode }
+        map.forEach { (t, u) ->
+            list.add(GroupProjectDTO(t,null,u.map {project -> ProjectDTO(project.id,project.name)})) }
+        return list
+    }
+}

+ 4 - 5
scanbuilding/src/main/kotlin/com/persagy/server/util/GeoToolsUtil.kt

@@ -1,14 +1,13 @@
 package com.persagy.server.util
 
-import org.geotools.geometry.jts.JTSFactoryFinder
-import org.locationtech.jts.geom.LinearRing
 import cn.hutool.core.collection.CollUtil
 import com.fasterxml.jackson.databind.node.ObjectNode
 import com.persagy.server.datacenter.models.entities.assistant.PointPosition
+import org.geotools.geometry.jts.JTSFactoryFinder
 import org.locationtech.jts.geom.Coordinate
+import org.locationtech.jts.geom.LinearRing
 import org.locationtech.jts.geom.Point
 import org.locationtech.jts.geom.Polygon
-import kotlin.collections.ArrayList
 
 /**
  * @ClassName GeoToolsUtil
@@ -27,10 +26,10 @@ object GeoToolsUtil {
         var y = 0.0
         val z = 0.0
         if (pointLocal["X"] != null) {
-            x = pointLocal["X"].doubleValue()
+            x = pointLocal["X"].asDouble()
         }
         if (pointLocal["Y"] != null) {
-            y = pointLocal["Y"].doubleValue()
+            y = pointLocal["Y"].asDouble()
         }
         val geometryFactory = JTSFactoryFinder.getGeometryFactory()
         val coord = Coordinate(x, y, z)