From 85ef942e7195abeb71466b7159c3ee30161e1e54 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 07 四月 2026 08:51:01 +0800
Subject: [PATCH] 2026.4.7
---
src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt | 49 +++++++++++++++++++++++++++++++------------------
1 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt b/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt
index ec2d8ef..a11e82e 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/business/import/SceneImport.kt
@@ -7,6 +7,7 @@
import cn.flightfeather.supervision.domain.ds1.repository.RegionRep
import cn.flightfeather.supervision.lightshare.vo.SceneDetail
import com.google.gson.Gson
+import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.CellType
import org.springframework.stereotype.Component
import java.io.InputStream
@@ -111,23 +112,23 @@
when (scense?.typeid.toString()) {
Constant.SceneType.TYPE1.value -> {
subScene = SceneConstructionSite().apply {
- csProjectType = it.getCell(12)?.stringCellValue?.trim()
- csStatus = it.getCell(13)?.stringCellValue?.trim()
- siExtension1 = it.getCell(14)?.stringCellValue?.trim()
- csStartTime = it.getCell(15)?.stringCellValue?.trim()
- csEndTime = it.getCell(16)?.stringCellValue?.trim()
- csLeftTime = it.getCell(17)?.stringCellValue?.trim()
- csFloorSpace = it.getCell(18)?.numericCellValue?.toString()
- csConstructionArea = it.getCell(19)?.numericCellValue?.toString()
- csConstructionAreaPerMonth = it.getCell(20)?.numericCellValue?.toString()
- csEmployerUnit = it.getCell(21)?.stringCellValue?.trim()
- csEmployerContacts = it.getCell(22)?.stringCellValue?.trim()
- csEmployerContactsTel = it.getCell(23)?.stringCellValue?.trim()
- csConstructionUnit = it.getCell(24)?.stringCellValue?.trim()
- csConstructionContacts = it.getCell(25)?.stringCellValue?.trim()
- csConstructionContactsTel = it.getCell(26)?.stringCellValue?.trim()
- csSecurityOfficer = it.getCell(27)?.stringCellValue?.trim()
- csSecurityOfficerTel = it.getCell(28)?.stringCellValue?.trim()
+ csProjectType = getCellValueToString(it.getCell(12))
+ csStatus = getCellValueToString(it.getCell(13))
+ siExtension1 = getCellValueToString(it.getCell(14))
+ csStartTime = getCellValueToString(it.getCell(15))
+ csEndTime = getCellValueToString(it.getCell(16))
+ csLeftTime = getCellValueToString(it.getCell(17))
+ csFloorSpace = getCellValueToString(it.getCell(18))
+ csConstructionArea = getCellValueToString(it.getCell(19))
+ csConstructionAreaPerMonth = getCellValueToString(it.getCell(20))
+ csEmployerUnit = getCellValueToString(it.getCell(21))
+ csEmployerContacts = getCellValueToString(it.getCell(22))
+ csEmployerContactsTel = getCellValueToString(it.getCell(23))
+ csConstructionUnit = getCellValueToString(it.getCell(24))
+ csConstructionContacts = getCellValueToString(it.getCell(25))
+ csConstructionContactsTel = getCellValueToString(it.getCell(26))
+ csSecurityOfficer = getCellValueToString(it.getCell(27))
+ csSecurityOfficerTel = getCellValueToString(it.getCell(28))
}
}
Constant.SceneType.TYPE2.value -> {
@@ -145,7 +146,7 @@
result.add(data)
}
} catch (e: IllegalStateException) {
- throw BizException("excel鏂囦欢鍐呭閿欒锛屾暟鎹浆鎹㈠け璐ワ紒", e)
+ throw BizException(e.message, e)
}
return result
}
@@ -153,4 +154,16 @@
private fun errorStr(row: Int, col: Int, str: String): String {
return "绗�${row}琛岋紝绗�${col}鍒楀崟鍏冩牸閿欒锛�${str}"
}
+
+ private fun getCellValueToString(cell: Cell?): String {
+ cell ?: return ""
+ return when (cell.cellType) {
+ CellType.STRING -> cell.stringCellValue.trim()
+ CellType.NUMERIC -> cell.numericCellValue.toString().trim()
+ CellType.BLANK -> cell.stringCellValue.trim()
+ CellType.BOOLEAN -> cell.booleanCellValue.toString().trim()
+ CellType.ERROR -> cell.errorCellValue.toString().trim()
+ else -> throw BizException(errorStr(cell.rowIndex + 1, cell.columnIndex + 1, "鍗曞厓鏍兼牸寮忎笉鏄父瑙佹牸寮忥紝鏃犳硶璇嗗埆"))
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3