From 022af485fbd77bc3d6b01f9f779248b3c189dad2 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 04 七月 2024 17:35:33 +0800 Subject: [PATCH] 1. 新增走航报告自动道路识别模块 --- src/main/kotlin/com/flightfeather/uav/domain/mapper/SegmentInfoMapper.java | 9 src/main/resources/mapper/SegmentInfoMapper.xml | 30 +++ src/main/resources/generator/generatorConfig.xml | 4 src/test/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegmentTest.kt | 28 ++ src/main/kotlin/com/flightfeather/uav/common/location/TrackSegment.kt | 93 +++++++- src/main/kotlin/com/flightfeather/uav/domain/entity/SegmentInfo.java | 244 ++++++++++++++++++++++++ src/main/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegment.kt | 67 ++++++ src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt | 95 +++++++++ src/main/kotlin/com/flightfeather/uav/domain/repository/SegmentInfoRep.kt | 18 + src/main/kotlin/com/flightfeather/uav/common/net/HttpMethod.kt | 4 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt | 2 pom.xml | 2 12 files changed, 568 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 1db1d29..8436d7e 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> - <version>2.8.5</version> + <version>2.8.6</version> </dependency> <!--鍒嗛〉--> diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegment.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegment.kt new file mode 100644 index 0000000..e2fbd29 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegment.kt @@ -0,0 +1,67 @@ +package com.flightfeather.uav.biz.dataprocess + +import com.flightfeather.uav.common.location.TrackSegment +import com.flightfeather.uav.common.net.AMapService +import com.flightfeather.uav.domain.entity.BaseRealTimeData +import com.flightfeather.uav.domain.entity.Mission +import com.flightfeather.uav.domain.entity.SegmentInfo +import com.flightfeather.uav.domain.entity.avg +import com.flightfeather.uav.domain.repository.RealTimeDataRep +import com.flightfeather.uav.domain.repository.SegmentInfoRep +import org.springframework.stereotype.Component +import java.math.BigDecimal + +/** + * 璧拌埅杞ㄨ抗鎸夌収璺杩涜鍒嗗壊 + * @date 2024/7/4 + * @author feiyu02 + */ +@Component +class RoadSegment( + private val realTimeDataRep: RealTimeDataRep, + private val segmentInfoRep: SegmentInfoRep, +) { + + fun handle(mission: Mission) { + // 鑾峰彇鏁版嵁鍒嗘 + val data = mutableListOf<BaseRealTimeData>() + realTimeDataRep.fetchData(mission).forEach { + // 鍘婚櫎鏃犳晥缁忕含搴� + if ((it.longitude != null && it.longitude != BigDecimal.ZERO) + && (it.latitude != null && it.latitude != BigDecimal.ZERO) + ) { + data.add(it) + } + } + val sData = TrackSegment.segmentWithRoad(data) + // 鏍规嵁姣忎釜鍒嗘鐨凣PS鍧愭爣鍧囧�奸�氳繃楂樺痉API杞崲涓洪珮寰峰潗鏍� + val avgGPS = mutableListOf<Pair<Double, Double>>() + sData.forEach { + val d = it.avg() + if (d.longitude != null && d.latitude != null) { + avgGPS.add(d.longitude!!.toDouble() to d.latitude!!.toDouble()) + } + } + val gdGPS = AMapService.coordinateConvert(avgGPS) + // 閫氳繃楂樺痉API鏌ヨ鍧愭爣瀵瑰簲鐨勮矾娈� + val segmentInfoList = mutableListOf<SegmentInfo>() + gdGPS.forEachIndexed { i, pair -> + val address = AMapService.reGeo(pair) + segmentInfoList.add(SegmentInfo().apply { + missionCode = mission.missionCode + deviceCode = mission.deviceCode + startTime = sData[i][0].dataTime + endTime = sData[i].last().dataTime + provinceName = address.province + cityCode = address.citycode + districtCode = address.adcode + districtName = address.district + townCode = address.towncode + towmName = address.township + street = address.street + }) + } + // 缁撴灉鍏ュ簱 + segmentInfoRep.insert(segmentInfoList) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataprocess/TrackSegment.kt b/src/main/kotlin/com/flightfeather/uav/common/location/TrackSegment.kt similarity index 60% rename from src/main/kotlin/com/flightfeather/uav/biz/dataprocess/TrackSegment.kt rename to src/main/kotlin/com/flightfeather/uav/common/location/TrackSegment.kt index abd56ec..2b0ed10 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataprocess/TrackSegment.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/location/TrackSegment.kt @@ -1,9 +1,11 @@ -package com.flightfeather.uav.biz.dataprocess +package com.flightfeather.uav.common.location -import com.flightfeather.uav.common.location.CoordinateUtil import com.flightfeather.uav.domain.entity.BaseRealTimeData import java.math.BigDecimal import kotlin.math.abs +import kotlin.math.atan +import kotlin.math.cos +import kotlin.math.sin /** * 璧拌埅杞ㄨ抗鍒嗗壊鍒嗙被 @@ -13,10 +15,10 @@ object TrackSegment { // 鍧愭爣鐐归棿鏈�灏忚窛绂伙紝鍗曚綅绫� - private const val MIN_DISTANCE = 10 + private const val MIN_DISTANCE = 6 // 涓ゆ潯鐩寸嚎澶硅涓�90搴︽椂锛岃涓哄瀭鐩淬�傚疄闄呮儏鍐典腑锛岃搴﹀厑璁告湁涓�瀹氬亸宸紝鍏佽鍋忓樊瑙掑害 - private const val VERTICAL_OFFSET_DEG = 22.5 + private const val VERTICAL_OFFSET_DEG = 45 /** * 鎸夌収閬撹矾瀵硅蛋鑸建杩硅繘琛屽垎鍓� @@ -34,13 +36,13 @@ val closeList = mutableListOf<BaseRealTimeData>() records.add(mutableListOf()) data.forEachIndexed { i, d -> - if (records.size == 33) { + if (records.size == 23) { println(records.size) } var isSame = false if (i > 0) { // 鍓嶄竴涓湁鏁堢洃娴嬬偣 - val lastData = data[i - 1] + var lastData = data[i - 1] // 纭繚涓ょ偣鍧愭爣鍚堟硶 if ((lastData.longitude != null && lastData.longitude != BigDecimal.ZERO) && (lastData.latitude != null && lastData.latitude != BigDecimal.ZERO) @@ -57,6 +59,7 @@ // 濡傛灉宸茬粡鏈夎窛绂昏繃杩戠殑鐐归泦鍚堬紝鍒欒繕闇�瑕佸拰绗竴涓偣杩涜璺濈鍒ゆ柇锛� // 瑙e喅褰撹溅杈嗚椹堕�熷害杩囦綆鏃讹紝杩炵画鐐圭殑璺濈閮借繃杩戝鑷撮兘鍒ゅ畾涓哄悓涓�鐐圭殑闂 val firstCloseData = closeList[0] +// lastData = closeList.toList().avg() distance = CoordinateUtil.calculateDistance( firstCloseData.longitude!!.toDouble(), firstCloseData.latitude!!.toDouble(), d.longitude!!.toDouble(), d.latitude!!.toDouble()) @@ -69,27 +72,43 @@ ) isSame = if (lastDegList.isNotEmpty()) { var bool = true - // 鍑虹幇瑙掑害鎺ヨ繎鍨傜洿鐘舵�佺殑娆℃暟 - var unSameCount = 0 - // 姣旇緝褰撳墠鏂逛綅瑙掑拰涓婁竴缁勬瘡涓柟浣嶈鐨勫樊鍊兼槸鍚﹂兘澶勪簬鑼冨洿鍐� - for (lastDeg in lastDegList) { - val diffDeg = abs(deg - lastDeg) - if (diffDeg in (90.0 - VERTICAL_OFFSET_DEG)..(90.0 + VERTICAL_OFFSET_DEG) - || diffDeg in (270.0 - VERTICAL_OFFSET_DEG)..(270.0 + VERTICAL_OFFSET_DEG) - ) { - unSameCount++ - } + + +// // 鍑虹幇瑙掑害鎺ヨ繎鍨傜洿鐘舵�佺殑娆℃暟 +// var unSameCount = 0 +// // 姣旇緝褰撳墠鏂逛綅瑙掑拰涓婁竴缁勬瘡涓柟浣嶈鐨勫樊鍊兼槸鍚﹂兘澶勪簬鑼冨洿鍐� +// for (lastDeg in lastDegList) { +// val diffDeg = abs(deg - lastDeg) +// if (diffDeg in (90.0 - VERTICAL_OFFSET_DEG)..(90.0 + VERTICAL_OFFSET_DEG) +// || diffDeg in (270.0 - VERTICAL_OFFSET_DEG)..(270.0 + VERTICAL_OFFSET_DEG) +// ) { +// unSameCount++ +// } +// } +// // 褰撴帴杩戝瀭鐩寸殑瑙掑害瓒呰繃涓婁竴缁勫钩琛岃搴︾殑涓�鍗婃椂锛岃涓轰粠璇ョ偣杞ㄨ抗杞集锛堟秷闄や釜鍒潗鏍囩偣鐢变簬瀹氫綅璇樊瀵艰嚧鐨勯敊璇奖鍝嶏級 +// bool = unSameCount < (lastDegList.size / 3 + 1) + + val avgDeg = avgDegree(lastDegList) + val diffDeg = abs(deg - avgDeg) + if (diffDeg in (90.0 - VERTICAL_OFFSET_DEG)..(90.0 + VERTICAL_OFFSET_DEG) + || diffDeg in (270.0 - VERTICAL_OFFSET_DEG)..(270.0 + VERTICAL_OFFSET_DEG) + ) { + bool = false } - // 褰撴帴杩戝瀭鐩寸殑瑙掑害瓒呰繃涓婁竴缁勫钩琛岃搴︾殑涓�鍗婃椂锛岃涓轰粠璇ョ偣杞ㄨ抗杞集锛堟秷闄や釜鍒潗鏍囩偣鐢变簬瀹氫綅璇樊瀵艰嚧鐨勯敊璇奖鍝嶏級 - bool = unSameCount < (lastDegList.size / 3 + 1) + // 褰撳嚭鐜拌浆寮偣鏃讹紝娓呯┖鍘嗗彶瑙掑害锛屽苟涓旇垗寮冭浆寮偣鐩稿浜庡墠涓�涓偣鐨勮搴︼紙瑙e喅涓�绉嶆瀬绔儏鍐碉紝褰撹繛缁嚭鐜拌浆寮偣鏃讹紝褰撳墠鍧愭爣鐐逛細琚崟鐙垎鍓蹭负涓�娈碉級 - if (!bool) lastDegList.clear() + if (!bool) { + lastDegList.clear() + } else { + lastDegList.add(deg) + } bool } else { // 褰撳潗鏍囩偣褰㈡垚鏈夋晥璺緞鏃讹紝璁板綍涓轰笂涓�涓潗鏍囩偣 lastDegList.add(deg) true } + closeList.clear() } else { closeList.add(d) isSame = true @@ -110,4 +129,40 @@ return records } + + /** + * 姹傝浆鍚戣搴︾殑鍧囧�� + */ + private fun avgDegree(degList: List<Double>): Double { + if (degList.isEmpty()) return .0 + //閲囩敤鍗曚綅鐭㈤噺娉曟眰鍙栧潎鍊� + var u = .0//涓滆タ鏂逛綅鍒嗛噺鎬诲拰 + var v = .0//鍗楀寳鏂逛綅鍒嗛噺鎬诲拰 + var c = 0//鏁版嵁璁℃暟 + + degList.forEach { + val r = Math.toRadians(it) + u += sin(r) + v += cos(r) + c++ + } + + val avgU = u / c + val avgV = v / c + var a = atan(avgU / avgV) + a = Math.toDegrees(a) + /** + * avgU>0;avgV>0: 鐪熷疄瑙掑害澶勪簬绗竴璞¢檺锛屼慨姝e�间负+0掳 + * avgU>0;avgV<0: 鐪熷疄瑙掑害澶勪簬绗簩璞¢檺锛屼慨姝e�间负+180掳 + * avgU<0;avgV<0: 鐪熷疄瑙掑害澶勪簬绗笁璞¢檺锛屼慨姝e�间负+180掳 + * avgU<0;avgV>0: 鐪熷疄瑙掑害澶勪簬绗洓璞¢檺锛屼慨姝e�间负+360掳 + */ + a += if (avgV > 0) { + if (avgU > 0) 0 else 360 + } else { + 180 + } + + return a + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt b/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt index f4aa432..a9c5497 100644 --- a/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt @@ -1,19 +1,106 @@ package com.flightfeather.uav.common.net +import com.flightfeather.uav.common.exception.BizException +import com.google.gson.Gson +import com.google.gson.JsonElement +import com.google.gson.JsonObject +import com.google.gson.JsonParser +import java.nio.charset.Charset + /** * 楂樺痉鍦板浘Web鏈嶅姟API */ object AMapService { + private const val TAG = "AMapService" + private const val KEY = "520c5e5cf44c7793104e500cbf0ed711" + private val httpMethod = HttpMethod("restapi.amap.com", 443, true) - private val KEY = "" + + data class AMapAddress( + val country: String, + val province: String, + val city: String, + val citycode: String, + val district: String, + val adcode: String, + val township: String, + val towncode: String, + val street: String, + ) /** * 鍦扮悊閫嗙紪鐮� + * @param location 鍧愭爣鐐� + * @return 鎵�鍦ㄨ閬� */ - fun reGeo(location:List<Pair<Double, Double>>) { - httpMethod.get("v3/geocode/regeo", listOf( - + fun reGeo(location:Pair<Double, Double>):AMapAddress { + val res = httpMethod.get("/v3/geocode/regeo", listOf( + "key" to KEY, + "location" to "${location.first},${location.second}" )) + val obj = handleRes(res) + try { + val a = obj["regeocode"].asJsonObject["addressComponent"].asJsonObject + return AMapAddress( + a["country"].asString, + a["province"].asString, + "", + a["citycode"].asString, + a["district"].asString, + a["adcode"].asString, + a["township"].asString, + a["towncode"].asString, + a["streetNumber"].asJsonObject["street"].asString, + ) + } catch (e: Exception) { + throw BizException("楂樺痉API鍧愭爣杞崲閿欒锛�${e.message}") + } + } + + /** + * 鍧愭爣杞崲 + * @param locations 鍘熷鍧愭爣 + * @param coordsys 鍘熷潗鏍囩郴锛屽彲閫夊�硷細gps;mapbar;baidu;autonavi(涓嶈繘琛岃浆鎹�) + */ + fun coordinateConvert(locations: List<Pair<Double, Double>>, coordsys:String="gps"): List<Pair<Double, Double>> { + val res = httpMethod.get("/v3/assistant/coordinate/convert", listOf( + "key" to KEY, + "locations" to locations.joinToString("|") { "${it.first},${it.second}" }, + "coordsys" to coordsys + )) + val obj = handleRes(res) + try { + return obj["locations"].asString.split(";").map { + val l = it.split(",") + l[0].toDouble() to l[1].toDouble() + } + } catch (e: Exception) { + throw BizException("楂樺痉API鍧愭爣杞崲閿欒锛�${e.message}") + } + } + + private fun handleRes(res: HttpMethod.MyResponse):JsonObject { + if (res.success) { +// val str = if (res.m.responseCharSet == "utf-8") { +// res.m.responseBodyAsString +// } else { +// String(res.m.responseBody, Charset.forName("utf-8")) +// } + val str = res.m.responseBodyAsString + val json = JsonParser.parseString(str) + return resCheck(json) + } else { + throw BizException("楂樺痉API缃戣矾閾炬帴閿欒锛岀姸鎬佺爜锛�${res.m.statusCode}") + } + } + + private fun resCheck(json: JsonElement): JsonObject { + if (!json.isJsonObject) throw BizException("楂樺痉API澶辫触锛岃繑鍥炲�间笉鏄竴涓猳bject") + + val jo = json.asJsonObject + if (jo["status"].asInt != 1) throw BizException("楂樺痉API澶辫触锛岄敊璇�${jo["info"]}") + + return jo } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/common/net/HttpMethod.kt b/src/main/kotlin/com/flightfeather/uav/common/net/HttpMethod.kt index 350f640..7593aba 100644 --- a/src/main/kotlin/com/flightfeather/uav/common/net/HttpMethod.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/net/HttpMethod.kt @@ -18,8 +18,8 @@ private val logger = LoggerFactory.getLogger(HttpMethod::class.java) data class MyResponse( - val success: Boolean, - val m: HttpMethodBase + val success: Boolean, + val m: HttpMethodBase, ) object Head { diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/SegmentInfo.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/SegmentInfo.java new file mode 100644 index 0000000..a7a221c --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/SegmentInfo.java @@ -0,0 +1,244 @@ +package com.flightfeather.uav.domain.entity; + +import java.util.Date; +import javax.persistence.*; + +@Table(name = "segment_info") +public class SegmentInfo { + @Id + private Integer id; + + @Column(name = "mission_code") + private String missionCode; + + @Column(name = "device_code") + private String deviceCode; + + @Column(name = "start_time") + private Date startTime; + + @Column(name = "end_time") + private Date endTime; + + @Column(name = "district_code") + private String districtCode; + + @Column(name = "district_name") + private String districtName; + + @Column(name = "town_code") + private String townCode; + + @Column(name = "towm_name") + private String towmName; + + @Column(name = "province_code") + private String provinceCode; + + @Column(name = "province_name") + private String provinceName; + + @Column(name = "city_code") + private String cityCode; + + @Column(name = "city_name") + private String cityName; + + private String street; + + /** + * @return id + */ + public Integer getId() { + return id; + } + + /** + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return mission_code + */ + public String getMissionCode() { + return missionCode; + } + + /** + * @param missionCode + */ + public void setMissionCode(String missionCode) { + this.missionCode = missionCode == null ? null : missionCode.trim(); + } + + /** + * @return device_code + */ + public String getDeviceCode() { + return deviceCode; + } + + /** + * @param deviceCode + */ + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode == null ? null : deviceCode.trim(); + } + + /** + * @return start_time + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @return end_time + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @return district_code + */ + public String getDistrictCode() { + return districtCode; + } + + /** + * @param districtCode + */ + public void setDistrictCode(String districtCode) { + this.districtCode = districtCode == null ? null : districtCode.trim(); + } + + /** + * @return district_name + */ + public String getDistrictName() { + return districtName; + } + + /** + * @param districtName + */ + public void setDistrictName(String districtName) { + this.districtName = districtName == null ? null : districtName.trim(); + } + + /** + * @return town_code + */ + public String getTownCode() { + return townCode; + } + + /** + * @param townCode + */ + public void setTownCode(String townCode) { + this.townCode = townCode == null ? null : townCode.trim(); + } + + /** + * @return towm_name + */ + public String getTowmName() { + return towmName; + } + + /** + * @param towmName + */ + public void setTowmName(String towmName) { + this.towmName = towmName == null ? null : towmName.trim(); + } + + /** + * @return province_code + */ + public String getProvinceCode() { + return provinceCode; + } + + /** + * @param provinceCode + */ + public void setProvinceCode(String provinceCode) { + this.provinceCode = provinceCode == null ? null : provinceCode.trim(); + } + + /** + * @return province_name + */ + public String getProvinceName() { + return provinceName; + } + + /** + * @param provinceName + */ + public void setProvinceName(String provinceName) { + this.provinceName = provinceName == null ? null : provinceName.trim(); + } + + /** + * @return city_code + */ + public String getCityCode() { + return cityCode; + } + + /** + * @param cityCode + */ + public void setCityCode(String cityCode) { + this.cityCode = cityCode == null ? null : cityCode.trim(); + } + + /** + * @return city_name + */ + public String getCityName() { + return cityName; + } + + /** + * @param cityName + */ + public void setCityName(String cityName) { + this.cityName = cityName == null ? null : cityName.trim(); + } + + /** + * @return street + */ + public String getStreet() { + return street; + } + + /** + * @param street + */ + public void setStreet(String street) { + this.street = street == null ? null : street.trim(); + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/mapper/SegmentInfoMapper.java b/src/main/kotlin/com/flightfeather/uav/domain/mapper/SegmentInfoMapper.java new file mode 100644 index 0000000..b472372 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/mapper/SegmentInfoMapper.java @@ -0,0 +1,9 @@ +package com.flightfeather.uav.domain.mapper; + +import com.flightfeather.uav.domain.MyMapper; +import com.flightfeather.uav.domain.entity.SegmentInfo; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SegmentInfoMapper extends MyMapper<SegmentInfo> { +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SegmentInfoRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SegmentInfoRep.kt new file mode 100644 index 0000000..e508d45 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SegmentInfoRep.kt @@ -0,0 +1,18 @@ +package com.flightfeather.uav.domain.repository + +import com.flightfeather.uav.domain.entity.SegmentInfo +import com.flightfeather.uav.domain.mapper.SegmentInfoMapper +import org.springframework.stereotype.Repository + +/** + * 杞ㄨ抗鍒嗛殧鏁版嵁搴撴搷浣� + * @date 2024/7/4 + * @author feiyu02 + */ +@Repository +class SegmentInfoRep(private val segmentInfoMapper: SegmentInfoMapper) { + + fun insert(list: List<SegmentInfo>):Int { + return segmentInfoMapper.insertList(list) + } +} \ No newline at end of file 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 ffe64d4..ee7dd04 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 @@ -6,7 +6,7 @@ import com.flightfeather.uav.common.utils.ExcelUtil import com.flightfeather.uav.common.utils.FileExchange import com.flightfeather.uav.biz.dataprocess.AverageUtil -import com.flightfeather.uav.biz.dataprocess.TrackSegment +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 diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml index ef5ed18..e292e5a 100644 --- a/src/main/resources/generator/generatorConfig.xml +++ b/src/main/resources/generator/generatorConfig.xml @@ -47,7 +47,7 @@ </javaClientGenerator> <!-- 瑕佺敓鎴愮殑琛� tableName鏄暟鎹簱涓殑琛ㄥ悕鎴栬鍥惧悕 domainObjectName鏄疄浣撶被鍚�--> <!-- <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> - <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> +<!-- <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="el_minutevalue" domainObjectName="ElectricMinuteValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="co_complaint" domainObjectName="Complaint" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> @@ -60,5 +60,7 @@ <!-- <table tableName="real_time_data_grid_min" domainObjectName="RealTimeDataGridMin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="real_time_data_grid_opt" domainObjectName="RealTimeDataGridOpt" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="scene_info" domainObjectName="SceneInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> + <table tableName="segment_info" domainObjectName="SegmentInfo" enableCountByExample="false" + enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> </context> </generatorConfiguration> \ No newline at end of file diff --git a/src/main/resources/mapper/SegmentInfoMapper.xml b/src/main/resources/mapper/SegmentInfoMapper.xml new file mode 100644 index 0000000..6509f7c --- /dev/null +++ b/src/main/resources/mapper/SegmentInfoMapper.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.flightfeather.uav.domain.mapper.SegmentInfoMapper"> + <resultMap id="BaseResultMap" type="com.flightfeather.uav.domain.entity.SegmentInfo"> + <!-- + WARNING - @mbg.generated + --> + <id column="id" jdbcType="INTEGER" property="id" /> + <result column="mission_code" jdbcType="VARCHAR" property="missionCode" /> + <result column="device_code" jdbcType="VARCHAR" property="deviceCode" /> + <result column="start_time" jdbcType="TIMESTAMP" property="startTime" /> + <result column="end_time" jdbcType="TIMESTAMP" property="endTime" /> + <result column="district_code" jdbcType="VARCHAR" property="districtCode" /> + <result column="district_name" jdbcType="VARCHAR" property="districtName" /> + <result column="town_code" jdbcType="VARCHAR" property="townCode" /> + <result column="towm_name" jdbcType="VARCHAR" property="towmName" /> + <result column="province_code" jdbcType="VARCHAR" property="provinceCode" /> + <result column="province_name" jdbcType="VARCHAR" property="provinceName" /> + <result column="city_code" jdbcType="VARCHAR" property="cityCode" /> + <result column="city_name" jdbcType="VARCHAR" property="cityName" /> + <result column="street" jdbcType="VARCHAR" property="street" /> + </resultMap> + <sql id="Base_Column_List"> + <!-- + WARNING - @mbg.generated + --> + id, mission_code, device_code, start_time, end_time, district_code, district_name, + town_code, towm_name, province_code, province_name, city_code, city_name, street + </sql> +</mapper> \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegmentTest.kt b/src/test/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegmentTest.kt new file mode 100644 index 0000000..809c608 --- /dev/null +++ b/src/test/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegmentTest.kt @@ -0,0 +1,28 @@ +package com.flightfeather.uav.biz.dataprocess + +import com.flightfeather.uav.common.exception.BizException +import com.flightfeather.uav.domain.repository.MissionRep +import org.junit.Test + +import org.junit.Assert.* +import org.junit.runner.RunWith +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.junit4.SpringRunner + +@RunWith(SpringRunner::class) +@SpringBootTest +class RoadSegmentTest { + + @Autowired + lateinit var roadSegment: RoadSegment + + @Autowired + lateinit var missionRep: MissionRep + + @Test + fun handle() { + val mission = missionRep.findOne("SH-CN-20240514") ?: throw BizException("浠诲姟涓嶅瓨鍦�") + roadSegment.handle(mission) + } +} \ No newline at end of file -- Gitblit v1.9.3