|
|
|
@@ -52,6 +52,29 @@ object PyJobOrderListMapper { |
|
|
|
return nameNorm.contains(norm) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Item codes where /laserPrint must not append stock UOM to [itemName] (laser field length limit). |
|
|
|
* BOM base name only, e.g. PP1175 "鮮檸檬汁(P+4)" without "(1包X2磅)" suffix. |
|
|
|
*/ |
|
|
|
private val LASER_OMIT_APPENDED_STOCK_UOM_ITEM_CODES = setOf("PP1175") |
|
|
|
|
|
|
|
/** |
|
|
|
* Display name for GET /py/laser-job-orders and /plastic/laser-job-orders (/laserPrint page). |
|
|
|
* Same as [buildDisplayItemName] except listed item codes never get stock UOM appended. |
|
|
|
*/ |
|
|
|
fun buildDisplayItemNameForLaser( |
|
|
|
baseName: String?, |
|
|
|
stockUnitDesc: String?, |
|
|
|
itemCode: String?, |
|
|
|
): String? { |
|
|
|
val code = itemCode?.trim().orEmpty() |
|
|
|
if (code in LASER_OMIT_APPENDED_STOCK_UOM_ITEM_CODES) { |
|
|
|
val baseTrim = baseName?.trim().orEmpty() |
|
|
|
return baseTrim.ifEmpty { null } |
|
|
|
} |
|
|
|
return buildDisplayItemName(baseName, stockUnitDesc) |
|
|
|
} |
|
|
|
|
|
|
|
fun toListItem( |
|
|
|
jo: JobOrder, |
|
|
|
printed: PrintedQtyByChannel?, |
|
|
|
@@ -86,4 +109,40 @@ object PyJobOrderListMapper { |
|
|
|
laserPrintedQty = p.laserPrintedQty, |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
/** /laserPrint list: may shorten [itemName] for laser length limits (see [buildDisplayItemNameForLaser]). */ |
|
|
|
fun toLaserListItem( |
|
|
|
jo: JobOrder, |
|
|
|
printed: PrintedQtyByChannel?, |
|
|
|
stockInLineRepository: StockInLineRepository, |
|
|
|
itemUomService: ItemUomService, |
|
|
|
): PyJobOrderListItem { |
|
|
|
val itemCode = jo.bom?.item?.code ?: jo.bom?.code |
|
|
|
val baseName = jo.bom?.name ?: jo.bom?.item?.name |
|
|
|
val itemId = jo.bom?.item?.id |
|
|
|
val stockUnitDesc = itemId?.let { id -> |
|
|
|
itemUomService.findStockUnitByItemId(id)?.uom?.udfudesc |
|
|
|
} |
|
|
|
val itemName = buildDisplayItemNameForLaser(baseName, stockUnitDesc, itemCode) |
|
|
|
|
|
|
|
val stockInLine = jo.id?.let { stockInLineRepository.findFirstByJobOrder_IdAndDeletedFalse(it) } |
|
|
|
val stockInLineId = stockInLine?.id |
|
|
|
val lotNo = stockInLine?.lotNo |
|
|
|
val p = printed ?: PrintedQtyByChannel() |
|
|
|
|
|
|
|
return PyJobOrderListItem( |
|
|
|
id = jo.id!!, |
|
|
|
code = jo.code, |
|
|
|
planStart = jo.planStart, |
|
|
|
itemCode = itemCode, |
|
|
|
itemName = itemName, |
|
|
|
reqQty = jo.reqQty, |
|
|
|
stockInLineId = stockInLineId, |
|
|
|
itemId = itemId, |
|
|
|
lotNo = lotNo, |
|
|
|
bagPrintedQty = p.bagPrintedQty, |
|
|
|
labelPrintedQty = p.labelPrintedQty, |
|
|
|
laserPrintedQty = p.laserPrintedQty, |
|
|
|
) |
|
|
|
} |
|
|
|
} |