From 344d9006faa27ea65e3eaf5e8f9173aad2266038 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 23 七月 2025 17:23:53 +0800 Subject: [PATCH] 2025.7.23 1. 动态溯源模块完成,发布 --- src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt | 97 ++++++++++++++++++++++++++++++------------------ 1 files changed, 60 insertions(+), 37 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt index 3e24c07..33c310e 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt @@ -4,15 +4,12 @@ import com.flightfeather.uav.biz.satellite.SatelliteGridManage import com.flightfeather.uav.common.exception.BizException import com.flightfeather.uav.common.utils.FileExchange -import com.flightfeather.uav.domain.entity.GridAod -import com.flightfeather.uav.domain.entity.GridCell -import com.flightfeather.uav.domain.entity.GridData -import com.flightfeather.uav.domain.entity.GridDataDetail -import com.flightfeather.uav.domain.entity.GridGroup +import com.flightfeather.uav.domain.entity.* 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.eunm.SatelliteDataType import com.flightfeather.uav.lightshare.service.SatelliteTelemetryService import com.github.pagehelper.PageHelper import org.springframework.stereotype.Service @@ -38,10 +35,15 @@ ) : SatelliteTelemetryService { private val fileExchange = FileExchange() - override fun fetchGridGroup(areaVo: AreaVo, page: Int?, perPage: Int?): Pair<DataHead, List<GridGroup?>> { + override fun fetchGridGroup(areaVo: AreaVo, type: String?, page: Int?, perPage: Int?): Pair<DataHead, + List<GridGroup?>> { val pageInfo = PageHelper.startPage<GridGroup>(page ?: 1, perPage ?: 100) - val res = satelliteGridRep.fetchGridGroup(areaVo) + val res = satelliteGridRep.fetchGridGroup(areaVo, type) return DataHead(pageInfo.pageNum, pageInfo.pages) to res + } + + override fun deleteGridGroup(groupId: Int) { + satelliteGridRep.deleteGridGroup(groupId) } override fun fetchGridCell(groupId: Int): List<GridCell?> { @@ -52,18 +54,60 @@ return satelliteGridRep.fetchGridData(groupId, dataTime, type) } - override fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { - return satelliteGridRep.fetchGridAod(groupId, dataTime) + override fun fetchGridData(gridData: GridData): List<GridData?> { + return satelliteGridRep.fetchGridData(gridData) + } + + override fun deleteGridData(dataId: Int): Boolean { + try { + satelliteGridRep.deleteGridData(dataId) + } catch (e: Exception) { + // todo: 鍔犲叆鏃ュ織瀛樺偍閫昏緫 + return false + } + return true } override fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> { val res = satelliteGridRep.fetchGridDataDetail(dataId, groupId, cellId) res.forEach { if (it?.pm25 != null) { - it.pm25 = round(it.pm25 * 100) / 100 + it.pm25 = round(it.pm25 * 10) / 10 } } return res + } + + @Transactional + override fun createGridDataAndDataDetail( + groupId: Int, + dataTime: LocalDateTime?, + gridDataDetail: List<GridDataDetail>, + ): Boolean { + // 淇濆瓨鎷熷悎鐨勫崼鏄熼仴娴嬫暟鎹� type濮嬬粓涓�0 + val type = SatelliteDataType.Original.value + + // 鏌ユ壘鏄惁鏈夊巻鍙茶褰� + val gridData = satelliteGridRep.fetchGridData(groupId, dataTime, type) + // 鏃犲巻鍙茶褰曞垯鍒涘缓鏁版嵁绱㈠紩GridData锛屼箣鍚庡啀瀛樺叆鎷熷悎鐨勬暟鎹� + if (gridData.isEmpty()) { + val gridDataEntity = GridData() + gridDataEntity.groupId = groupId + gridDataEntity.dataTime = dataTime?.atZone(ZoneId.systemDefault())?.toInstant()?.toEpochMilli() + ?.let { Date(it) } + gridDataEntity.type = type.toByte() + satelliteGridRep.insertGridDataAndDetail(gridDataEntity, gridDataDetail) + } + // 鏇存柊鍘嗗彶鏁版嵁 + else { + gridDataDetail.forEach { + it.dataId = gridData[0]?.id + it.groupId = gridData[0]?.groupId + } + satelliteGridRep.updatePM25Batch(gridDataDetail) + } + + return true } @Transactional @@ -72,7 +116,7 @@ // 1. 鏍规嵁鏁版嵁涓婚敭id鏁扮粍锛屾煡璇㈣缁勫悎涓嬫槸鍚﹀凡鏈夋暟鎹瀺鍚堣褰� val exist = satelliteGridRep.fetchGridData(GridData().apply { type = 1 - mixDataId = dataIdList.joinToString(",") + mixDataId = dataIdList.sorted().joinToString(",") }) // 2. 鑻ヨ瀺鍚堟暟鎹凡瀛樺湪锛岀洿鎺ヨ繑鍥� return exist.ifEmpty { @@ -206,32 +250,11 @@ return true } - override fun calGridVertex(groupId: Int): List<GridCell?> { - val cellList = satelliteGridRep.fetchGridCell(groupId) - val vertexList = SatelliteGridManage.calGridVertex(cellList.map { - if (it?.longitude == null || it.latitude == null) { - throw BizException("鍗槦閬ユ祴缃戞牸璁$畻椤剁偣鍧愭爣鐐瑰け璐ワ紝瀛樺湪涓績鐐瑰潗鏍囦负绌虹殑鎯呭喌") - } - it.longitude?.toDouble()!! to it.latitude?.toDouble()!! - }) + override fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { + return satelliteGridRep.fetchGridAod(groupId, dataTime) + } - cellList.forEachIndexed { i, c -> - val v = vertexList[i] - c?.point1Lon = v.point1Lon.toBigDecimal() - c?.point1Lat = v.point1Lat.toBigDecimal() - - c?.point2Lon = v.point2Lon.toBigDecimal() - c?.point2Lat = v.point2Lat.toBigDecimal() - - c?.point3Lon = v.point3Lon.toBigDecimal() - c?.point3Lat = v.point3Lat.toBigDecimal() - - c?.point4Lon = v.point4Lon.toBigDecimal() - c?.point4Lat = v.point4Lat.toBigDecimal() - } - - satelliteGridRep.updateGridCellBatch(cellList) - - return cellList + override fun fetchGridAODDetail(aodId: Int, groupId: Int?, cellId: Int?): List<GridAodDetail?> { + return satelliteGridRep.fetchGridAodDetail(aodId, groupId, cellId) } } \ No newline at end of file -- Gitblit v1.9.3