| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.biz.FactorFilter |
| | | import com.flightfeather.uav.biz.report.MissionReport |
| | | import com.flightfeather.uav.common.exception.BizException |
| | | import com.flightfeather.uav.domain.entity.Mission |
| | |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.io.File |
| | | import java.util.* |
| | | import javax.servlet.http.HttpServletResponse |
| | | |
| | | @Service |
| | |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages),data = result) |
| | | } |
| | | |
| | | @Synchronized |
| | | override fun createMission(mission: Mission): BaseResponse<Boolean> { |
| | | missionMapper.selectByPrimaryKey(mission.missionCode)?.run { |
| | | return BaseResponse(false, "任务编号已存在") |
| | | } |
| | | missionMapper.insert(mission).let { |
| | | return BaseResponse(it == 1) |
| | | } |
| | | } |
| | | |
| | | override fun updateMission(mission: Mission): BaseResponse<Boolean> { |
| | | missionMapper.updateByPrimaryKey(mission).let { |
| | | return BaseResponse(it == 1) |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | override fun getReport(missionCode: String, response: HttpServletResponse) { |
| | | missionReport.execute(missionCode) |
| | | val path = missionReport.execute(missionCode, FactorFilter.default()) |
| | | val pathArr = path.split("/") |
| | | val file = File(path) |
| | | if (file.exists()) { |
| | | response.contentType = "application/vnd.ms-excel;charset=UTF-8" |
| | | val name = Base64.getEncoder().encodeToString(pathArr.last().toByteArray()) |
| | | response.setHeader("fileName", name) |
| | | response.outputStream.write(file.readBytes()) |
| | | } |
| | | return |
| | | } |
| | | } |