JoypcSdkTools.java 3.13 KB
Newer Older
wang-jinfeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
package mobvista.dmp.datasource.joypac;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import org.apache.hadoop.hive.ql.exec.UDF;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import sun.misc.BASE64Decoder;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 刘凯 2018-01-18 16:20 adn_sdk 工具类
 */
public class JoypcSdkTools extends UDF implements Serializable{
	public static void mainss(String[] args) {
		// TODO Auto-generated method stub
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String password ="";
		try{
		password = buf.readLine();
		JSONObject json=getEtlJSON(password);
		System.out.println(json.toString());
		System.out.println(json.get("apps_info"));
		
		String business_name = json.getString("business_name");
		System.out.println(business_name);
        String business_pass = json.getString("business_pass");
        System.out.println(business_pass);
		boolean   result = business_name.equals("joypac_ios") && business_pass.equals("joypac_ios-sdk0121");
		System.out.println(result);
		}catch(IOException e)

		
		{

		System.out.println(e);

		System.exit(0);

		}
	}
	
	/**
	 * 
	 * @param log
	 * @return
	 */
	public static JSONObject getEtlJSON(String log) {
		String id = "";
		String idfa = "";
		String app_version = "";
		String brand = "";
		String network_type = "";
		String package_name = "";
		String platform = "";
		String language = "";
		String business_name = "";
		String apps_info = "";
		String business_pass = "";
		String os_version = "";
		String app_version_code = "";
		String model = "";
		String time_zone = "";
		String time = "";
			JSONObject json = null;
			try {
				json = JSON.parseObject(log);
			} catch (Exception e) {
				e.printStackTrace();
				json=new JSONObject();
			}
			
			if(json.get("id")==null){
				json.put("id", "");
			}
			
			if(json.get("idfa")==null){
				json.put("idfa", "");
			}
			
			if(json.get("app_version")==null){
				json.put("app_version", "");
			}
			
			if(json.get("brand")==null){
				json.put("brand", "");
			}
			if(json.get("network_type")==null){
				json.put("network_type", "");
			}
			if(json.get("package_name")==null){
				json.put("package_name", "");
			}
			if(json.get("platform")==null){
				json.put("platform", "");
			}
			if(json.get("language")==null){
				json.put("language", "");
			}
			if(json.get("business_name")==null){
				json.put("business_name", "");
			}
			if(json.get("business_pass")==null){
				json.put("business_pass", "");
			}
			
			if(json.get("apps_info")==null){
				json.put("apps_info", "");
			}
			
			if(json.get("os_version")==null){
				json.put("os_version", "");
			}
			if(json.get("app_version_code")==null){
				json.put("app_version_code", "");
			}
			if(json.get("model")==null){
				json.put("model", "");
			}
			if(json.get("time_zone")==null){
				json.put("time_zone", "");
			}
			if(json.get("time")==null){
				json.put("time", "");
			}
		return json;
	}

}