-- ============================================
-- 巡视整改销号流程（partymatter_close）节点权限对齐
-- 依据: 巡视整改销号流程.ods（以 ODS 为准）
-- 涉及表: ext_act_process_node / ext_act_process_node_reject_target
-- 目标: 10 个节点按 ODS 设置 model_and_view(URL参数)、default_opinion、reject_status、cc_status、驳回目标
-- 说明:
--   - 基本信息权限全部"可见，不可编辑" → form_edit_status 保持 0（不改）
--   - 反馈信息权限: 不可见→只带showProcessHandle; 可反馈可编辑→showAdd+showEdit;
--     纪检字段可编辑其他只读→showEditFeedback+nonJiJianFieldsReadonly+showJiJianFields;
--     纪检字段只读→showJiJianFields
--   - 选择经办人权限: 仅 1.1 可见 → showSubApproveUser=1
--   - 表单沿用现有 DqInspectTaskBPMForm（该组件已支持全部权限参数）
--   - 抄送: ODS 全部"不抄送" → cc_status='0'
--   - 驳回: 可驳回→reject_status='1'+reject_target；不可驳回→'0'
-- 执行环境: 先 deploy-test 验证，再同步其他环境；执行后去流程设计器点"发布"
-- ============================================

START TRANSACTION;

-- ============================================
-- 1. 节点配置 UPDATE（10 节点，按 ODS 全量覆盖）
-- ============================================

-- 1.1 责任部门负责人分配任务/直接办结（可反馈可编辑+经办人 / 办结或派单 / 不可驳回 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showSubApproveUser=1&showFeedbackInfo=1&showAddFeedback=1&showEditFeedback=1',
  default_opinion = '办结的话，填已办结，请党群经办人确认，没办结的话填经xxx办',
  reject_status = '0',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_1k6n75g';

-- 1.2 责任部门经办人反馈（可反馈可编辑 / 已反馈，请领导审批 / 不可驳回 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showAddFeedback=1&showEditFeedback=1',
  default_opinion = '已反馈，请领导审批',
  reject_status = '0',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_0r2vutj';

-- 1.3 责任部门负责人审批（可反馈可编辑 / 已审批，请党群经办人确认 / 可驳回1.2 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showAddFeedback=1&showEditFeedback=1',
  default_opinion = '已审批，请党群经办人确认',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_1k36lmv';

-- 1.4 党群经办人确认（反馈不可见 / 已确认，请领导审批 / 可驳回1.1,1.2,1.3 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1',
  default_opinion = '已确认，请领导审批',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_1cvft2f';

-- 1.5 党群领导确认（反馈不可见 / 已审批，请纪检部经办人确认 / 可驳回1.1-1.4 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1',
  default_opinion = '已审批，请纪检部经办人确认',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_1dwzsa6';

-- 1.6 纪检部经办人监察（纪检字段可编辑其他只读 / 已监察，请领导审批 / 可驳回1.1-1.5 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showEditFeedback=1&nonJiJianFieldsReadonly=1&showJiJianFields=1',
  default_opinion = '已监察，请领导审批',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_1azpeqj';

-- 1.7 纪检部领导审批（纪检字段可编辑其他只读 / 已审批，请分管所领导审批 / 可驳回1.1-1.6 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showEditFeedback=1&nonJiJianFieldsReadonly=1&showJiJianFields=1',
  default_opinion = '已审批，请分管所领导审批',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_0mfkcdx';

-- 1.8 分管所领导审批（纪检字段只读 / 同意，请纪委书记审批 / 可驳回1.1-1.7 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showJiJianFields=1',
  default_opinion = '同意，请纪委书记审批',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_1k1zt37';

-- 1.9 纪委书记审批（纪检字段只读 / 同意，请党委书记审批 / 可驳回1.1-1.8 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showJiJianFields=1',
  default_opinion = '同意，请党委书记审批',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_09qxoto';

-- 1.10 党委书记审批（纪检字段只读 / 同意 / 可驳回1.1-1.9 / 不抄送）
UPDATE ext_act_process_node SET
  model_and_view = 'dq/inspectTask/components/DqInspectTaskBPMForm?showProcessHandle=1&showFeedbackInfo=1&showJiJianFields=1',
  default_opinion = '同意',
  reject_status = '1',
  cc_status = '0'
