| 
					
				 | 
			
			
				@@ -21,11 +21,20 @@ import com.ym.mec.util.http.HttpUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Value("${push.jiguang.appKey:0e7422e1d6e73637e678716a}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private String appKey = "7e0282ca92c12c8c45a93bb3"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Value("${push.jiguang.appKey.student}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String studentAppKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Value("${push.jiguang.masterSecret.student}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String studentMasterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Value("${push.jiguang.masterSecret:c2361016604eab56ab2db2ac}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private String masterSecret = "d47430e2f4755ef5dc050ac5"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Value("${push.jiguang.appKey.teacher}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String teacherAppKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Value("${push.jiguang.masterSecret.teacher}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String teacherMasterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Value("${push.jiguang.appKey.system}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String systemAppKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	@Value("${push.jiguang.masterSecret.system}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String systemMasterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Value("${push.jiguang.apns_production:false}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	private boolean apns_production = true; // 推送环境 True 表示推送生产环境,False 表示要推送开发环境 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -105,8 +114,19 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param alert 推送消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param content 推送内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	private String push(String[] alias, String alert, String content, String url) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		String base64_auth_string = encryptBASE64(this.appKey + ":" + this.masterSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	private String push(String[] alias, String alert, String content, String url,String type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		String base64_auth_string = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		switch (type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case "STUDENT": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				base64_auth_string = encryptBASE64(this.studentAppKey + ":" + this.studentMasterSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			case "TEACHER": 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				base64_auth_string = encryptBASE64(this.teacherAppKey + ":" + this.teacherMasterSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				base64_auth_string = encryptBASE64(this.systemAppKey + ":" + this.systemMasterSecret); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String authorization = "Basic " + base64_auth_string; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return sendPostRequest(generateJson(alias, alert, content, url).toString(), authorization); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -142,7 +162,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void afterPropertiesSet() throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 参数检查 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if (StringUtils.isBlank(appKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		/*if (StringUtils.isBlank(appKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new RuntimeException("Init parameter [appKey] can not blank"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (StringUtils.isBlank(masterSecret)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -150,13 +170,13 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (StringUtils.isBlank(reqURL)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			throw new RuntimeException("Init parameter [reqURL] can not blank"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		}*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public boolean send(String subject, String content, String receiver, String url) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public boolean send(String subject, String content, String receiver, String url, String type) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String[] alias = { receiver }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		String result = this.push(alias, subject, content, url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		String result = this.push(alias, subject, content, url,type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		JSONObject json = JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (json.containsKey("error")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			JSONObject jsonObject = json.getJSONObject("error"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -166,8 +186,8 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public boolean batchSend(String subject, String content, String[] receivers, String url) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		String result = this.push(receivers, subject, content, url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public boolean batchSend(String subject, String content, String[] receivers, String url, String type) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		String result = this.push(receivers, subject, content, url,type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		JSONObject json = JSONObject.parseObject(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		if (json.containsKey("error")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			JSONObject jsonObject = json.getJSONObject("error"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -176,12 +196,28 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public void setAppKey(String appKey) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		this.appKey = appKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setStudentAppKey(String studentAppKey) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.studentAppKey = studentAppKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setStudentMasterSecret(String studentMasterSecret) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.studentMasterSecret = studentMasterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setTeacherAppKey(String teacherAppKey) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.teacherAppKey = teacherAppKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setTeacherMasterSecret(String teacherMasterSecret) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.teacherMasterSecret = teacherMasterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public void setMasterSecret(String masterSecret) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		this.masterSecret = masterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setSystemAppKey(String systemAppKey) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.systemAppKey = systemAppKey; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public void setSystemMasterSecret(String systemMasterSecret) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		this.systemMasterSecret = systemMasterSecret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	public void setApns_production(boolean apns_production) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -196,7 +232,7 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		this.reqURL = reqURL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public static void main(String[] args) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	/*public static void main(String[] args) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		String str = "2094588"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -204,6 +240,6 @@ public class JiguangPushPlugin implements MessageSenderPlugin, InitializingBean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		JiguangPushPlugin plugin = new JiguangPushPlugin(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		plugin.batchSend("基础技能训练报名通知", "家长您好:经五路小学比赛团乐团基础技能训练已经开始缴费。请您在收到本通知后,点击http://mstuonline.dayaedu.com/#/smallRegister?musicGroupId=19121912014300001 进行缴费,若有疑问请咨询800-8208820", str.split(","), "5?http://mstudev.dayaedu.com/#/smallRegister?musicGroupId=19121912014300001"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	}*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |