|  | @ -0,0 +1,99 @@
 | 
	
		
			
				|  |  | package com.yihu.wlyy.service.third.sign;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.Patient;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.entity.patient.PatientReservation;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.organization.HospitalMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.repository.patient.PatientReservationDao;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.common.account.PatientService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.third.guahao.GuahaoDoctor;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.third.guahao.IGuahaoService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.util.*;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.exception.ExceptionContext;
 | 
	
		
			
				|  |  | import org.apache.http.NameValuePair;
 | 
	
		
			
				|  |  | import org.apache.http.message.BasicNameValuePair;
 | 
	
		
			
				|  |  | import org.dom4j.Document;
 | 
	
		
			
				|  |  | import org.dom4j.DocumentHelper;
 | 
	
		
			
				|  |  | import org.dom4j.Element;
 | 
	
		
			
				|  |  | import org.json.JSONArray;
 | 
	
		
			
				|  |  | import org.json.JSONObject;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by hzp on 2016/9/26.
 | 
	
		
			
				|  |  |  * 基卫签约服务
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | public class SignJwService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //基卫服务地址
 | 
	
		
			
				|  |  |     private String jwUrl = SystemConf.getInstance().getJwUrl();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ObjectMapper objectMapper = new ObjectMapper();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询是否已签约
 | 
	
		
			
				|  |  |      * true 已签约 false 未签约
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean CheckSignFamily(String idcard) throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         boolean re = true;
 | 
	
		
			
				|  |  |         String url = jwUrl+"third/sign/CheckSignFamily";
 | 
	
		
			
				|  |  |         List<NameValuePair> params = new ArrayList<NameValuePair>();
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("idcard", idcard));
 | 
	
		
			
				|  |  |         String response = HttpClientUtil.post(url,params,"UTF-8");
 | 
	
		
			
				|  |  |         Map<String,Object> map = objectMapper.readValue(response,Map.class);
 | 
	
		
			
				|  |  |         if(map.get("status").equals(200))
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             Map<String,String> data = (Map<String,String>)map.get("data");
 | 
	
		
			
				|  |  |             if(data.get("status").equals("1"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 System.out.print("已签约ID:"+data.get("code"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else{
 | 
	
		
			
				|  |  |                 re = false;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else{
 | 
	
		
			
				|  |  |             throw new Exception(map.get("msg").toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return re;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 推送签约接口
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean UploadSignFamily(String code)
 | 
	
		
			
				|  |  |     {
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             String url = jwUrl+"third/sign/UploadSignFamily";
 | 
	
		
			
				|  |  |             List<NameValuePair> params = new ArrayList<NameValuePair>();
 | 
	
		
			
				|  |  |             params.add(new BasicNameValuePair("code", code));
 | 
	
		
			
				|  |  |             String response = HttpClientUtil.post(url,params,"UTF-8");
 | 
	
		
			
				|  |  |             Map<String,Object> map = objectMapper.readValue(response,Map.class);
 | 
	
		
			
				|  |  |             if(map.get("status").equals(200))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 return true;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             else{
 | 
	
		
			
				|  |  |                 System.out.print(map.get("msg"));
 | 
	
		
			
				|  |  |                 return false;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             System.out.print(ex.getMessage());
 | 
	
		
			
				|  |  |             return false;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static void main(String args[]) throws Exception {
 | 
	
		
			
				|  |  |         System.out.print(new SignJwService().UploadSignFamily("66ae08fd897643048ed8feba09549554")+"\r\n");
 | 
	
		
			
				|  |  |          System.out.print(new SignJwService().CheckSignFamily("1")+"\r\n");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |