package test.com.philisense.www.controller.http.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.philisense.www.core.text.Convert;
import com.philisense.www.utils.StringUtils;
import com.philisense.www.utils.des.RegistCodeCript;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;


import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import test.base.HttpUtilsForm;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.philisense.www.common.config.CommonConst;

import java.nio.file.Files;
import java.nio.file.Paths;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.ResponseEntity;

public class TestProOrgControllerWithHttpClientForWeb  {




            @BeforeEach
            public void setUpTestDataWithinTransaction() {

            // set up test data within the transaction

            }

            @AfterEach
            public void tearDownWithinTransaction() {

            // execute "tear down" logic within the transaction

            }

            @Test
            @Disabled
            public void testProOrgDeleteByPrimaryKeyForWeb(){
                String id = UUID.randomUUID().toString().replaceAll("-","");
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/delete?recordid="+id;
            	String charset = HttpUtilsForm.UTF8;
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doGet(url, charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }

            @Test
            @Disabled
            public void testProOrgSelectByPrimaryKeyForWeb(){
                String id = UUID.randomUUID().toString().replaceAll("-","");
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/get?recordid="+id;
            	String charset = HttpUtilsForm.UTF8;
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doGet(url, charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }

            @Test
            @Disabled
            public void testProOrgInsertForWeb(){
            	
            	Map<String, Object> headerMap = new HashMap<String, Object>();
            	
            	headerMap.put("Content-Type", "application/json");
            	
            	
            	
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/insert";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                }               
                
            }

            @Test
            @Disabled
            public void testProOrgUpdateForWeb(){
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/update";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }

            @Test
            @Disabled
            public void testProOrgDeleteByMapForWeb(){
	        	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/deleteByMap";
	        	String charset = HttpUtilsForm.UTF8;
	        	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
	            try {
	                //括号里的是前台发送的url连接
	                String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
	                System.out.println(body);                                                       
	            } catch (Exception e) {
	                e.printStackTrace();
	            } 
                
            }

            @Test
            @Disabled
            public void testProOrgUpdateByMapForWeb(){
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/updateByMap";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }


            @Test
            @Disabled
            public void testProOrgGetOneForWeb(){
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/getOne";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }


            @Test
            @Disabled
            public void testProOrgGetAllForWeb(){
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/getAll";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }

            @Test
            @Disabled
            public void testProOrgCountForWeb(){
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/count";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }


            @Test
            @Disabled
            public void testProOrgQueryPageForWeb(){
            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/queryPage";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> params = new HashMap<String, Object>();
                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }

            @Test
            @Disabled
            public void testProOrgInsertBatchForWeb(){

                List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();


                Map<String, Object> params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式



                list.add(params);


                params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


                params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


               	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/insertBatch";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> paramsbody = new HashMap<String, Object>();
                //设置 请求参数
            	paramsbody.put("list",list);//用户Id
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Test
            @Disabled
            public void testProOrgDeleteBatchForWeb(){

                List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();


                Map<String, Object> params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


                params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


                params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式

                list.add(params);


            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/deleteBatch";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> paramsbody = new HashMap<String, Object>();
                //设置 请求参数
            	paramsbody.put("list",list);//用户Id
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }

            @Test
            @Disabled
            public void testProOrgUpdateBatchForWeb(){

                List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();


                Map<String, Object> params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


                params = new HashMap<String, Object>();


                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


                params = new HashMap<String, Object>();

                //设置 请求参数
                params.put("org_id","org_id");//机构Id
                params.put("org_name","org_name");//机构名称
                params.put("org_code","org_code");//机构code
                params.put("parentid","parentid");//父机构Id
                params.put("levelcode","levelcode");//层次码
                params.put("leaf","leaf");//是否叶子
                params.put("icon","icon");//图标
                params.put("cls","cls");//层叠样式


                list.add(params);


            	String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/updateBatch";
            	String charset = HttpUtilsForm.UTF8;
            	Map<String, Object> paramsbody = new HashMap<String, Object>();
                //设置 请求参数
            	paramsbody.put("list",list);//用户Id
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(params), charset);
                    System.out.println(body);                                                       
                } catch (Exception e) {
                    e.printStackTrace();
                } 
            }


            @Test
            @Disabled
            public void testexportForProOrgForWeb() throws IOException {
                    /*
                    // 待下载的文件地址
                    String url = CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/export";
                    ResponseEntity<byte[]> rsp = template.getForEntity(url, byte[].class);
                    System.out.println("文件下载请求结果状态码：" + rsp.getStatusCode());

                    String filename = "客户用户表";
                    // 将下载下来的文件内容保存到本地
                    String targetPath = "path_xxx/"+filename+"_ProOrg.xlsx";
                    Files.write(Paths.get(targetPath), Objects.requireNonNull(rsp.getBody(),
                    "未获取到下载文件"));
                    */
            }

            @Test
            @Disabled
            public void testexportTemplateForProOrgForWeb() throws IOException {
                    /*
            	    // 待下载的文件地址
                    String url = CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/exportTemplate";
                    ResponseEntity<byte[]> rsp = template.getForEntity(url, byte[].class);
                    System.out.println("文件下载请求结果状态码：" + rsp.getStatusCode());

                    // 将下载下来的文件内容保存到本地
                    String filename = "客户用户表";
                    // 将下载下来的文件内容保存到本地
                    String targetPath = "path_xxx/"+filename+"_ProOrg.xlsx";
                    Files.write(Paths.get(targetPath), Objects.requireNonNull(rsp.getBody(),
                    "未获取到下载文件"));
                    */
            }

            @Test
            @Disabled
            public void testimportExcelForProOrgForWeb()  {
                /*
            	// 文件上传服务上传接口
                String url = CommonConst.WEB_REST_SERVICE_PREFICX+"proorg/importExcel";
                // 待上传的文件（存在客户端本地磁盘）
                String filename = "客户用户表";
                // 将下载下来的文件内容保存到本地
                String targetPath = "path_xxx/"+filename+"_ProOrg.xlsx";
                // 封装请求参数
                FileSystemResource resource = new FileSystemResource(new File(targetPath));
                MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
                param.add("file", resource);  //服务端MultipartFile uploadFile
                //param.add("param1", "test");   //服务端如果接受额外参数，可以传递


                // 发送请求并输出结果
                System.out.println("--- 开始上传文件 ---");
                String result = template.postForObject(url, param, String.class);
                System.out.println("--- 访问地址：" + result);
                */
            }

    @Test
    public void testSyncProOrgInsertBatchForWeb(){
        try {
            /*
             部门sql: SELECT DISTINCT d.DEPTID, DEPARTMENTNAME, PARENTID FROM SYSDEPARTMENT d WHERE ENABEL_FLAG = 'T'
             结果：
             [
                {
                    "DEPTID": "001007005008",
                    ......
                }
             ]
             父节点sql: SELECT DISTINCT PARENTID FROM SYSDEPARTMENT
             结果：
             [
                "001007"
             ]
            */
            File file = new File("E:\\tmp\\nksyncdata\\dept-20230104.json");
            File deptFidFile = new File("E:\\tmp\\nksyncdata\\deptp-20230104.json");

            String jsonStr = readerMethod(file);
            String deptFidJsonStr = readerMethod(deptFidFile);
            List<String> deptfids = new ArrayList<>();
            if(StringUtils.isNotEmpty(deptFidJsonStr)) {
                deptfids = JSONArray.parseObject(deptFidJsonStr, List.class);
            }
            if(StringUtils.isNotEmpty(jsonStr)) {
                List<JSONObject> orgList = JSONArray.parseObject(jsonStr, List.class);
                List<Map<String, Object>> list = new ArrayList<>();
                for (JSONObject org : orgList) {
                    if("001".equals(org.getString("DEPTID"))) {
                        continue;
                    }
                    Map<String, Object> params = new HashMap<>();
                    params.put("org_id", org.getString("DEPTID"));//机构Id
                    params.put("org_name", org.getString("DEPARTMENTNAME"));//机构名称
                    params.put("org_code", org.getString("DEPTID"));//机构code
                    params.put("parentid", "001".equals(org.getString("PARENTID")) ? "000000000000" : org.getString("PARENTID"));//父机构Id
                    String deptid = Convert.toStr(org.getString("DEPTID"), "");
                    String levelcode = "";
                    if(StringUtils.isNotEmpty(deptid)) {
                        int count = (deptid.length() / 3) + 1;
                        StringBuilder sb = new StringBuilder();
                        for (int j = 1; j < count; j++) {
                            String substring = deptid.substring(0, j * 3);
                            sb.append("001".equals(substring) ? "000000000000" : substring).append("/");
                        }
                        levelcode = StringUtils.isNotEmpty(sb.toString()) ? sb.toString().substring(0, sb.toString().length() - 1) : "";
                    }
                    params.put("levelcode", levelcode);//层次码
                    params.put("leaf", deptfids.contains(org.getString("DEPTID")) ? "0" : "1");//是否叶子
                    params.put("icon", null);//图标
                    params.put("cls", null);//层叠样式

                    readerLocalFile(params);
//                    list.add(params);
                }
                /*System.out.println(list);
                String url = HttpUtilsForm.WebconnectURL+CommonConst.WEB_REST_SERVICE_PREFICX+"prouser/insertBatch";
                String charset = HttpUtilsForm.UTF8;
                Map<String, Object> paramsbody = new HashMap<String, Object>();
                //设置 请求参数
                paramsbody.put("list",list);//用户Id
                try {
                    //括号里的是前台发送的url连接
                    String body = HttpUtilsForm.doPost(url, JSON.toJSONString(list), charset);
                    System.out.println(body);
                } catch (Exception e) {
                    e.printStackTrace();
                }*/
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static String readerMethod(File file) throws IOException {
        FileReader fileReader = new FileReader(file);
        Reader reader = new InputStreamReader(new FileInputStream(file), "Utf-8");
        int ch = 0;
        StringBuffer sb = new StringBuffer();
        while ((ch = reader.read()) != -1) {
            sb.append((char) ch);
        }
        fileReader.close();
        reader.close();
        String jsonStr = sb.toString();
        return jsonStr;
    }

    private static void readerLocalFile(Map<String, Object> map) throws Exception {
        boolean mapflag = false;
        StringBuilder keySb = new StringBuilder("INSERT INTO `pro_org` (");
        StringBuilder valueSb = new StringBuilder(" VALUES (");
        for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
            if(null != stringObjectEntry.getValue()) {
                keySb.append("`").append(stringObjectEntry.getKey()).append("`, ");
                valueSb.append("'").append(stringObjectEntry.getValue()).append("', ");
                mapflag = true;
            }
        }
        if(mapflag) {
            String keyStr = keySb.toString().substring(0, keySb.toString().length() - 2) + ")";
            String valueStr = valueSb.toString().substring(0, valueSb.toString().length() - 2) + ")";
            String sqls = keyStr + valueStr + ";";
            StringToSql(sqls,  "E:\\tmp\\proorg-20230104.sql");
        }
    }

    /**
     * 将生成等String字符串 写进sql文件
     *
     * @param str  String字符串
     * @param path sql文件路径路径
     */
    public static void StringToSql(String str, String path) {
        System.out.println(str);
        byte[] sourceByte = str.getBytes();
        BufferedWriter out = null;
        if (null != sourceByte) {
            try {
                //文件路径（路径+文件名）
                File file = new File(path);
                //文件不存在则创建文件，先创建目录
                if (!file.exists()) {
                    File dir = new File(file.getParent());
                    dir.mkdirs();
                    file.createNewFile();
                }
                out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
                out.write(str + "\r\n");
                System.out.println("生成成功!!");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                // 关闭文件输出流
                try {
                    if (out != null) {
                        out.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
