<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package com.baichuanxin.openrestapi.common.utils;


import cn.hutool.core.convert.NumberChineseFormatter;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baichuanxin.openrestapi.common.OnlineTaskConstant;
import com.baichuanxin.openrestapi.configs.OneTaskConfig;
import com.baichuanxin.openrestapi.dtos.*;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Decoder;


import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.io.File;
import java.math.BigDecimal;
import java.util.*;

@Slf4j
@Component
public class OnlineTaskUtil {

    private static String key = "58563214";
    private static String key1 = "32128158";


    @Autowired
    private OneTaskConfig oneTaskConfig;

    /***
     *@Author duxiangyun
     *@Description  鏋勯€犳柟娉曠鏈夊寲锛岄槻姝㈠疄渚嬪寲
     *@Date 2024/8/23
     */
    private OnlineTaskUtil(){}

    /**
     *@Author duxiangyun
     *@Description 鍔炰欢涓嬪彂纭鎺ュ彛
     *@Date 2024/8/23
     */
    public static boolean taskConfirm(String taskId,Map&lt;String,Object&gt; confirmMap){
        confirmMap.put("taskId",taskId);
        //涓嬪彂鍔炰欢纭鎺ュ彛
        HttpResponse execute = HttpUtil.createPost(OnlineTaskConstant.ONE_TASK_CONFIRM).contentType("application/json").body(JSON.toJSONString(confirmMap)).execute();
        if (execute.isOk()){
            String body = execute.body();
            log.info("==================纭鍝嶅簲浣搟}",body);
            ConfirmDataResultDto confirmDataResultDto = JSON.parseObject(body, ConfirmDataResultDto.class);
            if (confirmDataResultDto.getCode()==200||confirmDataResultDto.getCode()==2002){
                return true;
            }else{
                return false;
            }
        }else  {
            return false;
        }
    }

    /**
     *@Author duxiangyun
     *@Description 鏍规嵁鍔炰欢ID鑾峰彇鍔炰欢鏁版嵁鎺ュ彛
     *@Date 2024/8/23
     */
    public static  String getTaskInfo(String taskId){
        List&lt;Map&lt;String ,Object&gt;&gt; listMap = new ArrayList&lt;&gt;();
        //鑾峰彇鍔炰欢璇︽儏鎺ュ彛
        String taskInfoUrl= "http://65.26.1.31:80/one/task/info?taskId=%s";
        HttpResponse execute = HttpUtil.createGet(String.format(taskInfoUrl, taskId)).contentType("application/json").execute();
        //鍒ゆ柇鎺ュ彛鏄惁姝ｅ父璋冪敤
        if (execute.isOk()){
            log.info("=====================鍔炰欢鏁版嵁鑾峰彇鎺ュ彛璋冪敤鎴愬姛==========================");
            String responseBody = execute.body();
            log.info("+++++++++++++++++++鑾峰彇鍔炰欢鏁版嵁鍝嶅簲浣搟}",responseBody);
            TaskInfoApiResultDto taskInfoApiResultDto = JSON.parseObject(responseBody,TaskInfoApiResultDto.class);
            Map&lt;String, Object&gt; data = taskInfoApiResultDto.getData();
            if (taskInfoApiResultDto.getCode()==200){
                return JSON.toJSONString(data);
            }else {
                //鑾峰彇缁撴灉澶辫触
                log.info("==========================鍔炰欢鏁版嵁鑾峰彇鎺ュ彛璋冪敤澶辫触");
                log.info("==========================鍔炰欢鏁版嵁鑾峰彇鎺ュ彛璋冪敤澶辫触鍘熷洜锛歿}",getStatusText(taskInfoApiResultDto.getCode()));
                log.info("==========================鍔炰欢鏁版嵁鑾峰彇鎺ュ彛璋冪敤澶辫触淇℃伅锛歿}",taskInfoApiResultDto.getMsg());
                return "false";
            }
        }else {
            log.info("鍔炰欢鏁版嵁鑾峰彇鎺ュ彛璋冪敤澶辫触,taskId:{}",taskId);
        }
        return "false";
    }


