Browse Source

新增易联众对接

chenweida 7 năm trước cách đây
mục cha
commit
7ecf48961b

+ 10 - 10
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/SocialSecurityInfo.java

@ -11,17 +11,17 @@ import javax.persistence.*;
@Table(name = "sb_info")
public class SocialSecurityInfo {
    private String id;
    private String xming0;
    private String xbie00;
    private String csrqi0;
    private String id; //主键   必填
    private String xming0;//名字 必填
    private String xbie00;//性别  1男 2女 必填
    private String csrqi0;//出生日志 yyyyMMdd 必填
    private String zjlxbh;
    private String sfzh18;
    private String grsfen;
    private String id0000;
    private String gzztai;
    private String cardno;
    private String card16;
    private String sfzh18;//身份证号
    private String grsfen; // 必填
    private String id0000;//保险号
    private String gzztai; //必填
    private String cardno;//社保卡号
    private String card16;//必填
    private String zhgxsj;
    private String bjlxbh;

+ 15 - 10
patient-co/patient-co-wlyy/pom.xml

@ -426,16 +426,16 @@
            <version>2.4.1.0</version>
        </dependency>
        <!--elasticsearch start-->
  <!--      <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>2.4.4</version>
        </dependency>
        <dependency>
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
            <version>2.4.0</version>
        </dependency>-->
        <!--      <dependency>
                  <groupId>org.elasticsearch</groupId>
                  <artifactId>elasticsearch</artifactId>
                  <version>2.4.4</version>
              </dependency>
              <dependency>
                  <groupId>io.searchbox</groupId>
                  <artifactId>jest</artifactId>
                  <version>2.4.0</version>
              </dependency>-->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
@ -488,6 +488,11 @@
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.ylz</groupId>
            <artifactId>ehc-empi-java-sdk</artifactId>
            <version>20180522</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>

+ 55 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/aop/SQLTimeAdivce.java

@ -0,0 +1,55 @@
//package com.yihu.wlyy.aop;
//
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * Created by chenweida on 2018/5/21 0021.
// * 数据库sql的拦截
// */
//@Aspect
//@Component
//public class SQLTimeAdivce {
//    public SQLTimeAdivce() {
//    }
//
//    private Logger logger = LoggerFactory.getLogger(SQLTimeAdivce.class);
//
//    @Around("execution(* org.springframework.jdbc.core.JdbcTemplate.batchUpdate*(..)) " +
//            "|| execution(* org.springframework.jdbc.core.JdbcTemplate.query*(..)) " +
//            "|| execution(* org.springframework.jdbc.core.JdbcTemplate.execute*(..)) " +
//            "|| this(org.springframework.data.repository.Repository) " +
//            "|| this(org.springframework.data.jpa.repository.JpaSpecificationExecutor)")
//    public Object process(ProceedingJoinPoint point) throws Throwable {
//        HttpServletRequest request = null;
//        if (RequestContextHolder.getRequestAttributes() != null) {
//            request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//            logger.info("uri:" + request.getRequestURI());
//        }
//        //访问目标方法的参数:
//        Object[] args = point.getArgs();
//        String sql = null;
//        //第一个参数是sql
//        if (args != null && args.length > 0 && args[0].getClass() == String.class) {
//            sql = args[0].toString();
//            //第一个参数是sql数组
//        }
//        //用改变后的参数执行目标方法
//        Long startTime = System.currentTimeMillis();
//        Object returnValue = point.proceed(args);
//        Long endTime = System.currentTimeMillis();
//
//        logger.info("sql:" + sql);
//        logger.info("sql-time:" + (endTime - startTime));
//        return returnValue;
//
//    }
//}

+ 0 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/jpa/WlyyJpa.java

@ -51,13 +51,10 @@ public class WlyyJpa {
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyyTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(

+ 8 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/area/AreaService.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@ -21,6 +22,8 @@ public class AreaService extends BaseService {
    TownDao townDao;
    @Autowired
    HospitalDao hospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 查询城市城镇
@ -28,11 +31,13 @@ public class AreaService extends BaseService {
     * @param city
     * @return
     */
    public List<Town> getCityTowns(String city){
    public List<Town> getCityTowns(String city) {
        return townDao.findByCityCode(city);
    }
    public List<Hospital> getTownHospitals(String town){
     return hospitalDao.findByTownCode10(town);
    public List<Hospital> getTownHospitals(String town) {
        String sql = " select * from dm_hospital where town = ?";
        jdbcTemplate.queryForList(sql, town);
        return hospitalDao.findByTownCode10(town);
    }
}

+ 49 - 36
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/ylz/YLZUserService.java

@ -6,12 +6,20 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.third.ylz.model.YLZAccessToken;
import com.yihu.wlyy.service.third.ylz.model.YLZUser;
import com.yihu.wlyy.service.third.ylz.model.YLZUserCard;
import com.yihu.wlyy.util.HttpClientUtil;
import com.ylzinfo.ehc.empi.sdk.EhcEmpiClient;
import com.ylzinfo.ehc.empi.sdk.dto.request.AuthorizationTokenRequest;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import com.ylzinfo.onepay.sdk.utils.SecurityUtil;
import com.ylzinfo.onepay.sdk.utils.Signature;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -35,8 +43,10 @@ public class YLZUserService {
    @Value("${ylz.appId}")
    private String appId;
    @Value("${ylz.aapSecret}")
    private String aapSecret;
    @Value("${ylz.termId}")
    private String termId;
    @Value("${ylz.appSecret}")
    private String appSecret;
    @Value("${ylz.redirectUrl}")
    private String redirectUrl;
@ -44,48 +54,51 @@ public class YLZUserService {
    private String signType = "MD5";
    private String encryptType = "AES";
    private String responseType = "token";
    @Autowired
    private HttpClientUtil httpClientUtil;
    public String getAccessToken(String openId) {
    public String getAccessToken() {
        try {
            YLZAccessToken ylzAccessToken = null;
            String result = null;
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(
                    empiUimcAuthorization,
                    appId,
                    aapSecret, signType, encryptType);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            //业务参数
            JSONObject params = new JSONObject();
            params.put("response_type", responseType);  //接入应用结算业务流水号
            params.put("redirect_url", redirectUrl);
            params.put("domain_cust_id", openId);
            requestParams.setParam(params);
            logger.info("requestParams:" + requestParams.toString());
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            if (OnepayDefaultClient.isSuccessful(res)) {
                result = JSON.toJSONString(res.getParam());
                logger.info("易联众返回结果:" + result);
//             新增保存数据
                JSONObject resultJson = JSON.parseObject(result).getJSONObject("biz_content");
                ylzAccessToken = new YLZAccessToken();
                ylzAccessToken.setAccessToken(resultJson.getString("access_token"));
                ylzAccessToken.setExpiresIn(resultJson.getInteger("expires_in"));
                ylzAccessToken.setCreateTime(new Date());
            EhcEmpiClient empiClient = new EhcEmpiClient(gatewayURL, appId, appSecret, termId, "1.0", signType, encryptType);
            try {
                AuthorizationTokenRequest params = new AuthorizationTokenRequest();
                params.setRedirectUrl(redirectUrl);
                params.setUserName("48");
                String url = empiClient.createUrl("gatewayPage", empiUimcAuthorization, params);
                String responseStr = httpClientUtil.get(url, "UTF-8");
                net.sf.json.JSONObject responseJSON = net.sf.json.JSONObject.fromObject(responseStr);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return ylzAccessToken.getAccessToken();
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
        return null;
    }
    private String initParams(RequestParams requestParams) throws PayException {
        String sign = Signature.createSign(requestParams, this.appSecret);
        requestParams.setSign(sign);
        String requestMessage;
        try {
            logger.info("加密前报文:" + JSONObject.toJSONString(requestParams));
            requestMessage = SecurityUtil.encrypt(JSONObject.toJSONString(requestParams.getParam()), this.encryptType, this.appSecret, this.appId);
            logger.info("加密后报文:" + requestMessage);
            requestParams.setEncryptData(requestMessage);
        } catch (Exception var11) {
            throw new PayException("请求报文加密失败");
        }
        requestParams.setParam((Object) null);
        requestMessage = JSON.toJSONString(requestParams);
        System.out.println("请求参数报文:" + requestMessage);
        return requestMessage;
    }
    /**
@ -97,7 +110,7 @@ public class YLZUserService {
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(
                    empiUimcQuery,
                    appId,
                    aapSecret, signType, encryptType);
                    appSecret, signType, encryptType);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());

+ 126 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/ylz/model/YLZRequestParams.java

@ -0,0 +1,126 @@
//package com.yihu.wlyy.service.third.ylz.model;
//
//import com.alibaba.fastjson.annotation.JSONField;
//import net.sf.json.JSONObject;
//
///**
// * Created by chenweida on 2018/5/22 0022.
// */
//public class YLZRequestParams {
//    @JSONField(name = "timestamp")
//    private String timestamp;
//    @JSONField(name = "sign")
//    private String sign;
//    @JSONField(name = "biz_content")
//    private String bizContent;
//    @JSONField(name = "enc_type")
//    private String signType = "MD5";
//    @JSONField(name = "term_id")
//    private String termId;
//    @JSONField(name = "method")
//    private String method;
//    @JSONField(name = "app_id")
//    private String appId;
//    @JSONField(name = "version")
//    private String version = "1.0";
//    @JSONField(name = "sign_type")
//    private String encType = "AES";
//
//
//    public String getTimestamp() {
//        return timestamp;
//    }
//
//    public void setTimestamp(String timestamp) {
//        this.timestamp = timestamp;
//    }
//
//    public String getSign() {
//        return sign;
//    }
//
//    public void setSign(String sign) {
//        this.sign = sign;
//    }
//
//    public String getBizContent() {
//        return bizContent;
//    }
//
//    public void setBizContent(String bizContent) {
//        this.bizContent = bizContent;
//    }
//
//    public String getSignType() {
//        return signType;
//    }
//
//    public void setSignType(String signType) {
//        this.signType = signType;
//    }
//
//    public String getTermId() {
//        return termId;
//    }
//
//    public void setTermId(String termId) {
//        this.termId = termId;
//    }
//
//    public String getMethod() {
//        return method;
//    }
//
//    public void setMethod(String method) {
//        this.method = method;
//    }
//
//    public String getAppId() {
//        return appId;
//    }
//
//    public void setAppId(String appId) {
//        this.appId = appId;
//    }
//
//    public String getVersion() {
//        return version;
//    }
//
//    public void setVersion(String version) {
//        this.version = version;
//    }
//
//    public String getEncType() {
//        return encType;
//    }
//
//    public void setEncType(String encType) {
//        this.encType = encType;
//    }
//
//    /**
//     * 1. 筛选
//     获取所有请求参数,不包括字节类型参数,如文件、字节流,剔除sign字段。
//     (app_id.、term_id、method、version、timestamp、sign_type、enc_type、)
//     2. 排序
//     将筛选的参数按照第一个字符的键值ASCII码递增排序(字母升序排序),如果遇到相同字符则按照第二个字符的键值ASCII码递增排序,以此类推。
//
//     3. 拼接
//     将排序后的参数与其对应值,组合成“参数=参数值”的格式,并且把这些参数用&字符连接起来,最后拼接上应用密钥在“…参数=参数值key=你的密钥”,此时生成的字符串为待签名字符串,将待签名字符串MD5运算,即是签名(sign)的值。
//     * @return
//     */
//    public String initSign(){
//        JSONObject jo=new JSONObject();
//        jo.put("app_id",this.appId);
//        jo.put("enc_type",this.encType);
//        jo.put("method",this.method);
//        jo.put("sign_type",this.signType);
//        jo.put("term_id",this.termId);
//        jo.put("timestamp",this.timestamp);
//        jo.put("version",this.version);
//
//        StringBuffer sb=new StringBuffer();
//        sb.append("app_id="+this.appId);
//    }
//}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdCheckUserController.java

@ -39,7 +39,7 @@ public class ThirdCheckUserController extends BaseController {
    @RequestMapping(value = "/checkUser", method = RequestMethod.POST)
    public String checkUser(String mediaIds) {
        try {
            checkService.getAccessToken();
            return write(200, "获取成功!", "data", "");
        } catch (Exception e) {

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -164,7 +164,8 @@ Riva:
ylz:
  appId: aaa
  aapSecret:  aaa
  appSecret:  aaa
  redirectUrl:  aaa
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -166,7 +166,8 @@ Riva:
ylz:
  appId: aaa
  aapSecret:  aaa
  appSecret:  aaa
  redirectUrl:  aaa
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -149,7 +149,8 @@ Riva:
ylz:
  appId: aaa
  aapSecret:  aaa
  appSecret:  aaa
  redirectUrl:  aaa
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -150,7 +150,8 @@ Riva:
ylz:
  appId: aaa
  aapSecret:  aaa
  appSecret:  aaa
  redirectUrl:  aaa
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -171,7 +171,8 @@ Riva:
ylz:
  appId: aaa
  aapSecret:  aaa
  appSecret:  aaa
  redirectUrl:  aaa
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -155,7 +155,8 @@ Riva:
ylz:
  appId: aaa
  aapSecret:  aaa
  appSecret:  aaa
  redirectUrl:  aaa
  termId: aaa
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -42,6 +42,9 @@ spring:
      min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
      time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  aop:
    proxy-target-class: true
    # REDIS
  redis:
    database: 0 # Database index used by the connection factory.