fix(firstleg): support platform scope port schedules
This commit is contained in:
@@ -23,7 +23,7 @@ public final class PortScheduleDtos {
|
||||
public Query { if (page == 0) page = 1; if (size == 0) size = 20; }
|
||||
}
|
||||
|
||||
public record ScheduleData(@NotNull @Positive Long customerId,
|
||||
public record ScheduleData(@NotNull @Min(0) Long customerId,
|
||||
@NotNull @Positive Long oceanBookingId,
|
||||
@Positive Long containerBookingId,
|
||||
@NotBlank @Size(max = 24) String sourceType,
|
||||
|
||||
+2
-1
@@ -102,7 +102,8 @@ public class PortScheduleService {
|
||||
private void validateLinks(ScheduleData data) {
|
||||
OceanBookingEntity booking = repository.oceanBooking(data.oceanBookingId());
|
||||
if (booking == null) throw new BizException(ResultCode.NOT_FOUND, "关联订舱不存在");
|
||||
if (!Objects.equals(booking.getCustomerId(), data.customerId())) throw badRequest("customerId与订舱客户不一致");
|
||||
long expectedCustomerId = booking.getCustomerId() == null ? 0L : booking.getCustomerId();
|
||||
if (expectedCustomerId != data.customerId()) throw badRequest("customerId与订舱客户不一致");
|
||||
if (data.containerBookingId() != null) {
|
||||
if (repository.containerBooking(data.containerBookingId()) == null) {
|
||||
throw new BizException(ResultCode.NOT_FOUND, "关联柜次不存在");
|
||||
|
||||
@@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS fl_port_schedule (
|
||||
KEY idx_port_schedule_expiry (expires_at,id),
|
||||
CONSTRAINT fk_port_schedule_booking FOREIGN KEY (ocean_booking_id) REFERENCES fl_ocean_booking(id),
|
||||
CONSTRAINT fk_port_schedule_container FOREIGN KEY (container_booking_id) REFERENCES fl_container_booking(id),
|
||||
CONSTRAINT chk_port_schedule_customer CHECK (customer_id > 0),
|
||||
CONSTRAINT chk_port_schedule_customer CHECK (customer_id >= 0),
|
||||
CONSTRAINT chk_port_schedule_source_type CHECK (source_type IN ('MANUAL','CARRIER','TERMINAL','API')),
|
||||
CONSTRAINT chk_port_schedule_eta CHECK (etd_at IS NULL OR eta_at IS NULL OR eta_at >= etd_at),
|
||||
CONSTRAINT chk_port_schedule_expiry CHECK (expires_at > observed_at),
|
||||
@@ -93,7 +93,7 @@ DROP TRIGGER IF EXISTS trg_port_schedule_before_update;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER trg_port_schedule_before_insert BEFORE INSERT ON fl_port_schedule FOR EACH ROW
|
||||
BEGIN
|
||||
IF (SELECT customer_id FROM fl_ocean_booking WHERE id=NEW.ocean_booking_id) <> NEW.customer_id THEN
|
||||
IF COALESCE((SELECT customer_id FROM fl_ocean_booking WHERE id=NEW.ocean_booking_id),0) <> NEW.customer_id THEN
|
||||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='船期客户与订舱客户不一致';
|
||||
END IF;
|
||||
IF NEW.container_booking_id IS NOT NULL AND NOT EXISTS (
|
||||
|
||||
Reference in New Issue
Block a user