package com.muyu.parse.uitl;


import lombok.extern.log4j.Log4j2;

/**
 * @version 1.0
 * @Author xie ya ru
 * @Date 2024/9/28 16:48
 * @注释 进制转换
 */
@Log4j2
public class DataParseUtil {
    public static final Integer STARTPOSITION = 1;

    public static final Integer ENDPOSITION = 18;

    public static final Integer INDEX = 16;
    public static String dataParsing(String jsonVin){

        //根据空格切割数据
        String[] hexArray = jsonVin.split(" ");
        StringBuilder result = new StringBuilder();
        //遍历十六进制数据转换为字符
        for (String hex : hexArray) {
            int decimal = Integer.parseInt(hex, INDEX);
            result.append((char) decimal);
        }
        //取出车辆VIN码
        String vehicleVin = result.substring(STARTPOSITION, ENDPOSITION);
        log.info("车辆VIN码: " + vehicleVin);
        return vehicleVin;

    }
}
