Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 7 years ago
parent
commit
43d6e14435

+ 22 - 5
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/util/WebserviceUtil.java

@ -1,7 +1,10 @@
package com.yihu.wlyy.service.common.util;
import com.yihu.wlyy.service.controller.PrescriptionController;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.namespace.QName;
import java.util.Map;
@ -13,6 +16,8 @@ import java.util.Map;
 **/
public class WebserviceUtil {
    private static Logger logger = LoggerFactory.getLogger(WebserviceUtil.class);
    /**
     * webservice 调用接口
@ -20,34 +25,46 @@ public class WebserviceUtil {
    public static String post(String urlString,String namespace,String api, Map<String,String> params) throws Exception {
        try {
            Service service = new Service();
            logger.info("ca_url:"+urlString);
            logger.info("ca_namespace:"+namespace);
            logger.info("api:"+api);
            Service service = new Service();
            logger.info("=======>通过service创建call对象");
            Call call = (Call) service.createCall();// 通过service创建call对象
            logger.info("=======>设置service所在URL");
            // 设置service所在URL
            call.setTargetEndpointAddress(new java.net.URL(urlString));
            call.setOperationName(new QName(namespace, api));
            call.setUseSOAPAction(true);
            Object[] objs = null;
            logger.info("=======>组装参数:"+params.size());
            if(params!=null && params.size()>0)
            {
                logger.info("=======>遍历参数");
                objs = new Object[params.size()];
                int i=0;
                for(String key : params.keySet())
                {
                    logger.info("=======>参数key:"+key);
                    logger.info("=======>接口参数:"+key);
                    call.addParameter(new QName(key), org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);//接口的参数
                    logger.info("=======>参数值:"+params.get(key));
                    objs[i] = params.get(key);
                    i++;
                }
            }
            logger.info("=======>设置返回类型");
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//设置返回类型
            String  ret = (String )call.invoke(objs);
            logger.info("=======>开始请求");
            String  ret = (String)call.invoke(objs);
            logger.info("=======>请求结果:"+ret);
            logger.info("=======>请求结果.toString():"+ret.toString());
            return ret.toString();
        } catch (Exception e) {
            System.out.print("urlString:"+urlString +" "+namespace+api);
            logger.info("=======>CA请求报错:"+e.getMessage());
            e.printStackTrace();
            throw e;
        }

+ 69 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftApi.java

@ -199,4 +199,73 @@ public class ZysoftApi extends AbstractApiExecuter {
    {
        return cryptoParameter(key, param);
    }
    /**
     * CA底层Post统一接口
     */
    public String capost(Map<String,String> params, Map<String,String> headers, boolean openCrypto) throws Exception
    {
        List<RequestValue> paramsList = null;
        HeaderValue[] headersList = null;
        if(params!=null)
        {
            paramsList = new ArrayList<>();
            for(String key :params.keySet())
            {
                RequestValue obj = new RequestValue(key,params.get(key));
                paramsList.add(obj);
            }
        }
        if(headers!=null)
        {
            headersList = new HeaderValue[headers.size()];
            int i = 0;
            for(String key :headers.keySet())
            {
                headersList[i] = new HeaderValue(key,headers.get(key));
                i++;
            }
        }
        String ca_url = SystemConfig.sysPropertiesSets.get("ca_url");
        System.out.println("ca_url:"+ca_url);
        String response = doHttpPost(ca_url,licence,openCrypto,paramsList,headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        //System.out.print("response:"+response+"\r\n");
        return response;
    }
    /**
     * CA底层Get统一接口
     */
    public String caget(Map<String,String> params, Map<String,String> headers, boolean openCrypto) throws Exception
    {
        List<RequestValue> paramsList = null;
        HeaderValue[] headersList = null;
        if(params!=null)
        {
            paramsList = new ArrayList<>();
            for(String key :params.keySet())
            {
                RequestValue obj = new RequestValue(key,params.get(key));
                paramsList.add(obj);
            }
        }
        if(headers!=null)
        {
            headersList = new HeaderValue[headers.size()];
            int i = 0;
            for(String key :headers.keySet())
            {
                headersList[i] = new HeaderValue(key,headers.get(key));
                i++;
            }
        }
        String ca_url = SystemConfig.sysPropertiesSets.get("ca_url");
        String response = doHttpGet(ca_url, licence, openCrypto, paramsList, headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        System.out.print("response:"+response+"\r\n");
        return response;
    }
}

+ 2 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/common/InitiSysProService.java

@ -32,9 +32,10 @@ public class InitiSysProService {
        List<SystemProperties> sysvalueList = systemPropertiesDao.findSystemPropertiesByClientAndSpaValue(1);
        if(!sysvalueList.isEmpty()){
            for (SystemProperties systemProperties : sysvalueList) {
                System.out.println("key:"+systemProperties.getKey());
                System.out.println("value:"+systemProperties.getValue());
                sysPropertiesSets.put(systemProperties.getKey(),systemProperties.getValue());
            }
            SystemConfig.sysPropertiesSets = sysPropertiesSets;
        }
    }

+ 106 - 8
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCAService.java

@ -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,90 @@ 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 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);
            re = ZysoftApi.getSingleton().capost(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);
            System.out.println("error1:"+ex.getMessage());
            error = sw.toString();
            System.out.println("error2:"+error);
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                System.out.println("error3:"+ex.getMessage());
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                System.out.println("error4:"+ex.getMessage());
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /**
     * 测试环境:CA认证服务二次封装
     */
    private String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception
    {
@ -98,7 +189,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 +240,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 +292,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 +341,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 +395,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("返回为空!");

+ 16 - 16
patient-co-service/wlyy_service/src/main/resources/system.properties

@ -1,20 +1,20 @@
###基卫测试环境服务
#gateway_url = http://117.25.173.18:18280/
#gateway_licence = 5YGl5bq45LmL7Lev
#gateway_public_key = PublicKeyTest.key
#jw_hospital = 350211B1013
#jw_licence = 5YGl5bq45LmL7Lev
#ca_url = http://117.29.183.114:8081/XMCAService?wsdl
#ca_namespace = http://platfomservice.xmca.com/
##基卫服务
guahao_url =  http://10.95.18.10/urp.service/urp.open.service/ReservationPulic.asmx
guahao_namespace = http://www.zysoft.com.cn/
gateway_url = http://10.95.21.21:18280/
gateway_url = http://117.25.173.18:18280/
gateway_licence = 5YGl5bq45LmL7Lev
gateway_public_key = PublicGov.key
jw_hospital = 350211B1004
jw_licence = 5YGl5bq35LmL6LevMzUwMjExQjEwMDQ=
gateway_public_key = PublicKeyTest.key
jw_hospital = 350211B1013
jw_licence = 5YGl5bq45LmL7Lev
ca_url = http://117.29.183.114:8081/XMCAService?wsdl
ca_namespace = http://platfomservice.xmca.com/
ca_namespace = http://platfomservice.xmca.com/
##基卫服务
#guahao_url =  http://10.95.18.10/urp.service/urp.open.service/ReservationPulic.asmx
#guahao_namespace = http://www.zysoft.com.cn/
#gateway_url = http://10.95.21.21:18280/
#gateway_licence = 5YGl5bq45LmL7Lev
#gateway_public_key = PublicGov.key
#jw_hospital = 350211B1004
#jw_licence = 5YGl5bq35LmL6LevMzUwMjExQjEwMDQ=
#ca_url = http://10.95.21.21:18280/base/XMCA6_UnifiedCallInterface
#ca_namespace = http://platfomservice.xmca.com/

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -281,7 +281,6 @@ public class PrescriptionInfoService extends BaseService {
     */
    public com.alibaba.fastjson.JSONObject getPrescription(String code,String patient) {
        Patient p = patientDao.findByCode(patient);
        String rs = jwPrescriptionService.getRecipe(code, p.getSsc());
        com.alibaba.fastjson.JSONObject r = presModeAdapter.modelToSinglePrescription(rs);
        String rState = presCheckStateObj(code);

+ 16 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -29,6 +29,8 @@ import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -48,6 +50,7 @@ import java.util.*;
@Api(description = "预约挂号接口")
public class BookingController extends WeixinBaseController {
    private static final Logger logger = LoggerFactory.getLogger(BookingController.class);
    @Autowired
    private GuahaoXMService guahaoXM;
@ -370,18 +373,19 @@ public class BookingController extends WeixinBaseController {
                }
                //发送短信小时
                // 调用总部发送信息的接口
                //String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, p.getMobile()), "GBK");
                //JSONObject json = toJson(result);
//				if (json == null) {
//					// 发送失败
//					throw new Exception("短信发送失败!");
//				} else if (json.getInt("result") != 0) {
//					return json.getString("description");
//				} else {
//					//发送成功,保存到数据库
//				}
                //发送短信消息
                 //调用总部发送信息的接口
                String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, p.getMobile()), "GBK");
                JSONObject r = toJson(result);
				if (r == null) {
					// 发送失败
                    logger.error("短信发送失败!");
					//throw new Exception("短信发送失败!");
				} else if (r.getInt("result") != 0) {
					return r.getString("description");
				} else {
					//发送成功,保存到数据库
				}
                BusinessLogs.info(BusinessLogs.BusinessType.appointment, getUID(), p.getCode(), new JSONObject(obj));
                return write(200, "创建挂号单成功!");
            } else {