| | |
| | | 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 |
| | |
| | | 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 -> { |
| | |
| | | result.add(data) |
| | | } |
| | | } catch (e: IllegalStateException) { |
| | | throw BizException("excel文件内容错误,数据转换失败!", e) |
| | | throw BizException(e.message, e) |
| | | } |
| | | return result |
| | | } |
| | |
| | | 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, "单元格格式不是常见格式,无法识别")) |
| | | } |
| | | } |
| | | } |