From 9ed0b1847912221197697791d69e01ccae17f5b9 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 27 八月 2024 17:36:11 +0800 Subject: [PATCH] 1. 新增NO监测因子 2. 新增第三方数据接口数据获取相关模块 --- src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt index d9cffe4..a1b05e1 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt @@ -1,6 +1,8 @@ package com.flightfeather.uav.lightshare.service.impl -import com.flightfeather.uav.common.exception.ResponseErrorException +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.flightfeather.uav.domain.entity.RealTimeDataVehicle import com.flightfeather.uav.domain.mapper.MissionMapper @@ -11,11 +13,15 @@ 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 class MissionServiceImpl( private val missionMapper: MissionMapper, private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper, + private val missionReport: MissionReport, ) : MissionService { override fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> { val _perPage = perPage ?: 60 @@ -31,6 +37,7 @@ 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, "浠诲姟缂栧彿宸插瓨鍦�") @@ -47,7 +54,7 @@ } override fun deleteMissionAndData(missionCode: String): Boolean { - val mission = missionMapper.selectByPrimaryKey(missionCode) ?: throw ResponseErrorException("浠诲姟涓嶅瓨鍦�") + val mission = missionMapper.selectByPrimaryKey(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�") missionMapper.deleteByPrimaryKey(missionCode) realTimeDataVehicleMapper.deleteByExample(Example(RealTimeDataVehicle::class.java).apply { createCriteria().andEqualTo("deviceCode", mission.deviceCode) @@ -55,4 +62,17 @@ }) return true } + + override fun getReport(missionCode: String, response: HttpServletResponse) { + 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 + } } \ No newline at end of file -- Gitblit v1.9.3