From 6d766eed50f34b102e607ea471f2ee565a8b9d30 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 17 一月 2025 16:15:43 +0800 Subject: [PATCH] 1. 修改融合数据逻辑中,融合数据id数组为先排序后转换为字符串,修复同一批原始数据因为id排序不一样被判定为不同的融合数据的问题; --- src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 43 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 f88d392..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 @@ -1,16 +1,28 @@ 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.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 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) : MissionService { +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 val _page = page ?: 1 @@ -25,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, "浠诲姟缂栧彿宸插瓨鍦�") @@ -34,9 +47,38 @@ } } + override fun updateMission(mission: Mission): BaseResponse<Boolean> { + missionMapper.updateByPrimaryKey(mission).let { + return BaseResponse(it == 1) + } + } + override fun deleteMission(missionCode: String): BaseResponse<Boolean> { missionMapper.deleteByPrimaryKey(missionCode).let { return BaseResponse(it == 1) } } + + override fun deleteMissionAndData(missionCode: String): Boolean { + val mission = missionMapper.selectByPrimaryKey(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�") + missionMapper.deleteByPrimaryKey(missionCode) + realTimeDataVehicleMapper.deleteByExample(Example(RealTimeDataVehicle::class.java).apply { + createCriteria().andEqualTo("deviceCode", mission.deviceCode) + .andBetween("dataTime", mission.startTime, mission.endTime) + }) + 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