| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.biz.satellite.SatelliteDataMix |
| | | 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.lightshare.service.SatelliteTelemetryService |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | | import org.springframework.transaction.annotation.Transactional |
| | | import org.springframework.web.multipart.MultipartFile |
| | | import java.io.ByteArrayInputStream |
| | | import java.io.File |
| | |
| | | import java.time.ZoneId |
| | | import java.util.* |
| | | import javax.servlet.http.HttpServletResponse |
| | | import kotlin.math.round |
| | | |
| | | /** |
| | | * |
| | |
| | | * @author feiyu02 |
| | | */ |
| | | @Service |
| | | class SatelliteTelemetryServiceImpl(private val satelliteGridRep: SatelliteGridRep) : SatelliteTelemetryService { |
| | | class SatelliteTelemetryServiceImpl( |
| | | private val satelliteGridRep: SatelliteGridRep, |
| | | private val satelliteDataMix: SatelliteDataMix, |
| | | ) : SatelliteTelemetryService { |
| | | |
| | | private val fileExchange = FileExchange() |
| | | override fun fetchGridGroup(areaVo: AreaVo, page: Int?, perPage: Int?): Pair<DataHead, List<GridGroup?>> { |
| | | val pageInfo = PageHelper.startPage<GridGroup>(page ?: 1, perPage ?: 100) |
| | | val res = satelliteGridRep.fetchGridGroup(areaVo) |
| | | return DataHead(pageInfo.pageNum, pageInfo.pages) to res |
| | | } |
| | | |
| | | override fun deleteGridGroup(groupId: Int) { |
| | | satelliteGridRep.deleteGridGroup(groupId) |
| | | } |
| | | |
| | | override fun fetchGridCell(groupId: Int): List<GridCell?> { |
| | |
| | | } |
| | | |
| | | override fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> { |
| | | return satelliteGridRep.fetchGridDataDetail(dataId, groupId, cellId) |
| | | val res = satelliteGridRep.fetchGridDataDetail(dataId, groupId, cellId) |
| | | res.forEach { |
| | | if (it?.pm25 != null) { |
| | | it.pm25 = round(it.pm25 * 100) / 100 |
| | | } |
| | | } |
| | | return res |
| | | } |
| | | |
| | | @Transactional |
| | | override fun mixGridData(dataIdList: List<Int>): List<GridData?> { |
| | | if (dataIdList.isEmpty()) throw BizException("融合所需数据id不能为空") |
| | | // 1. 根据数据主键id数组,查询该组合下是否已有数据融合记录 |
| | | val exist = satelliteGridRep.fetchGridData(GridData().apply { |
| | | type = 1 |
| | | mixDataId = dataIdList.sorted().joinToString(",") |
| | | }) |
| | | // 2. 若融合数据已存在,直接返回 |
| | | return exist.ifEmpty { |
| | | listOf(satelliteDataMix.mixData(dataIdList).first) |
| | | } |
| | | } |
| | | |
| | | override fun importGridData(groupId: Int, dataTime: LocalDateTime?, update: Boolean, file: MultipartFile): GridDataImportResult? { |
| | |
| | | } |
| | | 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()!! |
| | | }) |
| | | |
| | | 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 |
| | | } |
| | | } |