From 275ad59f206d9bc1801b28daeb31b4207f609ce3 Mon Sep 17 00:00:00 2001 From: hcong <1050828145@qq.com> Date: 星期四, 02 一月 2025 09:10:09 +0800 Subject: [PATCH] 1. 修改网格组数据导入接口返回值为bool 2. 修改网格组数据批量更新 使用Transactional注解 --- src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt | 31 ++++++++++++++++--------------- 1 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt b/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt index 423644f..13ffed5 100644 --- a/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/utils/FileExchange.kt @@ -8,7 +8,6 @@ import com.flightfeather.uav.domain.entity.RealTimeDataVehicle import com.flightfeather.uav.socket.bean.AirData import org.apache.poi.hssf.usermodel.HSSFWorkbook -import org.apache.poi.ss.usermodel.Cell import org.apache.poi.ss.usermodel.CellType import org.apache.poi.ss.util.CellAddress import org.apache.poi.xssf.streaming.SXSSFWorkbook @@ -166,23 +165,24 @@ this.pm25 = it.getCell(1)?.numericCellValue?.toFloat() } else -> { - throw BizException("鍗曞厓鏍糩${pm25CellPosStr}]涓嶆槸鏁板瓧绫诲瀷") + throw BizException("鍗曞厓鏍糩${pm25CellPosStr}]涓嶆槸鏁板瓧绫诲瀷鎴栬�呮枃鏈被鍨�") } } } result.add(data) }) - } catch (e: BizException) { - throw e + } catch (e: Exception) { + e.printStackTrace() + throw BizException("excel鏂囦欢鍐呭閿欒锛屾暟鎹浆鎹㈠け璐ワ紒", e) } // 鍒ゆ柇缃戞牸鍗曞厓鏍肩紪鍙锋槸鍚﹀湪姝g‘鐨勮寖鍥村唴 - val resultCellIdSet = result.asSequence().map { it.cellId ?: -1 }.toSet() + val resultCellIdSet = result.map { it.cellId ?: -1 }.toSet() // 鐢ㄦ埛瀵煎叆涓己灏戠殑鐨勫崟鍏冩牸 - val shortCells = correctRangeGridCells - resultCellIdSet + val lackCells = correctRangeGridCells - resultCellIdSet // excel 涓鍑虹殑鐨勫崟鍏冩牸 val outCells = resultCellIdSet - correctRangeGridCells - if (shortCells.isNotEmpty()) { - throw BizException("瀵煎叆鏁版嵁涓己灏戜互涓嬬綉鏍煎崟鍏冩牸锛�${shortCells.joinToString(",")}") + if (lackCells.isNotEmpty()) { + throw BizException("瀵煎叆鏁版嵁涓己灏戜互涓嬬綉鏍煎崟鍏冩牸锛�${lackCells.joinToString(",")}") } if (outCells.isNotEmpty()) { throw BizException("瀵煎叆鏁版嵁涓湁澶氫綑缃戞牸鍗曞厓鏍硷細${outCells.joinToString(",")}") @@ -265,17 +265,18 @@ } result.add(data) }) - } catch (e: BizException) { - throw e + } catch (e: Exception) { + e.printStackTrace() + throw BizException("excel鏂囦欢鍐呭閿欒锛屾暟鎹浆鎹㈠け璐ワ紒", e) } // 鍒ゆ柇缃戞牸鍗曞厓鏍肩紪鍙锋槸鍚﹀湪姝g‘鐨勮寖鍥村唴 - val resultCellIdSet = result.asSequence().map { it.cellId ?: -1 }.toSet() + val resultCellIdSet = result.map { it.cellId ?: -1 }.toSet() // 鐢ㄦ埛瀵煎叆涓己灏戠殑鐨勫崟鍏冩牸 - val shortCells = correctRangeGridCells - resultCellIdSet + val lackCells = correctRangeGridCells - resultCellIdSet // excel 涓鍑虹殑鐨勫崟鍏冩牸 val outCells = resultCellIdSet - correctRangeGridCells - if (shortCells.isNotEmpty()) { - throw BizException("瀵煎叆鏁版嵁涓己灏戜互涓嬬綉鏍煎崟鍏冩牸锛�${shortCells.joinToString(",")}") + if (lackCells.isNotEmpty()) { + throw BizException("瀵煎叆鏁版嵁涓己灏戜互涓嬬綉鏍煎崟鍏冩牸锛�${lackCells.joinToString(",")}") } if (outCells.isNotEmpty()) { throw BizException("瀵煎叆鏁版嵁涓湁澶氫綑缃戞牸鍗曞厓鏍硷細${outCells.joinToString(",")}") @@ -619,4 +620,4 @@ out.flush() out.close() } -} \ No newline at end of file +} -- Gitblit v1.9.3