| | |
| | | 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 gridAodDetailMapper: GridAodDetailMapper, |
| | | ) { |
| | | |
| | | fun fetchGridGroup(areaVo: AreaVo): List<GridGroup?> { |
| | | fun fetchGridGroup(areaVo: AreaVo, type: String?): List<GridGroup?> { |
| | | return gridGroupMapper.selectByExample(Example(GridGroup::class.java).apply { |
| | | createCriteria() |
| | | .andEqualTo("provinceCode", areaVo.provinceCode).andEqualTo("provinceName", areaVo.provinceName) |
| | | .andEqualTo("cityCode", areaVo.cityCode).andEqualTo("cityName", areaVo.cityName) |
| | | .andEqualTo("districtCode", areaVo.districtCode).andEqualTo("districtName", areaVo.districtName) |
| | | .andEqualTo("townCode", areaVo.townCode).andEqualTo("townName", areaVo.townName) |
| | | .andEqualTo("type", type) |
| | | }) |
| | | } |
| | | |
| | | fun fetchGridGroup(id: Int): GridGroup? { |
| | | return gridGroupMapper.selectByPrimaryKey(id) |
| | | } |
| | | |
| | | fun fetchGridGroup(gridGroup: GridGroup): List<GridGroup?> { |
| | | 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 { |
| | |
| | | orderBy("id") |
| | | }) |
| | | } |
| | | |
| | | fun insertGridCell(gridCellList: List<GridCell?>): Int { |
| | | return gridCellMapper.insertList(gridCellList) |
| | | } |
| | | |
| | | /*****************************************************************/ |
| | | |
| | | fun fetchGridData(groupId: Int, dataTime: LocalDateTime?, type: Int?): List<GridData?> { |
| | | return gridDataMapper.selectByExample(Example(GridData::class.java).apply { |
| | |
| | | return gridDataMapper.select(gridData) |
| | | } |
| | | |
| | | fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> { |
| | | 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 updateGridDataDetail(gridDataDetails: List<GridDataDetail?>): Int { |
| | | var res = 0 |
| | | gridDataDetails.forEach { |
| | | res += gridDataDetailMapper.updateByPrimaryKey(it) |
| | | } |
| | | return res |
| | | } |
| | | |
| | | fun fetchGridDataDetail(dataId: Int?, groupId: Int?, cellId: Int?): List<GridDataDetail?> { |
| | | return gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply { |
| | | createCriteria().andEqualTo("dataId", dataId) |
| | | .andEqualTo("groupId", groupId) |
| | |
| | | gridDataDetailMapper.updatePM25Batch(gridDataDetails) |
| | | } |
| | | |
| | | /*****************************************************************/ |
| | | |
| | | // aod 相关操作 |
| | | fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { |
| | |
| | | .andEqualTo("cellId", it.cellId) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | fun updateGridCellBatch(gridCellList: List<GridCell?>) { |
| | | gridCellList.forEach { gridCellMapper.updateByPrimaryKey(it) } |
| | | } |
| | | |
| | | } |