瀏覽代碼

update bug

production_process
MSI\derek 2 月之前
父節點
當前提交
bf2e656493
共有 3 個文件被更改,包括 74 次插入113 次删除
  1. +1
    -0
      src/main/java/com/ffii/fpsms/modules/master/entity/UomConversionRepository.kt
  2. +72
    -112
      src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt
  3. +1
    -1
      src/main/java/com/ffii/fpsms/modules/master/web/models/SaveBomRequest.kt

+ 1
- 0
src/main/java/com/ffii/fpsms/modules/master/entity/UomConversionRepository.kt 查看文件

@@ -10,6 +10,7 @@ interface UomConversionRepository : AbstractRepository<UomConversion, Long> {
fun findAllByDeletedFalse(): List<UomConversion>;

fun findByIdAndDeletedFalse(id: Long): UomConversion?;
fun findByCodeAndDeletedFalse(code: String): UomConversion?;

fun findByM18IdAndDeletedFalse(m18Id: Long): UomConversion?;



+ 72
- 112
src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt 查看文件

@@ -137,9 +137,6 @@ open class BomService(
return bomProcessMaterialRepository.saveAndFlush(bomProcessMaterial)
}
private fun importExcelBomMaterial(bom: Bom, sheet: Sheet) {
var bomMatRequest = ImportBomMatRequest(
bom = bom
)
var bomProcessMatRequest = ImportBomProcessMaterialRequest()
var startRowIndex = 10
val endRowIndex = 30
@@ -155,6 +152,9 @@ open class BomService(
}
startRowIndex++
}
var bomMatRequest = ImportBomMatRequest(
bom = bom
)
while (startRowIndex != endRowIndex || startColumnIndex != endColumnIndex) {
val tempRow = sheet.getRow(startRowIndex)
val tempCell = tempRow.getCell(startColumnIndex)
@@ -172,57 +172,49 @@ open class BomService(
?: itemsRepository.findByNameAndDeletedFalse(nameCell.stringCellValue.trim())
// println("getting item.....:")
// println(item)
bomMatRequest.apply {
this.item = item
}
bomMatRequest.item = item
}
2 -> {
bomMatRequest.apply {
this.qty = tempCell.numericCellValue.toBigDecimal()
}
bomMatRequest.qty = tempCell.numericCellValue.toBigDecimal()
}
3 -> {
bomMatRequest.apply {
this.uomName = tempCell.stringCellValue.trim()
}
bomMatRequest.uomName = tempCell.stringCellValue.trim()
}
7 -> {
val salesUnit = uomConversionRepository.findByCodeAndDeletedFalse(tempCell.stringCellValue.trim())
bomMatRequest.apply {
this.salesUnit = salesUnit
}
bomMatRequest.salesUnit = salesUnit
}
10 -> {
val bomProcess = bomProcessRepository.findBySeqNoAndBomIdAndDeletedIsFalse(
seqNo = tempCell.numericCellValue.toInt(),
bomId = bom.id!!
)!! // if null = bugged
bomProcessMatRequest.apply {
this.bomProcess = bomProcess
}
bomProcessMatRequest.bomProcess = bomProcess
}
}
if (startColumnIndex < endColumnIndex) {
startColumnIndex++
} else if (startRowIndex < endRowIndex) {
startRowIndex++
// do save
val bomMaterial = saveBomMaterial(bomMatRequest)
bomProcessMatRequest.bomMaterial = bomMaterial
val bomProcessMaterial = saveBomProcessMaterial(bomProcessMatRequest)
// clean up
startColumnIndex = 0
bomMatRequest = ImportBomMatRequest(
bom = bom
)
}
} catch(e: Error) {
println("DEBUG ERROR:")
println(e)
}
}
if (startColumnIndex < endColumnIndex) {
startColumnIndex++
} else if (startRowIndex < endRowIndex) {
startRowIndex++
// do save
val bomMaterial = saveBomMaterial(bomMatRequest)
bomProcessMatRequest.apply {
this.bomMaterial = bomMaterial
}
val bomProcessMaterial = saveBomProcessMaterial(bomProcessMatRequest)
startColumnIndex = 0
}
}
}

