|
|
@@ -79,8 +79,8 @@ open class BomService( |
|
|
|
|
|
|
|
//////// -------------------------------- for excel import ------------------------------- ///////// |
|
|
|
private fun saveBomEntity(req: ImportBomRequest): Bom { |
|
|
|
val item = if (req.itemId != null) itemsRepository.findById(req.itemId).orElseThrow() else null |
|
|
|
val uom = if (req.uomId != null) uomConversionRepository.findById(req.uomId).orElseThrow() else null |
|
|
|
val item = itemsRepository.findByCodeAndDeletedFalse(req.code) ?: itemsRepository.findByNameAndDeletedFalse(req.name) |
|
|
|
val uom = if (req.uomId != null) uomConversionRepository.findById(req.uomId!!).orElseThrow() else null |
|
|
|
val bom = Bom().apply { |
|
|
|
this.isDark = req.isDark |
|
|
|
this.isFloat = req.isFloat |
|
|
@@ -101,11 +101,15 @@ open class BomService( |
|
|
|
} |
|
|
|
|
|
|
|
fun saveBomMaterial(req: ImportBomMatRequest): BomMaterial { |
|
|
|
// val uom = uomConversionRepository.findByCodeAndDeletedFalse() |
|
|
|
val bomMaterial = BomMaterial().apply { |
|
|
|
this.item = req.item |
|
|
|
this.itemName = req.item!!.name |
|
|
|
this.isConsumable = req.isConsumable |
|
|
|
this.qty = req.qty |
|
|
|
this.salesUnit = req.salesUnit |
|
|
|
this.salesUnitCode = req.salesUnit?.code |
|
|
|
this.uom = req.uom |
|
|
|
this.uomName = req.uomName |
|
|
|
this.bom = req.bom |
|
|
|
|
|
|
@@ -118,7 +122,7 @@ open class BomService( |
|
|
|
this.equipment = req.equipment |
|
|
|
this.description = req.description |
|
|
|
this.seqNo = req.seqNo |
|
|
|
this.duration = req.duration |
|
|
|
this.durationInMinute = req.durationInMinute |
|
|
|
this.prepTimeInMinute = req.prepTimeInMinute |
|
|
|
this.postProdTimeInMinute = req.postProdTimeInMinute |
|
|
|
this.bom = req.bom |
|
|
@@ -182,6 +186,12 @@ open class BomService( |
|
|
|
this.uomName = tempCell.stringCellValue.trim() |
|
|
|
} |
|
|
|
} |
|
|
|
7 -> { |
|
|
|
val salesUnit = uomConversionRepository.findByCodeAndDeletedFalse(tempCell.stringCellValue.trim()) |
|
|
|
bomMatRequest.apply { |
|
|
|
this.salesUnit = salesUnit |
|
|
|
} |
|
|
|
} |
|
|
|
10 -> { |
|
|
|
val bomProcess = bomProcessRepository.findBySeqNoAndBomIdAndDeletedIsFalse( |
|
|
|
seqNo = tempCell.numericCellValue.toInt(), |
|
|
@@ -219,9 +229,9 @@ open class BomService( |
|
|
|
description = "", |
|
|
|
) |
|
|
|
var startRowIndex = 0 |
|
|
|
val endRowIndex = 15 |
|
|
|
val endRowIndex = 8 |
|
|
|
var startColumnIndex = 0 |
|
|
|
val endColumnIndex = 15 |
|
|
|
val endColumnIndex = 9 |
|
|
|
while (startRowIndex != endRowIndex || startColumnIndex != endColumnIndex) { |
|
|
|
val tempRow = sheet.getRow(startRowIndex) |
|
|
|
val tempCell = tempRow.getCell(startColumnIndex) |
|
|
@@ -270,14 +280,14 @@ open class BomService( |
|
|
|
} |
|
|
|
val leftTargetValueRow = sheet.getRow(startRowIndex) |
|
|
|
val leftTargetValueCell = leftTargetValueRow.getCell(startColumnIndex + 1) |
|
|
|
when (tempCellVal) { |
|
|
|
"顔色深淺度" -> request.apply { |
|
|
|
when { |
|
|
|
tempCellVal.contains("深淺") -> request.apply { |
|
|
|
isDark = calculateColourScore(leftTargetValueCell.stringCellValue.trim()) |
|
|
|
} |
|
|
|
"浮沉" -> request.apply { |
|
|
|
tempCellVal.contains("浮沉") -> request.apply { |
|
|
|
isFloat = calculateFloatScore(leftTargetValueCell.stringCellValue.trim()) |
|
|
|
} |
|
|
|
"濃淡程度" -> request.apply { |
|
|
|
tempCellVal.contains("濃淡") -> request.apply { |
|
|
|
isDense = if (leftTargetValueCell.cellType == CellType.NUMERIC) leftTargetValueCell.numericCellValue.toInt() else 0 |
|
|
|
} |
|
|
|
} |
|
|
@@ -399,25 +409,55 @@ open class BomService( |
|
|
|
} |
|
|
|
} |
|
|
|
6 -> { //duration |
|
|
|
val durationString = tempCell.stringCellValue.trim() |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.duration = extractDurationStringToMinutes(durationString) |
|
|
|
when (tempCell.cellType) { |
|
|
|
CellType.NUMERIC -> { |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.durationInMinute = tempCell.numericCellValue.toInt() |
|
|
|
} |
|
|
|
} |
|
|
|
CellType.STRING -> { |
|
|
|
val durationString = tempCell.stringCellValue.trim() |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.durationInMinute = extractDurationStringToMinutes(durationString) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else -> {} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
10 -> { //prepTimeInMinute |
|
|
|
if (tempCell.cellType != CellType.BLANK) { |
|
|
|
val prepTimeInMinute = tempCell.stringCellValue.trim() |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.prepTimeInMinute = extractDurationStringToMinutes(prepTimeInMinute) |
|
|
|
when (tempCell.cellType) { |
|
|
|
CellType.NUMERIC -> { |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.prepTimeInMinute = tempCell.numericCellValue.toInt() |
|
|
|
} |
|
|
|
} |
|
|
|
CellType.STRING -> { |
|
|
|
val prepTimeInMinuteString = tempCell.stringCellValue.trim() |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.prepTimeInMinute = extractDurationStringToMinutes(prepTimeInMinuteString) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
11 -> { //prepTimeInMinute |
|
|
|
if (tempCell.cellType != CellType.BLANK) { |
|
|
|
val prepTimeInMinute = tempCell.stringCellValue.trim() |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.prepTimeInMinute = extractDurationStringToMinutes(prepTimeInMinute) |
|
|
|
11 -> { //postProdTimeInMinute |
|
|
|
when (tempCell.cellType) { |
|
|
|
CellType.NUMERIC -> { |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.postProdTimeInMinute = tempCell.numericCellValue.toInt() |
|
|
|
} |
|
|
|
} |
|
|
|
CellType.STRING -> { |
|
|
|
val postProdTimeInMinuteString = tempCell.stringCellValue.trim() |
|
|
|
bomProcessRequest.apply { |
|
|
|
this.postProdTimeInMinute = extractDurationStringToMinutes(postProdTimeInMinuteString) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else -> {} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|