From d085d6e7d0be5b5bd799ce67f760712225e1c076 Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Thu, 19 Mar 2026 11:11:16 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E6=96=B0=E5=A2=9E=E5=AE=89=E7=81=AF?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=BA=8F=E5=88=97=E6=A3=80=E6=9F=A5=E4=B8=8E?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aucma/base/mapper/OrderBomInfoMapper.java | 2 +- .../mapper/base/OrderBomInfoMapper.xml | 6 +- ...0260319_andon_sequences_check_and_sync.sql | 133 ++++++++++++++++++ .../mapper/production/ProdOrderNoteMapper.xml | 19 +-- .../mapper/production/ProdRouteMapper.xml | 26 ++-- .../ProdStationCapabilityMapper.xml | 28 ++-- .../mapper/production/ProdTaskPoolMapper.xml | 29 ++-- .../mapper/production/ProdTeamShiftMapper.xml | 25 ++-- 8 files changed, 204 insertions(+), 64 deletions(-) create mode 100644 aucma-production/src/main/resources/mapper/20260319_andon_sequences_check_and_sync.sql diff --git a/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java b/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java index 1030003..28672b8 100644 --- a/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java +++ b/aucma-base/src/main/java/com/aucma/base/mapper/OrderBomInfoMapper.java @@ -75,7 +75,7 @@ public interface OrderBomInfoMapper * @param materialCode * @return */ - List selectChildrenBomById(String materialCode); + List selectChildrenBomById(@Param("materialCode") String materialCode); /** * 修改子元素关系 diff --git a/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml b/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml index 7e4a22a..a1b4389 100644 --- a/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml +++ b/aucma-base/src/main/resources/mapper/base/OrderBomInfoMapper.xml @@ -86,7 +86,8 @@ @@ -174,7 +175,8 @@ diff --git a/aucma-production/src/main/resources/mapper/20260319_andon_sequences_check_and_sync.sql b/aucma-production/src/main/resources/mapper/20260319_andon_sequences_check_and_sync.sql new file mode 100644 index 0000000..38d8f58 --- /dev/null +++ b/aucma-production/src/main/resources/mapper/20260319_andon_sequences_check_and_sync.sql @@ -0,0 +1,133 @@ +-- ============================================================ +-- 安灯模块序列检查与同步脚本 +-- 适用数据库:Oracle 11g +-- 生成时间:2026-03-19 +-- 说明:检查安灯相关序列是否存在, +-- 存在则根据表中最大主键值重建(同步), +-- 不存在则直接创建。 +-- 执行方式:以 DBA 或拥有 CREATE SEQUENCE 权限的用户执行 +-- 注意:若使用 SQL*Plus,请在执行前手动运行:SET SERVEROUTPUT ON SIZE UNLIMITED +-- DBeaver / SQL Developer 等工具无需此命令,在会话/输出设置中启用即可 +-- ============================================================ + +DECLARE + v_count NUMBER; + v_max_id NUMBER; + v_start_val NUMBER; + + -- 辅助过程:检查并创建/重建序列 + PROCEDURE sync_sequence( + p_seq_name IN VARCHAR2, + p_table IN VARCHAR2, + p_col IN VARCHAR2 + ) IS + v_cnt NUMBER; + v_max NUMBER; + v_start NUMBER; + v_sql VARCHAR2(500); + BEGIN + -- 1. 检查序列是否已存在 + SELECT COUNT(*) INTO v_cnt + FROM USER_SEQUENCES + WHERE SEQUENCE_NAME = UPPER(p_seq_name); + + -- 2. 获取当前表最大主键值,计算下一个起始值 + BEGIN + EXECUTE IMMEDIATE + 'SELECT NVL(MAX(' || p_col || '), 0) + 1 FROM ' || p_table + INTO v_max; + EXCEPTION + WHEN OTHERS THEN + v_max := 1; -- 表不存在或无数据时默认从1开始 + END; + v_start := GREATEST(v_max, 1); + + IF v_cnt = 0 THEN + -- 序列不存在:直接创建 + v_sql := 'CREATE SEQUENCE ' || p_seq_name + || ' START WITH ' || v_start + || ' INCREMENT BY 1 MINVALUE 1 NOCACHE NOCYCLE NOORDER'; + EXECUTE IMMEDIATE v_sql; + DBMS_OUTPUT.PUT_LINE('[创建] ' || p_seq_name + || ' → START WITH ' || v_start); + ELSE + -- 序列已存在:删除后以新起点重建(Oracle 11g 不支持 RESTART WITH) + EXECUTE IMMEDIATE 'DROP SEQUENCE ' || p_seq_name; + v_sql := 'CREATE SEQUENCE ' || p_seq_name + || ' START WITH ' || v_start + || ' INCREMENT BY 1 MINVALUE 1 NOCACHE NOCYCLE NOORDER'; + EXECUTE IMMEDIATE v_sql; + DBMS_OUTPUT.PUT_LINE('[更新] ' || p_seq_name + || ' → 重建,START WITH ' || v_start); + END IF; + + EXCEPTION + WHEN OTHERS THEN + DBMS_OUTPUT.PUT_LINE('[错误] 处理序列 ' || p_seq_name + || ' 时发生异常:' || SQLERRM); + END sync_sequence; + +BEGIN + DBMS_OUTPUT.PUT_LINE('===== 安灯模块序列检查与同步开始 ====='); + DBMS_OUTPUT.PUT_LINE(''); + + -- ① 看板配置序列 + sync_sequence( + p_seq_name => 'ANDON_BOARD_CONFIG_SEQ', + p_table => 'ANDON_BOARD_CONFIG', + p_col => 'BOARD_ID' + ); + + -- ② 安灯事件序列 + sync_sequence( + p_seq_name => 'ANDON_EVENT_SEQ', + p_table => 'ANDON_EVENT', + p_col => 'EVENT_ID' + ); + + -- ③ 安灯事件分配序列 + sync_sequence( + p_seq_name => 'ANDON_EVENT_ASSIGNMENT_SEQ', + p_table => 'ANDON_EVENT_ASSIGNMENT', + p_col => 'ASSIGNMENT_ID' + ); + + -- ④ 安灯事件日志序列 + sync_sequence( + p_seq_name => 'ANDON_EVENT_LOG_SEQ', + p_table => 'ANDON_EVENT_LOG', + p_col => 'LOG_ID' + ); + + -- ⑤ 安灯规则序列 + sync_sequence( + p_seq_name => 'ANDON_RULE_SEQ', + p_table => 'ANDON_RULE', + p_col => 'RULE_ID' + ); + + DBMS_OUTPUT.PUT_LINE(''); + DBMS_OUTPUT.PUT_LINE('===== 安灯模块序列检查与同步完成 ====='); + +END; +/ + +-- 验证:查询所有安灯序列当前状态 +SELECT + SEQUENCE_NAME, + MIN_VALUE, + MAX_VALUE, + INCREMENT_BY, + LAST_NUMBER, + CACHE_SIZE, + CYCLE_FLAG, + ORDER_FLAG +FROM USER_SEQUENCES +WHERE SEQUENCE_NAME IN ( + 'ANDON_BOARD_CONFIG_SEQ', + 'ANDON_EVENT_SEQ', + 'ANDON_EVENT_ASSIGNMENT_SEQ', + 'ANDON_EVENT_LOG_SEQ', + 'ANDON_RULE_SEQ' +) +ORDER BY SEQUENCE_NAME; diff --git a/aucma-production/src/main/resources/mapper/production/ProdOrderNoteMapper.xml b/aucma-production/src/main/resources/mapper/production/ProdOrderNoteMapper.xml index 2bacfdc..2e93acf 100644 --- a/aucma-production/src/main/resources/mapper/production/ProdOrderNoteMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/ProdOrderNoteMapper.xml @@ -63,21 +63,22 @@ obj_id, order_code, note_type, note_content, status, remark, create_by, create_time, update_by, update_time ) values ( - #{objId}, #{orderCode}, #{noteType}, #{noteContent}, #{status}, #{remark}, - #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime} + #{objId,jdbcType=NUMERIC}, #{orderCode,jdbcType=VARCHAR}, #{noteType,jdbcType=VARCHAR}, + #{noteContent,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, + #{createdBy,jdbcType=VARCHAR}, #{createdTime,jdbcType=DATE}, #{updatedBy,jdbcType=VARCHAR}, #{updatedTime,jdbcType=DATE} ) update prod_order_note - order_code = #{orderCode}, - note_type = #{noteType}, - note_content = #{noteContent}, - status = #{status}, - remark = #{remark}, - update_by = #{updatedBy}, - update_time = #{updatedTime} + order_code = #{orderCode,jdbcType=VARCHAR}, + note_type = #{noteType,jdbcType=VARCHAR}, + note_content = #{noteContent,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + update_by = #{updatedBy,jdbcType=VARCHAR}, + update_time = #{updatedTime,jdbcType=DATE} where obj_id = #{objId} diff --git a/aucma-production/src/main/resources/mapper/production/ProdRouteMapper.xml b/aucma-production/src/main/resources/mapper/production/ProdRouteMapper.xml index 85cc8a0..9b1d48e 100644 --- a/aucma-production/src/main/resources/mapper/production/ProdRouteMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/ProdRouteMapper.xml @@ -100,22 +100,23 @@ obj_id, route_code, route_name, material_code, version_no, status, remark, create_by, create_time, update_by, update_time ) values ( - #{objId}, #{routeCode}, #{routeName}, #{materialCode}, #{versionNo}, #{status}, #{remark}, - #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime} + #{objId,jdbcType=NUMERIC}, #{routeCode,jdbcType=VARCHAR}, #{routeName,jdbcType=VARCHAR}, + #{materialCode,jdbcType=VARCHAR}, #{versionNo,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, + #{createdBy,jdbcType=VARCHAR}, #{createdTime,jdbcType=DATE}, #{updatedBy,jdbcType=VARCHAR}, #{updatedTime,jdbcType=DATE} ) update prod_route - route_code = #{routeCode}, - route_name = #{routeName}, - material_code = #{materialCode}, - version_no = #{versionNo}, - status = #{status}, - remark = #{remark}, - update_by = #{updatedBy}, - update_time = #{updatedTime} + route_code = #{routeCode,jdbcType=VARCHAR}, + route_name = #{routeName,jdbcType=VARCHAR}, + material_code = #{materialCode,jdbcType=VARCHAR}, + version_no = #{versionNo,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + update_by = #{updatedBy,jdbcType=VARCHAR}, + update_time = #{updatedTime,jdbcType=DATE} where obj_id = #{objId} @@ -139,8 +140,9 @@ obj_id, route_code, process_code, sort_no, required_flag, standard_work_time, remark, create_by, create_time, update_by, update_time ) values ( - #{objId}, #{routeCode}, #{processCode}, #{sortNo}, #{requiredFlag}, #{standardWorkTime}, #{remark}, - #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime} + #{objId,jdbcType=NUMERIC}, #{routeCode,jdbcType=VARCHAR}, #{processCode,jdbcType=VARCHAR}, + #{sortNo,jdbcType=NUMERIC}, #{requiredFlag,jdbcType=VARCHAR}, #{standardWorkTime,jdbcType=DECIMAL}, #{remark,jdbcType=VARCHAR}, + #{createdBy,jdbcType=VARCHAR}, #{createdTime,jdbcType=DATE}, #{updatedBy,jdbcType=VARCHAR}, #{updatedTime,jdbcType=DATE} ) diff --git a/aucma-production/src/main/resources/mapper/production/ProdStationCapabilityMapper.xml b/aucma-production/src/main/resources/mapper/production/ProdStationCapabilityMapper.xml index 145a5a9..1a0df1a 100644 --- a/aucma-production/src/main/resources/mapper/production/ProdStationCapabilityMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/ProdStationCapabilityMapper.xml @@ -79,25 +79,27 @@ obj_id, station_code, material_code, standard_ct, shift_cap, day_cap, changeover_min, team_code, status, remark, create_by, create_time, update_by, update_time ) values ( - #{objId}, #{stationCode}, #{materialCode}, #{standardCt}, #{shiftCap}, #{dayCap}, #{changeoverMin}, - #{teamCode}, #{status}, #{remark}, #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime} + #{objId,jdbcType=NUMERIC}, #{stationCode,jdbcType=VARCHAR}, #{materialCode,jdbcType=VARCHAR}, + #{standardCt,jdbcType=DECIMAL}, #{shiftCap,jdbcType=DECIMAL}, #{dayCap,jdbcType=DECIMAL}, #{changeoverMin,jdbcType=NUMERIC}, + #{teamCode,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createdBy,jdbcType=VARCHAR}, + #{createdTime,jdbcType=DATE}, #{updatedBy,jdbcType=VARCHAR}, #{updatedTime,jdbcType=DATE} ) update prod_sta_cap - station_code = #{stationCode}, - material_code = #{materialCode}, - standard_ct = #{standardCt}, - shift_cap = #{shiftCap}, - day_cap = #{dayCap}, - changeover_min = #{changeoverMin}, - team_code = #{teamCode}, - status = #{status}, - remark = #{remark}, - update_by = #{updatedBy}, - update_time = #{updatedTime} + station_code = #{stationCode,jdbcType=VARCHAR}, + material_code = #{materialCode,jdbcType=VARCHAR}, + standard_ct = #{standardCt,jdbcType=DECIMAL}, + shift_cap = #{shiftCap,jdbcType=DECIMAL}, + day_cap = #{dayCap,jdbcType=DECIMAL}, + changeover_min = #{changeoverMin,jdbcType=NUMERIC}, + team_code = #{teamCode,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + update_by = #{updatedBy,jdbcType=VARCHAR}, + update_time = #{updatedTime,jdbcType=DATE} where obj_id = #{objId} diff --git a/aucma-production/src/main/resources/mapper/production/ProdTaskPoolMapper.xml b/aucma-production/src/main/resources/mapper/production/ProdTaskPoolMapper.xml index 80a4981..0704ed0 100644 --- a/aucma-production/src/main/resources/mapper/production/ProdTaskPoolMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/ProdTaskPoolMapper.xml @@ -16,7 +16,6 @@ - @@ -51,7 +50,6 @@ tp.owner_user_id, su.nick_name as owner_user_name, nvl(tp.priority_level, 'NORMAL') as priority_level, - oi.device_code, oi.end_date, oi.start_time, oi.end_time as finish_time, @@ -116,19 +114,20 @@ obj_id, order_code, owner_user_id, priority_level, task_remark, create_by, create_time, update_by, update_time ) values ( - #{objId}, #{orderCode}, #{ownerUserId}, #{priorityLevel}, #{remark}, - #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime} + #{objId,jdbcType=NUMERIC}, #{orderCode,jdbcType=VARCHAR}, #{ownerUserId,jdbcType=NUMERIC}, + #{priorityLevel,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, + #{createdBy,jdbcType=VARCHAR}, #{createdTime,jdbcType=DATE}, #{updatedBy,jdbcType=VARCHAR}, #{updatedTime,jdbcType=DATE} ) update prod_task_pool - owner_user_id = #{ownerUserId}, - priority_level = #{priorityLevel}, - task_remark = #{remark}, - update_by = #{updatedBy}, - update_time = #{updatedTime} + owner_user_id = #{ownerUserId,jdbcType=NUMERIC}, + priority_level = #{priorityLevel,jdbcType=VARCHAR}, + task_remark = #{remark,jdbcType=VARCHAR}, + update_by = #{updatedBy,jdbcType=VARCHAR}, + update_time = #{updatedTime,jdbcType=DATE} where order_code = #{orderCode} @@ -142,11 +141,11 @@ update base_orderinfo - set execution_status = #{executionStatus}, - start_time = case when #{executionStatus} = 'RUNNING' and start_time is null then sysdate else start_time end, - end_time = case when #{executionStatus} = 'COMPLETED' then sysdate else end_time end, - complete_date = case when #{executionStatus} = 'COMPLETED' then trunc(sysdate) else complete_date end, - updated_time = #{updatedTime} - where order_code = #{orderCode} + set execution_status = #{executionStatus,jdbcType=VARCHAR}, + start_time = case when #{executionStatus,jdbcType=VARCHAR} = 'RUNNING' and start_time is null then sysdate else start_time end, + end_time = case when #{executionStatus,jdbcType=VARCHAR} = 'COMPLETED' then sysdate else end_time end, + complete_date = case when #{executionStatus,jdbcType=VARCHAR} = 'COMPLETED' then trunc(sysdate) else complete_date end, + updated_time = #{updatedTime,jdbcType=DATE} + where order_code = #{orderCode,jdbcType=VARCHAR} diff --git a/aucma-production/src/main/resources/mapper/production/ProdTeamShiftMapper.xml b/aucma-production/src/main/resources/mapper/production/ProdTeamShiftMapper.xml index af3d80f..92bcf75 100644 --- a/aucma-production/src/main/resources/mapper/production/ProdTeamShiftMapper.xml +++ b/aucma-production/src/main/resources/mapper/production/ProdTeamShiftMapper.xml @@ -81,24 +81,25 @@ obj_id, team_code, shift_date, shift_code, leader_user_id, line_code, area_desc, status, remark, create_by, create_time, update_by, update_time ) values ( - #{objId}, #{teamCode}, #{shiftDate}, #{shiftCode}, #{leaderUserId}, #{lineCode}, #{areaDesc}, #{status}, - #{remark}, #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime} + #{objId,jdbcType=NUMERIC}, #{teamCode,jdbcType=VARCHAR}, #{shiftDate,jdbcType=DATE}, #{shiftCode,jdbcType=VARCHAR}, + #{leaderUserId,jdbcType=NUMERIC}, #{lineCode,jdbcType=VARCHAR}, #{areaDesc,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, + #{remark,jdbcType=VARCHAR}, #{createdBy,jdbcType=VARCHAR}, #{createdTime,jdbcType=DATE}, #{updatedBy,jdbcType=VARCHAR}, #{updatedTime,jdbcType=DATE} ) update prod_team_sch - team_code = #{teamCode}, - shift_date = #{shiftDate}, - shift_code = #{shiftCode}, - leader_user_id = #{leaderUserId}, - line_code = #{lineCode}, - area_desc = #{areaDesc}, - status = #{status}, - remark = #{remark}, - update_by = #{updatedBy}, - update_time = #{updatedTime} + team_code = #{teamCode,jdbcType=VARCHAR}, + shift_date = #{shiftDate,jdbcType=DATE}, + shift_code = #{shiftCode,jdbcType=VARCHAR}, + leader_user_id = #{leaderUserId,jdbcType=NUMERIC}, + line_code = #{lineCode,jdbcType=VARCHAR}, + area_desc = #{areaDesc,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + remark = #{remark,jdbcType=VARCHAR}, + update_by = #{updatedBy,jdbcType=VARCHAR}, + update_time = #{updatedTime,jdbcType=DATE} where obj_id = #{objId}