package com.gxwebsoft.ai.constants;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.*;

/**
 * 党风廉政建设责任制审计常量类
 */
public class AuditContent10PartyConductConstants {
    
    // 大类定义
    public static final String CATEGORY_TARGET_RESPONSIBILITY = "落实党风廉政建设责任制";
    public static final String CATEGORY_INSPECTION_RECTIFICATION = "巡视整改工作";
    public static final String CATEGORY_DISCIPLINE_REFORM = "深化纪律检查体制改革";
    
    // 子类定义 - 落实党风廉政建设责任制
    public static final String SUBCATEGORY_MAIN_RESPONSIBILITY = "落实主体责任和监督责任";
    public static final String SUBCATEGORY_EIGHT_REGULATIONS = "落实中央八项规定精神工作";
    public static final String SUBCATEGORY_ANTI_CORRUPTION = "开展查处发生在群众身边的\"四风\"和腐败问题专项工作";
    public static final String SUBCATEGORY_DISCIPLINE_ENFORCEMENT = "严明纪律确保政令畅通";
    
    // 子类定义 - 巡视整改工作
    public static final String SUBCATEGORY_MONTHLY_REPORT = "严格执行月报告制度";
    public static final String SUBCATEGORY_RECTIFICATION_TASK = "按时完成整改任务";
    public static final String SUBCATEGORY_RECTIFICATION_ACCOUNTABILITY = "因巡视整改不给力被追究";
    
    // 子类定义 - 深化纪律检查体制改革
    public static final String SUBCATEGORY_THREE_TURNS = "聚焦主业主责，持续深化\"三转\"工作";
    public static final String SUBCATEGORY_SYSTEM_CONSTRUCTION = "健全完善深化纪检体制改革的相关制度文件并抓好贯彻落实";
    
    // 小类定义
    public static final String DETAIL_LEADERSHIP_STRENGTHENING = "1 强化组织领导";
    public static final String DETAIL_TASK_DEPLOYMENT = "2 及时部署工作任务";
    public static final String DETAIL_PRESSURE_TRANSMISSION = "3 层层传到责任和压力";
    public static final String DETAIL_CASE_DOUBLE_CHECK = "4 坚持\"一案双查\"";
    public static final String DETAIL_WORK_REPORTING = "5 及时汇报工作情况";
    public static final String DETAIL_INSPECTION_AND_SUPERVISION = "1 开展监督检查";
    public static final String DETAIL_DATA_SUBMISSION = "2 报送数据和资料";
    public static final String DETAIL_CASE_HANDLING = "3 查办违反中央八项规定精神案件";
    public static final String DETAIL_EXPOSURE_NOTIFICATION = "4 通报曝光";
    public static final String DETAIL_HOUSING_CLEARANCE = "5 清退干部职工多占住房";
    public static final String DETAIL_PROBLEM_CLUE_HANDLING = "1 及时梳理处置问题线索";
    public static final String DETAIL_CASE_INVESTIGATION = "2 查处一批案件";
    public static final String DETAIL_TYPICAL_CASE_EXPOSURE = "3 通报曝光一批典型案件";
    public static final String DETAIL_ATMOSPHERE_CREATION = "4 营造氛围";
    public static final String DETAIL_PROBLEM_CONFESSION = "5 督促违纪人员主动交代问题";
    public static final String DETAIL_SUMMARY_AND_MECHANISM = "6 进行总结并建立长效机制";
    public static final String DETAIL_NORMALIZED_GOVERNANCE = "7 专项工作纳入常态化治理";
    public static final String DETAIL_POLITICAL_DISCIPLINE = "1 严明政治纪律和组织纪律";
    public static final String DETAIL_MAJOR_DECISION = "2 按时完成中央和自治区重大决策部署";
    public static final String DETAIL_CASE_COMPLETION = "3 按时完成转办督办案件";
    
