| | |
| | | package com.flightfeather.uav.domain.repository |
| | | |
| | | 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.entity.* |
| | | import com.flightfeather.uav.domain.mapper.GridAodDetailMapper |
| | | import com.flightfeather.uav.domain.mapper.GridAodMapper |
| | | import com.flightfeather.uav.domain.mapper.GridCellMapper |
| | | import com.flightfeather.uav.domain.mapper.GridDataDetailMapper |
| | | import com.flightfeather.uav.domain.mapper.GridDataMapper |
| | | import com.flightfeather.uav.domain.mapper.GridGroupMapper |
| | | import com.flightfeather.uav.lightshare.bean.AreaVo |
| | | import org.springframework.stereotype.Repository |
| | | import org.springframework.transaction.annotation.Transactional |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.time.LocalDateTime |
| | | |
| | |
| | | private val gridCellMapper: GridCellMapper, |
| | | private val gridDataMapper: GridDataMapper, |
| | | private val gridDataDetailMapper: GridDataDetailMapper, |
| | | private val gridAodMapper: GridAodMapper, |
| | | private val gridAodDetailMapper: GridAodDetailMapper, |
| | | ) { |
| | | |
| | | fun fetchGridGroup(areaVo: AreaVo): List<GridGroup?> { |
| | |
| | | orderBy("cellId") |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 插入网格组PM2.5数据索引和详细数据。 |
| | | * |
| | | * @param data 网格组PM2.5数据索引。 |
| | | * @param gridDataDetails 网格组PM2.5详细数据列表。 |
| | | * @author hc |
| | | * @date 2024-12-29 |
| | | */ |
| | | fun insertGridDataAndDetail(data: GridData, gridDataDetails: List<GridDataDetail>) { |
| | | gridDataMapper.insert(data) |
| | | gridDataDetails.forEach { |
| | | it.dataId = data.id |
| | | it.groupId = data.groupId |
| | | } |
| | | gridDataDetailMapper.insertList(gridDataDetails) |
| | | } |
| | | |
| | | /** |
| | | * 更新网格组详细数据。 |
| | | * |
| | | * @param gridDataDetails 需要更新的网格组详细数据列表。 |
| | | * @author hc |
| | | * @date 2024-12-29 |
| | | */ |
| | | @Transactional(rollbackFor = [Exception::class]) |
| | | fun updatePM25Batch(gridDataDetails: List<GridDataDetail>) { |
| | | gridDataDetails.forEach { |
| | | gridDataDetailMapper.updateByExample(it, Example(GridDataDetail::class.java).apply { |
| | | createCriteria().andEqualTo("dataId", it.dataId) |
| | | .andEqualTo("groupId", it.groupId) |
| | | .andEqualTo("cellId", it.cellId) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据组ID和数据时间获取网格组aod数据索引。 |
| | | * |
| | | * @param groupId 网格组ID。 |
| | | * @param dataTime 数据时间。 |
| | | * @return 网格组aod数据索引列表。 |
| | | * @author hc |
| | | * @date 2024-12-29 |
| | | */ |
| | | fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { |
| | | return gridAodMapper.selectByExample(Example(GridAod::class.java).apply { |
| | | createCriteria().andEqualTo("groupId", groupId) |
| | | .andEqualTo("dataTime", dataTime) |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 获取网格组aod数据详情。 |
| | | * |
| | | * @param aodId aod数据ID。 |
| | | * @param groupId 网格组ID。 |
| | | * @param cellId 单元格ID。 |
| | | * @return 网格组aod数据详情列表。 |
| | | * @author hc |
| | | * @date 2024-12-29 |
| | | */ |
| | | fun fetchGridAodDetail(aodId: Int, groupId: Int?, cellId: Int?): List<GridAodDetail?> { |
| | | return gridAodDetailMapper.selectByExample(Example(GridAodDetail::class.java).apply { |
| | | createCriteria().andEqualTo("aodId", aodId) |
| | | .andEqualTo("groupId", groupId) |
| | | .andEqualTo("cellId", cellId) |
| | | orderBy("cellId") |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * 插入网格组aod数据索引和详细数据。 |
| | | * |
| | | * @param aod 网格组aod数据索引。 |
| | | * @param gridAodDetails 网格组aod详细数据列表。 |
| | | * @author hc |
| | | * @date 2024-12-29 |
| | | */ |
| | | fun insertGridAodAndDetail(aod: GridAod, gridAodDetails: List<GridAodDetail>) { |
| | | gridAodMapper.insert(aod) |
| | | gridAodDetails.forEach { |
| | | it.aodId = aod.id |
| | | it.groupId = aod.groupId |
| | | } |
| | | gridAodDetailMapper.insertList(gridAodDetails) |
| | | } |
| | | |
| | | /** |
| | | * 更新网格组aod数据详情。 |
| | | * |
| | | * @param gridDataDetails 需要更新的网格组aod详细数据列表。 |
| | | * @author hc |
| | | * @date 2024-12-29 |
| | | */ |
| | | @Transactional(rollbackFor = [Exception::class]) |
| | | fun updateGridAodBatch(gridDataDetails: List<GridAodDetail>) { |
| | | gridDataDetails.forEach { |
| | | gridAodDetailMapper.updateByExample(it, Example(GridAodDetail::class.java).apply { |
| | | createCriteria().andEqualTo("aodId", it.aodId) |
| | | .andEqualTo("groupId", it.groupId) |
| | | .andEqualTo("cellId", it.cellId) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | } |