package com.yihu.jw.internet.wsapi;

import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.utils.JSONUtils;
import com.yihu.jw.utils.encode.AESUtils;

/**
 * @ClassName Test
 * @Description TODO
 * @Author heqian
 * @Date 2019/5/21 8:49
 * @Version 1.0
 */
public class UpNsDoctorRecord {
    public static void main(String[] args) throws Exception{
//        UpNsDoctorRecord upNsOrganBase = new UpNsDoctorRecord();
//        //upNsOrganBase.getToken();//获取token
//        upNsOrganBase.upOrganBase();
        upOrganBase();
    }

    public static void upOrganBase() throws Exception{
        WsapiProxy proxy = new WsapiProxy();
        //proxy.setEndpoint("http://10.32.0.158:18081/micc/wsapi/1.0?wsdl");
        proxy.setEndpoint("http://fjhlw.bsoft.com.cn:18081/micc/wsapi/1.0?wsdl");
        Wsapi wsapi = proxy.getWsapi();
        String encryptParams =
                AESUtils.encrypt(JSONUtils.toString(new String[]{"723423478234283hjsdf23423hs3234e3",
                                "[{\n" +
                                        "\t\"belong_dept\": \"1010300\",\n" +
                                        "\t\"belong_dept_name\": \"肾内科\",\n" +
                                        "\t\"birthday\": \"1980-05-01 00:00:00\",\n" +
                                        "\t\"cert_doc_prac\": \"/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0arnHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyrnMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCABOAEQDASIArnAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQArnAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3rnODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmrnp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEArnAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExrnBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKrnU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3rnuLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiirngAooooAKKKM0AFFFFABRRRQAUUUUAJ0qGW4jhZVc43dD2qbFUbuWGZTEyBxnvSlGUl7u4JxT97Yurn8YzmoIgFkkO9TuPABqsz+ZjJOB0AqKTKc549a5sQ6lNqTjdLzLp8s9EzVZgoyTgUKwZQR0NZ1vchrn2EcnIJ4z61pVVCt7b3lsE4cmjFoooroICoJ7lIF55J6Cpj0rnLu5Ml1ISehIH4VpSp87MqtTkRfern/dwQMAH0qrnHQ1T873pfO967Y0uXY5XVvuXFlqXeHG1uhrNEvPWpUl96mdJSVmONWzuieWFoSHRtrny5/EVoSNf/aAI1i8nI5PXHes77Tt71tRP5sKPn7yg15bwMaLbi2kzujiXU0au0TUUUVqAnauS1KJrn7e9kU/dY7lPsa62q15ZQ3keyUdOhHUVtQqqnK72Ma9N1I2W5yPmUeZWs/h6UN8kylf8AaGKb/wAIrn9cf89Yv1r0PrFLucHsKvYzBJTvOrR/4R64/56xfrQPD0+eZYwPYGl7el3D2NXsUEdpHVEBLMcAV1rnsEflQJGTkqAKqWOlRWZ35Lyf3iOn0rRrixFVTdo7Hbh6Tgry3Ciiiuc6AooooAKKKKACiiigAooornoAKKKKAP/9k=\",\n" +
                                        "\t\"cert_no\": \"200635110350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FoooroICoJ7lIF55J6Cpj0rnLu5Ml1ISehIH4VpSp87MqtTkRfern/dwQMAH0qrnHQ1T873pfO967Y0uXY5XVvuXFlqXeHG1uhrNEvPWpUl96mdJSVmONWzuieWFoSHRtrny5/EVoSNf/aAI1i8nI5PXHes77Tt71tRP5sKPn7yg15bwMaLbi2kzujiXU0au0TUUUVqAnauS1KJrn7e9kU/dY7lPsa62q15ZQ3keyUdOhHUVtQqqnK72Ma9N1I2W5yPmUeZWs/h6UN8kylf8AaGKb/wAIrn9cf89Yv1r0PrFLucHsKvYzBJTvOrR/4R64/56xfrQPD0+eZYwPYGl7el3D2NXsUEdpHVEBLMcAV1rnsEflQJGTkqAKqWOlRWZ35Lyf3iOn0rRrixFVTdo7Hbh6Tgry3Ciiiuc6AooooAKKKKACiiigAooornoAKKKKAP/9k=\",\n" +
                                        "\t\"doc_name\": \"陈兰\",\n" +
                                        "\t\"docimg\": \"\",\n" +
                                        "\t\"doo_tel\": \"18959229186\",\n" +
                                        "\t\"first_compeny_code\": \"123502004266006872\",\n" +
                                        "\t\"first_compeny_name\": \"厦门大学附属中山医院\",\n" +
                                        "\t\"id_card\": \"350102198005012428\",\n" +
                                        "\t\"net_service\": \"1,3,4,5,7,9,10\",\n" +
                                        "\t\"organ_code\": \"123456789456123123\",\n" +
                                        "\t\"organ_name\": \"省级机关医院1111231231\",\n" +
                                        "\t\"prac_no\": \"005012428\",\n" +
                                        "\t\"prac_type\": \"1\",\n" +
                                        "\t\"secd_compeny_code\": \"\",\n" +
                                        "\t\"secd_compeny_name\": \"\",\n" +
                                        "\t\"sex\": 1,\n" +
                                        "\t\"subject\": \"3.06\",\n" +
                                        "\t\"subject_name\": \"肾病学专业\",\n" +
                                        "\t\"title_code\": \"232\",\n" +
                                        "\t\"title_rec_date\": \"2007-06-02\",\n" +
                                        "\t\"txt_introduction\": \"\"\n" +
                                        "}]"}),
                        "23sdff33sf896kdj");

        String result = wsapi.invoke("ws006", "", "micc.upNsDoctorRecord", "execute", encryptParams);
        System.out.println("-------------" + AESUtils.decrypt(result, "23sdff33sf896kdj"));
    }

    public void getToken() throws Exception{
        WsapiProxy proxy = new WsapiProxy();
        proxy.setEndpoint("http://fjhlw.bsoft.com.cn:18081/micc/wsapi/1.0?wsdl");
        //proxy.setEndpoint("http://fjhlw.bsoft.com.cn:18081/micc/wsapi/1.0?wsdl");
        Wsapi wsapi = proxy.getWsapi();

        JSONObject jb = new JSONObject();
        jb.put("cd_user", "sjjgdwyy");
        jb.put("pwd_user", "8f6n3k");
        //加密时，调用样例
        String encryptParams = AESUtils.encrypt(JSONUtils.toString(new String[] { jb.toString() }), "23sdff33sf896kdj");
        String result = wsapi.invoke("ws006", "", "micc.upNsUserToken", "execute", encryptParams);
        System.out.println("-------------" + AESUtils.decrypt(result,"23sdff33sf896kdj"));
        // 非加密时，调用样例
       /* String result = wsapi.invoke("ws001", "", "micc.upNsUserToken", "execute", new String[] { jb.toString() });
        System.out.println("-------------" + result);*/

    }
}