    // 大类与子类映射关系
    public static final Map<String, List<String>> CATEGORY_SUBCATEGORY_MAP = new HashMap<>();
    static {
        // 落实党风廉政建设责任制
        CATEGORY_SUBCATEGORY_MAP.put(CATEGORY_TARGET_RESPONSIBILITY, Arrays.asList(
            SUBCATEGORY_MAIN_RESPONSIBILITY,
            SUBCATEGORY_EIGHT_REGULATIONS,
            SUBCATEGORY_ANTI_CORRUPTION,
            SUBCATEGORY_DISCIPLINE_ENFORCEMENT
        ));
        
        // 巡视整改工作
        CATEGORY_SUBCATEGORY_MAP.put(CATEGORY_INSPECTION_RECTIFICATION, Arrays.asList(
            SUBCATEGORY_MONTHLY_REPORT,
            SUBCATEGORY_RECTIFICATION_TASK,
            SUBCATEGORY_RECTIFICATION_ACCOUNTABILITY
        ));
        
        // 深化纪律检查体制改革
        CATEGORY_SUBCATEGORY_MAP.put(CATEGORY_DISCIPLINE_REFORM, Arrays.asList(
            SUBCATEGORY_THREE_TURNS,
            SUBCATEGORY_SYSTEM_CONSTRUCTION
        ));
    }
    
    // 子类与小类映射关系
    public static final Map<String, List<String>> SUBCATEGORY_DETAIL_MAP = new HashMap<>();
    static {
        // 落实主体责任和监督责任
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_MAIN_RESPONSIBILITY, Arrays.asList(
            DETAIL_LEADERSHIP_STRENGTHENING,
            DETAIL_TASK_DEPLOYMENT,
            DETAIL_PRESSURE_TRANSMISSION,
            DETAIL_CASE_DOUBLE_CHECK,
            DETAIL_WORK_REPORTING
        ));
        
