|
|
@@ -4,6 +4,7 @@ import com.ffii.fpsms.modules.jobOrder.web.model.LaserBag2AutoSendReport |
|
|
import com.ffii.fpsms.modules.jobOrder.web.model.LaserBag2JobSendResult |
|
|
import com.ffii.fpsms.modules.jobOrder.web.model.LaserBag2JobSendResult |
|
|
import com.ffii.fpsms.modules.jobOrder.web.model.LaserBag2SendRequest |
|
|
import com.ffii.fpsms.modules.jobOrder.web.model.LaserBag2SendRequest |
|
|
import org.slf4j.LoggerFactory |
|
|
import org.slf4j.LoggerFactory |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value |
|
|
import org.springframework.stereotype.Service |
|
|
import org.springframework.stereotype.Service |
|
|
import java.time.LocalDate |
|
|
import java.time.LocalDate |
|
|
|
|
|
|
|
|
@@ -12,25 +13,22 @@ import java.time.LocalDate |
|
|
* ([LASER_PRINT.itemCodes]), then sends Bag2-style laser TCP payloads via [PlasticBagPrinterService.sendLaserBag2Job], |
|
|
* ([LASER_PRINT.itemCodes]), then sends Bag2-style laser TCP payloads via [PlasticBagPrinterService.sendLaserBag2Job], |
|
|
* which uses [com.ffii.fpsms.modules.common.SettingNames.LASER_PRINT_HOST] / [LASER_PRINT_PORT] from the database. |
|
|
* which uses [com.ffii.fpsms.modules.common.SettingNames.LASER_PRINT_HOST] / [LASER_PRINT_PORT] from the database. |
|
|
* |
|
|
* |
|
|
* Matches /laserPrint row click: [sendsPerJob] rounds with [delayBetweenSendsMs] between rounds (default 3 × 3s like the frontend). |
|
|
|
|
|
|
|
|
* [sendsPerJob] TCP rounds per job order (default from `laser.bag2.auto-send.sends-per-job`, typically 1). |
|
|
|
|
|
* [sendLaserBag2Job] may still retry once internally on failure. |
|
|
*/ |
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
class LaserBag2AutoSendService( |
|
|
class LaserBag2AutoSendService( |
|
|
private val plasticBagPrinterService: PlasticBagPrinterService, |
|
|
private val plasticBagPrinterService: PlasticBagPrinterService, |
|
|
|
|
|
@Value("\${laser.bag2.auto-send.sends-per-job:1}") private val defaultSendsPerJob: Int, |
|
|
|
|
|
@Value("\${laser.bag2.auto-send.delay-between-sends-ms:3000}") private val defaultDelayBetweenSendsMs: Long, |
|
|
) { |
|
|
) { |
|
|
private val logger = LoggerFactory.getLogger(javaClass) |
|
|
private val logger = LoggerFactory.getLogger(javaClass) |
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
/** Same as LaserPrint page (3 sends per row click). */ |
|
|
|
|
|
const val DEFAULT_SENDS_PER_JOB = 3 |
|
|
|
|
|
const val DEFAULT_DELAY_BETWEEN_SENDS_MS = 3000L |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun runAutoSend( |
|
|
fun runAutoSend( |
|
|
planStart: LocalDate, |
|
|
planStart: LocalDate, |
|
|
limitPerRun: Int = 0, |
|
|
limitPerRun: Int = 0, |
|
|
sendsPerJob: Int = DEFAULT_SENDS_PER_JOB, |
|
|
|
|
|
delayBetweenSendsMs: Long = DEFAULT_DELAY_BETWEEN_SENDS_MS, |
|
|
|
|
|
|
|
|
sendsPerJob: Int = defaultSendsPerJob, |
|
|
|
|
|
delayBetweenSendsMs: Long = defaultDelayBetweenSendsMs, |
|
|
): LaserBag2AutoSendReport { |
|
|
): LaserBag2AutoSendReport { |
|
|
val (reachable, laserIp, laserPort) = plasticBagPrinterService.probeLaserBag2Tcp() |
|
|
val (reachable, laserIp, laserPort) = plasticBagPrinterService.probeLaserBag2Tcp() |
|
|
if (!reachable) { |
|
|
if (!reachable) { |
|
|
|