|  | @ -1,13 +1,21 @@
 | 
	
		
			
				|  |  | package com.yihu.wlyy.service.service.prescription;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.serializer.SerializerFeature;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.common.SystemConfig;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.common.http.HttpApiException;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.common.util.StringUtil;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.common.util.WebserviceUtil;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.service.LogService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.service.ZysoftApi;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.service.service.ZysoftBaseService;
 | 
	
		
			
				|  |  | import com.zoe.phip.ssp.sdk.ApiException;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.io.PrintWriter;
 | 
	
		
			
				|  |  | import java.io.StringWriter;
 | 
	
		
			
				|  |  | import java.util.HashMap;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -17,7 +25,7 @@ import java.util.Map;
 | 
	
		
			
				|  |  |  * 长处方CA认证服务
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | public class PrescriptionCAService {
 | 
	
		
			
				|  |  | public class PrescriptionCAService extends ZysoftBaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private String IS_APPLIED="XMCAF_SOFT_judgeRealNameSoftCertIsApplied"; //判断实名软证书是否已申请
 | 
	
		
			
				|  |  |     private String REQUEST_SIGN = "XMCAF_SOFT_requestRealNameSoftCertAndSign";//请求实名软证书并进行数字签名
 | 
	
	
		
			
				|  | @ -54,7 +62,84 @@ public class PrescriptionCAService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * CA认证服务二次封装
 | 
	
		
			
				|  |  |      * 生产环境 智业CA接口二次封装
 | 
	
		
			
				|  |  |      * @param api
 | 
	
		
			
				|  |  |      * @param params
 | 
	
		
			
				|  |  |      * @param srcBusinessStreamNO
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
 | 
	
		
			
				|  |  |         String ca_url = SystemConfig.sysPropertiesSets.get("ca_url");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
 | 
	
		
			
				|  |  |                 "<root>\n";
 | 
	
		
			
				|  |  |         if(params!=null && params.size()>0)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             for(String key : params.keySet())
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         msgBody += "</root>";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String msgHeader = getHeaderXml(api,srcBusinessStreamNO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         System.out.println("msgHerder:"+msgHeader);
 | 
	
		
			
				|  |  |         System.out.println("msgBody:"+msgBody);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String re = "";
 | 
	
		
			
				|  |  |         Map<String,String> paramsList = new HashMap<>();
 | 
	
		
			
				|  |  |         paramsList.put("msgHeader",msgHeader);
 | 
	
		
			
				|  |  |         paramsList.put("msgBody",msgBody);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //新增日志
 | 
	
		
			
				|  |  |         String method = "POST";
 | 
	
		
			
				|  |  |         Boolean isSuccess = true;
 | 
	
		
			
				|  |  |         String error = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         int times = 0;
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String,String> map = objectMapper.readValue(re,Map.class);
 | 
	
		
			
				|  |  |             String code = map.get("CODE");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(!code.equals("1"))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存http日志
 | 
	
		
			
				|  |  |             logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         catch (Exception ex)
 | 
	
		
			
				|  |  |         {
 | 
	
		
			
				|  |  |             StringWriter sw = new StringWriter();
 | 
	
		
			
				|  |  |             PrintWriter pw = new PrintWriter(sw);
 | 
	
		
			
				|  |  |             ex.printStackTrace(pw);
 | 
	
		
			
				|  |  |             error = sw.toString();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存http日志
 | 
	
		
			
				|  |  |             logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,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;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 测试环境:CA认证服务二次封装
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     private String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception
 | 
	
		
			
				|  |  |     {
 | 
	
	
		
			
				|  | @ -98,7 +183,9 @@ public class PrescriptionCAService {
 | 
	
		
			
				|  |  |             params.put("strUserIdcardNum",strUserIdcardNum);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             body = objectMapper.writeValueAsString(params);
 | 
	
		
			
				|  |  |             re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  | //            re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  |             //生产环境,调用智业统一平台接口,rest接口
 | 
	
		
			
				|  |  |             re = postZyCaServer(action, params,srcBusinessStreamNO,"判断是否有实名证书");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(StringUtil.isEmpty(re))
 | 
	
		
			
				|  |  |             {
 | 
	
	
		
			
				|  | @ -147,7 +234,10 @@ public class PrescriptionCAService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             body = objectMapper.writeValueAsString(params);
 | 
	
		
			
				|  |  |             re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  |             //测试环境开启下面这行代码,webservice接口
 | 
	
		
			
				|  |  | //            re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  |             //生产环境,调用智业统一平台接口,rest接口
 | 
	
		
			
				|  |  |             re = postZyCaServer(action, params,srcBusinessStreamNO,"请求实名软证书并进行数字签名");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(StringUtil.isEmpty(re))
 | 
	
		
			
				|  |  |             {
 | 
	
	
		
			
				|  | @ -196,8 +286,9 @@ public class PrescriptionCAService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             body = objectMapper.writeValueAsString(params);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  | //            re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             re = postZyCaServer(action, params,srcBusinessStreamNO,"获取实名软证书的过期时间");
 | 
	
		
			
				|  |  |             if(StringUtil.isEmpty(re))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 throw new Exception("返回为空!");
 | 
	
	
		
			
				|  | @ -244,7 +335,8 @@ public class PrescriptionCAService {
 | 
	
		
			
				|  |  |             params.put("strNewCalledPasswd",strNewCalledPasswd);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             body = objectMapper.writeValueAsString(params);
 | 
	
		
			
				|  |  |             re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  | //            re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  |             re = postZyCaServer(action, params,srcBusinessStreamNO,"修改实名软证书调用保护口令");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(StringUtil.isEmpty(re))
 | 
	
		
			
				|  |  |             {
 | 
	
	
		
			
				|  | @ -297,8 +389,8 @@ public class PrescriptionCAService {
 | 
	
		
			
				|  |  |             params.put("strOriginalData",strOriginalData);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             body = objectMapper.writeValueAsString(params);
 | 
	
		
			
				|  |  |             re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //            re = postCAServer(action, params,srcBusinessStreamNO);
 | 
	
		
			
				|  |  |             re = postZyCaServer(action, params,srcBusinessStreamNO,"验证签名(带多服务器负载均衡)");
 | 
	
		
			
				|  |  |             if(StringUtil.isEmpty(re))
 | 
	
		
			
				|  |  |             {
 | 
	
		
			
				|  |  |                 throw new Exception("返回为空!");
 |