feiyu02
2024-02-02 83455446544f89b0663a3f520744331ad8259289
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt
@@ -1,7 +1,10 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.common.exception.ResponseErrorException
import com.flightfeather.uav.domain.entity.Mission
import com.flightfeather.uav.domain.entity.RealTimeDataVehicle
import com.flightfeather.uav.domain.mapper.MissionMapper
import com.flightfeather.uav.domain.mapper.RealTimeDataVehicleMapper
import com.flightfeather.uav.lightshare.bean.BaseResponse
import com.flightfeather.uav.lightshare.bean.DataHead
import com.flightfeather.uav.lightshare.service.MissionService
@@ -10,7 +13,10 @@
import tk.mybatis.mapper.entity.Example
@Service
class MissionServiceImpl(private val missionMapper: MissionMapper) : MissionService {
class MissionServiceImpl(
    private val missionMapper: MissionMapper,
    private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper,
) : MissionService {
    override fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> {
        val _perPage = perPage ?: 60
        val _page = page ?: 1
@@ -39,4 +45,14 @@
            return BaseResponse(it == 1)
        }
    }
    override fun deleteMissionAndData(missionCode: String): Boolean {
        val mission = missionMapper.selectByPrimaryKey(missionCode) ?: throw ResponseErrorException("任务不存在")
        missionMapper.deleteByPrimaryKey(missionCode)
        realTimeDataVehicleMapper.deleteByExample(Example(RealTimeDataVehicle::class.java).apply {
            createCriteria().andEqualTo("deviceCode", mission.deviceCode)
                .andBetween("dataTime", mission.startTime, mission.endTime)
        })
        return true
    }
}