You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							76 lines
						
					
					
						
							2.4 KiB
						
					
					
				
			
		
		
	
	
							76 lines
						
					
					
						
							2.4 KiB
						
					
					
				| package com.ynxbd.wx.ext.report;
 | |
| 
 | |
| import com.ynxbd.common.bean.Patient;
 | |
| import com.ynxbd.common.dao.PatientDao;
 | |
| import com.ynxbd.common.helper.common.HttpHelper;
 | |
| import com.ynxbd.wx.config.WeChatConfig;
 | |
| import lombok.extern.slf4j.Slf4j;
 | |
| import org.apache.commons.lang3.StringUtils;
 | |
| import org.slf4j.MDC;
 | |
| 
 | |
| import javax.servlet.ServletException;
 | |
| import javax.servlet.annotation.WebServlet;
 | |
| import javax.servlet.http.HttpServlet;
 | |
| import javax.servlet.http.HttpServletRequest;
 | |
| import javax.servlet.http.HttpServletResponse;
 | |
| import javax.servlet.http.HttpSession;
 | |
| import java.io.IOException;
 | |
| import java.nio.charset.StandardCharsets;
 | |
| import java.util.List;
 | |
| 
 | |
| /**
 | |
|  * 石林体检报告
 | |
|  *
 | |
|  * @Author wsq
 | |
|  * @Date 2020/8/4 17:38
 | |
|  * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
 | |
|  */
 | |
| @Slf4j
 | |
| @WebServlet("/ext/tj")
 | |
| public class TJServlet extends HttpServlet {
 | |
| 
 | |
|     @Override
 | |
|     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 | |
|         MDC.remove("ip");
 | |
|         MDC.put("ip", HttpHelper.getIpAddress(req));
 | |
| 
 | |
|         HttpSession session = req.getSession();
 | |
| 
 | |
|         Object openid = session.getAttribute("openid");
 | |
|         if (openid == null) {
 | |
|             log.info("[石林体检]openid为空");
 | |
|             String state = WeChatConfig.getBaseUrl() + "/ext/tj";
 | |
|             resp.sendRedirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + WeChatConfig.APP_ID + "&redirect_uri=" + WeChatConfig.getBaseUrl() + "auth&response_type=code&scope=snsapi_userinfo&state=" + state + "#wechat_redirect");
 | |
|             return;
 | |
|         }
 | |
| 
 | |
|         List<Patient> patients = new PatientDao().selectListByOpenid(openid.toString());
 | |
| 
 | |
|         StringBuilder sb = new StringBuilder();
 | |
| 
 | |
|         String idCardNo;
 | |
|         for (int i = 0; i < patients.size(); i++) {
 | |
|             idCardNo = patients.get(i).getIdCardNo();
 | |
|             if (StringUtils.isEmpty(idCardNo)) break;
 | |
| 
 | |
|             idCardNo = encode(idCardNo);
 | |
| 
 | |
|             sb.append(idCardNo);
 | |
|             if ((i + 1) != patients.size()) {
 | |
|                 sb.append(",");
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         resp.sendRedirect("http://www.slxrmyy.cn:9899/?id=" + sb);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     /**
 | |
|      * BASE64加密
 | |
|      *
 | |
|      * @param data data
 | |
|      */
 | |
|     private static String encode(String data) {
 | |
|         return java.util.Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
 | |
|     }
 | |
| }
 | |
| 
 |