    /**
     *@Author duxiangyun
     *@Description 鏍规嵁鍔炰欢ID鑾峰彇鍔炰欢鏁版嵁鎺ュ彛
     *@Date 2024/8/23
     */
    public static  String getFeedBack(String taskId){
        List&lt;Map&lt;String ,Object&gt;&gt; listMap = new ArrayList&lt;&gt;();
        //鑾峰彇鍔炰欢璇︽儏鎺ュ彛
        String taskInfoUrl= "http://65.26.1.31:80/one/task/get-feedback-info?taskId=%s";
        HttpResponse execute = HttpUtil.createGet(String.format(taskInfoUrl, taskId)).contentType("application/json").execute();
        //鍒ゆ柇鎺ュ彛鏄惁姝ｅ父璋冪敤
        if (execute.isOk()){
            log.info("=====================鍔炰欢鍥炴墽鑾峰彇鎺ュ彛璋冪敤鎴愬姛==========================");
            String responseBody = execute.body();
            log.info("+++++++++++++++++++鑾峰彇鍔炰欢鍥炴墽鍝嶅簲浣搟}",responseBody);
            TaskFeedBackDto taskFeedBackDto = JSON.parseObject(responseBody, TaskFeedBackDto.class);
            if (taskFeedBackDto.isSucc()){
                List&lt;Map&lt;String, Object&gt;&gt; data = taskFeedBackDto.getData();
               return JSON.toJSONString(data);
           }else {
               log.info("鍔炰欢鍥炴墽鑾峰彇鎺ュ彛璋冪敤澶辫触,鍝嶅簲鐮�:{}",taskFeedBackDto.getMsg());
           }
        }else {
            log.info("鍔炰欢鍥炴墽鑾峰彇鎺ュ彛璋冪敤澶辫触,taskId:{}",taskId);
        }
        return "false";
    }

    /***
     *@Author duxiangyun
     *@Description 鑾峰彇鍔炰欢鍥炴墽璇︽儏
     *@Date 2024/10/29  
     */
    public static  String getFeedback(String taskId){
        log.info("================鑾峰彇鍔炰欢璇︽儏鍥炴墽鎺ュ彛=============");
        log.info("璇锋眰task锛歿}",taskId);
        //鑾峰彇鍔炰欢鍥炴墽璇︽儏
        HttpResponse execute = HttpUtil.createPost(OnlineTaskConstant.ONE_TASK_GET_FEEDBACK_FILE)
                .contentType("multipart/form-data;charset=UTF-8")
                .form("taskId",taskId).execute();
        if (execute.isOk()){
            String returnResult = execute.body();
            TaskInfoApiResultDto taskInfoApiResultDto = JSON.parseObject(returnResult, TaskInfoApiResultDto.class);
            return JSON.toJSONString(taskInfoApiResultDto.getData());
        }
        return null;
    }
    /***
     *@Author duxiangyun
     *@Description 杩斿洖鍔炰欢缁撴灉
     *@Date 2024/8/26
     */
    public static boolean returnResult(String requestBody){
        log.info("==========================鍥炰紶鍔炰欢瀹℃壒缁撴灉=================");
        log.info("璇锋眰浣擄細{}",requestBody);
        HttpResponse execute = HttpUtil.createPost(OnlineTaskConstant.ONE_TASK_RESULT).contentType("application/json")
                .body(requestBody).execute();
        if (execute.isOk()){
            String returnResult = execute.body();
            TaskInfoApiResultDto taskInfoApiResultDto = JSON.parseObject(returnResult, TaskInfoApiResultDto.class);
            if (taskInfoApiResultDto.getCode()==200||taskInfoApiResultDto.getCode()==2005){
                return taskInfoApiResultDto.isSucc();
            }else {
                log.info("==========================鍥炰紶鍔炰欢瀹℃壒缁撴灉澶辫触=================");
                log.info("鍥炰紶鍔炰欢瀹℃壒缁撴灉澶辫触鍘熷洜锛歿}",getStatusText(taskInfoApiResultDto.getCode()));
                log.info("鍥炰紶鍔炰欢瀹℃壒缁撴灉澶辫触淇℃伅锛歿}",taskInfoApiResultDto.getMsg());
                return false;
            }
        }else{
            return false;
        }
    }

