| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.biz.FactorFilter |
| | | import com.flightfeather.uav.biz.mission.MissionUtil |
| | | import com.flightfeather.uav.biz.report.MissionReport |
| | | import com.flightfeather.uav.common.exception.BizException |
| | | 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.domain.repository.MissionRep |
| | | import com.flightfeather.uav.domain.repository.RealTimeDataRep |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.service.MissionService |
| | |
| | | private val missionMapper: MissionMapper, |
| | | private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper, |
| | | private val missionReport: MissionReport, |
| | | private val missionRep: MissionRep, |
| | | private val realTimeDataRep: RealTimeDataRep |
| | | ) : MissionService { |
| | | override fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> { |
| | | override fun getMission(type: String?, page: Int?, perPage: Int?): Pair<DataHead, List<Mission>> { |
| | | val _perPage = perPage ?: 60 |
| | | val _page = page ?: 1 |
| | | val pageInfo = PageHelper.startPage<Mission>(_page, _perPage) |
| | |
| | | } |
| | | orderBy("startTime").desc() |
| | | }).forEach { it?.let { result.add(it) } } |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages),data = result) |
| | | // return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages),data = result) |
| | | return DataHead(pageInfo.pageNum, pageInfo.pages) to result |
| | | } |
| | | |
| | | @Synchronized |
| | | override fun createMission(mission: Mission): BaseResponse<Boolean> { |
| | | override fun createMission(mission: Mission): Boolean { |
| | | missionMapper.selectByPrimaryKey(mission.missionCode)?.run { |
| | | return BaseResponse(false, "任务编号已存在") |
| | | // return BaseResponse(false, "任务编号已存在") |
| | | throw BizException("任务编号已存在") |
| | | } |
| | | missionMapper.insert(mission).let { |
| | | return BaseResponse(it == 1) |
| | | return it == 1 |
| | | } |
| | | } |
| | | |
| | | override fun deleteMission(missionCode: String): BaseResponse<Boolean> { |
| | | override fun updateMission(mission: Mission): Boolean { |
| | | missionMapper.updateByPrimaryKey(mission).let { |
| | | return it == 1 |
| | | } |
| | | } |
| | | |
| | | override fun deleteMission(missionCode: String): Boolean { |
| | | missionMapper.deleteByPrimaryKey(missionCode).let { |
| | | return BaseResponse(it == 1) |
| | | return it == 1 |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | return |
| | | } |
| | | |
| | | override fun calMissionInfo(missionCode: String): Boolean { |
| | | val mission = missionRep.findOne(missionCode) ?: throw BizException("走航任务不存在") |
| | | val data = realTimeDataRep.fetchData(mission) |
| | | mission.kilometres = MissionUtil.calKilometres(data).toFloat() |
| | | // todo: 计算走航任务所在中心区域 |
| | | mission.region = MissionUtil.calRegion(data) |
| | | return updateMission(mission) |
| | | } |
| | | } |