From e133600480d5f688a8375db7708fe531b4726f4a Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 07 二月 2025 17:38:38 +0800 Subject: [PATCH] 1. 新增卫星网格拆分、遥测数据拆分映射功能 --- src/main/kotlin/com/flightfeather/uav/domain/entity/GridGroup.java | 25 ++++ src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt | 75 ++++++++++++ src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java | 1 src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImplTest.kt | 22 +++ src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt | 85 ++++++++++++- src/main/kotlin/com/flightfeather/uav/domain/mapper/GridCellMapper.kt | 10 + src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt | 5 src/main/kotlin/com/flightfeather/uav/domain/entity/GridDataDetail.java | 1 src/main/resources/application-test.yml | 12 +- src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt | 8 + src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt | 36 ++++++ src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt | 29 ++++ src/main/resources/generator/generatorConfig.xml | 2 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt | 4 src/main/kotlin/com/flightfeather/uav/domain/entity/GridAodDetail.java | 5 src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt | 2 src/main/kotlin/com/flightfeather/uav/lightshare/eunm/SatelliteDataType.kt | 2 src/main/resources/mapper/GridGroupMapper.xml | 3 src/main/kotlin/com/flightfeather/uav/domain/mapper/GridGroupMapper.kt | 10 + 19 files changed, 311 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt b/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt index 783ceb6..1bfc3e9 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt @@ -1,7 +1,10 @@ package com.flightfeather.uav.biz.satellite import com.flightfeather.uav.common.utils.MapUtil +import com.flightfeather.uav.domain.entity.BaseRealTimeData import com.flightfeather.uav.domain.entity.GridCell +import com.flightfeather.uav.domain.entity.GridData +import com.flightfeather.uav.domain.entity.GridDataDetail import kotlin.math.PI import kotlin.math.sqrt @@ -87,15 +90,15 @@ val p2 = p.point2Lon to p.point2Lat val p3 = p.point3Lon to p.point3Lat val p4 = p.point4Lon to p.point4Lat - // p1銆乸3鐨勭粡绾害鍗曚綅宸�� - val dx1 = (p3.first - p1.first) / scale.toBigDecimal() - val dy1 = (p3.second - p1.second) / scale.toBigDecimal() + // p1銆乸4鐨勭粡绾害鍗曚綅宸�� + val dx1 = (p4.first - p1.first) / scale.toBigDecimal() + val dy1 = (p4.second - p1.second) / scale.toBigDecimal() // p1銆乸2鐨勭粡绾害鍗曚綅宸�� val dx2 = (p2.first - p1.first) / scale.toBigDecimal() val dy2 = (p2.second - p1.second) / scale.toBigDecimal() - // p3銆乸4鐨勭粡绾害鍗曚綅宸�� - val dx3 = (p4.first - p3.first) / scale.toBigDecimal() - val dy3 = (p4.second - p3.second) / scale.toBigDecimal() + // p4銆乸3鐨勭粡绾害鍗曚綅宸�� + val dx3 = (p3.first - p4.first) / scale.toBigDecimal() + val dy3 = (p3.second - p4.second) / scale.toBigDecimal() // 涓績鐐瑰拰p1鐨勭粡绾害鍗曚綅宸�� val dxC = (p.longitude - p1.first) / scale.toBigDecimal() val dyC = (p.latitude - p1.second) / scale.toBigDecimal() @@ -116,14 +119,14 @@ newGridCell1.point1Lon = g.point1Lon + dx1 * row.toBigDecimal() newGridCell1.point1Lat = g.point1Lat + dy1 * row.toBigDecimal() // 宸︿笅瑙掗《鐐规牴鎹墍鍦ㄨ鏁板湪鍘熷缃戞牸椤剁偣鍩虹涓婂鍔犲亸绉婚噺锛堟瘮宸︿笂瑙掗《鐐瑰涓�涓亸绉伙級 - newGridCell1.point3Lon = g.point1Lon + dx1 * (row + 1).toBigDecimal() - newGridCell1.point3Lat = g.point1Lat + dy1 * (row + 1).toBigDecimal() + newGridCell1.point4Lon = g.point1Lon + dx1 * (row + 1).toBigDecimal() + newGridCell1.point4Lat = g.point1Lat + dy1 * (row + 1).toBigDecimal() // 鍙充笂瑙掗《鐐瑰湪缁嗗垎缃戞牸宸︿笂瑙掔殑鍩虹涓婂鍔犵浉搴旂殑鍋忕Щ閲� newGridCell1.point2Lon = newGridCell1.point1Lon + dx2 newGridCell1.point2Lat = newGridCell1.point1Lat + dy2 // 鍙充笅瑙掗《鐐瑰湪缁嗗垎缃戞牸宸︿笅瑙掔殑鍩虹涓婂鍔犵浉搴旂殑鍋忕Щ閲� - newGridCell1.point4Lon = newGridCell1.point3Lon + dx3 - newGridCell1.point4Lat = newGridCell1.point3Lat + dy3 + newGridCell1.point3Lon = newGridCell1.point4Lon + dx3 + newGridCell1.point3Lat = newGridCell1.point4Lat + dy3 // 涓績鐐瑰湪缁嗗垎缃戞牸宸︿笂瑙掔殑鍩虹涓婂鍔犲浐瀹氬亸绉婚噺 newGridCell1.longitude = newGridCell1.point1Lon + dxC newGridCell1.latitude = newGridCell1.point1Lat + dyC @@ -160,4 +163,66 @@ return newGridCellList } + /** + * 鎷嗗垎鏁版嵁锛屽皢鍘熷鍗槦缃戞牸閬ユ祴鏁版嵁鏄犲皠鍒板搴旂粏鍒嗙綉鏍间笂 + * @param subGridCellList 缁嗗垎缃戞牸, 鎸夌収 + * @param subGridData 缁嗗垎缃戞牸瀵瑰簲鐨勬暟鎹储寮� + * @param originGridDataDetailList 缁嗗垎缃戞牸鎵�灞炵綉鏍肩殑鍘熷缃戞牸鏁版嵁 + */ + fun splitData( + subGridCellList: List<GridCell?>, subGridData: GridData, originGridDataDetailList: List<GridDataDetail?> + ): List<GridDataDetail> { + if (subGridCellList.isEmpty() || originGridDataDetailList.isEmpty()) return emptyList() + + val result = mutableListOf<GridDataDetail>() + + // 灏嗙粏鍒嗙綉鏍兼寜鐓х埗缃戞牸id鍜岃嚜韬綉鏍糹d杩涜鍗囧簭鎺掑垪 + val _subGridCellList = subGridCellList.sortedWith(Comparator { o1, o2 -> + if (o1 == null && o2 == null) { + return@Comparator 0 + } else if (o1 == null) { + return@Comparator -1 + } else if (o2 == null) { + return@Comparator 1 + } else { + if (o1.fatherCellIndex == o2.fatherCellIndex) { + return@Comparator o1.cellIndex - o2.cellIndex + } else { + return@Comparator o1.fatherCellIndex - o2.fatherCellIndex + } + } + }) + + // 灏嗗師濮嬬綉鏍兼暟鎹寜鐓х綉鏍糹d鍗囧簭鎺掑垪 + val _originGridDataDetailIterator = originGridDataDetailList.sortedBy { it?.cellId }.iterator() + var fatherGridData = _originGridDataDetailIterator.next() + + // 閬嶅巻缁嗗垎缃戞牸锛屼负姣忎釜缁嗗垎缃戞牸鐢熸垚涓�鏉$綉鏍兼暟鎹� + _subGridCellList.forEach { + while (fatherGridData?.cellId != it?.fatherCellIndex && _originGridDataDetailIterator.hasNext()) { + fatherGridData = _originGridDataDetailIterator.next() + } + val subGridDataDetail = GridDataDetail().apply { + dataId = subGridData.id + groupId = it?.groupId + cellId = it?.cellIndex + pm25 = fatherGridData?.pm25 + rank = fatherGridData?.rank + } + + result.add(subGridDataDetail) + } + + return result + } + + /** + * 鏁版嵁铻嶅悎 + * @param realTimeDataList 寰呰瀺鍚堢殑璧拌埅鐩戞祴鏁版嵁 + * @param gridData 铻嶅悎鍚庣殑鏁版嵁缁勭储寮� + * @param gridCellList 寰呰瀺鍚堢殑鍗槦缃戞牸 + */ + fun dataFusion(realTimeDataList:List<BaseRealTimeData>, gridData: GridData, gridCellList: List<GridCell?>) { + + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridAodDetail.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridAodDetail.java index 15b16ad..3561280 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridAodDetail.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridAodDetail.java @@ -1,12 +1,11 @@ package com.flightfeather.uav.domain.entity; -import javax.persistence.Column; -import javax.persistence.Id; -import javax.persistence.Table; +import javax.persistence.*; @Table(name = "grid_aod_detail") public class GridAodDetail { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name = "aod_id") diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java index 16e1d75..4ed0692 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java @@ -6,6 +6,7 @@ @Table(name = "grid_cell") public class GridCell { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; /** diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridDataDetail.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridDataDetail.java index 4545740..c563a81 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridDataDetail.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridDataDetail.java @@ -5,6 +5,7 @@ @Table(name = "grid_data_detail") public class GridDataDetail { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; /** diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridGroup.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridGroup.java index 9772b6e..6e0fd9a 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/GridGroup.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/GridGroup.java @@ -6,6 +6,7 @@ @Table(name = "grid_group") public class GridGroup { @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; /** @@ -49,6 +50,12 @@ * 缃戞牸绫诲瀷锛宱rigin锛氬師濮嬬綉鏍硷紱sub锛氬瓙缃戞牸锛堢粏鍒嗙綉鏍硷級 */ private String type; + + /** + * 褰撶綉鏍肩被鍨嬫槸Sub锛堝瓙缃戞牸锛夋椂锛屾墍灞炵埗缃戞牸缁勭殑id + */ + @Column(name = "father_group_id") + private Integer fatherGroupId; /** * @return id @@ -243,4 +250,22 @@ public void setType(String type) { this.type = type == null ? null : type.trim(); } + + /** + * 鑾峰彇褰撶綉鏍肩被鍨嬫槸Sub锛堝瓙缃戞牸锛夋椂锛屾墍灞炵埗缃戞牸缁勭殑id + * + * @return father_group_id - 褰撶綉鏍肩被鍨嬫槸Sub锛堝瓙缃戞牸锛夋椂锛屾墍灞炵埗缃戞牸缁勭殑id + */ + public Integer getFatherGroupId() { + return fatherGroupId; + } + + /** + * 璁剧疆褰撶綉鏍肩被鍨嬫槸Sub锛堝瓙缃戞牸锛夋椂锛屾墍灞炵埗缃戞牸缁勭殑id + * + * @param fatherGroupId 褰撶綉鏍肩被鍨嬫槸Sub锛堝瓙缃戞牸锛夋椂锛屾墍灞炵埗缃戞牸缁勭殑id + */ + public void setFatherGroupId(Integer fatherGroupId) { + this.fatherGroupId = fatherGroupId; + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridCellMapper.kt b/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridCellMapper.kt index 489ecf6..c03d7ff 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridCellMapper.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridCellMapper.kt @@ -3,6 +3,14 @@ import com.flightfeather.uav.domain.MyMapper import com.flightfeather.uav.domain.entity.GridCell import org.apache.ibatis.annotations.Mapper +import org.apache.ibatis.annotations.Select @Mapper -interface GridCellMapper : MyMapper<GridCell?> \ No newline at end of file +interface GridCellMapper : MyMapper<GridCell?> { + + /** + * 閲嶇疆鑷id + */ + @Select("alter table grid_cell auto_increment = #{param1}") + fun resetAutoIncrement(id: Int) +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridGroupMapper.kt b/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridGroupMapper.kt index f4e429f..9ec8b97 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridGroupMapper.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/mapper/GridGroupMapper.kt @@ -3,6 +3,14 @@ import com.flightfeather.uav.domain.MyMapper import com.flightfeather.uav.domain.entity.GridGroup import org.apache.ibatis.annotations.Mapper +import org.apache.ibatis.annotations.Select @Mapper -interface GridGroupMapper : MyMapper<GridGroup?> \ No newline at end of file +interface GridGroupMapper : MyMapper<GridGroup?> { + + /** + * 閲嶇疆鑷id + */ + @Select("alter table grid_group auto_increment = #{param1}") + fun resetAutoIncrement(id: Int) +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt index 4c35033..3fcdb97 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt @@ -46,11 +46,35 @@ return gridGroupMapper.select(gridGroup) } + fun insertGridGroup(gridGroup: GridGroup): Int { + return gridGroupMapper.insert(gridGroup) + } + + @Transactional + fun deleteGridGroup(groupId: Int) { + gridCellMapper.delete(GridCell().apply { this.groupId = groupId }) + gridCellMapper.selectByExample( + Example(GridCell::class.java).apply { orderBy("id").desc() } + ).takeIf { it.isNotEmpty() }?.get(0)?.id?.let { id -> + gridCellMapper.resetAutoIncrement(id + 1) + } + gridGroupMapper.deleteByPrimaryKey(groupId) + gridGroupMapper.selectByExample( + Example(GridGroup::class.java).apply { orderBy("id").desc() } + ).takeIf { it.isNotEmpty() }?.get(0)?.id?.let { id -> + gridGroupMapper.resetAutoIncrement(id + 1) + } + } + fun fetchGridCell(groupId: Int): List<GridCell?> { return gridCellMapper.selectByExample(Example(GridCell::class.java).apply { createCriteria().andEqualTo("groupId", groupId) orderBy("id") }) + } + + fun insertGridCell(gridCellList: List<GridCell?>): Int { + return gridCellMapper.insertList(gridCellList) } fun fetchGridData(groupId: Int, dataTime: LocalDateTime?, type: Int?): List<GridData?> { @@ -65,6 +89,18 @@ return gridDataMapper.select(gridData) } + fun fetchGridData(id: Int): GridData? { + return gridDataMapper.selectByPrimaryKey(id) + } + + fun insertGridData(gridData: GridData): Int { + return gridDataMapper.insert(gridData) + } + + fun insertGridDataDetail(gridDataDetails: List<GridDataDetail?>): Int { + return gridDataDetailMapper.insertList(gridDataDetails) + } + fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> { return gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply { createCriteria().andEqualTo("dataId", dataId) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/eunm/SatelliteDataType.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/eunm/SatelliteDataType.kt index fea796d..8147c61 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/eunm/SatelliteDataType.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/eunm/SatelliteDataType.kt @@ -12,4 +12,6 @@ Mix(1), // 缁嗗垎缃戞牸鏁版嵁 Sub(2), + // 璧拌埅鏄犲皠鏁版嵁 + Monitor(3) } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt index 17b7c44..3d4fa01 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt @@ -1,6 +1,7 @@ package com.flightfeather.uav.lightshare.service import com.flightfeather.uav.domain.entity.GridCell +import com.flightfeather.uav.domain.entity.GridDataDetail /** * @@ -21,4 +22,11 @@ * @param scale 鎷嗗垎鐨勭郴鏁帮紝渚嬪 2锛岃〃绀哄皢鍘熸湁缃戞牸鎸夎竟闀跨殑 1/2 鎷嗗垎鎴� 2 * 2 鐨�4涓綉鏍� */ fun splitGrid(groupId: Int, scale: Int): List<GridCell?> + + /** + * 灏嗗師濮嬬綉鏍肩殑鏁版嵁鏄犲皠濉厖鑷崇粏鍒嗙綉鏍� + * @param groupId 缁嗗垎缃戞牸缁勭储寮昳d + * @param dataId 鏁版嵁绱㈠紩id + */ + fun splitData(groupId: Int, dataId:Int): List<GridDataDetail?> } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt index 523f345..0799ea9 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt @@ -22,6 +22,8 @@ fun fetchGridGroup(areaVo: AreaVo, page: Int?, perPage: Int?): Pair<DataHead, List<GridGroup?>> + fun deleteGridGroup(groupId: Int) + fun fetchGridCell(groupId: Int): List<GridCell?> fun fetchGridData(groupId: Int, dataTime: LocalDateTime?, type: Int?): List<GridData?> diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt index 1d0acf1..d69174c 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt @@ -3,10 +3,18 @@ import com.flightfeather.uav.biz.satellite.SatelliteGridManage import com.flightfeather.uav.common.exception.BizException import com.flightfeather.uav.domain.entity.GridCell +import com.flightfeather.uav.domain.entity.GridData +import com.flightfeather.uav.domain.entity.GridDataDetail import com.flightfeather.uav.domain.entity.GridGroup import com.flightfeather.uav.domain.repository.SatelliteGridRep +import com.flightfeather.uav.lightshare.eunm.GridType +import com.flightfeather.uav.lightshare.eunm.SatelliteDataType import com.flightfeather.uav.lightshare.service.SatelliteDataCalculateService +import org.springframework.beans.BeanUtils import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import java.util.Date +import kotlin.math.round /** * 鍗槦缃戞牸鍧愭爣鍙婄洃娴嬫暟鎹簩娆¤绠� @@ -47,13 +55,74 @@ } override fun splitGrid(groupId: Int, scale: Int): List<GridCell?> { + // 妫�鏌ヨ缃戞牸灞炴�ф槸鍚﹀悎瑙� + val gridGroup = + satelliteGridRep.fetchGridGroup(groupId) ?: throw BizException("璇ョ綉鏍肩粍涓嶅瓨鍦紝鏃犳硶杩涜缃戞牸缁嗗垎") + if (gridGroup.length == null) throw BizException("璇ョ綉鏍肩粍娌℃湁璁惧畾缃戞牸杈归暱锛屾棤娉曡繘琛岀綉鏍肩粏鍒�") + // 妫�鏌ヨ缃戞牸涓嬭绉嶇被鐨勭粏鍒嗙綉鏍兼槸鍚﹀瓨鍦紝鑻ヤ笉瀛樺湪锛屽垯鏂板缓 - satelliteGridRep.fetchGridGroup(groupId) + val searchGridGroup = GridGroup().apply { + type = GridType.Sub.name.lowercase() + fatherGroupId = gridGroup.id + length = round(gridGroup.length / scale) + } + val subGridGroupList = satelliteGridRep.fetchGridGroup(searchGridGroup) + // 鑻ョ粏鍒嗙綉鏍艰褰曡秴杩�1涓紝璇存槑涓氬姟閫昏緫瀛樺湪闂锛岀浉鍚岃竟闀跨殑缁嗗垎缃戞牸搴旇鍙湁1涓� + if (subGridGroupList.size > 1) { + throw BizException("璇ョ綉鏍肩粍涓�${searchGridGroup.length}绫宠竟闀跨殑缃戞牸璁板綍瓒呰繃1涓紝鏃犳硶鍐嶈繘琛岀綉鏍肩粏鍒嗭紝骞朵笖璇锋鏌ョ敓鎴愰�昏緫鏄惁闂") + } + // 鑻ョ粏鍒嗙綉鏍艰褰曟湁涓斿彧鏈�1涓紝鍒欐棤闇�鍐嶆缁嗗垎锛岀洿鎺ヨ繑鍥炲凡鏈夌粨鏋� + else if (subGridGroupList.size == 1) { + val g = subGridGroupList.first() + ?: throw BizException("璇ョ綉鏍肩粍涓嬬殑缁嗗垎缃戞牸璁板綍宸叉崯鍧忥紝鏃犳硶浣跨敤锛岃妫�鏌ユ暟鎹簱璁板綍") + return satelliteGridRep.fetchGridCell(g.id) + } + // 褰撴病鏈夎褰曟椂锛屾墽琛岀敓鎴愰�昏緫 + + // 鐢熸垚鏂扮殑缁嗗垎缃戞牸缁勮褰� + val newGridGroup = GridGroup() + BeanUtils.copyProperties(gridGroup, newGridGroup) + newGridGroup.apply { + id = null + name += "${searchGridGroup.length.toInt()}绫崇粏鍒�" + createTime = Date() + length = searchGridGroup.length + type = GridType.Sub.name.lowercase() + fatherGroupId = groupId + } + satelliteGridRep.insertGridGroup(newGridGroup) + // 鑾峰彇鍏蜂綋缃戞牸淇℃伅 val cellList = satelliteGridRep.fetchGridCell(groupId) // 鎸夌収缁欏畾鐨勬媶鍒嗙郴鏁拌繘琛屾媶鍒� -// val subCellList = SatelliteGridManage.splitGrid(cellList, scale) + val subCellList = SatelliteGridManage.splitGrid(cellList, scale, newGridGroup.id) + satelliteGridRep.insertGridCell(subCellList) - return emptyList() + return subCellList + } + + @Transactional + override fun splitData(groupId: Int, dataId:Int): List<GridDataDetail?> { + // 妫�鏌ユ槸鍚︽槸缁嗗垎缃戞牸绫诲瀷 + val gridGroup = satelliteGridRep.fetchGridGroup(groupId) ?: throw BizException("璇ョ綉鏍肩粍涓嶅瓨鍦紝鏃犳硶杩涜缁嗗垎缃戞牸鏁版嵁鏄犲皠") + if (gridGroup.type != GridType.Sub.name.lowercase()) throw BizException("璇ョ綉鏍肩粍涓嶆槸缁嗗垎缃戞牸绫诲瀷瀛樺湪锛屾棤娉曡繘琛岀粏鍒嗙綉鏍兼暟鎹槧灏�") + + val subGridCellList = satelliteGridRep.fetchGridCell(groupId) + val originGridData = satelliteGridRep.fetchGridData(dataId) + val originGridDataDetailList = satelliteGridRep.fetchGridDataDetail(dataId, null, null) + + val subGridData = GridData().apply { + this.groupId = groupId + dataTime = originGridData?.dataTime + type = SatelliteDataType.Sub.value.toByte() + } + satelliteGridRep.insertGridData(subGridData) + + val subGridDataDetailList = + SatelliteGridManage.splitData(subGridCellList, subGridData, originGridDataDetailList) + + satelliteGridRep.insertGridDataDetail(subGridDataDetailList) + + return subGridDataDetailList } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt index 982c6ca..1caf954 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt @@ -44,6 +44,10 @@ return DataHead(pageInfo.pageNum, pageInfo.pages) to res } + override fun deleteGridGroup(groupId: Int) { + satelliteGridRep.deleteGridGroup(groupId) + } + override fun fetchGridCell(groupId: Int): List<GridCell?> { return satelliteGridRep.fetchGridCell(groupId) } diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 02d8369..75ca738 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -7,13 +7,13 @@ # password: cn.FLIGHTFEATHER # 杩滅▼鏈嶅姟鍣� - url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false - username: remoteU1 - password: eSoF8DnzfGTlhAjE - -# url: jdbc:mysql://114.215.109.124:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false +# url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false # username: remoteU1 -# password: feiyu2024 +# password: eSoF8DnzfGTlhAjE + + url: jdbc:mysql://114.215.109.124:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false + username: remoteU1 + password: feiyu2024 springfox: documentation: diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml index 469419f..4daa38b 100644 --- a/src/main/resources/generator/generatorConfig.xml +++ b/src/main/resources/generator/generatorConfig.xml @@ -67,7 +67,7 @@ <!-- <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"/>--> <table tableName="grid_group" domainObjectName="GridGroup" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> - <table tableName="grid_cell" domainObjectName="GridCell" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> +<!-- <table tableName="grid_cell" domainObjectName="GridCell" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="grid_data" domainObjectName="GridData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> </context> diff --git a/src/main/resources/mapper/GridGroupMapper.xml b/src/main/resources/mapper/GridGroupMapper.xml index 8f2ec4b..c7a1641 100644 --- a/src/main/resources/mapper/GridGroupMapper.xml +++ b/src/main/resources/mapper/GridGroupMapper.xml @@ -18,12 +18,13 @@ <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="length" jdbcType="DOUBLE" property="length" /> <result column="type" jdbcType="VARCHAR" property="type" /> + <result column="father_group_id" jdbcType="INTEGER" property="fatherGroupId" /> </resultMap> <sql id="Base_Column_List"> <!-- WARNING - @mbg.generated --> id, name, province_code, province_name, city_code, city_name, district_code, district_name, - town_code, town_name, create_time, length, type + town_code, town_name, create_time, length, type, father_group_id </sql> </mapper> \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt new file mode 100644 index 0000000..c01f0d5 --- /dev/null +++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt @@ -0,0 +1,29 @@ +package com.flightfeather.uav.lightshare.service.impl + +import com.flightfeather.uav.lightshare.service.SatelliteDataCalculateService +import org.junit.Test +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 SatelliteDataCalculateServiceImplTest { + + @Autowired + lateinit var satelliteDataCalculateService: SatelliteDataCalculateService + + @Test + fun splitGrid() { + val res = satelliteDataCalculateService.splitGrid(1, 4) +// println(res) + } + + @Test + fun splitData() { + val res = satelliteDataCalculateService.splitData(4, 25) +// println(res) + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt index 795f892..a675491 100644 --- a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt @@ -27,4 +27,9 @@ fun calGridVertex() { satelliteTelemetryService.calGridVertex(1) } + + @Test + fun deleteGridGroup() { + satelliteTelemetryService.deleteGridGroup(2) + } } \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImplTest.kt new file mode 100644 index 0000000..1d378c9 --- /dev/null +++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/ThirdPartyServiceImplTest.kt @@ -0,0 +1,22 @@ +package com.flightfeather.uav.lightshare.service.impl + +import com.flightfeather.uav.lightshare.eunm.ThirdPartyLabel +import com.flightfeather.uav.lightshare.service.ThirdPartyService +import org.junit.Test +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 ThirdPartyServiceImplTest { + + @Autowired + lateinit var thirdPartyService: ThirdPartyService + + @Test + fun fetchMissionData() { + thirdPartyService.fetchMissionData(ThirdPartyLabel.ShenXin.value, "20240914") + } +} \ No newline at end of file -- Gitblit v1.9.3