| @@ -14,6 +14,7 @@ import com.ffii.fpsms.modules.stock.enums.StockTakeLineStatus | |||||
| import com.ffii.fpsms.modules.stock.enums.StockTakeStatus | import com.ffii.fpsms.modules.stock.enums.StockTakeStatus | ||||
| import com.ffii.fpsms.modules.stock.web.model.* | import com.ffii.fpsms.modules.stock.web.model.* | ||||
| import org.apache.poi.ss.usermodel.Cell | import org.apache.poi.ss.usermodel.Cell | ||||
| import org.apache.poi.ss.usermodel.CellType | |||||
| import org.apache.poi.ss.usermodel.Sheet | import org.apache.poi.ss.usermodel.Sheet | ||||
| import org.apache.poi.ss.usermodel.Workbook | import org.apache.poi.ss.usermodel.Workbook | ||||
| import org.slf4j.Logger | import org.slf4j.Logger | ||||
| @@ -63,6 +64,15 @@ class StockTakeService( | |||||
| } | } | ||||
| // ---------------------------------------------- Import Excel ---------------------------------------------- // | // ---------------------------------------------- Import Excel ---------------------------------------------- // | ||||
| fun getCellStringValue(cell: Cell): String { | |||||
| return cell.let { | |||||
| when (it.cellType) { | |||||
| CellType.STRING -> it.stringCellValue | |||||
| CellType.NUMERIC -> it.numericCellValue | |||||
| else -> null | |||||
| } | |||||
| }.toString() | |||||
| } | |||||
| fun importExcel(workbook: Workbook?): String { | fun importExcel(workbook: Workbook?): String { | ||||
| logger.info("--------- Start - Import Stock Take Excel -------"); | logger.info("--------- Start - Import Stock Take Excel -------"); | ||||
| @@ -107,9 +117,9 @@ class StockTakeService( | |||||
| // Warehouse | // Warehouse | ||||
| val warehouse = try { | val warehouse = try { | ||||
| val code = row.getCell(COLUMN_WAREHOSE_INDEX).stringCellValue | |||||
| val zone = row.getCell(COLUMN_ZONE_INDEX).stringCellValue | |||||
| val slot = row.getCell(COLUMN_SLOT_INDEX).stringCellValue | |||||
| val code = getCellStringValue(row.getCell(COLUMN_WAREHOSE_INDEX)) | |||||
| val zone = getCellStringValue(row.getCell(COLUMN_ZONE_INDEX)) | |||||
| val slot = getCellStringValue(row.getCell(COLUMN_SLOT_INDEX)) | |||||
| // logger.info("Warehouse code - zone - slot: ${row.getCell(COLUMN_WAREHOSE_INDEX).cellType} - ${row.getCell(COLUMN_ZONE_INDEX).cellType} - ${row.getCell(COLUMN_SLOT_INDEX).cellType}") | // logger.info("Warehouse code - zone - slot: ${row.getCell(COLUMN_WAREHOSE_INDEX).cellType} - ${row.getCell(COLUMN_ZONE_INDEX).cellType} - ${row.getCell(COLUMN_SLOT_INDEX).cellType}") | ||||
| val defaultCapacity = BigDecimal(10000) | val defaultCapacity = BigDecimal(10000) | ||||