Explorar o código

基卫签约调用接口

hzp %!s(int64=8) %!d(string=hai) anos
pai
achega
346d01351e

+ 99 - 0
src/main/java/com/yihu/wlyy/service/third/sign/SignJwService.java

@ -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");
    }
}

+ 0 - 14
src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -318,19 +318,5 @@ public class SystemConf {
		return getSystemProperties().getProperty("jw_url");
	}
	/**
	 * 获取基卫授权机构
	 */
	public String getJwOrgCode() {
		return getSystemProperties().getProperty("jw_org_code");
	}
	/**
	 * 获取基卫授权码
	 */
	public String getJwLicence() {
		return getSystemProperties().getProperty("jw_licence");
	}
	/**************************************************************************************/
}

+ 3 - 0
src/main/resources/system.properties

@ -164,3 +164,6 @@ template_appoint_failed=tldWEb9AN7p_RoHoD8ml0GxWW3V1V_mpEEhp2v6p56s
guahao_url = http://www.xmsmjk.com/UrpNetService/ReservationNet.asmx
guahao_namespace = http://www.zysoft.com.cn/
# »ùÎÀ¶Ô½Ó·þÎñµØÖ·
jw_url = http://localhost:8011/