|
@@ -1,6 +1,7 @@
|
|
|
package cn.sagacloud.server.algorithm.services.endpoint
|
|
|
|
|
|
import cn.sagacloud.server.algorithm.backstage.sync.SyncFloor
|
|
|
+import cn.sagacloud.server.algorithm.backstage.sync.SyncUtil
|
|
|
import cn.sagacloud.server.algorithm.dao.mapper.FloorMapper
|
|
|
import cn.sagacloud.server.algorithm.models.config.MyProperties
|
|
|
import cn.sagacloud.server.algorithm.models.message.MessageType
|
|
@@ -13,6 +14,7 @@ import cn.sagacloud.server.algorithm.services.BaseDataService
|
|
|
import cn.sagacloud.server.algorithm.services.CommonService
|
|
|
import cn.sagacloud.server.algorithm.services.excel.ExcelService
|
|
|
import cn.sagacloud.server.algorithm.services.http.HttpService
|
|
|
+import cn.sagacloud.server.algorithm.services.message.MessageService
|
|
|
import cn.sagacloud.server.algorithm.services.monitor.ModelMonitorService
|
|
|
import com.alibaba.fastjson.JSON
|
|
|
import com.sybotan.database.SFilter
|
|
@@ -52,6 +54,15 @@ class ModelFileService {
|
|
|
@Autowired
|
|
|
lateinit var monitorService: ModelMonitorService
|
|
|
|
|
|
+ @Autowired
|
|
|
+ lateinit var myProperties: MyProperties
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ lateinit var syncUtil : SyncUtil
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ lateinit var messageService: MessageService
|
|
|
+
|
|
|
var dataService = BaseDataService
|
|
|
|
|
|
// /**
|
|
@@ -456,44 +467,54 @@ class ModelFileService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// fun import(floorModelId: String): SBaseResponse {
|
|
|
-//
|
|
|
-// try {
|
|
|
-// val floorModelArr = dataService.floorModelService.select(SFilter.eq("id", floorModelId!!)).exec()
|
|
|
-// if (floorModelArr.size != 1)
|
|
|
-// return
|
|
|
-// val floor = floorModelArr[0]
|
|
|
-// val folderFloorName = CommonService.getReportPrefix(floor)
|
|
|
-// // 获取模型导出的zip文件
|
|
|
-// val objData = monitorService.analyzeJsonz(it.id!!)
|
|
|
-// // 导入数据进数据库
|
|
|
-// val bimIdPrefix = CommonService.generateBIMIDPrefix(it.projectId!!, floor.folderId!!, floor.floorName!!, true)
|
|
|
-// monitorService.persistenceData(it.id!!, objData!!, bimIdPrefix)
|
|
|
-// // excel报告
|
|
|
-// val excelService = SSpringContextUtil.getBean(ExcelService::class.java) as ExcelService
|
|
|
-// excelService.readBlockingExcel2007()
|
|
|
-//
|
|
|
-// val syncFloor = SSpringContextUtil.getBean(SyncFloor::class.java) as SyncFloor
|
|
|
-// syncFloor.init(floor).prepareDataCenterData()
|
|
|
-// // 开始同步设备, 部件, 元空间
|
|
|
-// syncUtil.syncDataWithBindingFloor(syncFloor, it, floor)
|
|
|
-// // 转状态到4
|
|
|
-// it.status = 4
|
|
|
-// dataService.modelFileService.update(it, arrayListOf("status"))
|
|
|
-// val message = messageService.buildMessageEntityWithoutLink("${folderFloorName.first}的${folderFloorName.second}模型上传成功", MessageType.Success, it.projectId, arrayListOf(it.userId?:""), "")
|
|
|
-// messageService.sendMessage(message)
|
|
|
-// } catch (e: Exception) {
|
|
|
-// // 转状态到31
|
|
|
-// try {
|
|
|
-// it.status = 31
|
|
|
-// it.syncRetryDate = Date()
|
|
|
-// it.syncErrorMsg = e.message + CommonService.getStackTrace(e)
|
|
|
-// dataService.modelFileService.update(it, arrayListOf("status", "syncRetryDate", "syncErrorMsg"))
|
|
|
-// }catch (e : Exception){}
|
|
|
-// e.printStackTrace()
|
|
|
-// logger.error(e.message)
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
+ fun import(floorModelId: String): SBaseResponse {
|
|
|
+ val floorModelArr = dataService.floorModelService.select(SFilter.eq("id", floorModelId!!)).exec()
|
|
|
+
|
|
|
+ if (floorModelArr.size != 1)
|
|
|
+ return SBaseResponse(SResponseType.failure,"楼层不存在")
|
|
|
+ val floor = floorModelArr[0]
|
|
|
+ if(floor.currentModelId.isNullOrEmpty()){
|
|
|
+ return SBaseResponse(SResponseType.failure,"楼层没绑模型")
|
|
|
+ }
|
|
|
+
|
|
|
+ val modelFile = dataService.modelFileService.select(SFilter.eq("id",floor.currentModelId!!)).entity()
|
|
|
+ if(modelFile == null){
|
|
|
+ return SBaseResponse(SResponseType.failure,"模型不存在")
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ val folderFloorName = CommonService.getReportPrefix(floor)
|
|
|
+ // 获取模型导出的zip文件
|
|
|
+ val objData = monitorService.analyzeJsonz(floor.currentModelId!!)
|
|
|
+ // 导入数据进数据库
|
|
|
+ val bimIdPrefix = CommonService.generateBIMIDPrefix(modelFile.id!!, floor.folderId!!, floor.floorName!!, true)
|
|
|
+ monitorService.persistenceData(floor.currentModelId!!, objData!!, bimIdPrefix)
|
|
|
+ // excel报告
|
|
|
+ val excelService = SSpringContextUtil.getBean(ExcelService::class.java) as ExcelService
|
|
|
+ excelService.readBlockingExcel2007()
|
|
|
+
|
|
|
+ val syncFloor = SSpringContextUtil.getBean(SyncFloor::class.java) as SyncFloor
|
|
|
+ syncFloor.init(floor).prepareDataCenterData()
|
|
|
+ // 开始同步设备, 部件, 元空间
|
|
|
+ syncUtil.syncDataWithBindingFloor(syncFloor, modelFile, floor)
|
|
|
+ // 转状态到4
|
|
|
+ modelFile.status = 4
|
|
|
+ dataService.modelFileService.update(modelFile, arrayListOf("status"))
|
|
|
+ val message = messageService.buildMessageEntityWithoutLink("${folderFloorName.first}的${folderFloorName.second}模型上传成功", MessageType.Success, modelFile.projectId, arrayListOf(modelFile.userId?:""), "")
|
|
|
+ messageService.sendMessage(message)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // 转状态到31
|
|
|
+ try {
|
|
|
+ modelFile.status = 31
|
|
|
+ modelFile.syncRetryDate = Date()
|
|
|
+ modelFile.syncErrorMsg = e.message + CommonService.getStackTrace(e)
|
|
|
+ dataService.modelFileService.update(modelFile, arrayListOf("status", "syncRetryDate", "syncErrorMsg"))
|
|
|
+ }catch (e : Exception){}
|
|
|
+ e.printStackTrace()
|
|
|
+ logger.error(e.message)
|
|
|
+ }
|
|
|
+ return SBaseResponse(SResponseType.success,"")
|
|
|
+ }
|
|
|
|
|
|
}
|