    /**
     * 鍙戦€佺粨鏋滅墿
     * @param
     * @return
     */
    public static boolean returnResultFile(String taskId, String attachName , File file,String specialResultFile ){
        log.info("=========================寮€濮嬭繑鍥炵粨鏋滅墿===========================");
        log.info("缁撴灉鐗﹖askId锛歿}",taskId);
        HttpResponse execute = HttpUtil.createPost(OnlineTaskConstant.ONE_TASK_RESULT_FILE).contentType("multipart/form-data;charset=UTF-8")
                .form("taskId",taskId)
                .form("attachName",attachName)
                .form("file",file)
                .form("specialResultFile",specialResultFile).execute();
        if (execute.isOk()){
            String returnResult = execute.body();
            log.info("鍙戦€佺粨鏋滅墿缁撴灉{}",returnResult);
            TaskInfoApiResultDto taskInfoApiResultDto = JSON.parseObject(returnResult, TaskInfoApiResultDto.class);
            if (taskInfoApiResultDto.getCode()==200){
                log.info("=========================缁撴灉鐗╄繑鍥炴垚鍔�===========================");
                return taskInfoApiResultDto.isSucc();
            }else {
                log.info("=========================缁撴灉鐗╄繑鍥炲け璐�===========================");
                return  false;
            }
        }else {
            log.info("=========================璇锋眰杩斿洖缁撴灉鐗╁け璐�===========================");
            return  false;
        }
    }