fun importExcelBomBasicInfo(sheet: Sheet): Bom {
private fun importExcelBomBasicInfo(sheet: Sheet): Bom {
var request = ImportBomRequest(
code = "",
name = "",
@@ -242,23 +234,12 @@ open class BomService(
val topTargetValueCell = topTargetValueRow.getCell(startColumnIndex)
when (tempCellVal) {
"編號" -> {
println(topTargetValueCell.stringCellValue.trim())
request.apply {
code = topTargetValueCell.stringCellValue.trim()
}
}
"產品名稱" -> request.apply {
name = topTargetValueCell.stringCellValue.trim()
}
"種類" -> request.apply {
description = topTargetValueCell.stringCellValue.trim()
}
"份量 (Qty)" -> request.apply {
outputQty = topTargetValueCell.numericCellValue.toBigDecimal()
}
"單位" -> request.apply {
outputQtyUom = topTargetValueCell.stringCellValue.trim()
request.code = topTargetValueCell.stringCellValue.trim()
}
"產品名稱" -> request.name = topTargetValueCell.stringCellValue.trim()
"種類" -> request.description = topTargetValueCell.stringCellValue.trim()
"份量 (Qty)" -> request.outputQty = topTargetValueCell.numericCellValue.toBigDecimal()
"單位" -> request.outputQtyUom = topTargetValueCell.stringCellValue.trim()
}
// ----------------------------------------------------------------------------------------------- //
// --------------------- assigning value that is next to a header to request ------------------------ //
@@ -281,15 +262,11 @@ open class BomService(
val leftTargetValueRow = sheet.getRow(startRowIndex)
val leftTargetValueCell = leftTargetValueRow.getCell(startColumnIndex + 1)
when {
tempCellVal.contains("深淺") -> request.apply {
isDark = calculateColourScore(leftTargetValueCell.stringCellValue.trim())
}
tempCellVal.contains("浮沉") -> request.apply {
isFloat = calculateFloatScore(leftTargetValueCell.stringCellValue.trim())
}
tempCellVal.contains("濃淡") -> request.apply {
isDense = if (leftTargetValueCell.cellType == CellType.NUMERIC) leftTargetValueCell.numericCellValue.toInt() else 0
}
tempCellVal.contains("深淺") -> request.isDark = calculateColourScore(leftTargetValueCell.stringCellValue.trim())
tempCellVal.contains("浮沉") -> request.isFloat = calculateFloatScore(leftTargetValueCell.stringCellValue.trim())
tempCellVal.contains("濃淡") -> request.isDense = if (leftTargetValueCell.cellType == CellType.NUMERIC)
leftTargetValueCell.numericCellValue.toInt()
else 0
}
}
if (startRowIndex < endRowIndex) {
@@ -350,15 +327,11 @@ open class BomService(
return number * multiplier
}
private fun importExcelBomProcess(bom: Bom, sheet: Sheet) {
var bomProcessRequest = ImportBomProcessRequest(
bom = bom
)
var startRowIndex = 30
val endRowIndex = 70
var startColumnIndex = 0
val endColumnIndex = 11
while (startRowIndex < endRowIndex) {
println("")
val tempRow = sheet.getRow(startRowIndex)
val tempCell = tempRow.getCell(startColumnIndex)
if (tempCell != null && tempCell.cellType == CellType.STRING && tempCell.stringCellValue.trim() == "工序") {
@@ -368,6 +341,9 @@ open class BomService(
}
startRowIndex++
}
var bomProcessRequest = ImportBomProcessRequest(
bom = bom
)
while (startRowIndex != endRowIndex || startColumnIndex != endColumnIndex) {
val tempRow = sheet.getRow(startRowIndex)
val tempCell = tempRow.getCell(startColumnIndex)
@@ -381,45 +357,37 @@ open class BomService(
try {
when (startColumnIndex) {
0 -> {
println(tempCell.cellType)
bomProcessRequest.apply {
this.seqNo = tempCell.numericCellValue.toLong()
}
println("startRowIndex: $startRowIndex")
bomProcessRequest.seqNo = tempCell.numericCellValue.toLong()
println("seqNo: ${tempCell.numericCellValue.toLong()}")
println("bomProcessRequest: $bomProcessRequest")
}
1 -> {
val equipmentName = tempCell.stringCellValue.trim()
if (equipmentName != "不適用") {0
if (equipmentName != "不適用") {
val equipment = bomGetOrCreateEquipment(equipmentName)
bomProcessRequest.apply {
this.equipment = equipment
}
println("equipment created")
bomProcessRequest.equipment = equipment
}
}
2 -> {
val processName = tempCell.stringCellValue.trim()
val process = bomGetOrCreateProcess(processName)
bomProcessRequest.apply {
this.process = process
}
bomProcessRequest.process = process
println("process created")
}
3 -> {
val description = tempCell.stringCellValue.trim()
bomProcessRequest.apply {
this.description = description
}
bomProcessRequest.description = description
}
6 -> { //duration
when (tempCell.cellType) {
CellType.NUMERIC -> {
bomProcessRequest.apply {
this.durationInMinute = tempCell.numericCellValue.toInt()
}
bomProcessRequest.durationInMinute = tempCell.numericCellValue.toInt()
}
CellType.STRING -> {
val durationString = tempCell.stringCellValue.trim()
bomProcessRequest.apply {
this.durationInMinute = extractDurationStringToMinutes(durationString)
}
bomProcessRequest.durationInMinute = extractDurationStringToMinutes(durationString)
}

else -> {}
@@ -429,15 +397,11 @@ open class BomService(
10 -> { //prepTimeInMinute
when (tempCell.cellType) {
CellType.NUMERIC -> {
bomProcessRequest.apply {
this.prepTimeInMinute = tempCell.numericCellValue.toInt()
}
bomProcessRequest.prepTimeInMinute = tempCell.numericCellValue.toInt()
}
CellType.STRING -> {
val prepTimeInMinuteString = tempCell.stringCellValue.trim()
bomProcessRequest.apply {
this.prepTimeInMinute = extractDurationStringToMinutes(prepTimeInMinuteString)
}
bomProcessRequest.prepTimeInMinute = extractDurationStringToMinutes(prepTimeInMinuteString)
}

else -> {}
@@ -446,44 +410,40 @@ open class BomService(
11 -> { //postProdTimeInMinute
when (tempCell.cellType) {
CellType.NUMERIC -> {
bomProcessRequest.apply {
this.postProdTimeInMinute = tempCell.numericCellValue.toInt()
}
bomProcessRequest.postProdTimeInMinute = tempCell.numericCellValue.toInt()
}
CellType.STRING -> {
val postProdTimeInMinuteString = tempCell.stringCellValue.trim()
bomProcessRequest.apply {
this.postProdTimeInMinute = extractDurationStringToMinutes(postProdTimeInMinuteString)
}
bomProcessRequest.postProdTimeInMinute = extractDurationStringToMinutes(postProdTimeInMinuteString)
}

else -> {}
}
}
}
println("req:")
println(bomProcessRequest)
// moving the loop
if (startColumnIndex < endColumnIndex) {
println("case1")
startColumnIndex++
println("next col startColumnIndex: $startColumnIndex")
} else if (startRowIndex < endRowIndex) {
println("case2")
// when doesn't meet first condition, falls to this and go new row
startRowIndex++
println("next row startRowIndex: $startRowIndex")
// do save
saveBomProcess(bomProcessRequest)
// clean up
startColumnIndex = 0
bomProcessRequest = ImportBomProcessRequest(
bom = bom
)
}
} catch (e: Error) {
throw e
}
}
println("startRowIndex: $startRowIndex")
println("endRowIndex: $endRowIndex")
println(startRowIndex < endRowIndex)

println("startColumnIndex: $startColumnIndex")
println("endColumnIndex: $endColumnIndex")
println(startColumnIndex < endColumnIndex)
// moving the loop
if (startColumnIndex < endColumnIndex) {
println("1st")
startColumnIndex++
} else if (startRowIndex < endRowIndex) {
println("2nd")
// when doesn't meet first condition, falls to this and go new row
startRowIndex++
// do save
saveBomProcess(bomProcessRequest)
startColumnIndex = 0
}
}
}



+ 1
- 1
src/main/java/com/ffii/fpsms/modules/master/web/models/SaveBomRequest.kt 查看文件

@@ -55,7 +55,7 @@ data class ImportBomProcessRequest(
var description: String? = null,
var equipment: Equipment? = null,
var seqNo: Long? = null,
var durationInMinute: Int? = null,
var durationInMinute: Int? = 0,
var prepTimeInMinute: Int? = 0,
var postProdTimeInMinute: Int? = 0,
var bom: Bom? = null,


Loading…
取消
儲存