Browse Source

代码修改

LAPTOP-KB9HII50\70708 1 year ago
parent
commit
9758bb1bb1
21 changed files with 1611 additions and 28 deletions
  1. 107 13
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java
  2. 56 0
      svr/svr-internet-hospital-entrance/pom.xml
  3. 85 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/SystemConfig.java
  4. 13 15
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java
  5. 36 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/zy/IotDeviceController.java
  6. 37 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/IotDeviceService.java
  7. 95 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/LogService.java
  8. 25 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/HttpApiException.java
  9. 242 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftApi.java
  10. 253 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftApiSeconde.java
  11. 330 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftBaseService.java
  12. 300 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftService.java
  13. BIN
      svr/svr-internet-hospital-entrance/src/main/lib/jna-4.2.2.jar
  14. BIN
      svr/svr-internet-hospital-entrance/src/main/lib/zoe-encrypt-sm-1.0-PK-SNAPSHOT.jar
  15. 1 0
      svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PrivateKey.SM2.key
  16. 5 0
      svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PrivateKey.SM2_V2.key
  17. 1 0
      svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PublicKey.SM2.key
  18. 4 0
      svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PublicKey.SM2_V2.key
  19. 1 0
      svr/svr-internet-hospital-entrance/src/main/resources/jwkey/ZOE.PLATFORM_PublicKey.SM2.key
  20. 4 0
      svr/svr-internet-hospital-entrance/src/main/resources/jwkey/ZOE.PLATFORM_PublicKey.SM2_V2.key
  21. 16 0
      svr/svr-internet-hospital-entrance/src/main/resources/system.properties

+ 107 - 13
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/DsyyEntranceService.java