    /***
     *@Author duxiangyun
     *@Description   鏁版嵁瑙ｅ瘑
     *@Date 2024/8/28
     */
    public static String decrypt(String message) {
        try {
//            System.out.println("decrypt:" + message);
            log.info("============================寮€濮嬫暟鎹В瀵�================================");
            byte[] bytesrc = new BASE64Decoder().decodeBuffer(message);
            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
            SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
            IvParameterSpec iv = new IvParameterSpec(key1.getBytes("UTF-8"));
            cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
            byte[] retByte = cipher.doFinal(bytesrc);
            log.info("============================鏁版嵁瑙ｅ瘑瀹屾垚================================");
            return new String(retByte);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String convertStatus(String status) {
        switch (status){
            case "0":
                return "NG";
            case "1":
                return "OK";
            case "OK":
                return "閫氳繃";
            case "NG":
                return "閫€鍥�";
        }
        return status;
    }
    /**
     * @Description  涓€缃戦€氬姙骞冲彴鍝嶅簲鐮�
     * @param statusCode
     * @return
     */
    public static String  getStatusText(int statusCode) {
        switch (statusCode) {
            case 200:
                return "璇锋眰鎴愬姛";
            case 1001:
                return "缂哄皯璇锋眰鍙傛暟";
            case 1002:
                return "璇锋眰鍙傛暟瑙ｆ瀽寮傚父";
            case 1003:
                return "鍙傛暟鏍￠獙寮傚父";
            case 2002:
                return "鍔炰欢宸蹭笅鍙戯紝璇峰嬁閲嶅纭";
            case 2003:
                return "瀹℃壒杩囩▼涓俊鎭繚瀛樺け璐�";
            case 2004:
                return "瀹℃壒缁撴灉淇℃伅淇濆瓨澶辫触";
            case 2005:
                return "璇ュ姙浠跺凡鍔炵粨鎴栭€€鍥�";
            case 9999:
                return "绯荤粺寮傚父";
            default:
                return StrUtil.toString(statusCode);
        }
    }
    /***
     *@Author duxiangyun
     *@Description 缁忚惀鑼冨洿鏍煎紡鍖�
     *@Date 2024/9/21
     */
    public static   String  scopConvert(List&lt;String&gt; strings){
        String s = strings.toString()
                .replace(",",";")
                .replace("[","")
                .replace("]","")
                .replace(" ","")
                .replace("\"","");
        return s;
    }

    /***
     *@Author duxiangyun
     *@Description   鏀挎不闈㈣矊杞崲
     *@Date 2024/10/8
     */
    public static   String  identConvert(String s){
        switch (s){
            case "01":
                return "涓叡鍏氬憳";
            case "02":
                return "涓叡棰勫鍏氬憳";
            case "03":
                return "鍏遍潚鍥㈠憳";
            case "04":
                return "姘戦潻浼氬憳";
            case "05":
                return "姘戠洘鐩熷憳";
            case "06":
                return "鏄庡缓浼氬憳";
            case "07":
                return "姘戣繘浼氬憳";
            case "08":
                return "鍐滃伐鍏氬厷鍛�";
            case "09":
                return "鑷村叕鍏氬厷鍛�";
            case "10":
                return "涔濅笁瀛︾ぞ绀惧憳";
            case "11":
                return "鍙扮洘鐩熷憳";
            case "12":
                return "鏃犲厷娲炬皯涓讳汉澹�";
            case "13":
                return "缇や紬";
            default:
                return "鍏朵粬";
        }
    }
    /***
     *@Author duxiangyun
     *@Description   鏂囧寲绋嬪害杞崲
     *@Date 2024/10/8
     */
    public static   String  eduConvert(String s){
        switch (s){
            case "1":
                return "8";
            case "2":
                return "7";
            case "3":
                return "澶у鏈";
            case "4":
                return "5";
            case "6":
                return "4";
            case "8":
                return "3";
            case "9":
                return "2";
            case "10":
                return "1";
            default:
                return "鍏朵粬";
        }
    }

    /***
     *@Author duxiangyun
     *@Description   鑱屽姟
     *@Date 2024/10/8
     */
    public static   String  jobConvert(String s){
        switch (s){
            case "1":
                return "鎬荤粡鐞�";
            case "2":
                return "鍓€荤粡鐞�";
            case "3":
                return "娉曞畾浠ｈ〃浜�";
            case "4":
                return "娉曞畾浠ｈ〃浜哄吋鎬荤粡鐞�";
            default:
                return "鍏朵粬";
        }
    }
    /***
     *@Author duxiangyun
     *@Description   韬唤璇佺被鍨�
     *@Date 2024/10/8
     */
    public static   String  idCardTypeConvert(String s){
        switch (s){
            case "111":
                return "0";  //灞呮皯韬唤璇�
            case "113":
                return "0";   //鎴峰彛绨�
            default:
                return "鍏朵粬";
        }
    }

    /***
     *@Author duxiangyun
     *@Description   韬唤璇佺被鍨�
     *@Date 2024/10/8
     */
    public static   String  idCardType2Convert(String s){
        switch (s){
            case "111":
                return "1";  //灞呮皯韬唤璇�
            case "113":
                return "1";   //鎴峰彛绨�
            default:
                return "鍏朵粬";
        }
    }
    /**
     * 鏈嶅姟鑼冨洿鏍煎紡鍖�
     * @return
     */
    public static String strHandle(String data){
        StringBuffer stringBuffer =new StringBuffer();
        String[] split = data.split(";");
        List&lt;String&gt; strList = Arrays.asList(split);
        for (int i = 0; i &lt; strList.size(); i++) {
            switch (strList.get(i)){
                case "01":
                    stringBuffer.append("闂ㄥ崼锛�");
                    break;
                case "02":
                    stringBuffer.append("宸￠€伙紝");
                    break;
                case "03":
                    stringBuffer.append("瀹堟姢锛�");
                    break;
                case "04":
                    stringBuffer.append("鎶艰繍锛�");
                    break;
                case "05":
                    stringBuffer.append("闅忚韩鎶ゅ崼锛�");
                    break;
                case "06":
                    stringBuffer.append("瀹夊叏妫€鏌ワ紝");
                    break;
                case "08":
                    stringBuffer.append("瀹夊叏椋庨櫓璇勪及锛�");
                    break;
                case "09":
                    stringBuffer.append("瀹夊叏鎶€鏈槻鑼�,");
                    break;
                default:
                    stringBuffer.append("");
                    break;
            }

        }
        String str  =  stringBuffer.deleteCharAt(stringBuffer.length() - 1).toString();
        return str;
    }

    /**
     * xml 鏁版嵁澶勭悊
     */
    public static String  handleXml(Map&lt;String,String&gt;  stringMap  ){
//         List&lt;Map&lt;String ,String &gt;&gt; mapList  =new ArrayList&lt;&gt;();
//        Map&lt;String, String &gt; map = new HashMap&lt;&gt;();
//        map.put("XM", "椤圭洰");
//        map.put("BG", "鍙樻洿");
//        map.put("SJ", "鏃堕棿");
//        map.put("YZ", "鍗扮珷");
//        mapList.add(map);
        String  dataXml  =  "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n" +
                "&lt;license&gt;\n" +
                "    &lt;catalog catalogId=\"2fcd6fca68bf46709b5983151af86272\" catalogName=\"淇濆畨鏈嶅姟璁稿彲璇乗" templateId=\"43d6d300ff7741338489d24354df48ba\" templateName=\"淇濆畨鏈嶅姟璁稿彲璇佹ā鏉縗" version=\"2024V2.0\"/&gt;\n" +
                "    &lt;surface&gt;\n" +
                "        &lt;item alias=\"whose\" name=\"璇佺収褰掑睘\" require=\"1\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"holderCodeType\" code=\"certificateHolderTypeCode\" name=\"璇佷欢绫诲瀷\" require=\"1\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"issueUnitname\" catetype=\"0\" code=\"certificateIssuingAuthorityName\" name=\"棰佽瘉鍗曚綅\" require=\"1\" type=\"banzhengdanwei\" value=\"婀栧崡鐪佸叕瀹夊巺\"/&gt;\n" +
                "        &lt;item alias=\"licenseNumber\" catetype=\"0\" code=\"certificateNumber\" name=\"璇佺収缂栧彿\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"issueDate\" catetype=\"0\" code=\"certificateIssuedDate\" dateFormat=\"yyyy-MM-dd\" name=\"棰佽瘉鏃堕棿\" require=\"1\" type=\"riqi\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"validTimeBegin\" catetype=\"0\" code=\"certificateEffectiveDate\" dateFormat=\"yyyy-MM-dd\" name=\"鏈夋晥鏈燂紙璧峰锛塡" require=\"0\" type=\"riqi\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"holder\" catetype=\"0\" code=\"certificateHolderName\" name=\"鎸佽瘉鑰匼" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"validTimeEnd\" catetype=\"0\" code=\"certificateExpiringDate\" dateFormat=\"yyyy-MM-dd\" name=\"鏈夋晥鏈燂紙鎴锛塡" require=\"0\" type=\"riqi\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"holderCode\" catetype=\"0\" code=\"certificateHolderCode\" name=\"缁熶竴绀句細淇＄敤浠ｇ爜\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"ZS\" catetype=\"1\" code=\"KZ_ZS\" name=\"浣忔墍\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"FDDBR\" catetype=\"1\" code=\"KZ_FDDBR\" name=\"娉曞畾浠ｈ〃浜篭" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"FWFW\" catetype=\"1\" code=\"KZ_FWFW\" name=\"鏈嶅姟鑼冨洿\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"ZCZB\" catetype=\"1\" code=\"KZ_ZCZB\" name=\"娉ㄥ唽璧勬湰\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"PZWH\" catetype=\"1\" code=\"KZ_PZWH\" name=\"鎵瑰噯鏂囧彿\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"MJXM\" catetype=\"1\" code=\"KZ_MJXM\" name=\"姘戣濮撳悕\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"MJSFZHM\" catetype=\"1\" code=\"KZ_MJSFZHM\" name=\"姘戣韬唤璇佸彿鐮乗" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"MJJH\" catetype=\"1\" code=\"KZ_MJJH\" name=\"姘戣璀﹀彿\" require=\"0\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;item alias=\"YHID\" catetype=\"1\" code=\"KZ_YHID\" name=\"鐢ㄦ埛Id\" require=\"1\" type=\"string\" value=\"\"/&gt;\n" +
                "    &lt;/surface&gt;\n" +
                "    &lt;detail&gt;\n" +
                "        &lt;items sort=\"0\"&gt;\n" +
                "            &lt;item alias=\"XM\" code=\"KZ_XM\" name=\"椤圭洰\" require=\"1\" rowNo=\"0\" type=\"string\" value=\"\"/&gt;\n" +
                "            &lt;item alias=\"BG\" code=\"KZ_BG\" name=\"鍙樻洿\" require=\"1\" rowNo=\"0\" type=\"string\" value=\"\"/&gt;\n" +
                "            &lt;item alias=\"SJ\" code=\"KZ_SJ\" name=\"鏃堕棿\" require=\"1\" rowNo=\"0\" type=\"string\" value=\"\"/&gt;\n" +
                "            &lt;item alias=\"YZ\" code=\"KZ_YZ\" name=\"鍗扮珷\" require=\"1\" rowNo=\"0\" type=\"string\" value=\"\"/&gt;\n" +
                "        &lt;/items&gt;\n" +
                "    &lt;/detail&gt;\n" +
                "&lt;/license&gt;";
        Document document = null;
        try {
            document = DocumentHelper.parseText(dataXml);
            Element rootElement = document.getRootElement();
            Element surface = rootElement.element("surface");
            List&lt;Element&gt; itemElementList = surface.elements("item");
            itemElementList.get(0).attribute("value").setValue("0");  //0 浠ｈ〃娉曚汉韬唤璇佸彿
            itemElementList.get(1).attribute("value").setValue("001");
            itemElementList.get(2).attribute("value").setValue("婀栧崡鐪佸叕瀹夊巺");    //棰佽瘉鍗曚綅濉厖鍊�
            itemElementList.get(3).attribute("value").setValue(stringMap.get("licenseNumber").substring(4,11));       //璇佺収缂栧彿
            itemElementList.get(4).attribute("value").setValue(stringMap.get("issueDate"));
            itemElementList.get(5).attribute("value").setValue(stringMap.get("issueDate"));
            itemElementList.get(6).attribute("value").setValue(stringMap.get("holder"));
            itemElementList.get(7).attribute("value").setValue("2199-01-01 00:00:00");
            itemElementList.get(8).attribute("value").setValue(stringMap.get("holderCode"));
            itemElementList.get(9).attribute("value").setValue(stringMap.get("zs"));
            itemElementList.get(10).attribute("value").setValue(stringMap.get("fddbr"));
            itemElementList.get(11).attribute("value").setValue(stringMap.get("fwfw"));
            double v = Double.parseDouble(stringMap.get("zczb"));
            String zczb = NumberChineseFormatter.format(v,true,false);
            itemElementList.get(11).attribute("value").setValue(String.join("",zczb,"涓囧厓浜烘皯甯�"));
            itemElementList.get(12).attribute("value").setValue(stringMap.get("pzwh"));
            itemElementList.get(13).attribute("value").setValue("鏉滄箻浜�");
            itemElementList.get(14).attribute("value").setValue("430581200012137314");
            itemElementList.get(16).attribute("value").setValue("134132");

//            for (int i = 0; i &lt; mapList.size(); i++) {   娉曚汉鍙樻洿鏁版嵁琛ュ厖
//                Map&lt;String, String&gt; map1 = mapList.get(i);
//                Element detailElement = rootElement.element("detail");
//                Element items = detailElement.addElement("items").addAttribute("sort", String.valueOf(i));
//                items.addElement("item").addAttribute("alias","XM").addAttribute("code","KZ_XM")
//                        .addAttribute("name","椤圭洰").addAttribute("require","1").addAttribute("rowNo","0")
//                        .addAttribute("type","string").addAttribute("value",map1.get("XM"));
//                items.addElement("item").addAttribute("alias","BG").addAttribute("code","KZ_BG")
//                        .addAttribute("name","鍙樻洿").addAttribute("require","1").addAttribute("rowNo","0")
//                        .addAttribute("type","string").addAttribute("value",map1.get("BG"));
//                items.addElement("item").addAttribute("alias","SJ").addAttribute("code","KZ_SJ")
//                        .addAttribute("name","鏃堕棿").addAttribute("require","1").addAttribute("rowNo","0")
//                        .addAttribute("type","string").addAttribute("value",map1.get("SJ"));
//                items.addElement("item").addAttribute("alias","YZ").addAttribute("code","KZ_YZ")
//                        .addAttribute("name","鍗扮珷").addAttribute("require","1").addAttribute("rowNo","0")
//                        .addAttribute("type","string").addAttribute("value",map1.get("YZ"));
//
//            }
        } catch (DocumentException e) {
            e.printStackTrace();
        }
        return document.asXML();
    }
    /**
     * 鎻愪氦鐓ч潰淇℃伅鑷崇涓夋柟
     * unId  璇佺収鐨勫敮涓€鏍囪瘑锛岄噰鐢ㄨ瘉鐓х殑缂栧彿鐢ㄥ仛鍞竴鏍囪瘑锛�  鎴栬€呯敵璇锋暟鎹殑id  寰呭晢姒�
     */
    public static Map&lt;String,String&gt; xmlDataSend(String xmlData,String unId,String eCToken){
        Map&lt;String ,String &gt;  map   = new HashMap&lt;&gt;();
        String xmlDataSendUrl = "http://65.26.106.115:8003/license-api-release/m/v2/license/license_info/save";
        Map&lt;String ,Object&gt;  formDataMap= new  HashMap&lt;&gt;();
        formDataMap.put("access_token",eCToken);
        formDataMap.put("xml",xmlData);
        formDataMap.put("unid",unId);
        formDataMap.put("state","2");
        HttpResponse execute = HttpUtil.createPost(xmlDataSendUrl).header("Content-Type", "application/x-www-form-urlencoded")
                .form(formDataMap).execute();
        log.info("鎻愪氦鐓ч潰淇℃伅璇锋眰鍙傛暟{}", JSON.toJSONString(formDataMap));
        int status = execute.getStatus();
        log.error("鐓ч潰淇℃伅鎻愪氦璇锋眰鐘舵€佺爜锛歿}锛�",status);
        String responseBody = execute.body();
        if (status==200){
            JSONObject jsonObject = JSON.parseObject(responseBody);
            String head = jsonObject.getString("head");
            JSONObject jsonHead = JSON.parseObject(head);
            String headStatus = jsonHead.getString("status");
            log.error("鍝嶅簲浣撹繑鍥炵姸鎬佺爜{}",status,headStatus);
            log.error("鎻愪氦鐓ч潰淇℃伅杩斿洖鍊納}",responseBody);
            if(headStatus.equals("0")){    //濡傛灉鎶ラ敊浜嗗氨涓嶈淇濆瓨浜�
                String data = jsonObject.getString("data");
                JSONObject jsonData = JSON.parseObject(data);
                String fileNumber = jsonData.getString("fileNumber");
                String licenseId = jsonData.getString("licenseId");
                map.put("fileNumber",fileNumber);
                map.put("licenseId",licenseId);
            }
        }
        return map ;
    }

    public static int  updateXmlDataSend(String eCToken,String licenseId,String xmlData,String unId){
        Map&lt;String ,String &gt;  map   = new HashMap&lt;&gt;();
        String updateXmlDataSendUrl = "http://65.26.106.115:8003/license-api-release/m/v2/license/change";
        Map&lt;String ,Object&gt;  formDataMap= new  HashMap&lt;&gt;();
        formDataMap.put("access_token",eCToken);
        formDataMap.put("licenseId",licenseId);
        formDataMap.put("xml",xmlData);
        formDataMap.put("unid",unId);
        formDataMap.put("state","2");  // 2 涓鸿嚜鍔ㄧ绔� 1涓烘墜鍔ㄧ绔�
        HttpResponse execute = HttpUtil.createPost(updateXmlDataSendUrl).header("Content-Type", "application/x-www-form-urlencoded")
                .form(formDataMap).execute();
        log.info("鎻愪氦鐓ч潰淇℃伅璇锋眰鍙傛暟{}", JSON.toJSONString(formDataMap));
        log.info("娉曚汉鍙樻洿浜屾鎻愪氦鍙樻洿鍝嶅簲浣搟}",execute.body());
        if (execute.isOk()){
            Map&lt;String,Object&gt; objectMap= JSON.parseObject(execute.body(),Map.class);
            String jsonString = JSON.toJSONString(objectMap.get("head"));
            Map&lt;String,Object&gt; headMap= JSON.parseObject(jsonString,Map.class);
            int status =  (Integer)headMap.get("status");
            log.info("鍙樻洿鐢靛瓙璇佺収鏁版嵁璋冪敤缁撴灉:message{},鐘舵€亄}",status);
            return status;
        }else {
            log.info("鍙樻洿鐢靛瓙璇佺収鏁版嵁璋冪敤澶辫触");
            return -1;
        }
    }

    //鑾峰彇璇佺収鐨刡ase64缂栫爜
    public static String getFileRequest(String  fileNumber){
        String  url  = "http://65.26.106.115:8003/license-api-release/license/national/downloadfile";
        Map&lt;String ,Map&lt;String,String&gt;&gt;  requestMap =  new  HashMap&lt;&gt;();
        Map&lt;String,String&gt;  dataMap = new HashMap&lt;&gt;();
        dataMap.put("certificateIdentifier",fileNumber);
        requestMap.put("head",new HashMap&lt;&gt;());
        requestMap.put("data",dataMap);
        String requestJson = JSON.toJSONString(requestMap);
        String fileStr ="";
        HttpResponse response = HttpUtil.createPost(url).body(requestJson).execute();
        String responseBody = response.body();
        //瑙ｆ瀽鍝嶅簲浣�
        Map&lt;String,Map&lt;String,Object&gt;&gt; responseMap = JSON.parseObject(responseBody, Map.class);
        Map&lt;String, Object&gt; head = responseMap.get("head");
        String status = head.get("status").toString();
        if (status.equals("0")){  //鐘舵€佷负0 璇存槑鏂囦欢宸茬粡鐩栫珷瀹屾垚 銆佷负鍏跺畠鍊艰鏄庢枃浠惰繕娌＄敓鎴愩€�
            Map&lt;String, Object&gt; data = responseMap.get("data");
            fileStr = data.get("content").toString();
        }
        return  fileStr;
    }

    public static String removeTrailingZeros(String number) {
        // 浣跨敤姝ｅ垯琛ㄨ揪寮忓幓闄ゅ皬鏁扮偣鍚庣殑鏃犳晥闆�
        return number.replaceAll("0+(?=[^\\.]*\\.)", "");
    }
}
</pre></body></html>