优化
This commit is contained in:
@@ -706,9 +706,20 @@ public class LoadingPickService {
|
||||
/** 进入PDA拣货任务即将预装柜计划推进为拣货中;状态推进和历史写入保持幂等。 */
|
||||
private void startPickingIfNeeded(LoadingPickTaskEntity task, long operatorId, String operatorName) {
|
||||
if (smartLoadingRepository.startPicking(task.getLoadingPlanId(), operatorId, operatorName) == 1) {
|
||||
String operationId = "PDA-START-" + task.getId();
|
||||
LoadingPlanHistoryEntity existing = smartLoadingRepository.operation(operationId);
|
||||
if (existing != null) {
|
||||
if (!Objects.equals(existing.getLoadingPlanId(), task.getLoadingPlanId())
|
||||
|| !"START_LOADING".equals(existing.getActionType())
|
||||
|| !"EDITING".equals(existing.getFromStatus())
|
||||
|| !"LOADING".equals(existing.getToStatus())) {
|
||||
throw conflict("PDA开始装柜历史与当前任务不一致");
|
||||
}
|
||||
return;
|
||||
}
|
||||
LoadingPlanHistoryEntity history = new LoadingPlanHistoryEntity();
|
||||
history.setLoadingPlanId(task.getLoadingPlanId());
|
||||
history.setOperationId("PDA-START-" + task.getId());
|
||||
history.setOperationId(operationId);
|
||||
history.setActionType("START_LOADING");
|
||||
history.setFromStatus("EDITING");
|
||||
history.setToStatus("LOADING");
|
||||
|
||||
@@ -175,3 +175,39 @@ CREATE TABLE IF NOT EXISTS fl_container_transport_history (
|
||||
UNIQUE KEY uk_container_transport_history_operation (container_booking_id,operator_id,operation_id),
|
||||
KEY idx_container_transport_history (container_booking_id,created_at,id)
|
||||
) ENGINE=InnoDB COMMENT='柜次真实运输字段不可变变更审计';
|
||||
|
||||
DROP PROCEDURE IF EXISTS ensure_container_transport_history_schema;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE ensure_container_transport_history_schema()
|
||||
BEGIN
|
||||
IF (NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE()
|
||||
AND table_name='fl_container_transport_history' AND column_name='operation_id')
|
||||
OR NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE()
|
||||
AND table_name='fl_container_transport_history' AND column_name='request_hash'))
|
||||
AND EXISTS (SELECT 1 FROM fl_container_transport_history LIMIT 1) THEN
|
||||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='运输历史升级失败:旧表已有数据且缺少幂等字段';
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE()
|
||||
AND table_name='fl_container_transport_history' AND column_name='operation_id') THEN
|
||||
ALTER TABLE fl_container_transport_history
|
||||
ADD COLUMN operation_id VARCHAR(64) NOT NULL COMMENT '运输字段操作幂等ID' AFTER after_voyage_no;
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=DATABASE()
|
||||
AND table_name='fl_container_transport_history' AND column_name='request_hash') THEN
|
||||
ALTER TABLE fl_container_transport_history
|
||||
ADD COLUMN request_hash CHAR(64) NOT NULL COMMENT '运输字段请求哈希' AFTER operation_id;
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE()
|
||||
AND table_name='fl_container_transport_history' AND index_name='uk_container_transport_history_operation') THEN
|
||||
ALTER TABLE fl_container_transport_history
|
||||
ADD UNIQUE KEY uk_container_transport_history_operation (container_booking_id,operator_id,operation_id);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema=DATABASE()
|
||||
AND table_name='fl_container_transport_history' AND index_name='idx_container_transport_history') THEN
|
||||
ALTER TABLE fl_container_transport_history
|
||||
ADD KEY idx_container_transport_history (container_booking_id,created_at,id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
CALL ensure_container_transport_history_schema();
|
||||
DROP PROCEDURE ensure_container_transport_history_schema;
|
||||
|
||||
@@ -902,20 +902,6 @@ BEGIN
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
-- 旧版本在推送预装时即写入 LOADING。仅回收从未发生实际拣货的计划;有实际拣货记录的数据不回退。
|
||||
UPDATE fl_loading_plan plan
|
||||
SET plan_status = 'EDITING',
|
||||
updated_at = CURRENT_TIMESTAMP(3),
|
||||
version = version + 1
|
||||
WHERE plan.plan_status = 'LOADING'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM fl_loading_pick_item pick_item
|
||||
JOIN fl_loading_pick_task pick_task ON pick_task.id = pick_item.pick_task_id
|
||||
WHERE pick_task.loading_plan_id = plan.id
|
||||
AND pick_item.picked_package_count > 0
|
||||
);
|
||||
|
||||
DROP TRIGGER IF EXISTS trg_loading_item_before_insert;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER trg_loading_item_before_insert
|
||||
|
||||
Reference in New Issue
Block a user