From 9d4ca2e7bdfc0d634b0cc27c7fbe23740f4bb398 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期五, 27 十二月 2024 15:43:30 +0800 Subject: [PATCH] 1. 新增aod数据索引,aod详细数据实体类,mapper,service 2. 新增卫星遥测数据网格数据pm2.5、aod数据导入,模板下载 3. FileExchange.kt 新增转换pm2.5和aod数据方法 --- src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt index ae74aed..4bf03aa 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt @@ -1,19 +1,21 @@ package com.flightfeather.uav.lightshare.service.impl -import com.flightfeather.uav.common.exception.ResponseErrorException +import com.flightfeather.uav.common.exception.BizException import com.flightfeather.uav.common.scaleMap import com.flightfeather.uav.common.utils.DateUtil import com.flightfeather.uav.common.utils.ExcelUtil import com.flightfeather.uav.common.utils.FileExchange -import com.flightfeather.uav.common.utils.GsonUtils -import com.flightfeather.uav.dataprocess.AverageUtil +import com.flightfeather.uav.biz.dataprocess.AverageUtil +import com.flightfeather.uav.common.location.TrackSegment import com.flightfeather.uav.domain.entity.* import com.flightfeather.uav.domain.mapper.* +import com.flightfeather.uav.domain.repository.MissionRep +import com.flightfeather.uav.domain.repository.RealTimeDataRep +import com.flightfeather.uav.domain.repository.SegmentInfoRep import com.flightfeather.uav.lightshare.bean.* import com.flightfeather.uav.lightshare.service.RealTimeDataService import com.flightfeather.uav.model.epw.EPWDataPrep import com.flightfeather.uav.repository.AirDataRepository -import com.flightfeather.uav.socket.bean.AirData import com.flightfeather.uav.socket.eunm.UWDeviceType import com.github.pagehelper.PageHelper import org.apache.poi.xssf.streaming.SXSSFWorkbook @@ -30,7 +32,6 @@ import java.time.format.DateTimeFormatter import java.util.* import javax.servlet.http.HttpServletResponse -import javax.swing.text.DateFormatter import kotlin.math.sqrt @Service @@ -43,6 +44,9 @@ private val realTimeDataGridOptMapper: RealTimeDataGridOptMapper, private val realTimeDataGridMinMapper: RealTimeDataGridMinMapper, private val missionMapper: MissionMapper, + private val missionRep: MissionRep, + private val realTimeDataRep: RealTimeDataRep, + private val segmentInfoRep: SegmentInfoRep, ) : RealTimeDataService { @Value("\${filePath}") @@ -53,6 +57,7 @@ private val fileExchange = FileExchange() override fun getSecondData( + deviceType: String?, deviceCode: String?, startTime: String?, endTime: String?, @@ -69,7 +74,12 @@ var pages = 0 val result = mutableListOf<DataVo>() - when (UWDeviceType.getType(deviceCode)) { + val _deviceType = if (deviceType != null) { + UWDeviceType.fromValue(deviceType) + } else { + UWDeviceType.getType(deviceCode) + } + when (_deviceType) { UWDeviceType.VEHICLE -> { val pageInfo = PageHelper.startPage<RealTimeDataVehicle>(_page, _perPage) realTimeDataVehicleMapper.selectByExample(Example(RealTimeDataVehicle::class.java).apply { @@ -184,6 +194,31 @@ example.orderBy("dataTime") } + override fun getSegmentData(missionCode: String): List<List<DataVo>> { + val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�") + val data = realTimeDataRep.fetchData(mission) + + val segInfo = SegmentInfo().apply { this.missionCode = missionCode } + val segList = segmentInfoRep.findList(segInfo) +// return TrackSegment.segmentWithRoad(data).map { it.map { b -> b.toDataVo() } } + val res = mutableListOf<MutableList<DataVo>>() + res.add(mutableListOf()) + var index = 0 + data.forEach { + if (it.dataTime == null) return@forEach + if (it.dataTime!! <= segList[index]?.endTime) { + res[index].add(it.toDataVo()) + if (it.dataTime!! == segList[index]?.endTime) { + index++ + res.add(mutableListOf()) + } + } + } + // 绉婚櫎鏈�鍚庝竴涓┖闆嗗悎 + if (res.last().isEmpty()) res.removeLast() + return res + } + override fun importData(file: MultipartFile): BaseResponse<DataImportResult> { val f = ByteArrayInputStream(file.bytes) fileExchange.exchangeBoatData("0c0000000001", f).forEach { @@ -194,6 +229,7 @@ override fun importJinanData(code: String, file: MultipartFile): DataImportResult { val f = ByteArrayInputStream(file.bytes) +// val result = fileExchange.exchangeVehicleData(code, f) val result = fileExchange.exchangeJinanData(code, f) if (result.isNotEmpty()) { val first = result.first() @@ -205,7 +241,7 @@ deviceType = UWDeviceType.getType(code)?.value deviceCode = code } - missionMapper.selectOne(mission)?.run { throw ResponseErrorException("璇ヨ澶囪鏃舵浠诲姟宸插瓨鍦紝鏃犳硶閲嶅瀵煎叆") } + missionMapper.selectOne(mission)?.run { throw BizException("璇ヨ澶囪鏃舵浠诲姟宸插瓨鍦紝鏃犳硶閲嶅瀵煎叆") } mission.apply { startTime = first.dataTime endTime = last.dataTime @@ -376,7 +412,7 @@ val averageUtil = AverageUtil<RealTimeDataGridOpt, RealTimeDataGridMin>({ d -> minFormatter.format(d.dataTime) }, { list -> - list.avg() + list.avg() as RealTimeDataGridMin }) while (total == -1 || page <= total) { -- Gitblit v1.9.3