|
|
@@ -311,4 +311,47 @@ open class InventorySetup { |
|
|
return printedCount |
|
|
return printedCount |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = [Exception::class]) |
|
|
|
|
|
open fun printLotStockInLabelsByItemIds( |
|
|
|
|
|
printerId: Long, |
|
|
|
|
|
itemIds: List<Long>, |
|
|
|
|
|
printQty: Int = 1, |
|
|
|
|
|
fromIndex: Int? = null, |
|
|
|
|
|
toIndex: Int? = null |
|
|
|
|
|
): Int { |
|
|
|
|
|
if (itemIds.isEmpty()) return 0 |
|
|
|
|
|
|
|
|
|
|
|
val allInventoryLotLines = inventoryLotLineRepository |
|
|
|
|
|
.findAllByItemIdIn(itemIds) |
|
|
|
|
|
.filter { it.deleted == false && it.inventoryLot?.stockInLine != null } |
|
|
|
|
|
|
|
|
|
|
|
if (allInventoryLotLines.isEmpty()) return 0 |
|
|
|
|
|
|
|
|
|
|
|
val inventoryLotLinesToPrint = if (fromIndex != null && toIndex != null) { |
|
|
|
|
|
val startIndex = fromIndex.coerceAtLeast(0) |
|
|
|
|
|
val endIndex = toIndex.coerceAtMost(allInventoryLotLines.size - 1) |
|
|
|
|
|
if (startIndex > endIndex || startIndex >= allInventoryLotLines.size) return 0 |
|
|
|
|
|
allInventoryLotLines.subList(startIndex, endIndex + 1) |
|
|
|
|
|
} else { |
|
|
|
|
|
allInventoryLotLines |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var printedCount = 0 |
|
|
|
|
|
for ((index, inventoryLotLine) in inventoryLotLinesToPrint.withIndex()) { |
|
|
|
|
|
val stockInLineId = inventoryLotLine.inventoryLot?.stockInLine?.id |
|
|
|
|
|
?: throw IllegalArgumentException("Stock in line missing") |
|
|
|
|
|
val actualIndex = if (fromIndex != null) fromIndex + index else index |
|
|
|
|
|
println("Processing lot ${actualIndex + 1}/${allInventoryLotLines.size}: Lot No: ${inventoryLotLine.inventoryLot?.lotNo}, StockInLineId: $stockInLineId") |
|
|
|
|
|
stockInLineService.printQrCode( |
|
|
|
|
|
PrintQrCodeForSilRequest( |
|
|
|
|
|
stockInLineId = stockInLineId, |
|
|
|
|
|
printerId = printerId, |
|
|
|
|
|
printQty = printQty |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
|
|
|
printedCount++ |
|
|
|
|
|
} |
|
|
|
|
|
return printedCount |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |