|  | @ -22,6 +22,7 @@ import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Value;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
	
		
			
				|  | @ -58,8 +59,8 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |     private BaseDoctorDao baseDoctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao basePatientDao;
 | 
	
		
			
				|  |  |     @Value("${server.server_url}")
 | 
	
		
			
				|  |  |     private String server_url;
 | 
	
		
			
				|  |  |     @Value("${tnzyy.tnzyy_url}")
 | 
	
		
			
				|  |  |     private String tnzyy_url;
 | 
	
		
			
				|  |  |     //发送微信模板消息
 | 
	
		
			
				|  |  |     private  String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -153,9 +154,24 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //推送模板消息
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param wechatId
 | 
	
		
			
				|  |  |      * @param templateName
 | 
	
		
			
				|  |  |      * @param scene
 | 
	
		
			
				|  |  |      * @param openId
 | 
	
		
			
				|  |  |      * @param first
 | 
	
		
			
				|  |  |      * @param url 跳转链接
 | 
	
		
			
				|  |  |      * @param remark
 | 
	
		
			
				|  |  |      * @param type  模板通知类型
 | 
	
		
			
				|  |  |      * @param josn 用于对跳转连接的修改,
 | 
	
		
			
				|  |  |      * @param keywords
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first,String url, String remark, Integer type,JSONObject josn,String ...keywords) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             System.out.println(wechatId);
 | 
	
		
			
				|  |  |             wxAccessTokenService.getWxAccessTokenById(wechatId);
 | 
	
		
			
				|  |  |             List<WxAccessTokenDO> list = wxAccessTokenDao.getWxAccessTokenById(wechatId);
 | 
	
		
			
				|  |  |             if(list.size()==0){
 | 
	
		
			
				|  |  |                 return;
 | 
	
	
		
			
				|  | @ -166,7 +182,9 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |                 logger.info("wx_access_token表获取为空,wechatId" + wechatId);
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             WxTemplateConfigDO newConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
 | 
	
		
			
				|  |  |             WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
 | 
	
		
			
				|  |  |             WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
 | 
	
		
			
				|  |  |             BeanUtils.copyProperties(templateConfig,newConfig);
 | 
	
		
			
				|  |  |             if (newConfig == null) {
 | 
	
		
			
				|  |  |                 logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
 | 
	
		
			
				|  |  |                 return;
 | 
	
	
		
			
				|  | @ -176,7 +194,7 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |                 newConfig.setFirst(first);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(url)){
 | 
	
		
			
				|  |  |                 newConfig.setUrl(url);
 | 
	
		
			
				|  |  |                newConfig.setUrl(url);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(remark)){
 | 
	
		
			
				|  |  |                 newConfig.setRemark(remark);
 | 
	
	
		
			
				|  | @ -190,32 +208,32 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (keyLength >= 2) {
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(keywords[1])){
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(keywords[1]);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword2(keywords[1]);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (keyLength >= 3) {
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(keywords[2])){
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(keywords[2]);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3(keywords[2]);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (keyLength >= 4) {
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(keywords[3])){
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(keywords[3]);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword4(keywords[3]);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (keyLength >= 5) {
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(keywords[4])){
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(keywords[4]);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword5(keywords[4]);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (keyLength >= 6) {
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(keywords[5])){
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(keywords[5]);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword6(keywords[5]);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (keyLength >= 7) {
 | 
	
		
			
				|  |  |                 if(StringUtils.isNoneBlank(keywords[6])){
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1(keywords[6]);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword7(keywords[6]);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //发起微信消息模板推送
 | 
	
	
		
			
				|  | @ -228,7 +246,10 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public WxTemplateConfigDO setTemPlateUrl(WxTemplateConfigDO wxTemplateConfigDO,Integer type,String openid,JSONObject json){
 | 
	
		
			
				|  |  |         String url = server_url + "wx/html/";
 | 
	
		
			
				|  |  |         String url = tnzyy_url + "taian-wx/html/";
 | 
	
		
			
				|  |  |         if (json==null){
 | 
	
		
			
				|  |  |             return wxTemplateConfigDO;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (type==30){//反馈通知 测试 TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
 | 
	
		
			
				|  |  |             if(json.containsKey("consult")) {
 | 
	
		
			
				|  |  |                 wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&consult=" + json.getString("consult"));
 | 
	
	
		
			
				|  | @ -240,17 +261,17 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |                 wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?resultCode=" + json.getString("resultCode"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (type==31){ //上门服务医生评分   //TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
 | 
	
		
			
				|  |  |         if (type==31){ //上门服务医生评分   //
 | 
	
		
			
				|  |  |             wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&id=" + json.getString("id")+ "&finish=" + json.getString("finish"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(type==32){  //TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
 | 
	
		
			
				|  |  |             String url1 = server_url + "wx/common/";
 | 
	
		
			
				|  |  |         if(type==32){  //
 | 
	
		
			
				|  |  |             String url1 = tnzyy_url + "wx/common/";
 | 
	
		
			
				|  |  |             wxTemplateConfigDO.setUrl(url1 + wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&consult=" + json.getString("consult") + "&status=" + json.getInteger("status"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(type==34){ //TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
 | 
	
		
			
				|  |  |             wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&orderId=" + json.get("orderId")+ "&authorizeImage=" + json.getString("authorizeImage"));
 | 
	
		
			
				|  |  |         if(type==34){ //居民授权电子健康卡
 | 
	
		
			
				|  |  |             wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&orderId=" + json.getString("orderId")+ "&authorizeImage=" + json.getString("authorizeImage"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (type==19){  //zSR9w5AjfZFLc_g8AxGBvDKZASoKAeXQuGnvPAQzvps
 | 
	
		
			
				|  |  |         if (type==19){  //
 | 
	
		
			
				|  |  |             String urlStr= wxTemplateConfigDO.getUrl();
 | 
	
		
			
				|  |  |             boolean status = urlStr.contains("openid=");
 | 
	
		
			
				|  |  |             if(!status){
 | 
	
	
		
			
				|  | @ -258,6 +279,9 @@ public class MessageUtil {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             wxTemplateConfigDO.setUrl(url + urlStr );
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (type==35){//支付提醒
 | 
	
		
			
				|  |  |             wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl()+json.getString("orderId"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return wxTemplateConfigDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 |