优化
This commit is contained in:
@@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS fl_truck_appointment (
|
||||
store_name VARCHAR(128) NULL, store_contact VARCHAR(64) NULL, store_phone VARCHAR(32) NULL, store_address VARCHAR(255) NULL,
|
||||
store_city VARCHAR(64) NULL, store_zipcode VARCHAR(16) NULL, package_count INT UNSIGNED NULL, gross_weight_kg DECIMAL(18,3) NULL,
|
||||
volume_cbm DECIMAL(18,4) NULL, pallet_count INT UNSIGNED NULL, po_no VARCHAR(255) NULL, planned_loading_at DATETIME(3) NULL,
|
||||
actual_loading_at DATETIME(3) NULL, transit_minutes INT UNSIGNED NULL, payable_amount DECIMAL(18,2) NULL, receivable_amount DECIMAL(18,2) NULL,
|
||||
actual_arrived_warehouse_at DATETIME(3) NULL, actual_loading_at DATETIME(3) NULL, actual_departed_at DATETIME(3) NULL, transit_minutes INT UNSIGNED NULL, payable_amount DECIMAL(18,2) NULL, receivable_amount DECIMAL(18,2) NULL,
|
||||
currency VARCHAR(8) NOT NULL DEFAULT 'RMB', status VARCHAR(32) NOT NULL DEFAULT 'DRAFT', revision INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
version INT UNSIGNED NOT NULL DEFAULT 0, remark VARCHAR(1000) NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), PRIMARY KEY(id), UNIQUE KEY uk_truck_appointment_no(appointment_no),
|
||||
@@ -30,6 +30,38 @@ CREATE TABLE IF NOT EXISTS fl_truck_appointment_operation (
|
||||
action VARCHAR(32) NOT NULL, response_snapshot JSON NULL, created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), PRIMARY KEY(id), UNIQUE KEY uk_truck_operation(idempotency_key), KEY idx_truck_operation_appointment(appointment_id)
|
||||
) ENGINE=InnoDB COMMENT='拖车操作幂等记录';
|
||||
|
||||
DROP PROCEDURE IF EXISTS phase3_truck_add_column;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE phase3_truck_add_column(
|
||||
IN p_column_name VARCHAR(64), IN p_definition TEXT
|
||||
)
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'fl_truck_appointment'
|
||||
AND column_name = p_column_name
|
||||
) THEN
|
||||
SET @phase3_truck_ddl = CONCAT(
|
||||
'ALTER TABLE fl_truck_appointment ADD COLUMN `', p_column_name, '` ', p_definition
|
||||
);
|
||||
PREPARE phase3_truck_stmt FROM @phase3_truck_ddl;
|
||||
EXECUTE phase3_truck_stmt;
|
||||
DEALLOCATE PREPARE phase3_truck_stmt;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
CALL phase3_truck_add_column(
|
||||
'actual_arrived_warehouse_at',
|
||||
'DATETIME(3) NULL AFTER planned_loading_at'
|
||||
);
|
||||
CALL phase3_truck_add_column(
|
||||
'actual_departed_at',
|
||||
'DATETIME(3) NULL AFTER actual_loading_at'
|
||||
);
|
||||
DROP PROCEDURE IF EXISTS phase3_truck_add_column;
|
||||
|
||||
USE baiyue_iam;
|
||||
DROP PROCEDURE IF EXISTS assert_truck_appointment_permission_ids_available;
|
||||
DELIMITER $$
|
||||
|
||||
@@ -1,8 +1,71 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Truck Appointment Attachments and History API
|
||||
version: 1.0.0
|
||||
title: Truck Appointment API
|
||||
version: 1.1.0
|
||||
paths:
|
||||
/api/platform/v1/truck-appointments:
|
||||
get:
|
||||
summary: Query truck appointments
|
||||
responses:
|
||||
'200': {description: Paged truck appointments}
|
||||
post:
|
||||
summary: Create a truck appointment linked to a released ocean booking
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema: {$ref: '#/components/schemas/SaveRequest'}
|
||||
responses:
|
||||
'200': {description: Created appointment}
|
||||
/api/platform/v1/truck-appointments/{id}:
|
||||
parameters: [{$ref: '#/components/parameters/AppointmentId'}]
|
||||
get:
|
||||
summary: Query a truck appointment
|
||||
responses:
|
||||
'200': {description: Appointment detail}
|
||||
put:
|
||||
summary: Update an editable truck appointment with optimistic locking
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema: {$ref: '#/components/schemas/SaveRequest'}
|
||||
responses:
|
||||
'200': {description: Updated appointment}
|
||||
/api/platform/v1/truck-appointments/{id}/{action}:
|
||||
parameters:
|
||||
- {$ref: '#/components/parameters/AppointmentId'}
|
||||
- {$ref: '#/components/parameters/Action'}
|
||||
- {$ref: '#/components/parameters/IdempotencyKey'}
|
||||
- {$ref: '#/components/parameters/RequestHash'}
|
||||
post:
|
||||
summary: Apply an idempotent appointment lifecycle action
|
||||
description: ARRIVE, LOAD and DEPART persist their actual event timestamps atomically with the status transition.
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema: {$ref: '#/components/schemas/ActionRequest'}
|
||||
responses:
|
||||
'200': {description: Updated or replayed appointment}
|
||||
/api/platform/v1/truck-appointments/{id}/reschedule:
|
||||
parameters:
|
||||
- {$ref: '#/components/parameters/AppointmentId'}
|
||||
- {$ref: '#/components/parameters/IdempotencyKey'}
|
||||
- {$ref: '#/components/parameters/RequestHash'}
|
||||
- name: plannedLoadingAt
|
||||
in: query
|
||||
required: true
|
||||
schema: {type: string, format: date-time}
|
||||
post:
|
||||
summary: Idempotently reschedule an appointment
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema: {$ref: '#/components/schemas/ActionRequest'}
|
||||
responses:
|
||||
'200': {description: Rescheduled or replayed appointment}
|
||||
/api/platform/v1/truck-appointments/{id}/history:
|
||||
parameters: [{$ref: '#/components/parameters/AppointmentId'}]
|
||||
get:
|
||||
@@ -47,3 +110,28 @@ components:
|
||||
parameters:
|
||||
AppointmentId: {name: id, in: path, required: true, schema: {type: string, pattern: '^[1-9][0-9]*$'}}
|
||||
AttachmentId: {name: attachmentId, in: path, required: true, schema: {type: string, pattern: '^[1-9][0-9]*$'}}
|
||||
Action:
|
||||
name: action
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum: [SUBMIT, DISPATCH, PICKUP, ARRIVE, LOAD, DEPART, COMPLETE, EXCEPTION, CANCEL]
|
||||
IdempotencyKey: {name: Idempotency-Key, in: header, required: true, schema: {type: string, maxLength: 128}}
|
||||
RequestHash: {name: X-Request-Hash, in: header, required: false, schema: {type: string, pattern: '^[0-9a-fA-F]{64}$'}}
|
||||
schemas:
|
||||
ActionRequest:
|
||||
type: object
|
||||
required: [expectedVersion]
|
||||
properties:
|
||||
expectedVersion: {type: integer, minimum: 0}
|
||||
reason: {type: string, maxLength: 500}
|
||||
SaveRequest:
|
||||
type: object
|
||||
required: [oceanBookingId, plannedLoadingAt, expectedVersion]
|
||||
properties:
|
||||
oceanBookingId: {type: integer, format: int64, minimum: 1}
|
||||
containerBookingId: {type: integer, format: int64, minimum: 1}
|
||||
loadingPlanId: {type: integer, format: int64, minimum: 1}
|
||||
plannedLoadingAt: {type: string, format: date-time}
|
||||
expectedVersion: {type: integer, minimum: 0}
|
||||
|
||||
Reference in New Issue
Block a user