        // 落实中央八项规定精神工作
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_EIGHT_REGULATIONS, Arrays.asList(
            DETAIL_INSPECTION_AND_SUPERVISION,
            DETAIL_DATA_SUBMISSION,
            DETAIL_CASE_HANDLING,
            DETAIL_EXPOSURE_NOTIFICATION,
            DETAIL_HOUSING_CLEARANCE
        ));
        
        // 开展查处发生在群众身边的"四风"和腐败问题专项工作
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_ANTI_CORRUPTION, Arrays.asList(
            DETAIL_PROBLEM_CLUE_HANDLING,
            DETAIL_CASE_INVESTIGATION,
            DETAIL_TYPICAL_CASE_EXPOSURE,
            DETAIL_ATMOSPHERE_CREATION,
            DETAIL_PROBLEM_CONFESSION,
            DETAIL_SUMMARY_AND_MECHANISM,
            DETAIL_NORMALIZED_GOVERNANCE
        ));
        
        // 严明纪律确保政令畅通
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_DISCIPLINE_ENFORCEMENT, Arrays.asList(
            DETAIL_POLITICAL_DISCIPLINE,
            DETAIL_MAJOR_DECISION,
            DETAIL_CASE_COMPLETION
        ));
        
        // 巡视整改工作的子类
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_MONTHLY_REPORT, Arrays.asList("1 严格执行月报告制度"));
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_RECTIFICATION_TASK, Arrays.asList("2 按时完成整改任务"));
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_RECTIFICATION_ACCOUNTABILITY, Arrays.asList("3 因巡视整改不给力被追究"));
        
        // 深化纪律检查体制改革的子类
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_THREE_TURNS, Arrays.asList("1 聚焦主业主责，持续深化\"三转\"工作"));
        SUBCATEGORY_DETAIL_MAP.put(SUBCATEGORY_SYSTEM_CONSTRUCTION, Arrays.asList("2 健全完善深化纪检体制改革的相关制度文件并抓好贯彻落实"));
    }
    
    // 固定顺序的示例数据列表（按审计内容10.txt中的顺序）
    private static final List<JSONObject> FIXED_ORDER_EXAMPLE_DATA = new ArrayList<>();
    static {
        // 落实主体责任和监督责任
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "1 强化组织领导", "建立责任清单、明确党组、纪检责任");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "1 强化组织领导", "建立健全反腐败领导机制，人员调整后及时进行分工，并全年召开两次以上协调会");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "1 强化组织领导", "主要领导认真履行第一责任人责任，对党风廉政建设重要工作亲自部署、重大问题亲自过问、重点环节亲自协调、重要案件亲自督办5次以上");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "1 强化组织领导", "领导班子其他成员对职责范围内的党风廉政建设承担主要责任，与分管联系部门研究安排党风廉政建设工作4次以上");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "2 及时部署工作任务", "有党风廉政建设任务分工方案，党组专题研究部署党风廉政建设工作4次以上");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "3 层层传到责任和压力", "主要领导检查和调研党风廉政建设各一次以上,每年听取分管联系部门的党风廉政建设一次以上，且每年亲自上廉政党课不少于1次");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "3 层层传到责任和压力", "分管领导对分管联系部门党风廉政建设检查和调研各1次以上，每年听取分管联系部门的党风廉政建设情况汇报一次以上，到分管联系部门上廉政党课1次以上");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "3 层层传到责任和压力", "党组、纪检组注重抓早抓小，经常进行咬耳扯袖、红脸出汗，及时开展约谈、集体廉政谈话等工作3次以上");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "3 层层传到责任和压力", "开展述责评议工作");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "4 坚持\"一案双查\"", "对发生在本单位的较严重的违反政治纪律、组织纪律等问题进行\"一案双查\"");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "4 坚持\"一案双查\"", "出现\"四风\"和腐败等顶风违纪问题的");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "4 坚持\"一案双查\"", "出现区域性系统性违纪违法问题突出的");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "4 坚持\"一案双查\"", "出现上级交办的党风廉政建设事项不传达部署和落实的");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "4 坚持\"一案双查\"", "出现违纪行为隐瞒不报压案不查等问题而未进行责任追究被中央、自治区进行挂牌督办或直接问责、约谈等");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "5 及时汇报工作情况", "党组、纪检组向自治区党委、纪委汇报\"两个\"责任落实情况两次以上");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "5 及时汇报工作情况", "班子成员年底向自治区纪委报送个人落实\"两个责任\"情况报告");
        addExampleData("落实党风廉政建设责任制", "落实主体责任和监督责任", "5 及时汇报工作情况", "按照自治区纪委部署开展其他工作，并按时报送总结报告的");
        
        // 落实中央八项规定精神工作
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "1 开展监督检查", "部署开展监督检查3次以上");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "2 报送数据和资料", "每月按时报送中央八项规定精神案件有关统计数据和有关资料");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "2 报送数据和资料", "每月不按时报送或未按要求报送的");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "3 查办违反中央八项规定精神案件", "及时查处监督检查中发现的问题和中央、自治区转办督办的问题线索");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "3 查办违反中央八项规定精神案件", "出现违反中央八项规定精神问题被上级查处的，或查处但问责太轻，被上级责令重新查办");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "4 通报曝光", "对受到党纪政纪处分的问题全部进行通报曝光的");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "5 清退干部职工多占住房", "到年底还不能完成干部职工多占住房清退的");
        addExampleData("落实党风廉政建设责任制", "落实中央八项规定精神工作", "5 清退干部职工多占住房", "信访反映清房工作不到位被查实的");
        
        // 开展查处发生在群众身边的"四风"和腐败问题专项工作
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "1 及时梳理处置问题线索", "对收到或者上级交办问题线索进行转办督办或直接查办的");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "2 查处一批案件", "因查处案件不力被自治区约谈或通报批评的");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "3 通报曝光一批典型案件", "对查处的案件进行通报曝光");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "4 营造氛围", "加大宣传力度，用典型案例进行警示教育");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "5 督促违纪人员主动交代问题", "以文件形式或在网络、报纸、电视等媒介上发布公告，督促违纪人员主动交代问题并主动上缴违纪所得");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "6 进行总结并建立长效机制", "没有在6月20日前进行总结");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "6 进行总结并建立长效机制", "没有结合专项工作中发现存在的突出问题建立完善制度措施");
        addExampleData("落实党风廉政建设责任制", "开展查处发生在群众身边的\"四风\"和腐败问题专项工作", "7 专项工作纳入常态化治理", "6月后，在全部二层单位开展专项工作");
        
        // 严明纪律确保政令畅通
        addExampleData("落实党风廉政建设责任制", "严明纪律确保政令畅通", "1 严明政治纪律和组织纪律", "有违反政治纪律等问题被中央、自治区查处的");
        addExampleData("落实党风廉政建设责任制", "严明纪律确保政令畅通", "2 按时完成中央和自治区重大决策部署", "出现问题被中央、自治区问责的");
        addExampleData("落实党风廉政建设责任制", "严明纪律确保政令畅通", "3 按时完成转办督办案件", "按时完成自治区纪委转办督办的党风政风类案件");
        addExampleData("落实党风廉政建设责任制", "严明纪律确保政令畅通", "3 按时完成转办督办案件", "不按时完成或不完成的");
        
        // 巡视整改工作
        addExampleData("巡视整改工作", "严格执行月报告制度", "1 严格执行月报告制度", "严格执行月报告制度");
        addExampleData("巡视整改工作", "按时完成整改任务", "2 按时完成整改任务", "按时完成整改任务");
        addExampleData("巡视整改工作", "因巡视整改不给力被追究", "3 因巡视整改不给力被追究", "因巡视整改不给力被追究");
        
        // 深化纪律检查体制改革
        addExampleData("深化纪律检查体制改革", "聚焦主业主责，持续深化\"三转\"工作", "1 聚焦主业主责，持续深化\"三转\"工作", "纪检组长或纪工委书记不分管具体业务工作，专职抓执纪监督问责工作");
        addExampleData("深化纪律检查体制改革", "聚焦主业主责，持续深化\"三转\"工作", "1 聚焦主业主责，持续深化\"三转\"工作", "检查发现有参与业务工作");
        addExampleData("深化纪律检查体制改革", "健全完善深化纪检体制改革的相关制度文件并抓好贯彻落实", "2 健全完善深化纪检体制改革的相关制度文件并抓好贯彻落实", "年底前制定有1项以上配套制度文件");
    }
    
    private static void addExampleData(String category, String subCategory, String detailCategory, String content) {
        JSONObject obj = new JSONObject();
        obj.put("category", category);
        obj.put("subCategory", subCategory);
        obj.put("detailCategory", detailCategory);
        obj.put("content", content);
        obj.put("executionStatus", "");
        obj.put("workPaperIndex", "[\"实际存在的完整文件名1||FileUrl1\", \"实际存在的完整文件名2||FileUrl2\", \"...\"]");
//        obj.put("workPaperIndex", "[\"实际存在的完整FileId1\", \"实际存在的完整FileId2\", \"...\"]");
        FIXED_ORDER_EXAMPLE_DATA.add(obj);
    }
    
    /**
     * 获取所有固定顺序的示例数据
     */
    public static List<JSONObject> getFixedOrderExampleData() {
        return new ArrayList<>(FIXED_ORDER_EXAMPLE_DATA);
    }
    
    /**
     * 获取指定子类的示例数据
     */
    public static JSONArray getExampleDataBySubCategory(String subCategory) {
        JSONArray result = new JSONArray();
        for (JSONObject example : FIXED_ORDER_EXAMPLE_DATA) {
            if (subCategory.equals(example.getString("subCategory"))) {
                result.add(example);
            }
        }
        return result;
    }
    
    /**
     * 获取固定顺序的内容列表
     */
    public static List<String> getFixedOrderContentList() {
        List<String> contentList = new ArrayList<>();
        for (JSONObject example : FIXED_ORDER_EXAMPLE_DATA) {
            contentList.add(example.getString("content"));
        }
        return contentList;
    }
    
    /**
     * 获取内容在固定顺序中的索引
     */
    public static int getContentFixedOrderIndex(String content) {
        List<String> fixedOrder = getFixedOrderContentList();
        int index = fixedOrder.indexOf(content);
        return index != -1 ? index : Integer.MAX_VALUE;
    }
    
    /**
     * 获取所有子类列表（包括所有大类的子类）
     */
    public static List<String> getAllSubCategories() {
        List<String> allSubCategories = new ArrayList<>();
        for (List<String> subCategories : CATEGORY_SUBCATEGORY_MAP.values()) {
            allSubCategories.addAll(subCategories);
        }
        return allSubCategories;
    }
    
    // 大类顺序 - 用于排序
    public static final List<String> CATEGORY_ORDER = Arrays.asList(
        CATEGORY_TARGET_RESPONSIBILITY,
        CATEGORY_INSPECTION_RECTIFICATION,
        CATEGORY_DISCIPLINE_REFORM
    );
    
    // 大类描述
    public static final Map<String, String> CATEGORY_DESCRIPTIONS = new HashMap<>();
    static {
        CATEGORY_DESCRIPTIONS.put(CATEGORY_TARGET_RESPONSIBILITY, "落实党风廉政建设主体责任和监督责任");
        CATEGORY_DESCRIPTIONS.put(CATEGORY_INSPECTION_RECTIFICATION, "巡视反馈问题的整改落实情况");
        CATEGORY_DESCRIPTIONS.put(CATEGORY_DISCIPLINE_REFORM, "深化纪律检查体制改革工作情况");
    }
    
    // 子类描述
    public static final Map<String, String> SUBCATEGORY_DESCRIPTIONS = new HashMap<>();
    static {
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_MAIN_RESPONSIBILITY, "党委主体责任和纪委监督责任落实情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_EIGHT_REGULATIONS, "中央八项规定精神落实情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_ANTI_CORRUPTION, "查处群众身边腐败问题工作情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_DISCIPLINE_ENFORCEMENT, "纪律执行和政令畅通情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_MONTHLY_REPORT, "巡视整改月报告制度执行情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_RECTIFICATION_TASK, "巡视整改任务完成情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_RECTIFICATION_ACCOUNTABILITY, "巡视整改责任追究情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_THREE_TURNS, "纪检机构转职能、转方式、转作风工作情况");
        SUBCATEGORY_DESCRIPTIONS.put(SUBCATEGORY_SYSTEM_CONSTRUCTION, "纪检体制改革制度建设情况");
    }
    
    // 执行状态选项
    public static final String STATUS_IMPLEMENTED = "已落实";
    public static final String STATUS_PARTIALLY_IMPLEMENTED = "部分落实";
    public static final String STATUS_NOT_IMPLEMENTED = "未落实";
    public static final String STATUS_NOT_APPLICABLE = "不适用";
    
    // 关键词权重
    public static final Map<String, Integer> KEYWORD_WEIGHTS = new HashMap<>();
    static {
        KEYWORD_WEIGHTS.put("党风廉政建设", 10);
        KEYWORD_WEIGHTS.put("主体责任", 9);
        KEYWORD_WEIGHTS.put("监督责任", 9);
        KEYWORD_WEIGHTS.put("中央八项规定", 8);
        KEYWORD_WEIGHTS.put("廉洁从业", 8);
        KEYWORD_WEIGHTS.put("巡视整改", 7);
        KEYWORD_WEIGHTS.put("纪律检查", 7);
        KEYWORD_WEIGHTS.put("廉政谈话", 6);
        KEYWORD_WEIGHTS.put("一案双查", 6);
        KEYWORD_WEIGHTS.put("四风", 5);
        KEYWORD_WEIGHTS.put("腐败", 5);
    }
    
    // 工作底稿关键词
    public static final Map<String, String> WORK_PAPER_KEYWORDS = new HashMap<>();
    static {
        WORK_PAPER_KEYWORDS.put("会议纪要", "党委会议纪要、党风廉政建设专题会议纪要");
        WORK_PAPER_KEYWORDS.put("责任清单", "党风廉政建设责任清单、主体责任清单");
        WORK_PAPER_KEYWORDS.put("检查报告", "党风廉政建设检查报告、巡视整改报告");
        WORK_PAPER_KEYWORDS.put("谈话记录", "廉政谈话记录、提醒谈话记录");
        WORK_PAPER_KEYWORDS.put("制度文件", "党风廉政建设制度、廉洁从业规定");
        WORK_PAPER_KEYWORDS.put("审批文件", "津补贴审批文件、车辆配备审批");
        WORK_PAPER_KEYWORDS.put("举报材料", "信访举报材料、问题线索登记");
    }
    
    /**
     * 对廉政情况数据进行排序（提供给ServiceImpl使用）
     */
    public static void sortPartyConductData(JSONArray data) {
        if (data == null || data.isEmpty()) {
            return;
        }
        
        // 转换为List进行排序
        List<JSONObject> dataList = new ArrayList<>();
        for (int i = 0; i < data.size(); i++) {
            dataList.add(data.getJSONObject(i));
        }
        
        // 排序：优先按固定顺序，其次按类别
        dataList.sort(AuditContent10PartyConductConstants::compareJSONObject);
        
        // 清空原数组并添加排序后的数据
        data.clear();
        data.addAll(dataList);
    }
    
    /**
     * 比较两个JSON对象的排序
     */
    public static int compareJSONObject(JSONObject o1, JSONObject o2) {
        String content1 = o1.getString("content");
        String content2 = o2.getString("content");
        
        // 1. 按固定顺序排序
        int index1 = getContentFixedOrderIndex(content1);
        int index2 = getContentFixedOrderIndex(content2);
        
        if (index1 != index2) {
            return Integer.compare(index1, index2);
        }
        
        // 2. 如果都不在固定顺序中，按类别排序
        return compareByCategory(o1, o2);
    }
    
    /**
     * 按照大类、子类、小类排序
     */
    public static int compareByCategory(JSONObject o1, JSONObject o2) {
        // 清理子类字符串用于比较
        String cleanSubCategory1 = cleanSubCategory(o1.getString("subCategory"));
        String cleanSubCategory2 = cleanSubCategory(o2.getString("subCategory"));
    	
        // 1. 按大类排序
        String category1 = o1.getString("category");
        String category2 = o2.getString("category");
        
        int categoryIndex1 = CATEGORY_ORDER.indexOf(category1);
        int categoryIndex2 = CATEGORY_ORDER.indexOf(category2);
        
        if (categoryIndex1 != categoryIndex2) {
            return Integer.compare(categoryIndex1, categoryIndex2);
        }
        
        // 2. 按子类排序
        String subCategory1 = o1.getString("subCategory");
        String subCategory2 = o2.getString("subCategory");
        
        List<String> subCategories = CATEGORY_SUBCATEGORY_MAP.get(category1);
        if (subCategories != null) {
            int subCategoryIndex1 = subCategories.indexOf(subCategory1);
            int subCategoryIndex2 = subCategories.indexOf(subCategory2);
            
            if (subCategoryIndex1 != subCategoryIndex2) {
                return Integer.compare(subCategoryIndex1, subCategoryIndex2);
            }
        }
        
        // 3. 按小类排序
        String detailCategory1 = o1.getString("detailCategory");
        String detailCategory2 = o2.getString("detailCategory");
        
        List<String> detailCategories = SUBCATEGORY_DETAIL_MAP.get(subCategory1);
        if (detailCategories != null) {
            int detailCategoryIndex1 = detailCategories.indexOf(detailCategory1);
            int detailCategoryIndex2 = detailCategories.indexOf(detailCategory2);
            
            if (detailCategoryIndex1 != detailCategoryIndex2) {
                return Integer.compare(detailCategoryIndex1, detailCategoryIndex2);
            }
        }
        
        // 4. 如果小类也相同，按内容排序
        String content1 = o1.getString("content");
        String content2 = o2.getString("content");
        return content1.compareTo(content2);
    }
    
    private static String cleanSubCategory(String subCategory) {
        if (subCategory == null) return "";
        if (subCategory.contains(" - ")) {
            return subCategory.split(" - ")[0].trim();
        }
        return subCategory;
    }
    
    /**
     * 获取指定子类的示例数据JSON字符串
     */
    public static String getExampleDataJsonString(String subCategory) {
        JSONArray exampleData = getExampleDataBySubCategory(subCategory);
        if (exampleData == null || exampleData.isEmpty()) {
            return "[]";
        }
        
        // 直接使用FastJSON的序列化，确保正确转义即可
        return exampleData.toJSONString();
    }
    
    private AuditContent10PartyConductConstants() {
        // 防止实例化
    }
}