WHERE process_id='2064643231758139394' AND process_node_code='Task_0cfjknn';

-- ============================================
-- 2. 驳回目标（先清后插，保证与 ODS 完全一致）
-- ============================================
DELETE FROM ext_act_process_node_reject_target WHERE process_id='2064643231758139394';

INSERT INTO ext_act_process_node_reject_target (id, process_id, source_node_code, target_node_code, target_node_name) VALUES
  -- 1.3 可驳回到 1.2
  (UUID(), '2064643231758139394', 'Task_1k36lmv', 'Task_0r2vutj', '责任部门经办人反馈'),
  -- 1.4 可驳回到 1.1, 1.2, 1.3
  (UUID(), '2064643231758139394', 'Task_1cvft2f', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_1cvft2f', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_1cvft2f', 'Task_1k36lmv', '责任部门负责人审批'),
  -- 1.5 可驳回到 1.1-1.4
  (UUID(), '2064643231758139394', 'Task_1dwzsa6', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_1dwzsa6', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_1dwzsa6', 'Task_1k36lmv', '责任部门负责人审批'),
  (UUID(), '2064643231758139394', 'Task_1dwzsa6', 'Task_1cvft2f', '党群经办人确认'),
  -- 1.6 可驳回到 1.1-1.5
  (UUID(), '2064643231758139394', 'Task_1azpeqj', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_1azpeqj', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_1azpeqj', 'Task_1k36lmv', '责任部门负责人审批'),
  (UUID(), '2064643231758139394', 'Task_1azpeqj', 'Task_1cvft2f', '党群经办人确认'),
  (UUID(), '2064643231758139394', 'Task_1azpeqj', 'Task_1dwzsa6', '党群领导确认'),
  -- 1.7 可驳回到 1.1-1.6
  (UUID(), '2064643231758139394', 'Task_0mfkcdx', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_0mfkcdx', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_0mfkcdx', 'Task_1k36lmv', '责任部门负责人审批'),
  (UUID(), '2064643231758139394', 'Task_0mfkcdx', 'Task_1cvft2f', '党群经办人确认'),
  (UUID(), '2064643231758139394', 'Task_0mfkcdx', 'Task_1dwzsa6', '党群领导确认'),
  (UUID(), '2064643231758139394', 'Task_0mfkcdx', 'Task_1azpeqj', '纪检部经办人监察'),
  -- 1.8 可驳回到 1.1-1.7
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_1k36lmv', '责任部门负责人审批'),
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_1cvft2f', '党群经办人确认'),
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_1dwzsa6', '党群领导确认'),
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_1azpeqj', '纪检部经办人监察'),
  (UUID(), '2064643231758139394', 'Task_1k1zt37', 'Task_0mfkcdx', '纪检部领导审批'),
  -- 1.9 可驳回到 1.1-1.8
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_1k36lmv', '责任部门负责人审批'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_1cvft2f', '党群经办人确认'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_1dwzsa6', '党群领导确认'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_1azpeqj', '纪检部经办人监察'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_0mfkcdx', '纪检部领导审批'),
  (UUID(), '2064643231758139394', 'Task_09qxoto', 'Task_1k1zt37', '分管所领导审批'),
  -- 1.10 可驳回到 1.1-1.9
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_1k6n75g', '责任部门负责人分配任务/直接办结'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_0r2vutj', '责任部门经办人反馈'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_1k36lmv', '责任部门负责人审批'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_1cvft2f', '党群经办人确认'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_1dwzsa6', '党群领导确认'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_1azpeqj', '纪检部经办人监察'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_0mfkcdx', '纪检部领导审批'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_1k1zt37', '分管所领导审批'),
  (UUID(), '2064643231758139394', 'Task_0cfjknn', 'Task_09qxoto', '纪委书记审批');

COMMIT;

-- ============================================
-- 校验语句（执行后核对，期望 43 行）
-- ============================================
-- SELECT COUNT(*) FROM ext_act_process_node_reject_target WHERE process_id='2064643231758139394';
