|
|
|
@@ -55,6 +55,7 @@ import com.fasterxml.jackson.databind.ObjectMapper |
|
|
|
import java.time.Duration |
|
|
|
import java.time.Instant |
|
|
|
import java.time.LocalDate |
|
|
|
import java.time.ZoneId |
|
|
|
|
|
|
|
// Data class to store bitmap bytes + width (for XML) |
|
|
|
data class BitmapResult(val bytes: ByteArray, val width: Int) |
|
|
|
@@ -80,6 +81,7 @@ class PlasticBagPrinterService( |
|
|
|
private val objectMapper: ObjectMapper, |
|
|
|
) { |
|
|
|
private val logger = LoggerFactory.getLogger(javaClass) |
|
|
|
private val hongKongZoneId = ZoneId.of("Asia/Hong_Kong") |
|
|
|
|
|
|
|
companion object { |
|
|
|
private const val DEFAULT_LASER_BAG2_HOST = "192.168.18.77" |
|
|
|
@@ -266,6 +268,23 @@ class PlasticBagPrinterService( |
|
|
|
return Triple(ok, host, port) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Returns true when [SettingNames.LASER_PRINT_LAST_RECEIVE_SUCCESS] has a [sentAt] on [date] |
|
|
|
* (interpreted in Asia/Hong_Kong local date). |
|
|
|
*/ |
|
|
|
fun hasLaserBag2ReceiveOnDate(date: LocalDate): Boolean { |
|
|
|
val last = readLaserLastReceiveSuccessFromSettings() ?: return false |
|
|
|
val sentAtRaw = last.sentAt?.trim().orEmpty() |
|
|
|
if (sentAtRaw.isEmpty()) return false |
|
|
|
return try { |
|
|
|
val sentDateHk = Instant.parse(sentAtRaw).atZone(hongKongZoneId).toLocalDate() |
|
|
|
sentDateHk == date |
|
|
|
} catch (e: Exception) { |
|
|
|
logger.warn("Could not parse LASER_PRINT.lastReceiveSuccess.sentAt='{}': {}", sentAtRaw, e.message) |
|
|
|
false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private fun sendLaserBag2TcpOnce( |
|
|
|
ip: String, |
|
|
|
port: Int, |
|
|
|
|