mengkang 5 éve
szülő
commit
50fd580257

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OauthYlzConfigDao.java

@ -8,4 +8,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by Trick on 2019/7/26.
 */
public interface OauthYlzConfigDao extends PagingAndSortingRepository<OauthYlzConfigDO, String>, JpaSpecificationExecutor<OauthYlzConfigDO> {
    OauthYlzConfigDO findById(String id);
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -237,6 +237,16 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String userId;
    private String register;
    @Column(name = "register")
    public String getRegister() {
        return register;
    }
    public void setRegister(String register) {
        this.register = register;
    }
    @Column(name = "saas_id")
    public String getSaasId() {

+ 21 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/ylzinfo/OauthYlzConfigDO.java

@ -2,6 +2,7 @@ package com.yihu.jw.entity.ylzinfo;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -19,6 +20,10 @@ public class OauthYlzConfigDO extends UuidIdentityEntity {
    private String signType;
    private String encType;
    private String url;
    @Column(name = "private_key")
    private String privateKey;
    @Column(name = "ehc_public_key")
    private String ehcPublicKey;
    public String getAppId() {
        return appId;
@ -75,4 +80,20 @@ public class OauthYlzConfigDO extends UuidIdentityEntity {
    public void setUrl(String url) {
        this.url = url;
    }
    public String getPrivateKey() {
        return privateKey;
    }
    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }
    public String getEhcPublicKey() {
        return ehcPublicKey;
    }
    public void setEhcPublicKey(String ehcPublicKey) {
        this.ehcPublicKey = ehcPublicKey;
    }
}

+ 8 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -715,4 +715,12 @@ public class BaseRequestMapping {
        public static final String getLog  = "/getLog";
    }
    /**ThirdInterface
     * 多码融合
     */
    public static class ThirdInterface extends Basic{
        public static final String PREFIX  = "/thirdInterface";
        public static final String selectHealthIdCard  = "/selectHealthIdCard";
    }
}

+ 8 - 3
svr/svr-internet-hospital/pom.xml

@ -69,10 +69,15 @@
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.ylz.loginsdk</groupId>-->
            <!--<artifactId>ehcsdk</artifactId>-->
            <!--<version>1.0</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>com.ylz.loginsdk</groupId>
            <artifactId>ehcsdk</artifactId>
            <version>1.0</version>
            <groupId>com.ylz.dmrh</groupId>
            <artifactId>ehcsdk-java-sdk-base</artifactId>
            <version>1.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>

+ 121 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/MultipleCode/MultipleCoderController.java

@ -0,0 +1,121 @@
package com.yihu.jw.hospital.endpoint.MultipleCode;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.service.MultipleCode.MultipleCodeService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.ylzinfo.ehc.trans.TransResponse;
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.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.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/9
 */
@RestController
@RequestMapping("mcf" )
@Api(tags ="多码融合", description = "互联网医院")
public class MultipleCoderController extends EnvelopRestEndpoint {
    @Autowired
    private MultipleCodeService multipleCodeService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private WlyyHttpLogDao wlyyHttpLogDao;
    /**
     *  多码融合-获取健康卡
     * @param patientId 居民id
     * @param wechatId 微信id
     * @return
     */
    @GetMapping(value = BaseRequestMapping.ThirdInterface.selectHealthIdCard)
    @ApiOperation(value = "多码融合-获取健康卡")
    public MixEnvelop getE_healthCard(@ApiParam(name = "patientId", value = "居民id")
                               @RequestParam(value = "patientId",required = true) String patientId,
                                      @ApiParam(name = "wechatId", value = "微信id")
                               @RequestParam(value = "wechatId",required = true) String wechatId){
        try {
            WlyyHttpLogDO logDO = new WlyyHttpLogDO();
            MixEnvelop envelop = new MixEnvelop();
            BasePatientDO patientDO = basePatientDao.findById(patientId);
            if (patientDO!=null&&patientDO.getRegister().equalsIgnoreCase("0")){
                logDO.setCode("ehc.ehealthcard.register");
                logDO.setName("注册多码融合信息");
                logDO.setPatient(patientId);
                logDO.setRequest("patientId="+patientId+"&wechatId="+wechatId);
                wlyyHttpLogDao.save(logDO);
                envelop = multipleCodeService.mcfRegister(patientDO,wechatId);
                Object obj = envelop.getObj();
                String response = JSONObject.toJSONString(obj);
                logDO.setResponse(response);
                logDO.setStatus("0");
                logDO.setCreateTime(DateUtil.getNowDate());
                wlyyHttpLogDao.save(logDO);
            }else {
                WlyyHttpLogDO queryInfoLogDO = new WlyyHttpLogDO();
                queryInfoLogDO.setCode("ehc.ehealthcard.queryInfo");
                queryInfoLogDO.setName("根据身份证查询多码融合信息");
                queryInfoLogDO.setPatient(patientId);
                queryInfoLogDO.setRequest("idType="+"01"+"&Idcard="+patientDO.getIdcard());//01代表证件类型为身份证
                wlyyHttpLogDao.save(queryInfoLogDO);
                TransResponse re = multipleCodeService.mcfQueryInfo("01", patientDO.getIdcard());
                String code = re.getRet_code();
                if (code.equals("0000")){
                    String ehealthCardId = JSONObject.parseObject(re.getBiz_content()).getString("ehealth_card_id").toString();
                    queryInfoLogDO.setResponse("ehealthCardId="+ehealthCardId);
                    queryInfoLogDO.setStatus("0");
                    queryInfoLogDO.setCreateTime(DateUtil.getNowDate());
                    wlyyHttpLogDao.save(queryInfoLogDO);
                    logDO.setCode("ehc.ehealthcard.getCodeUrl");
                    logDO.setName("获取多码融合展示码URL");
                    logDO.setPatient(patientId);
                    logDO.setRequest("ehealthCardId="+ehealthCardId);
                    wlyyHttpLogDao.save(logDO);
                    envelop = multipleCodeService.mcfGetCodeUrl(ehealthCardId);
                    Object obj = envelop.getObj();
                    String response = JSONObject.toJSONString(obj);
                    logDO.setResponse(response);
                    logDO.setStatus("0");
                    logDO.setCreateTime(DateUtil.getNowDate());
                    wlyyHttpLogDao.save(logDO);
                } else {
                    return MixEnvelop.getError(JSONObject.parseObject(re.getRet_msg()).toString());
                }
            }
            return envelop;
        } catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 185 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/MultipleCode/MultipleCodeService.java

@ -0,0 +1,185 @@
package com.yihu.jw.hospital.service.MultipleCode;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.common.utils.DateUtils;
import com.ylzinfo.ehc.trans.TransRequest;
import com.ylzinfo.ehc.trans.TransResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
/**
 * @author HZY
 * @vsrsion 1.0
 * Created at 2020/4/17
 */
@Service
public class MultipleCodeService {
    @Autowired
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    public MixEnvelop mcfRegister(BasePatientDO patientDO, String wechatId) throws Exception {
        BasePatientWechatDo patientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, patientDO.getId()).get(0);
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("mcf_config");
        TransResponse re= new TransResponse();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        try {
            TransRequest request = new TransRequest();
            request.setMethod("ehc.ehealthcard.register");
            request.setApp_id(oauthYlzConfigDO.getAppId());
            request.setTerm_id(oauthYlzConfigDO.getTermId());
            request.setVersion("X.M.0.1");
            request.setTimestamp(DateUtils.getOutTradeTime());
            request.setSign_type("RSA");
            request.setEnc_type("Plain");
            JSONObject bizContent = new JSONObject();
            bizContent.put("out_register_time", DateUtils.getOutTradeTime());
            bizContent.put("out_register_no", DateUtils.getOutTradeTime());
            bizContent.put("open_id", patientWechatDo.getOpenid());
            bizContent.put("account_id", "gh_a09552a72c9b");
            bizContent.put("certificate_mode", "01");
            bizContent.put("id_type", "01");
            bizContent.put("id_no", patientDO.getIdcard());
            bizContent.put("user_name", patientDO.getName());
            bizContent.put("birthday", patientDO.getBirthday());
            bizContent.put("address", patientDO.getAddress());
            bizContent.put("mobile_phone", patientDO.getMobile());
            bizContent.put("apply_method", "1");
            bizContent.put("user_sex", "1");
            bizContent.put("nation", "01");
            request.setBiz_content(JSONObject.toJSONString(bizContent));
            EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl()+"ehcweb/gateway.do", oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getPrivateKey(), oauthYlzConfigDO.getEhcPublicKey());
            re = ehcHandler.execute(request);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code_url",JSONObject.parseObject(re.getBiz_content()).getString("code_url"));
            String result = jsonObject.toJSONString().replaceAll("\\|888", "");
            if(result!=null){
                patientDO.setRegister("1");
                basePatientDao.save(patientDO);
                return MixEnvelop.getSuccess("注册成功",result);
            }
            return MixEnvelop.getError(JSONObject.parseObject(re.getRet_msg()).toString());
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(JSONObject.parseObject(re.getRet_msg()).toString());
        }
    }
//     根据openId、 accountId查询三码融合码信息
    public MixEnvelop mcfOpenquery(String openId,String accountId) throws Exception {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findOne("mcf_config");
            TransRequest request = new TransRequest();
            request.setMethod("ehc.ehealthcard.openquery");
            request.setApp_id(oauthYlzConfigDO.getAppId());
            request.setTerm_id(oauthYlzConfigDO.getTermId());
            request.setVersion("X.M.0.1");
            request.setTimestamp(DateUtils.getOutTradeTime());
            request.setSign_type("MD5");
            request.setEnc_type("Plain");
            JSONObject bizContent = new JSONObject();
            bizContent.put("open_id", openId);
            bizContent.put("account_id", accountId);
            request.setBiz_content(JSONObject.toJSONString(bizContent));
            EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl()+"ehcService/gateway.do", oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getAppKey());
            TransResponse re = ehcHandler.execute(request);
            if ("0000".equals(JSONObject.parseObject(re.getRet_code()))){
                String ehealth_card_id = JSONObject.parseObject(re.getBiz_content()).getString("ehealth_card_id").toString();
                if (ehealth_card_id!=null){
                    return MixEnvelop.getSuccess("查询用户信息成功",ehealth_card_id);
                }
            }
        return MixEnvelop.getError(JSONObject.parseObject(re.getRet_msg()).toString());
    }
//     获取展码地址
    public MixEnvelop mcfGetCodeUrl(String ehealth_card_id) throws Exception {
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("mcf_config");
        TransRequest request = new TransRequest();
        request.setMethod("ehc.ehealthcard.getCodeUrl");
        request.setApp_id(oauthYlzConfigDO.getAppId());
        request.setTerm_id(oauthYlzConfigDO.getTermId());
        request.setVersion("X.M.0.1");
        request.setTimestamp(DateUtils.getOutTradeTime());
        request.setSign_type("RSA");
        request.setEnc_type("Plain");
        JSONObject bizContent = new JSONObject();
        String no = UUID.randomUUID().toString();
        bizContent.put("ehealth_card_id",ehealth_card_id);
        bizContent.put("out_trade_no",no);
        bizContent.put("out_trade_time",DateUtils.getOutTradeTime());
        request.setBiz_content(JSONObject.toJSONString(bizContent));
        EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl()+"ehcweb/gateway.do", oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getPrivateKey(), oauthYlzConfigDO.getEhcPublicKey());
        TransResponse re = ehcHandler.execute(request);
        if ("0000".equalsIgnoreCase(re.getRet_code())){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code_url",JSONObject.parseObject(re.getBiz_content()).getString("code_url"));
            String code_url = jsonObject.toJSONString().replaceAll("\\|888", "");
            if (code_url!=null){
                return MixEnvelop.getSuccess("获取展码成功",code_url);
            }
        }
        return MixEnvelop.getError("获取展码失败");
    }
    //通过身边证查询用户信息
    public  TransResponse  mcfQueryInfo(String idType,String ID) throws Exception {
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("mcf_config");
        TransRequest request = new TransRequest();
        request.setMethod("ehc.ehealthcard.queryInfo");
        request.setApp_id(oauthYlzConfigDO.getAppId());
        request.setTerm_id(oauthYlzConfigDO.getTermId());
        request.setVersion("X.M.0.1");
        request.setTimestamp(DateUtils.getOutTradeTime());
        request.setSign_type("MD5");
        request.setEnc_type("Plain");
        JSONObject bizContent = new JSONObject();
        String no = UUID.randomUUID().toString();
        bizContent.put("id_type", idType);
        bizContent.put("id_no", ID);
        request.setBiz_content(JSONObject.toJSONString(bizContent));
        EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl()+"ehcService/gateway.do", oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getAppKey());
        TransResponse re = ehcHandler.execute(request);
        return re;
    }
    public MixEnvelop mcfQueryInfo(String ehealth_card_id ) throws Exception {
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("mcf_config");
        TransRequest request = new TransRequest();
        request.setMethod("ehc.ehealthcard.queryInfo");
        request.setApp_id(oauthYlzConfigDO.getAppId());
        request.setTerm_id(oauthYlzConfigDO.getTermId());
        request.setVersion("X.M.0.1");
        request.setTimestamp(DateUtils.getOutTradeTime());
        request.setSign_type("MD5");
        request.setEnc_type("Plain");
        JSONObject bizContent = new JSONObject();
        String no = UUID.randomUUID().toString();
        bizContent.put("ehealth_card_id",ehealth_card_id);
        request.setBiz_content(JSONObject.toJSONString(bizContent));
        EhcHandler ehcHandler = new EhcHandler(oauthYlzConfigDO.getUrl()+"ehcService/gateway.do", oauthYlzConfigDO.getAppId(), oauthYlzConfigDO.getTermId(), oauthYlzConfigDO.getAppKey());
        TransResponse re = ehcHandler.execute(request);
        if ("0000".equals(JSONObject.parseObject(re.getRet_code()))){
            return MixEnvelop.getSuccess("获取用户信息成功",re);
        }
        return MixEnvelop.getError("获取用户信息失败");
    }
}