package com.simuwang.base.common.conts;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;


/**
 * @author mozuwen
 * @date 2024/03/19
 * @describe 会计科目
 */
public class AccountingItems {

    /**
     * 现金类
     */
    public final static HashSet<String> CASH = toHashSet("1002,1051,1204,1021,1031,1114,310211,1121,1132,1203,1207,"
            + "1221,1304,1501,1522,1531,1532,3003,3999,2203,2204,2205,2206,2207,2210,2221,2231,2241,2261,2211,2331,2214");

    /**
     * 债券类
     */
    public final static HashSet<String> BOND = toHashSet("1107,1113,1321,1303,1401,1461,1104");

    /**
     * 其他
     */
    public final static HashSet<String> OTHER = toHashSet("1115,1503,1511");

    /**
     * 权证
     */
    public final static String WARRANT = "1106";

    /**
     * 股票类
     */
    public final static HashSet<String> EQUITY_LIST = toHashSet("1102,2101");

    /**
     * 债券类: 1202-正回购,2202-逆回购
     */
    public final static HashSet<String> BOND_LIST = toHashSet("1103,1202,2202");

    /**
     * 基金类
     */
    public final static List<String> FUND_LIST = toList("1105,1108,1109,1101");

    /**
     * 期货及衍生品类
     */
    public final static List<String> DERIVATIVES = toList("3102,3201,3103,3101");

    /**
     * 股指期货
     */
    public final static HashSet<String> INDEX_FUTRUE = toHashSet("IZ,IH,IF,IC,IM");

    /**
     * 国债期货
     */
    public final static HashSet<String> BOND_FUTRUE = toHashSet("TS,TL,TF,T");

    /**
     * 商品期货
     */
    public final static HashSet<String> CMDT_FUTRUE = toHashSet("SI,LC,ZC,WT,WH,UR,TA,SR,SM,SH,SF,SA,RS,RM,RI,PX,PM,PK,PF,OI,MA,LR,JR,GN,FG," +
            "CY,CJ,CF,AP,Y,V,S,RR,PP,PG,P,M,LH,L,JM,JD,J,I,FB,EG,EB,CS,C,BB,B,A,SCTAS,SC,NR,LU,EC,BC,ZN,WR,SS,SP,SN,RU,RB,PB,NI,HC,FU,CU,BU,BR,AU,AO,AL,AG");


    private static List<String> toList(String code) {
        if (null == code || "".equals(code.trim())) {
            return null;
        }
        return Arrays.asList(code.replaceAll("\\s+", "").split(","));
    }


    private static HashSet<String> toHashSet(String string) {
        String[] arr = string.replaceAll("\\s+", "").split(",");
        HashSet<String> set = new HashSet<>(arr.length);
		set.addAll(Arrays.asList(arr));
        return set;
    }
}