@ -8,15 +8,12 @@ import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
@ -29,26 +26,21 @@ import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.oauth.OauthRsaKeyDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyInspectionVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.encrypt.MD5;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.network.HttpResponse;
import com.yihu.jw.util.network.HttpUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import net.sf.json.xml.XMLSerializer;
import okhttp3.*;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
@ -57,6 +49,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 第三医院内网his对接服务
@ -985,24 +978,125 @@ public class DsyyEntranceService {
     * @throws Exception
     */
    public String authorize()throws Exception{
//        test1();
//        test();
        String api = "authorize";
        String msgHeader ="";
        String condition ="<![CDATA[{\"clientId\":\"12222222\",\"responseType\":\"code\"}]]";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<authorize><pinput>"+condition+"</pinput></authorize>";
        String condition ="<![CDATA[{\"clientId\":\"12222222\",\"responseType\":\"code\"}]]>";
//        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
        String msgBody = "<authorize><pinput>"+condition+"</pinput></authorize>";
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        Map<String,String> params = new HashedMap();
        params.put("Header",msgHeader);
        params.put("Body",msgBody);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("authorize params:"+params.toString());
        String xml = getDsyyJhWebServiceInfo("WritebackCvalueInterface",params,getJhServiceUrl());
        String xml = getDsyyJhWebServiceInfo(api,params,getJhServiceUrl());
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("authorize json:"+json);
        return json;
    }
//    public void test1(){
//        try {
//            String condition ="<![CDATA[{\"clientId\":\"12222222\",\"responseType\":\"code\"}]]>";
//            String msgBody = "<authorize><pinput>"+condition+"</pinput></authorize>";
//            WritebackCvalueInterfaceLocator locator = new WritebackCvalueInterfaceLocator();
//            String returnStr = locator.getWritebackCvalueInterfaceSoap().authorize(condition);
//            System.out.println("==========test1====================="+returnStr);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
    public void test(){
        try {
            OkHttpClient client = new OkHttpClient().newBuilder()
                    .build();
            MediaType mediaType = MediaType.parse("Content-Type");
            RequestBody body = RequestBody.create(mediaType, "<soapenv:Envelope " +
                    "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
                    " xmlns:good=\"http://goodwillcis.com\">  " +
                    " <soapenv:Header/>  <soapenv:Body>    " +
                    " <good:authorize>        " +
                    "<good:pInput><![CDATA[{\"clientId\":\"12222222\",\"responseType\":\"code\"}]]></good:pInput>     " +
                    " </good:authorize> " +
                    "  </soapenv:Body> </soapenv:Envelope>");
            Request request = new Request.Builder()
                    .url("http://10.95.8.41:80/csp/jhip/JHIP.BJCA.BS.BJCAServicesBS.cls")
                    .method("POST", body)
                    .addHeader("Content-Type", "Content-Type")
                    .addHeader("SOAPAction", "\"#authorize\"")
                    .build();
            Response response = client.newCall(request).execute();
            System.out.println("==============================="+response.code());
            System.out.println("==============================="+response.body().string());
            System.out.println("==============================="+response.message());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    //发送短信
    public String SendMessage(String strDllModel,String strPhoneNO,String strMsgContent) throws Exception {
        String api = "SendMessage";
        String msgHeader ="";
        String condition ="<![CDATA[{\"strDllModel\":\"\",\"strPhoneNO\":\"13559485270\",\"strMsgContent\":\"测试短信\"}]]>";
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        Map<String,String> params = new HashedMap();
        params.put("Header",msgHeader);
        params.put("strDllModel",strDllModel);
        params.put("strPhoneNO",strPhoneNO);
        params.put("strMsgContent",strMsgContent);
        wlyyHttpLogDO.setRequest(params.toString());
        logger.info("SendMessage params:"+params.toString());
        List<WlyyHospitalSysDictDO> distList =  wlyyHospitalSysDictDao.findByDictName("DX_SMS_SERVICE");
        Map<String,String> dictMap = distList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        String msgUrl = dictMap.get("SMS_SERVICE_URL");
        String soapaction = dictMap.get("SMS_SERVICE_SOAPACTION");
        String xml = getDsyyJhWebServiceInfo(api,params,msgUrl);
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("SendMessage json:"+json);
        return json;
/*        String operationName = "SendMessage";// 调用方法名
        org.apache.axis.client.Service service = new org.apache.axis.client.Service();
        String response = "";
        if (StringUtils.isBlank(strDllModel)){
            strDllModel="";
        }
        List<WlyyHospitalSysDictDO> distList =  wlyyHospitalSysDictDao.findByDictName("DX_SMS_SERVICE");
        Map<String,String> dictMap = distList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        String msgUrl = dictMap.get("SMS_SERVICE_URL");
        String soapaction = dictMap.get("SMS_SERVICE_SOAPACTION");
        Object[] obj =  new Object[]{};
        try {
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(msgUrl);
            call.setOperationName(new QName(soapaction, operationName)); // 设置要调用哪个方法
            call.addParameter(new QName(soapaction, "strDllModel"), // 设置要传递的参数
                    org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);
            call.addParameter(new QName(soapaction, "strPhoneNO"),
                    org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);
            call.addParameter(new QName(soapaction, "strMsgContent"),
                    org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);// (标准的类型)
            call.setUseSOAPAction(true);
            call.setSOAPActionURI(soapaction +"/"+ "JHIP.SMS.BS.SendMessge");
//            obj =  new Object[]{strMoID, strMobiles, strContent, strApiCode, NAME, PWD, strSender};
            obj =  new Object[]{strDllModel, strPhoneNO, strMsgContent};
            response = (String) call.invoke(obj);
            //response 返回字符串的不以error开头,则表示成功
            return response;
        }catch (Exception e) {
            e.printStackTrace();
            throw new Exception("短信下发失败");
        }*/
    }
    //========================集成平台调用结束===========================
    public String replaceHtml(String demoData,String oldChar,String newChar){

+ 56 - 0
svr/svr-internet-hospital-entrance/pom.xml

@ -85,6 +85,20 @@
            <groupId>com.yihu.jw</groupId>
            <artifactId>base-service</artifactId>
            <version>${project.parent.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.el</artifactId>
                    <groupId>org.glassfish</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>cron-utils</artifactId>
                    <groupId>com.cronutils</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
@ -120,6 +134,12 @@
            <groupId>com.yihu.jw</groupId>
            <artifactId>base-service</artifactId>
            <version>${version.wlyy-common}</version>
            <exclusions>
                <exclusion>
                    <artifactId>javax.el</artifactId>
                    <groupId>org.glassfish</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
@ -143,6 +163,12 @@
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>
            <version>1.2.5</version>
            <exclusions>
                <exclusion>
                    <artifactId>xalan</artifactId>
                    <groupId>xalan</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
@ -168,6 +194,36 @@
            <version>6.1.0.jre8</version>
        </dependency>
        <!-- 基卫统一平台接口 -->
        <dependency>
            <groupId>sehrCrypto</groupId>
            <artifactId>sehrCrypto</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.zoesoft</groupId>
            <artifactId>phip-ssp-sdk</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.zoesoft</groupId>
            <artifactId>zoe-crypto</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.2.2</version>
            <scope>system</scope>
            <systemPath>${basedir}/src/main/lib/jna-4.2.2.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.zoesoft</groupId>
            <artifactId>zoe-encrypt-sm</artifactId>
            <version>1.0-PK-SNAPSHOT</version>
            <scope>system</scope>
            <systemPath>${basedir}/src/main/lib/zoe-encrypt-sm-1.0-PK-SNAPSHOT.jar</systemPath>
        </dependency>
    </dependencies>

+ 85 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/SystemConfig.java

@ -0,0 +1,85 @@
package com.yihu.jw.entrance.config;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
 * @created hzp 2016/9/13.
 */
@Configuration
public class SystemConfig {
    private static Object lock = new Object();
    // 全局系统配置信息
    private static SystemConfig systemConf;
    // 系统配置文件
    private Properties systemProperties;
    //从system_properties表中取到的系统参数集,key参数key,value参数值
    public static Map<String,String> sysPropertiesSets = new HashMap<>();
    public static SystemConfig getInstance() {
        if (systemConf == null) {
            synchronized (lock) {
                systemConf = new SystemConfig();
            }
        }
        return systemConf;
    }
    /**
     * 加载系统配置文件
     * @return
     */
    public Properties getSystemProperties() {
        if (systemProperties == null) {
            InputStream is = null;
            try {
                is = this.getClass().getResourceAsStream("/system.properties");
                systemProperties = new Properties();
                systemProperties.load(is);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return systemProperties;
    }
    /************************* 基卫服务配置 ********************************************/
    public String getGatewayUrl()
    {
         return  getSystemProperties().getProperty("gateway_url");
    }
    public String getGatewayLicence()
    {
        return  getSystemProperties().getProperty("gateway_licence");
    }
    public String getPublicKey() { return  getSystemProperties().getProperty("gateway_public_key"); }
    public String getJwHospital()
    {
        return  getSystemProperties().getProperty("jw_hospital");
    }
    public String getJwLicence()
    {
        return  getSystemProperties().getProperty("jw_licence");
    }
}

+ 13 - 15
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/DsyyController.java

@ -1,35 +1,22 @@
package com.yihu.jw.entrance.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.service.entrance.DsyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -176,4 +163,15 @@ public class DsyyController extends EnvelopRestEndpoint {
    public Envelop saveInspectToHospital() throws Exception {
        return success(dsyyEntranceService.authorize());
    }
    @GetMapping(value = "/SendMessage")
    @ApiOperation(value = "发短信")
    public Envelop SendMessage(String strDllModel,String strPhoneNO,String strMsgContent) throws Exception {
        try {
            return success(dsyyEntranceService.SendMessage(strDllModel,strPhoneNO,strMsgContent));
        }catch (Exception e){
            e.printStackTrace();
        }
        return Envelop.getError("发送失败");
    }
}

+ 36 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/zy/IotDeviceController.java

@ -0,0 +1,36 @@
package com.yihu.jw.entrance.controller.zy;
import com.yihu.jw.entrance.service.IotDeviceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2023/12/6.
 */
@RestController
@RequestMapping(value ="/iotDevice")
@Api(value = "物联网设备", description = "物联网设备", tags = {"物联网设备"})
public class IotDeviceController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceService iotDeviceService;
    @GetMapping(value = "/accesstoken")
    @ApiOperation(value = "获取accesstoken")
    public Envelop getAccessToken() {
        try {
            return success(iotDeviceService.getAccessToken());
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("查询失败");
        }
    }
}

+ 37 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/IotDeviceService.java

@ -0,0 +1,37 @@
package com.yihu.jw.entrance.service;
import com.yihu.jw.entrance.util.zysoft.ZysoftBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * 三院物联网对接
 * Created by yeshijie on 2023/12/6.
 */
@Service
public class IotDeviceService {
    @Autowired
    private ZysoftBaseService zysoftBaseService;
    /**
     * 获取accesstoken
     * @return
     * @throws Exception
     */
    public String getAccessToken() throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE","350211A1004");
        header.put("LICENCE","1GPM6UKII0NF33155F0A0000348D061E");
        Map<String,String> params = new HashMap<>();
        params.put("appid","dsyy808081724b116c017254d437fe0008");
        params.put("appSecret","dsyy808081724b116c017254d437fe0008");
        String response = zysoftBaseService.postSecondYg("accesstoken","获取accesstoken",params,null,header,false,5,"5");
        return response;
    }
}

+ 95 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/LogService.java

@ -0,0 +1,95 @@
package com.yihu.jw.entrance.service;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.UUID;
/**
 * Created by hzp on 2016/9/24.
 * 日志服务
 */
@Service
public class LogService {
    private org.slf4j.Logger logger= LoggerFactory.getLogger(LogService.class);
    @Autowired
    private WlyyHttpLogDao httpLogDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    public String archiveType = "2";
    public String onePayType = "3";
    public String caType = "4";
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    /**
     * 新增开放api调用日志
     **/
    public void saveOpenApiLog(Boolean isSuccess,String url,String content,String method,String params,String response,String error)
    {
        try {
            WlyyHttpLogDO log = new WlyyHttpLogDO();
            log.setCode(url+method);
            log.setName(content);
            log.setRequest(params);
            log.setCreateTime(new Date());
            if(response.length()>10652261){
                log.setResponse(response.substring(0,10652260));
            }else {
                log.setResponse(response);
            }
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
    /**
     * 保存http调用日志【基卫接口】
     **/
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error)
    {
        saveHttpLog( isSuccess, url, content, method, header, params, response, error,"1");
    }
    /**
     * 保存http调用日志    0开放api  1基卫接口  2市民健康网接口   3易联众接口  4长处方接口
     **/
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error,String type)
    {
        try {
            WlyyHttpLogDO log = new WlyyHttpLogDO();
            log.setCode(url+method);
            log.setName(content);
            log.setRequest(params);
            log.setCreateTime(new Date());
            if(response.length()>10652261){
                log.setResponse(response.substring(0,10652260));
            }else {
                log.setResponse(response);
            }
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

+ 25 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/HttpApiException.java

@ -0,0 +1,25 @@
package com.yihu.jw.entrance.util.zysoft;
/**
 * add by hzp at 2016-9-21
 */
public class HttpApiException extends Exception{
    private Integer status;
    public Integer getStatus()
    {
        return status;
    }
    public HttpApiException(int errorCode, String reason) {
        super(reason);
        this.status = errorCode;
    }
    public HttpApiException(String reason, Throwable throwable) {
        super(reason, throwable);
        this.status = -1;
    }
}

+ 242 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftApi.java

@ -0,0 +1,242 @@
package com.yihu.jw.entrance.util.zysoft;
import cn.com.zoe.crypto.jna.CryptoKey;
import com.yihu.jw.entrance.config.SystemConfig;
import com.zoe.phip.ssp.sdk.AbstractApiExecuter;
import com.zoe.phip.ssp.sdk.ApiException;
import com.zoe.phip.ssp.sdk.HeaderValue;
import com.zoe.phip.ssp.sdk.RequestValue;
import com.zoe.phip.ssp.sdk.model.ApiCryptoParameter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/9/10.
 * 智业jdk接入基础类
 **/
public class ZysoftApi extends AbstractApiExecuter {
    @Override
    public String run(String authorizationCode, boolean openCrypto) throws ApiException {
        return null;
    }
    private static byte[]  publicKey;
    private static byte[]  zkzlPublicKey;
    private static byte[]  zkzlPrivateKey;
    
    /**
     * 智业公钥
     */
    private static byte[] getPublicKey() throws Exception {
        if(publicKey == null)
        {
            publicKey =  sehrCrypto.sehrCrypto.ReadFileBytes(ZysoftApi.class.getClassLoader().getResource(SystemConfig.getInstance().getPublicKey()).toURI().getPath());
        }
        return publicKey;
    }
    /**
     * 健康之路公钥
     */
    private static byte[] getZkzlPublicKey() throws Exception {
        if(zkzlPublicKey == null)
        {
            zkzlPublicKey =  sehrCrypto.sehrCrypto.ReadFileBytes(ZysoftApi.class.getClassLoader().getResource("jwkey/jkzl_publicKey.key").toURI().getPath());
        }
        return zkzlPublicKey;
    }
    /**
     * 健康之路私钥
     */
    private static byte[] getZkzlPrivateKey() throws Exception {
        if(zkzlPrivateKey == null)
        {
            zkzlPrivateKey =  sehrCrypto.sehrCrypto.ReadFileBytes(ZysoftApi.class.getClassLoader().getResource("jwkey/jkzl_privateKey.key").toURI().getPath());
        }
        return zkzlPrivateKey;
    }
    private String licence = SystemConfig.getInstance().getGatewayLicence();
    private String basepath = SystemConfig.getInstance().getGatewayUrl();
    private ZysoftApi(byte[] platformPublicKey, byte[] parameterPublicKey, byte[] resultPrivateKey) {
        super(platformPublicKey, parameterPublicKey, resultPrivateKey);
    }
    private volatile static ZysoftApi service;
    /**
     * 单例模式
     * @return
     */
    public static ZysoftApi getSingleton() throws Exception
    {
        if (service == null) {
            synchronized (ZysoftApi.class) {
                if (service == null) {
                    byte[] zysoftPublicKey = getPublicKey();
                    byte[] zkzlPublicKey = getZkzlPublicKey();
                    byte[] zkzlPrivateKey  = getZkzlPrivateKey();
                    service = new ZysoftApi(zysoftPublicKey,zkzlPublicKey,zkzlPrivateKey);
                }
            }
        }
        return service;
    }
    /**
     * 底层Get统一接口
     */
    public String get(String url,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 response = doHttpGet(basepath + url, licence, openCrypto, paramsList, headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
//        System.out.print("response:"+response+"\r\n");
        return response;
    }
    /**
     * 底层Post统一接口
     */
    public String post(String url,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 response = doHttpPost(basepath + url,licence,openCrypto,paramsList,headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        //System.out.print("response:"+response+"\r\n");
        return response;
    }
    private ApiCryptoParameter apiCryptoParameter;
    /**
     * 获取身份信息
     */
    public ApiCryptoParameter buildApiCryptoParameter() throws Exception
    {
        if(apiCryptoParameter == null)
        {
            apiCryptoParameter =  buildApiCryptoParameter(getPublicKey(), "<root><org code=\"jtqy\" /><visitor type=\"0\" code=\"jtqy\" key=\"jtqy\" /></root>");
        }
        return  apiCryptoParameter;
    }
    
    public String getCryptoCredential() throws Exception
    {
        return buildApiCryptoParameter().getTarget();
    }
    public String getCryptoKey() throws Exception
    {
        return buildApiCryptoParameter().getKey();
    }
    /**
     * 解密数据
     */
    public String decodeResult(String response) throws Exception
    {
         return decodeResult(buildApiCryptoParameter().getKeyBytes(), response);
    }
    /**
     * 获取加密钥
     */
    public CryptoKey buildCryptoKey() throws Exception
    {
        return buildCryptoKey(getPublicKey());
    }
    /**
     * 加密参数
     */
    public String encodeParam(CryptoKey key,String param) throws Exception
    {
        return cryptoParameter(key, param);
    }
    /**
     * TB底层Post统一接口
     */
    public String tbpost(String baseApi,Map<String,String> params, Map<String,String> headers, boolean openCrypto,Integer apiType) 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 response = doHttpPost(baseApi,licence,openCrypto,paramsList,headersList);
        System.out.print("response:"+response+"\r\n");
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        return response;
    }
}

+ 253 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftApiSeconde.java

@ -0,0 +1,253 @@
package com.yihu.jw.entrance.util.zysoft;
import cn.com.zoe.crypto.jna.CryptoKey;
import cn.com.zoe.crypto.jna.CryptoType;
import com.yihu.jw.entrance.config.SystemConfig;
import com.zoe.phip.ssp.sdk.AbstractApiExecuter2;
import com.zoe.phip.ssp.sdk.ApiException;
import com.zoe.phip.ssp.sdk.HeaderValue;
import com.zoe.phip.ssp.sdk.RequestValue;
import com.zoe.phip.ssp.sdk.model.ApiCryptoParameter;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/9/10.
 * 智业jdk接入基础类
 **/
public class ZysoftApiSeconde extends AbstractApiExecuter2 {
//    private static final String keyPath = "D:\\jkzl\\wlyy2.0-springb2.4\\svr\\svr-internet-hospital-entrance\\src\\main\\resources";
    private static final String keyPath = "/data/hospital/svr-internet-hospital-entrance-1024/resources";
    @Override
    public String run(String s, boolean b, CryptoType cryptoType) throws ApiException {
        return null;
    }
    private static byte[]  publicKey;
    private static byte[]  zkzlPublicKey;
    private static byte[]  zkzlPrivateKey;
    /**
     * 智业公钥
     */
    private static byte[] getPublicKey() throws Exception {
        if(publicKey == null)
        {
            String path = keyPath + File.separator + "jwkey" + File.separator + "ZOE.PLATFORM_PublicKey.SM2_V2.key";
            publicKey =  sehrCrypto.sehrCrypto.ReadFileBytes(path);
        }
        return publicKey;
    }
    /**
     * 三院公钥
     */
    private static byte[] getZkzlPublicKey() throws Exception {
        if(zkzlPublicKey == null)
        {
            String path = keyPath + File.separator + "jwkey" + File.separator + "350211A1004_PublicKey.SM2_V2.key";
            zkzlPublicKey =  sehrCrypto.sehrCrypto.ReadFileBytes(path);
        }
        return zkzlPublicKey;
    }
    /**
     * 三院私钥
     */
    private static byte[] getZkzlPrivateKey() throws Exception {
        if(zkzlPrivateKey == null)
        {
            String path = keyPath + File.separator + "jwkey" + File.separator + "350211A1004_PrivateKey.SM2_V2.key";
            zkzlPrivateKey =  sehrCrypto.sehrCrypto.ReadFileBytes(path);
        }
        return zkzlPrivateKey;
    }
    private String basepath = SystemConfig.getInstance().getGatewayUrl();
    private ZysoftApiSeconde(byte[] platformPublicKey, byte[] parameterPublicKey, byte[] resultPrivateKey) {
        super(platformPublicKey, parameterPublicKey, resultPrivateKey);
    }
    private volatile static ZysoftApiSeconde service;
    /**
     * 单例模式
     * @return
     */
    public static ZysoftApiSeconde getSingleton() throws Exception
    {
        if (service == null) {
            synchronized (ZysoftApiSeconde.class) {
                if (service == null) {
                    byte[] zysoftPublicKey = getPublicKey();
                    byte[] zkzlPublicKey = getZkzlPublicKey();
                    byte[] zkzlPrivateKey  = getZkzlPrivateKey();
                    service = new ZysoftApiSeconde(zysoftPublicKey,zkzlPublicKey,zkzlPrivateKey);
                }
            }
        }
        return service;
    }
    /**
     * 底层Get统一接口
     */
    public String get(String url,Map<String,String> params, Map<String,String> headers, boolean openCrypto,String cryptoTypeStr,String licence) 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++;
            }
        }
        CryptoType cryptoType = CryptoType.valueOf(cryptoTypeStr.toUpperCase());
        String response = doHttpGet(basepath + url, licence, openCrypto, paramsList,cryptoType, headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
//        System.out.print("response:"+response+"\r\n");
        return response;
    }
    /**
     * 底层Post统一接口
     * cryptoTypeStr 密钥类型
     * //密钥类型不为SM2_V2时 统一平台密钥需要修改,暂时获取SM2_V2的密钥
     */
    public String post(String url,Map<String,String> params, Map<String,String> headers, boolean openCrypto,String cryptoTypeStr,String licence) 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++;
            }
        }
        CryptoType cryptoType = CryptoType.valueOf(cryptoTypeStr.toUpperCase());
        String response = doHttpPost(basepath + url,licence,openCrypto,paramsList,cryptoType,headersList);
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        //System.out.print("response:"+response+"\r\n");
        return response;
    }
    private ApiCryptoParameter apiCryptoParameter;
    /**
     * 获取身份信息
     */
    public ApiCryptoParameter buildApiCryptoParameter() throws Exception
    {
        if(apiCryptoParameter == null)
        {
            apiCryptoParameter =  buildApiCryptoParameter(getPublicKey(), "<root><org code=\"jtqy\" /><visitor type=\"0\" code=\"jtqy\" key=\"jtqy\" /></root>");
        }
        return  apiCryptoParameter;
    }
    
    public String getCryptoCredential() throws Exception
    {
        return buildApiCryptoParameter().getTarget();
    }
    public String getCryptoKey() throws Exception
    {
        return buildApiCryptoParameter().getKey();
    }
    /**
     * 解密数据
     */
    public String decodeResult(String response) throws Exception
    {
         return decodeResult(buildApiCryptoParameter().getKeyBytes(), response);
    }
    /**
     * 获取加密钥
     */
    public CryptoKey buildCryptoKey() throws Exception
    {
        return buildCryptoKey(getPublicKey());
    }
    /**
     * 加密参数
     */
    public String encodeParam(CryptoKey key,String param) throws Exception
    {
        return cryptoParameter(key, param);
    }
    /**
     * TB底层Post统一接口
     */
    public String tbpost(String baseApi,Map<String,String> params, Map<String,String> headers, boolean openCrypto,String cryptoTypeStr,String licence,Integer apiType) 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++;
            }
        }
        CryptoType cryptoType = CryptoType.valueOf(cryptoTypeStr.toUpperCase());
        String response = doHttpPost(baseApi,licence,openCrypto,paramsList,cryptoType,headersList);
        System.out.print("response:"+response+"\r\n");
        response = response.replace("\r","").replace("\n","").replace("\t","").replace("\f","");
        return response;
    }
}

+ 330 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftBaseService.java

@ -0,0 +1,330 @@
package com.yihu.jw.entrance.util.zysoft;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entrance.service.LogService;
import com.zoe.phip.ssp.sdk.ApiException;
import org.slf4j.LoggerFactory;
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.List;
import java.util.Map;
import java.util.UUID;
/**
 * 智业接口--基本方法
 * Created by yeshijie on 2017/7/17.
 */
@Service
public class ZysoftBaseService {
    private org.slf4j.Logger logger= LoggerFactory.getLogger(ZysoftBaseService.class);
    @Autowired
    private LogService logService;
    @Autowired
    private ObjectMapper objectMapper;
    //默认重复次数
    private int retryTimes = 3;
    private Boolean openCrypto = true;
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    /**
     * 获取基础路径
     * @param apiType
     * @return
     */
    private String getBaseApi(Integer apiType){
        return "wlw";
    }
    /**
     * 基卫二次封装Get接口
     */
    public String getSecond(String api, String content, Map<String,String> params, Map<String,String> headers,
                            boolean needRetry,Integer apiType) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
        String msgHeader = JSONObject.toJSONString(headers, SerializerFeature.WriteMapNullValue);
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        logger.info("msgHeader:"+msgHeader+"\r\n");
        logger.info("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "GET";
        Boolean isSuccess = true;
        String error = "";
        String baseApi = getBaseApi(apiType);
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().get(baseApi, paramsList, null,openCrypto);
            if(needRetry)
            {
                while(retryTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApi.getSingleton().post(baseApi, paramsList, null,openCrypto);
                    retryTimes --;
                    times++;
                }
            }
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
            String message = map.get("MESSAGE");
            if(!code.equals("1"))
            {
                throw new HttpApiException(Integer.valueOf(code),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();
            isSuccess = false;
            //保存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;
    }
    /**
     * 基卫二次封装Post接口
     */
    public String postSecond(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,
                             boolean needRetry,Integer apiType,String type) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = params==null?JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue):
                JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
        String msgHeader = JSONObject.toJSONString(headers, SerializerFeature.WriteMapNullValue);
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        logger.info("msgHeader:"+msgHeader+"\r\n");
        logger.info("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        String baseApi = getBaseApi(apiType);
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().post(baseApi, paramsList, null,openCrypto);
            if(needRetry)
            {
                int maxTimes = retryTimes;
                while(maxTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApi.getSingleton().post(baseApi, paramsList, null,openCrypto);
                    maxTimes --;
                    times++;
                }
            }
            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"));
            }
//            com.alibaba.fastjson.JSONObject j = com.alibaba.fastjson.JSONObject.parseObject(re);
            //保存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)
            {
                logger.info(ex.getMessage());
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /**
     * 基卫二次封装Post接口
     * YG请求 新的公钥和私钥
     */
    public String postSecondYg(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,
                               boolean needRetry,Integer apiType,String type) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = params==null?JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue):
                JSONObject.toJSONString(params, SerializerFeature.WriteMapNullValue);
        String msgHeader = JSONObject.toJSONString(headers, SerializerFeature.WriteMapNullValue);
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        logger.info("msgHeader:"+msgHeader+"\r\n");
        logger.info("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        String baseApi = getBaseApi(apiType);
        int times = 0;
        try {
            re = ZysoftApiSeconde.getSingleton().post(baseApi, paramsList, null,openCrypto,"SM2_V2",headers.get("LICENCE").toString());
            if(needRetry)
            {
                int maxTimes = retryTimes;
                while(maxTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApiSeconde.getSingleton().post(baseApi, paramsList, null,openCrypto,"SM2_V2",headers.get("LICENCE").toString());
                    maxTimes --;
                    times++;
                }
            }
            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)
        {
            ex.printStackTrace();
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                logger.info(ex.getMessage());
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /*************************** 格式转换 *******************************************************/
    /**
     * 获取单对象
     */
    public Map<String,String> getJwOne(String response) throws Exception
    {
        Map<String,String> re = new HashMap<>();
        Map<String,Object> map = objectMapper.readValue(response,Map.class);
        String code = String.valueOf(map.get("CODE"));
        if(code.equals("1")) {
            List<Map<String, String>> list = (List<Map<String, String>>) map.get("DATA");
            if (list != null && list.size() > 0) {
                re = list.get(0);
            }
        }
        else{
            re.put("MESSAGE",String.valueOf(map.get("MESSAGE")));
        }
        return re;
    }
    /**
     * 获取单对象列表
     **/
    public List<Map<String,String>> getJwList(String response) throws Exception
    {
        Map<String,Object> map = objectMapper.readValue(response,Map.class);
        List<Map<String,String>> list = (List<Map<String,String>>)map.get("DATA");
        return list;
    }
    /**
     *
     * @param api
     * @param hospital
     * @param userName
     * @param password
     * @return
     */
    private String getHeaderXml(String api,String hospital,String userName,String password)
    {
        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>" +
                "   <serverName>"+api+"</serverName>" +
                "   <orgId>"+hospital+"</orgId>"+
                "   <userName>"+userName+"</userName>"+
                "   <password>"+password+"</password>"+
                "</root>";
    }
}

+ 300 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/util/zysoft/ZysoftService.java

@ -0,0 +1,300 @@
package com.yihu.jw.entrance.util.zysoft;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entrance.service.LogService;
import com.zoe.phip.ssp.sdk.ApiException;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/9/9.
 * 智业提供接口
 */
@Service
public class ZysoftService {
    
    @Autowired
    private LogService logService;
    @Autowired
    private ObjectMapper objectMapper;
    private Boolean openCrypto = true;
    //默认重复次数
    private int retryTimes = 3;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 基卫二次封装Get接口
     */
    private String getSecond(String api,String content, Map<String,String> params, Map<String,String> headers,boolean needRetry) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = JSONObject.fromObject(params).toString();
        String msgHeader = JSONObject.fromObject(headers).toString();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        //System.out.print("msgHeader:"+msgHeader+"\r\n");
        //System.out.print("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "GET";
        Boolean isSuccess = true;
        String error = "";
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().get("base/CallEhrInterface", paramsList, null,openCrypto);
            if(needRetry)
            {
                while(retryTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApi.getSingleton().post("base/CallEhrInterface", paramsList, null,openCrypto);
                    retryTimes --;
                    times++;
                }
            }
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
            String message = map.get("MESSAGE");
            if(!code.equals("1"))
            {
                throw new HttpApiException(Integer.valueOf(code),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();
            isSuccess = false;
            //保存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;
    }
    /**
     * 基卫二次封装Post接口
     */
    private String postSecond(String api,String content, Map<String,String> params, Map<String,String> headers,boolean needRetry) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = JSONObject.fromObject(params).toString();
        String msgHeader = JSONObject.fromObject(headers).toString();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
//        System.out.print("msgHeader:"+msgHeader+"\r\n");
//        System.out.print("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().post("base/CallEhrInterface", paramsList, null,openCrypto);
            if(needRetry)
            {
                int maxTimes = retryTimes;
                while(maxTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApi.getSingleton().post("base/CallEhrInterface", paramsList, null,openCrypto);
                    maxTimes --;
                    times++;
                }
            }
            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();
            isSuccess = false;
            //保存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;
    }
    /**
     * 基卫二次封装Post接口
     */
    private String postSecond(String api, String content, com.alibaba.fastjson.JSONObject jsonParams, Map<String,String> headers) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = com.alibaba.fastjson.JSONObject.toJSONString(jsonParams, SerializerFeature.WriteMapNullValue);
        String msgHeader = JSONObject.fromObject(headers).toString();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        //System.out.print("msgHeader:"+msgHeader+"\r\n");
        //System.out.print("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        try {
            re = ZysoftApi.getSingleton().post("base/CallEhrInterface", paramsList, null,openCrypto);
            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();
            isSuccess = false;
            //保存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;
    }
    /*************************** 格式转换 *******************************************************/
    /**
     * 获取单对象
     */
    public Map<String,String> getJwOne(String response) throws Exception
    {
        Map<String,String> re = new HashMap<>();
        Map<String,Object> map = objectMapper.readValue(response,Map.class);
        String code = String.valueOf(map.get("CODE"));
        if(code.equals("1")) {
            List<Map<String, String>> list = (List<Map<String, String>>) map.get("DATA");
            if (list != null && list.size() > 0) {
                re = list.get(0);
            }
        }
        else{
            re.put("MESSAGE",String.valueOf(map.get("MESSAGE")));
        }
        return re;
    }
    /**
     * 获取单对象列表
     **/
    public List<Map<String,String>> getJwList(String response) throws Exception
    {
        Map<String,Object> map = objectMapper.readValue(response,Map.class);
        List<Map<String,String>> list = (List<Map<String,String>>)map.get("DATA");
        return list;
    }
    /**************************** 建档相关接口 add by ysj at 2017-09-11 *************************************************/
    /**
     * 7.1查询居民是否有建立健康档案接口
     * @param idcard
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getSickArchiveFlag(String idcard,String hospital,String licence)  throws Exception
    {
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("IDENTITY_CARD_NO",idcard);
        String response = postSecond("getSickArchiveFlag","查询居民是否有建立健康档案接口",params,header,false);
        return response;
    }
}

BIN
svr/svr-internet-hospital-entrance/src/main/lib/jna-4.2.2.jar


BIN
svr/svr-internet-hospital-entrance/src/main/lib/zoe-encrypt-sm-1.0-PK-SNAPSHOT.jar


+ 1 - 0
svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PrivateKey.SM2.key

@ -0,0 +1 @@
00F0ABEEAD7DCE3B7DE11DA4D5B2E635A39C4F658FE49AC30E75D0E1CECBB7A4F3

+ 5 - 0
svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PrivateKey.SM2_V2.key

@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBG0wawIBAQQgOzgYGoFOD+9JVGZm
aEVRuvivVzosUhoUb4xSG/yLnuOhRANCAATVKoCgyDDr7uN9UKmSJYJC2O0TK9W8
dvejbAOFoxq+t9yRO0TJJYv7tCW/kR7cGrSBqclqAIgTuagFdKjXW5IE
-----END PRIVATE KEY-----

+ 1 - 0
svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PublicKey.SM2.key

@ -0,0 +1 @@
04796D934B3CF6C567E4B348DC96439C981EEA0E6B932461441B26A0E95FA911FFEF65A3F1B1D4EC3BCF5BCD1904A2ADB5A283794F342250BF6265B90724F052B6

+ 4 - 0
svr/svr-internet-hospital-entrance/src/main/resources/jwkey/350211A1004_PublicKey.SM2_V2.key

@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE1SqAoMgw6+7jfVCpkiWCQtjtEyvV
vHb3o2wDhaMavrfckTtEySWL+7Qlv5Ee3Bq0ganJagCIE7moBXSo11uSBA==
-----END PUBLIC KEY-----

+ 1 - 0
svr/svr-internet-hospital-entrance/src/main/resources/jwkey/ZOE.PLATFORM_PublicKey.SM2.key

@ -0,0 +1 @@
048C90BC86F59449E5C8784F043EEB0BB778212043029FB7F96FCD65E788B8F752DAA6787B385CFEFCC182DAB9827A7004E6F78DC3F1B75A1B642F66CC67C4EBF8

+ 4 - 0
svr/svr-internet-hospital-entrance/src/main/resources/jwkey/ZOE.PLATFORM_PublicKey.SM2_V2.key

@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAErmfpquDHQpe51A8K8DwiaFrUex6g
wsmi1k8JbkUAbFXJ6LJn9x7Fm3QlxExCKfnYV7mkCoK1u8i7sHsD9GbaOg==
-----END PUBLIC KEY-----

+ 16 - 0
svr/svr-internet-hospital-entrance/src/main/resources/system.properties

@ -0,0 +1,16 @@
##test
gateway_url = http://117.25.173.18:18280/
gateway_licence = 1GPM6UKII0NF33155F0A0000348D061E
gateway_public_key = PublicKeyTest.key
jw_hospital = 350211A1004
jw_licence = 1GPM6UKII0NF33155F0A0000348D061E
###prod
#gateway_url = http://10.95.21.21:18280/
#gateway_licence = 1GPM6UKII0NF33155F0A0000348D061E
#gateway_public_key = PublicGov.key
#jw_hospital = 350211A1004
#jw_licence = 1GPM6UKII0NF33155F0A0000348D061E