2 Commits

1 changed files with 22 additions and 11 deletions
Split View
  1. +22
    -11
      src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt

+ 22
- 11
src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt View File

@@ -316,17 +316,27 @@ open class BomService(
}
val leftTargetValueRow = sheet.getRow(startRowIndex)
val leftTargetValueCell = leftTargetValueRow.getCell(startColumnIndex + 1)

fun getCellValueAsString(cell: org.apache.poi.ss.usermodel.Cell?): String {
return when {
cell == null -> ""
cell.cellType == CellType.STRING -> cell.stringCellValue.trim()
cell.cellType == CellType.NUMERIC -> cell.numericCellValue.toString().trim()
cell.cellType == CellType.BLANK -> ""
else -> ""
}
}

when {
tempCellVal.contains("深淺") -> request.isDark = calculateColourScore(leftTargetValueCell.stringCellValue.trim())
tempCellVal.contains("浮沉") -> request.isFloat = calculateFloatScore(leftTargetValueCell.stringCellValue.trim())
tempCellVal.contains("過敏原 (如有)") -> request.allergicSubstances = calculateAllergicSubstancesScore(leftTargetValueCell.stringCellValue.trim())
tempCellVal.contains("濃淡") -> request.isDense = if (leftTargetValueCell.cellType == CellType.NUMERIC)
tempCellVal.contains("深淺") -> request.isDark = calculateColourScore(getCellValueAsString(leftTargetValueCell))
tempCellVal.contains("浮沉") -> request.isFloat = calculateFloatScore(getCellValueAsString(leftTargetValueCell))
tempCellVal.contains("過敏原 (如有)") -> request.allergicSubstances = calculateAllergicSubstancesScore(getCellValueAsString(leftTargetValueCell))
tempCellVal.contains("濃淡") -> request.isDense = if (leftTargetValueCell?.cellType == CellType.NUMERIC)
leftTargetValueCell.numericCellValue.toInt()
else 0
tempCellVal.contains("損耗率") -> request.scrapRate = if (leftTargetValueCell.cellType == CellType.NUMERIC)

tempCellVal.contains("損耗率") -> request.scrapRate = if (leftTargetValueCell?.cellType == CellType.NUMERIC)
leftTargetValueCell.numericCellValue.toInt()
else 0
else 0
}
}
if (startRowIndex < endRowIndex) {
@@ -356,9 +366,10 @@ open class BomService(
var process = processRepository.findByNameAndDeletedIsFalse(name)
?: processRepository.findByCodeAndDeletedIsFalse(name)
if (process == null) {
val truncatedName = name.take(30)
process = Process().apply {
this.name = name
this.code = name
this.name = truncatedName
this.code = truncatedName
this.description = name
}
process = processRepository.saveAndFlush(process)
@@ -526,8 +537,8 @@ open class BomService(
val resolver = PathMatchingResourcePatternResolver()
// val excels = resolver.getResources("bomImport/*.xlsx")
//val excels = resolver.getResources("file:C:/Users/Kelvin YAU/Downloads/bom/*.xlsx")
//val excels = resolver.getResources("file:C:/Users/Kelvin YAU/Downloads/bom/*.xlsx")
val excels = resolver.getResources("file:C:/Users/kw093/Downloads/bom/bom/*.xlsx")
val excels = resolver.getResources("file:C:/Users/Kelvin YAU/Downloads/bom/*.xlsx")
//val excels = resolver.getResources("file:C:/Users/kw093/Downloads/bom/bom/*.xlsx")
// val excels = resolver.getResources("file:C:/Users/2Fi/Desktop/Third Wave of BOM Excel/*.xlsx")
println("size: ${excels.size}")
val logExcel = ClassPathResource("excelTemplate/bom_excel_issue_log.xlsx")


Loading…
Cancel
Save