yeshijie %!s(int64=7) %!d(string=hai) anos
pai
achega
cca927b1b8

+ 45 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/GuahaoController.java

@ -478,4 +478,49 @@ public class GuahaoController {
	/**
	 * =============================计免预约挂号相关接口======================================END
	 */
	@RequestMapping(value = "/imm/getToken",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取口令")
	public Result getToken()
	{
		try {
			String data = guahaoService.getToken();
			return Result.success("获取口令成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	@RequestMapping(value = "/imm/ymjsAll",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取社区疫苗字典")
	public Result ymjsAll()
	{
		try {
			String data = guahaoService.ymjsAll();
			return Result.success("获取社区疫苗字典成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	@RequestMapping(value = "/imm/findWzymBymykh",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:获取计划免疫接种记录")
	public Result findWzymBymykh()
	{
		try {
			String data = guahaoService.findWzymBymykh();
			return Result.success("获取计划免疫接种记录成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
}

+ 109 - 10
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/guahao/GuahaoService.java

@ -1,13 +1,10 @@
package com.yihu.wlyy.service.service.guahao;
import cn.com.zoe.crypto.jna.CryptoKey;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.util.DateUtil;
import com.yihu.wlyy.service.common.util.SOAPUtil;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.dao.*;
import com.yihu.wlyy.service.entity.Patient;
import com.yihu.wlyy.service.entity.PatientReservation;
@ -19,19 +16,14 @@ import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.hibernate.validator.internal.util.privilegedactions.GetResource;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.crypto.Cipher;
import java.io.*;
import java.security.PublicKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.security.KeyFactory;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;
@ -1467,4 +1459,111 @@ public class GuahaoService {
    
        return result;
    }
     /***************************************易联众计免接口**********************************************************/
    /**
     * 计免预约Post接口
     */
    private String ylzImmGetSecond(String apistr,String content, Map<String,String> params) throws Exception
    {
        String re = "";
        ZysoftApi api = ZysoftApi.getSingleton();
        //新增日志
        String method = "GET";
        Boolean isSuccess = true;
        String error = "";
        int times = 0;
        try {
            re = api.get(immUrl+"/"+apistr, params, null,false);
            //---结果验证,并保存日志 ---START
            if (StringUtils.isEmpty(re)) {
                // 请求失败
                //保存http日志
                logService.saveHttpLog(isSuccess,apistr,content,method,apistr,net.sf.json.JSONObject.fromObject(params).toString(),re,"接口返回的结果为空");
                throw new Exception("接口返回的结果为空");
            } else if (StringUtils.startsWith(re, "System-Error")) {
                // 调用失败
                //保存http日志
                error = re.substring(re.indexOf(":") + 1, re.length());
                logService.saveHttpLog(isSuccess,apistr,content,method,apistr,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            } else if (StringUtils.startsWith(re, "Error")) {
                // 调用失败
                //保存http日志
                error = re.substring(re.indexOf(":") + 1, re.length());
                logService.saveHttpLog(isSuccess,apistr,content,method,apistr,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
                throw new Exception(error);
            }
            //---结果验证,并保存日志 ---END
            //保存http日志
            logService.saveHttpLog(isSuccess,apistr,content,method,apistr, net.sf.json.JSONObject.fromObject(params).toString(),re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
            isSuccess = false;
            //保存http日志
            logService.saveHttpLog(isSuccess,apistr,content,method,apistr,net.sf.json.JSONObject.fromObject(params).toString(),re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    private String apiString = "Action";
    /**
     * 获取口令,4小时有效,465439011
     * @return
     */
    public String getToken() throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("act", "getToken");
        params.put("accId", "q9Bt3TE00KaigEW5EJVIMA==");
        return ylzImmGetSecond(apiString,"计免预约-获取口令",params);
    }
    /**
     * 获取社区疫苗字典
     * @return
     */
    public String ymjsAll() throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("act", "ymjsAll");
        params.put("accId", "q9Bt3TE00KaigEW5EJVIMA==");
        params.put("_token", "525870222");
        return ylzImmGetSecond(apiString,"计免预约-获取社区疫苗字典",params);
    }
    /**
     * 获取计划免疫接种记录
     * @return
     */
    public String findWzymBymykh() throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("act", "findWzymBymykh");
        params.put("accId", "q9Bt3TE00KaigEW5EJVIMA==");
        params.put("_token", "525870222");
        params.put("etmykh", "0052182708");
        return ylzImmGetSecond(apiString,"计免预约-获取计划免疫接种记录",params);
    }
}