| | |
| | | import com.flightfeather.uav.domain.repository.SatelliteGridRep |
| | | import com.flightfeather.uav.lightshare.bean.AreaVo |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.bean.GridDataImportResult |
| | | import com.flightfeather.uav.lightshare.service.SatelliteTelemetryService |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | |
| | | return satelliteGridRep.fetchGridDataDetail(dataId, groupId, cellId) |
| | | } |
| | | |
| | | override fun importGridData(groupId: Int, dataTime: LocalDateTime?, update: Boolean, file: MultipartFile): GridDataImportResult? { |
| | | override fun importGridData(groupId: Int, dataTime: LocalDateTime?, update: Boolean, file: MultipartFile): Boolean? { |
| | | // 因为是导入卫星遥测数据 type始终为0 |
| | | val type = 0 |
| | | // 首先判断文件类型,文件类型不是xlsx直接报错 |
| | |
| | | val gridData = satelliteGridRep.fetchGridData(groupId, dataTime, type) |
| | | // 将用户导入的文件转换为数据 |
| | | // 转换的过程需要网格单元格数据 以判断网格单元格是否在正确的范围内 |
| | | val gridCellsInDBSet = satelliteGridRep.fetchGridCell(groupId).asSequence().map { it?.id ?: -1 }.toSet() |
| | | val gridCellsInDBSet = satelliteGridRep.fetchGridCell(groupId).map { it?.id ?: -1 }.toSet() |
| | | val importData |
| | | = fileExchange.exchangeGridData(ByteArrayInputStream(file.bytes), gridCellsInDBSet) |
| | | if (update) { |
| | |
| | | it.groupId = gridData[0]?.groupId |
| | | } |
| | | satelliteGridRep.updatePM25Batch(importData) |
| | | return GridDataImportResult(true, "覆盖成功") |
| | | return true |
| | | }else { |
| | | // 用户需要执行插入 |
| | | if (gridData.isNotEmpty()) { |
| | |
| | | ?.let { Date(it) } |
| | | gridDataEntity.type = type.toByte() |
| | | satelliteGridRep.insertGridDataAndDetail(gridDataEntity, importData) |
| | | return GridDataImportResult(true, "导入成功") |
| | | return true |
| | | } |
| | | } |
| | | |
| | |
| | | dataTime: LocalDateTime?, |
| | | update: Boolean, |
| | | file: MultipartFile |
| | | ): GridDataImportResult? { |
| | | ): Boolean? { |
| | | // 首先判断文件类型,文件类型不是xlsx直接报错 |
| | | if (!file.contentType!!.startsWith("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) { |
| | | throw BizException("文件类型错误,请上传xlsx类型文件") |
| | |
| | | val gridAod = satelliteGridRep.fetchGridAod(groupId, dataTime) |
| | | // 将用户导入的文件转换为数据 |
| | | // 转换的过程需要网格单元格数据 以判断网格单元格是否在正确的范围内 |
| | | val gridCellsInDBSet = satelliteGridRep.fetchGridCell(groupId).asSequence().map { it?.id ?: -1 }.toSet() |
| | | val gridCellsInDBSet = satelliteGridRep.fetchGridCell(groupId).map { it?.id ?: -1 }.toSet() |
| | | val importAod |
| | | = fileExchange.exchangeGridAod(ByteArrayInputStream(file.bytes), gridCellsInDBSet) |
| | | if (update) { |
| | |
| | | it.groupId = gridAod[0]?.groupId |
| | | } |
| | | satelliteGridRep.updateGridAodBatch(importAod) |
| | | return GridDataImportResult(true, "覆盖成功") |
| | | return true |
| | | }else { |
| | | // 用户需要执行插入 |
| | | if (gridAod.isNotEmpty()) { |
| | |
| | | gridAodEntity.dataTime = dataTime?.atZone(ZoneId.systemDefault())?.toInstant()?.toEpochMilli() |
| | | ?.let { Date(it) } |
| | | satelliteGridRep.insertGridAodAndDetail(gridAodEntity, importAod) |
| | | return GridDataImportResult(true, "导入成功") |
| | | return true |
| | | } |
| | | } |
| | | |