| | |
| | | <artifactId>jfreechart</artifactId> |
| | | <version>1.5.3</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>commons-httpclient</groupId> |
| | | <artifactId>commons-httpclient</artifactId> |
| | | <version>3.0</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.domain.entity.BaseRealTimeData |
| | | import com.flightfeather.uav.domain.entity.avg |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import java.time.Duration |
| | | |
| | |
| | | startData = start.getByFactorType(factor.main) |
| | | endData = end?.getByFactorType(factor.main) ?: startData |
| | | |
| | | val avgData = exceptionData.avg() |
| | | // æ±åæ±¡ææ°æ®çä¸å¿åæ |
| | | longitude = avgData.longitude |
| | | latitude = avgData.latitude |
| | | // æ±å主污æå åçåå¼åèå´ |
| | | val s = dataSummary(exceptionData, factor.main) |
| | | avg = s.first |
| | | min = s.second |
| | |
| | | } |
| | | } |
| | | |
| | | fun dataSummary(exceptionData: List<BaseRealTimeData?>, factorType: FactorType): Triple<Float, Float, Float> { |
| | | private fun dataSummary(exceptionData: List<BaseRealTimeData?>, factorType: FactorType): Triple<Float, Float, Float> { |
| | | var min = -1f |
| | | var max = -1f |
| | | var total = 0f |
| | |
| | | import com.flightfeather.uav.biz.dataanalysis.model.DataAnalysisConfig |
| | | import com.flightfeather.uav.biz.dataanalysis.model.ExceptionResult |
| | | import com.flightfeather.uav.biz.dataanalysis.model.ExceptionSetting |
| | | import com.flightfeather.uav.common.location.LocationRoadNearby |
| | | import com.flightfeather.uav.domain.entity.Mission |
| | | import com.flightfeather.uav.domain.repository.RealTimeDataRep |
| | | import org.springframework.stereotype.Component |
| | |
| | | @Component |
| | | class ExceptionAnalysisController( |
| | | private val realTimeDataRep: RealTimeDataRep, |
| | | private val locationRoadNearby: LocationRoadNearby, |
| | | ) { |
| | | |
| | | var running = false |
| | |
| | | private fun initTask(config: DataAnalysisConfig) { |
| | | taskList.clear() |
| | | taskList.apply { |
| | | // add(ExceptionDataExceed(config)) |
| | | // add(ExceptionValueMutation(config)) |
| | | add(ExceptionDataExceed(config)) |
| | | add(ExceptionValueMutation(config)) |
| | | add(ExceptionSlideAverage(config)) |
| | | } |
| | | } |
| | | |
| | | fun run(mission: Mission, factorFilter: FactorFilter): List<ExceptionResult> { |
| | | running = true |
| | | val config = DataAnalysisConfig(mission, ExceptionSetting(), 8, factorFilter) |
| | | val config = DataAnalysisConfig(mission, ExceptionSetting(), factorFilter) |
| | | initTask(config) |
| | | |
| | | val result = mutableListOf<ExceptionResult>() |
| | |
| | | } |
| | | // å个å¼å¸¸åæåå«ç»æ |
| | | taskList.forEach { it.onDone() } |
| | | // åå¨åæç»æ |
| | | |
| | | taskList.forEach { |
| | | // æ¥è¯¢å¼å¸¸å¨è¾¹å¯è½æ±¡ææº |
| | | it.resultList.forEach { r-> |
| | | if (r.longitude != null && r.latitude != null) { |
| | | val sceneList = locationRoadNearby.searchByRadius( |
| | | r.longitude!!.toDouble() to r.latitude!!.toDouble(), config.radius) |
| | | if (sceneList.isNotEmpty()) { |
| | | val idList = mutableListOf<String>() |
| | | val nameList = mutableListOf<String>() |
| | | sceneList.forEach { s-> |
| | | idList.add(s?.guid?:"") |
| | | nameList.add(s?.name ?: "") |
| | | } |
| | | r.relatedSceneId = idList |
| | | r.relatedSceneName = nameList |
| | | } |
| | | } |
| | | } |
| | | // åå¨åæç»æ |
| | | result.addAll(it.resultList) |
| | | } |
| | | running = false |
| | |
| | | val mission: Mission, |
| | | // æ°æ®å¼å¸¸é
ç½® |
| | | val exceptionSetting: ExceptionSetting, |
| | | // æ¶åçæµå åæ°é |
| | | val factorCount: Int, |
| | | // å åçé |
| | | val factorFilter: FactorFilter, |
| | | ){ |
| | |
| | | var changeTrendRate = 1 |
| | | // æ»å¨å¹³åå¼ååçå¼å¸¸è¿ç»æ¬¡æ° |
| | | var changeTrendTimes = 3 |
| | | |
| | | // å¼å¸¸å¨è¾¹å¯è½æ±¡ææºæ¥è¯¢èå´åå¾ï¼ç±³ï¼ |
| | | var radius = 500.0 |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.common.net |
| | | |
| | | /** |
| | | * é«å¾·å°å¾Webæå¡API |
| | | */ |
| | | object AMapService { |
| | | |
| | | private val httpMethod = HttpMethod("restapi.amap.com", 443, true) |
| | | private val KEY = "" |
| | | |
| | | /** |
| | | * å°çéç¼ç |
| | | */ |
| | | fun reGeo(location:List<Pair<Double, Double>>) { |
| | | httpMethod.get("v3/geocode/regeo", listOf( |
| | | |
| | | )) |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.common.net |
| | | |
| | | import org.apache.commons.httpclient.HttpClient |
| | | import org.apache.commons.httpclient.HttpMethodBase |
| | | import org.apache.commons.httpclient.methods.GetMethod |
| | | import org.apache.commons.httpclient.methods.PostMethod |
| | | import org.apache.commons.httpclient.methods.StringRequestEntity |
| | | import org.apache.commons.httpclient.protocol.Protocol |
| | | import org.slf4j.LoggerFactory |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2020/10/14 |
| | | */ |
| | | class HttpMethod( |
| | | private val host: String, private val port: Int, private val isHttps: Boolean = false |
| | | ) { |
| | | private val logger = LoggerFactory.getLogger(HttpMethod::class.java) |
| | | |
| | | data class MyResponse( |
| | | val success: Boolean, |
| | | val m: HttpMethodBase |
| | | ) |
| | | |
| | | object Head { |
| | | val TEXT_PLAIN = Pair("Content-Type", "text/plain") |
| | | } |
| | | |
| | | private val httpClient = HttpClient() |
| | | |
| | | init { |
| | | Protocol.registerProtocol("https", Protocol("https", SkipCertificateValidation.MySecureProtocolSocketFactory(), port)) |
| | | if (isHttps) { |
| | | httpClient.hostConfiguration.setHost(host, port, Protocol.getProtocol("https")) |
| | | } else { |
| | | httpClient.hostConfiguration.setHost(host, port) |
| | | } |
| | | } |
| | | |
| | | fun get(url: String, params: List<Pair<String, String>> = emptyList(), headers: List<Pair<String, String>> = emptyList()): MyResponse { |
| | | var p: String = "" |
| | | params.forEach { |
| | | p += if (p.isBlank()) { |
| | | it.first + "=" + it.second |
| | | } else { |
| | | "&" + it.first + "=" + it.second |
| | | } |
| | | } |
| | | val getMethod = GetMethod("$url?$p") |
| | | defaultConfig(getMethod) |
| | | headers.forEach { |
| | | getMethod.setRequestHeader(it.first, it.second) |
| | | } |
| | | |
| | | return when (httpClient.executeMethod(getMethod)) { |
| | | 200 -> MyResponse(true, getMethod) |
| | | else -> MyResponse(false, getMethod) |
| | | } |
| | | } |
| | | |
| | | fun post(url: String, data: String = "", headers: List<Pair<String, String>> = emptyList()): MyResponse { |
| | | val postMethod = PostMethod(url) |
| | | defaultConfig(postMethod) |
| | | headers.forEach { |
| | | postMethod.setRequestHeader(it.first, it.second) |
| | | } |
| | | if (data.isNotBlank()) { |
| | | postMethod.requestEntity = StringRequestEntity(data, "application/json", "utf-8") |
| | | } |
| | | |
| | | return try { |
| | | when (httpClient.executeMethod(postMethod)) { |
| | | 200 -> MyResponse(true, postMethod) |
| | | else -> MyResponse(false, postMethod) |
| | | } |
| | | } catch (e: Exception) { |
| | | logger.error(e.message) |
| | | MyResponse(false, postMethod) |
| | | } |
| | | } |
| | | |
| | | private fun defaultConfig(method: HttpMethodBase) { |
| | | method.setRequestHeader("Accept", "*/*"); |
| | | method.setRequestHeader("Connection", "Keep-Alive"); |
| | | // method.setRequestHeader("Accept-Language", "zh-cn,zh;q=0.5"); |
| | | method.setRequestHeader("Accept-Encoding", "gzip,deflate,br"); |
| | | // method.setRequestHeader("Content-Type", "application/json;charset=utf-8") |
| | | method.setRequestHeader("Content-Type", "application/json") |
| | | // method.setRequestHeader("Content-Type", "application/json;charset=GBK") |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.common.net |
| | | |
| | | import org.apache.commons.httpclient.ConnectTimeoutException |
| | | import org.apache.commons.httpclient.HttpClientError |
| | | import org.apache.commons.httpclient.params.HttpConnectionParams |
| | | import org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory |
| | | import org.apache.commons.httpclient.protocol.ProtocolSocketFactory |
| | | import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory |
| | | import java.io.IOException |
| | | import java.net.InetAddress |
| | | import java.net.Socket |
| | | import java.net.UnknownHostException |
| | | import java.security.cert.CertificateException |
| | | import java.security.cert.X509Certificate |
| | | import javax.net.ssl.* |
| | | |
| | | |
| | | /** |
| | | * éè¿java è¿è¡è®¿é®ææ¶å伿è¯ä¹¦è¿è¡æ¦æª |
| | | */ |
| | | object SkipCertificateValidation { |
| | | /** |
| | | * 忽ç¥HTTPS请æ±çSSLè¯ä¹¦ï¼å¿
é¡»å¨openConnectionä¹åè°ç¨ |
| | | * @throws Exception |
| | | */ |
| | | @Throws(Exception::class) |
| | | fun ignoreSsl() { |
| | | val hv = HostnameVerifier { urlHostName, session -> |
| | | println("Warning: URL Host: " + urlHostName + " vs. " + session.peerHost) |
| | | true |
| | | } |
| | | trustAllHttpsCertificates() |
| | | HttpsURLConnection.setDefaultHostnameVerifier(hv) |
| | | } |
| | | |
| | | @Throws(Exception::class) |
| | | private fun trustAllHttpsCertificates() { |
| | | val trustAllCerts = arrayOfNulls<TrustManager>(1) |
| | | val tm: TrustManager = MiTM() |
| | | trustAllCerts[0] = tm |
| | | val sc = SSLContext.getInstance("SSL") |
| | | sc.init(null, trustAllCerts, null) |
| | | HttpsURLConnection.setDefaultSSLSocketFactory(sc.socketFactory) |
| | | } |
| | | |
| | | internal class MiTM : X509TrustManager { |
| | | override fun getAcceptedIssuers(): Array<X509Certificate>? { |
| | | return null |
| | | } |
| | | |
| | | @Throws(CertificateException::class) |
| | | override fun checkServerTrusted(certs: Array<X509Certificate>, authType: String) { |
| | | return |
| | | } |
| | | |
| | | @Throws(CertificateException::class) |
| | | override fun checkClientTrusted(certs: Array<X509Certificate>, authType: String) { |
| | | return |
| | | } |
| | | } |
| | | |
| | | class MySecureProtocolSocketFactory : ProtocolSocketFactory { |
| | | //è¿éæ·»å ä¸ä¸ªå±æ§ï¼ä¸»è¦ç®çå°±æ¯æ¥è·åsslè·³è¿éªè¯ |
| | | private var sslContext: SSLContext? = null |
| | | |
| | | /** |
| | | * 夿è·åSSLContext |
| | | * @return |
| | | */ |
| | | private val sSLContext: SSLContext? |
| | | get() { |
| | | if (sslContext == null) { |
| | | sslContext = createEasySSLContext() |
| | | } |
| | | return sslContext |
| | | } |
| | | |
| | | //åé¢çæ¹æ³åºæ¬ä¸å°±æ¯å¸¦å
¥ç¸å
³åæ°å°±å¯ä»¥äº |
| | | /* |
| | | * (non-Javadoc) |
| | | * |
| | | * @see org.apache.commons.httpclient.protocol.ProtocolSocketFactory#createSocket(java.lang.String, |
| | | * int, java.net.InetAddress, int) |
| | | */ |
| | | @Throws(IOException::class, UnknownHostException::class) |
| | | override fun createSocket(host: String, port: Int, clientHost: InetAddress?, clientPort: Int): Socket { |
| | | return sSLContext!!.socketFactory.createSocket(host, port, clientHost, clientPort) |
| | | } |
| | | |
| | | /* |
| | | * (non-Javadoc) |
| | | * |
| | | * @see org.apache.commons.httpclient.protocol.ProtocolSocketFactory#createSocket(java.lang.String, |
| | | * int, java.net.InetAddress, int, |
| | | * org.apache.commons.httpclient.params.HttpConnectionParams) |
| | | */ |
| | | @Throws(IOException::class, UnknownHostException::class, ConnectTimeoutException::class) |
| | | override fun createSocket( |
| | | host: String, port: Int, localAddress: InetAddress?, localPort: Int, |
| | | params: HttpConnectionParams? |
| | | ): Socket { |
| | | requireNotNull(params) { "Parameters may not be null" } |
| | | val timeout: Int = params.connectionTimeout |
| | | return if (timeout == 0) { |
| | | createSocket(host, port, localAddress, localPort) |
| | | } else { |
| | | ControllerThreadSocketFactory.createSocket(this, host, port, localAddress, localPort, timeout) |
| | | } |
| | | } |
| | | |
| | | /* |
| | | * (non-Javadoc) |
| | | * |
| | | * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) |
| | | */ |
| | | @Throws(IOException::class, UnknownHostException::class) |
| | | override fun createSocket(host: String, port: Int): Socket { |
| | | return sSLContext!!.socketFactory.createSocket(host, port) |
| | | } |
| | | |
| | | /* |
| | | * (non-Javadoc) |
| | | * |
| | | * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean) |
| | | */ |
| | | // @Throws(IOException::class, UnknownHostException::class) |
| | | // override fun createSocket(socket: Socket?, host: String?, port: Int, autoClose: Boolean): Socket { |
| | | // return sSLContext!!.socketFactory.createSocket(socket, host, port, autoClose) |
| | | // } |
| | | |
| | | companion object { |
| | | /** |
| | | * è¿ä¸ªå建ä¸ä¸ªè·åSSLContextçæ¹æ³ï¼å¯¼å
¥MyX509TrustManagerè¿è¡åå§å |
| | | * @return |
| | | */ |
| | | private fun createEasySSLContext(): SSLContext { |
| | | return try { |
| | | val context = SSLContext.getInstance("SSL") |
| | | context.init( |
| | | null, arrayOf(MiTM()), |
| | | null |
| | | ) |
| | | context |
| | | } catch (e: Exception) { |
| | | throw HttpClientError(e.toString()) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.flightfeather.uav.domain.entity |
| | | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.biz.dataprocess.AvgPair |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | |
| | | import java.util.* |
| | | import javax.persistence.Column |
| | | import javax.persistence.Id |
| | | import kotlin.math.* |
| | | import kotlin.math.atan |
| | | import kotlin.math.cos |
| | | import kotlin.math.round |
| | | import kotlin.math.sin |
| | | |
| | | /** |
| | | * 宿¶çæµæ°æ®åºç±» |
| | |
| | | |
| | | } |
| | | |
| | | fun List<BaseRealTimeData>.avg(): RealTimeDataGridMin { |
| | | fun List<BaseRealTimeData>.avg(): BaseRealTimeData { |
| | | //é£åéç¨åä½ç¢éæ³æ±ååå¼ |
| | | var u = .0//ä¸è¥¿æ¹ä½åéæ»å |
| | | var v = .0//ååæ¹ä½åéæ»å |
| | |
| | | val averageUtil = AverageUtil<RealTimeDataGridOpt, RealTimeDataGridMin>({ d -> |
| | | minFormatter.format(d.dataTime) |
| | | }, { list -> |
| | | list.avg() |
| | | list.avg() as RealTimeDataGridMin |
| | | }) |
| | | |
| | | while (total == -1 || page <= total) { |
| | |
| | | <w:szCs w:val="28" /> |
| | | <w:lang w:val="en-US" w:eastAsia="zh-CN" /> |
| | | </w:rPr> |
| | | <w:t>${item_index + 1}. ä»${item.startTime}è³${item.endTime}ï¼${item.factorName}åºç°${item.exception}<#if item.relatedSceneName??>ï¼ç»åçæµæ°æ®ååååç¹ååæº¯æºï¼<#list item.relatedSceneName as scene>${scene}ã</#list>çå¯è½å卿±¡æé£é©ã<#else>ã</#if></w:t> |
| | | <w:t>${item_index + 1}. ä»${item.startTime}è³${item.endTime}ï¼${item.factorName}åºç°${item.exception}<#if item.relatedSceneName??>ï¼ç»åçæµæ°æ®ååååç¹ååæº¯æºï¼<#list item.relatedSceneName as scene><#if (scene_index > 0)>ã</#if>${scene}</#list>çå¯è½å卿±¡æé£é©ã<#else>ã</#if></w:t> |
| | | </w:r> |
| | | </w:p> |
| | | <w:p> |