package com.dcsoft.system.uniubi.controller;

import cn.hutool.core.util.NumberUtil;
import com.alibaba.nacos.shaded.com.google.gson.JsonParser;
import com.dcsoft.common.core.constant.Constants;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

public class test {
    public static void main(String[] args) throws ParseException {

        double floorNum = NumberUtil.div(20, 4);
        if (floorNum % 1 != 0) {
            floorNum = floorNum + 1;
        }
        int floorCount = (int) NumberUtil.mul((int) floorNum, 4);
        List<String> list = new ArrayList<>();
        for (int i = 0; i < floorCount; i++) {
            list.add("0");
        }

        list.set(floorCount - 20, "1");
        list.set(floorCount - 19, "1");
        list.set(floorCount - 18, "1");
        list.set(floorCount - 17, "1");
        list.set(floorCount - 16, "1");
        list.set(floorCount - 15, "1");
        list.set(floorCount - 14, "1");
        list.set(floorCount - 13, "1");
        list.set(floorCount - 12, "1");
        list.set(floorCount - 11, "1");
        list.set(floorCount - 10, "1");
        list.set(floorCount - 9, "1");
        list.set(floorCount - 8, "1");
        list.set(floorCount - 7, "1");
        list.set(floorCount - 6, "1");
        list.set(floorCount - 5, "1");
        list.set(floorCount - 4, "1");
        list.set(floorCount - 3, "1");
        list.set(floorCount - 2, "1");
        list.set(floorCount - 1, "1");


        // 二进制数
        String binaryString = String.join("", list);
        // 转换为十进制数
        int binaryNumber = Integer.parseInt(binaryString, 2);
        // 转换为十六进制数
        String hexString = Integer.toHexString(binaryNumber);
        System.out.println("十六进制数: " + hexString);

        String formattedNumber = String.format("%16s", hexString).replace(' ', '0');
        System.out.println(formattedNumber);

        String zeroString = String.format("%052d", 0);
        System.out.println(zeroString);

        String floor = "FF" + formattedNumber + zeroString;
        System.out.println(floor);


        SimpleDateFormat sf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        Date parse = sf.parse("2024年02月26日 11:14:08");
        System.out.println(parse);

        String  s = "{\"first\": {\n" +
                "          \"value\": \"广州腾讯科技有限公司\"\n" +
                "      },\n" +
                "      \"keyword1\": {\n" +
                "          \"value\": \"广州腾讯科技有限公司\"\n" +
                "      },\n" +
                "       \"keyword2\": {\n" +
                "          \"value\": \"2019年8月8日\"\n" +
                "      }}";
        System.out.println(JsonParser.parseString(Constants.CONTENT).getAsJsonObject());
    }
}
