| @@ -149,7 +149,12 @@ open class DoWorkbenchDopoAssignmentService( | |||||
| val candidateLimit = 50 | val candidateLimit = 50 | ||||
| val maxRounds = 3 | val maxRounds = 3 | ||||
| sql.append(" ORDER BY dop.requiredDeliveryDate ASC, dop.truckDepartureTime ASC, dop.id ASC LIMIT $candidateLimit ") | |||||
| val shouldOrderBySequence = actualStoreId == "2/F" && request.loadingSequence == null | |||||
| if (shouldOrderBySequence) { | |||||
| sql.append(" ORDER BY dop.requiredDeliveryDate ASC, dop.truckDepartureTime ASC, dop.loadingSequence ASC, dop.id ASC LIMIT $candidateLimit ") | |||||
| } else { | |||||
| sql.append(" ORDER BY dop.requiredDeliveryDate ASC, dop.truckDepartureTime ASC, dop.id ASC LIMIT $candidateLimit ") | |||||
| } | |||||
| fun extractIds(rows: List<Map<String, Any?>>): List<Long> { | fun extractIds(rows: List<Map<String, Any?>>): List<Long> { | ||||
| if (rows.isEmpty()) return emptyList() | if (rows.isEmpty()) return emptyList() | ||||
| @@ -242,7 +247,12 @@ open class DoWorkbenchDopoAssignmentService( | |||||
| sql.append(" AND dop.loadingSequence = :loadingSequence ") | sql.append(" AND dop.loadingSequence = :loadingSequence ") | ||||
| params["loadingSequence"] = request.loadingSequence | params["loadingSequence"] = request.loadingSequence | ||||
| } | } | ||||
| sql.append(" ORDER BY dop.requiredDeliveryDate ASC, dop.truckDepartureTime ASC, dop.id ASC LIMIT 1 ") | |||||
| val shouldOrderBySequenceV1 = actualStoreId == "2/F" && request.loadingSequence == null | |||||
| if (shouldOrderBySequenceV1) { | |||||
| sql.append(" ORDER BY dop.requiredDeliveryDate ASC, dop.truckDepartureTime ASC, dop.loadingSequence ASC, dop.id ASC LIMIT 1 ") | |||||
| } else { | |||||
| sql.append(" ORDER BY dop.requiredDeliveryDate ASC, dop.truckDepartureTime ASC, dop.id ASC LIMIT 1 ") | |||||
| } | |||||
| val candidates = try { | val candidates = try { | ||||
| jdbcDao.queryForList(sql.toString(), params) | jdbcDao.queryForList(sql.toString(), params) | ||||