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/ThirdPartyServiceImpl.kt | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImpl.kt index a2cf978..b8288c6 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImpl.kt @@ -1,12 +1,18 @@ package com.flightfeather.uav.lightshare.service.impl import com.flightfeather.uav.biz.datafetch.ShenXinDataFetch +import com.flightfeather.uav.biz.sourcetrace.SourceTraceController import com.flightfeather.uav.common.exception.BizException +import com.flightfeather.uav.domain.repository.MissionRep +import com.flightfeather.uav.domain.repository.RealTimeDataRep +import com.flightfeather.uav.domain.repository.SceneInfoRep +import com.flightfeather.uav.domain.repository.SourceTraceRep import com.flightfeather.uav.lightshare.eunm.ThirdPartyLabel import com.flightfeather.uav.lightshare.service.ThirdPartyService import com.flightfeather.uav.socket.eunm.UWDeviceType import org.springframework.stereotype.Service import java.time.LocalDateTime +import java.util.concurrent.ConcurrentHashMap /** * @@ -14,7 +20,17 @@ * @author feiyu02 */ @Service -class ThirdPartyServiceImpl(private val shenXinDataFetch: ShenXinDataFetch) : ThirdPartyService { +class ThirdPartyServiceImpl( + private val shenXinDataFetch: ShenXinDataFetch, + private val sceneInfoRep: SceneInfoRep, + private val sourceTraceRep: SourceTraceRep, + private val missionRep: MissionRep, + private val realTimeDataRep: RealTimeDataRep, +) : ThirdPartyService { + + // 瀹炴椂璧拌埅姹℃煋婧簮澶勭悊鍣� + private val sourceTraceMap = ConcurrentHashMap<String?, SourceTraceController>() + private val historySourceTraceTask = ConcurrentHashMap<String, Boolean>() override fun fetchMissionData(label: String, missionCode: String): Boolean { when (label) { @@ -31,10 +47,39 @@ ): Boolean { when (label) { ThirdPartyLabel.ShenXin.value -> { - shenXinDataFetch.fetchLatestData(type, deviceCode, startTime, endTime) + val data = shenXinDataFetch.fetchLatestData(type, deviceCode, startTime, endTime) + getSourceTraceCtrl(deviceCode)?.addDataList(data) return true } else -> throw BizException("绗笁鏂规帴鍙f爣璇嗕笉瀛樺湪") } } + + override fun sourceTrace(label: String, missionCode: String): Boolean { + when (label) { + ThirdPartyLabel.ShenXin.value -> { + if (!historySourceTraceTask.containsKey(missionCode)) { + historySourceTraceTask[missionCode] = false + } + if (historySourceTraceTask[missionCode] != true) { + historySourceTraceTask[missionCode] = true + val stc = SourceTraceController(sceneInfoRep, sourceTraceRep) + val mission = missionRep.findOne(missionCode) ?: throw BizException("璧拌埅浠诲姟涓嶅瓨鍦�") + val data = realTimeDataRep.fetchData(mission) + stc.addDataList(data) + } + return true + } + else -> throw BizException("绗笁鏂规帴鍙f爣璇嗕笉瀛樺湪") + } + } + + private fun getSourceTraceCtrl(key: String): SourceTraceController? { + // 姣忓彴璁惧鏈夊悇鑷崟鐙殑寮傚父鏁版嵁澶勭悊鍣� + if (!sourceTraceMap.containsKey(key)) { + sourceTraceMap[key] = SourceTraceController(sceneInfoRep, sourceTraceRep) + } + // 灏嗚蛋鑸暟鎹紶鍏ュ紓甯稿鐞嗗櫒 + return sourceTraceMap[key] + } } \ No newline at end of file -- Gitblit v1.9.3