package com.sptg.repeater;

import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

public class Test {
    public static void main1(String[] args) {
        int i10 = 1863041840;
        int i8 = 14733420;
        String keyID = "14733420";

        // 转换为16进制
        keyID = Integer.toHexString(Convert.toInt(keyID));
        // 转换为大写
//        keyID = keyID.toUpperCase();
        // 卡号位数不足10位，前面补0

        int len = keyID.length();
        int maxLen = 8;
        if(len < maxLen){
            int y = maxLen - len;
            System.err.println(y + "--"+maxLen+ "==="+ len);
            String bw = String.format("%0" + y + "d", 0);
            keyID = bw + keyID;
        }

        System.err.println(keyID);
    }

    public static void main(String[] args) {
        JSONObject json = new JSONObject();
        json.put("DEVICEID", "AEAC082E");
        json.put("RESULT", 0);
        json.put("OPERATE", "1B");

        String[] PARAMS = {"AEAC082E","00","64"};
        json.put("PARAMS", PARAMS);

        JSONObject j = new JSONObject();
        j.put("ddd" , JSONUtil.toJsonStr(json));
        System.out.println(json.toString());
        System.out.println(JSONUtil.toJsonStr(j));

        // {"DEVICEID":"AEAC082E","RESULT":0,"OPERATE":"1B","PARAMS":["AEAC082E","00","64"]}
    }
}
