From 9d4ca2e7bdfc0d634b0cc27c7fbe23740f4bb398 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期五, 27 十二月 2024 15:43:30 +0800
Subject: [PATCH] 1. 新增aod数据索引,aod详细数据实体类,mapper,service 2. 新增卫星遥测数据网格数据pm2.5、aod数据导入,模板下载 3. FileExchange.kt 新增转换pm2.5和aod数据方法

---
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 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 a7a0458..e0f0d8a 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
@@ -13,6 +13,8 @@
 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
@@ -35,11 +37,18 @@
         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)
         }
     }
@@ -61,6 +70,15 @@
     }
 
     override fun getReport(missionCode: String, response: HttpServletResponse) {
-        missionReport.execute(missionCode, FactorFilter.default())
+        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