Explorar el Código

多码融合 第三次修改

mengkang hace 5 años
padre
commit
34b2dbd77c

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

@ -25,6 +25,7 @@ public class OauthYlzConfigDO extends UuidIdentityEntity {
//    @Column(name = "ehc_public_key")
    private String ehcPublicKey;
    public String getAppId() {
        return appId;
    }

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

@ -68,58 +68,50 @@ public class MultipleCoderController extends EnvelopRestEndpoint {
            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);
            logDO.setCode("ehc.ehealthcard.queryInfo");
            logDO.setName("查询多码融合信息");
            logDO.setPatient(patientId);
            String patient = JSONObject.toJSONString(patientDO);
            logDO.setRequest("patientDO="+patient);
            wlyyHttpLogDao.save(logDO);
            String result = multipleCodeService.mcfQueryInfo(patientDO);
            logDO.setResponse(result);
            logDO.setStatus("0");
            logDO.setCreateTime(DateUtil.getNowDate());
            wlyyHttpLogDao.save(logDO);
            if (patientDO!=null&&patientDO.getRegister().equalsIgnoreCase("0")&&result==null){
                //用户表没查询到注册信息
                    BasePatientWechatDo basePatientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, patientId).get(0);
                    if (basePatientWechatDo.getOpenid()!=null){
//                    有openid 去注册
                        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);
                        return MixEnvelop.getSuccess("获取注册链接成功",response);
                    } else {
//                    无openID
                        return  MixEnvelop.getError("获取注册链接失败",-1);
                    }
            } else {
                logDO.setCode("ehc.ehealthcard.register");
                logDO.setName("查询多码融合信息");
                logDO.setPatient(patientId);
                logDO.setRequest("patientId="+patientId+"&wechatId="+wechatId);
                wlyyHttpLogDao.save(logDO);
                envelop = multipleCodeService.mcfOpenquery(patientId, wechatId);
                Object obj = envelop.getObj();
                String response = JSONObject.toJSONString(obj);
                logDO.setResponse(response);
                logDO.setStatus("0");
                logDO.setCreateTime(DateUtil.getNowDate());
                wlyyHttpLogDao.save(logDO);
                if(envelop!=null){
                    return null;
                }
//                注册成功 返回空
                return null;
            }
            return envelop;
        } catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
//    @GetMapping(value = BaseRequestMapping.ThirdInterface.queryHealthIdCard)
//    @ApiOperation(value = "多码融合-查询用户是否注册成功")
//    public MixEnvelop queryE_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) {
//        MixEnvelop<Object, Object> envelop = new MixEnvelop<>();
//        try {
//            envelop = multipleCodeService.mcfOpenquery(patientId, wechatId);
//            return envelop;
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return envelop;
//    }
}

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

@ -34,7 +34,7 @@ import java.util.UUID;
public class MultipleCodeService {
    @Autowired
    private static OauthYlzConfigDao oauthYlzConfigDao;
    private  OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private BasePatientDao basePatientDao;
@ -174,7 +174,7 @@ public class MultipleCodeService {
        return null;
    }
//     获取展码地址
    public static String mcfGetCodeUrl(String ehealth_card_id) throws Exception {
    public  String mcfGetCodeUrl(String ehealth_card_id) throws Exception {
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("mcf_config");
        TransRequest request = new TransRequest();
        request.setMethod("ehc.ehealthcard.getCodeUrl");
@ -204,7 +204,7 @@ public class MultipleCodeService {
        return null;
    }
    //通过身边证查询用户信息
    public  TransResponse  mcfQueryInfo(String idType,String ID) throws Exception {
    public  String  mcfQueryInfo(BasePatientDO patientDO) throws Exception {
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("mcf_config");
        TransRequest request = new TransRequest();
        request.setMethod("ehc.ehealthcard.queryInfo");
@ -216,12 +216,65 @@ public class MultipleCodeService {
        request.setEnc_type("Plain");
        JSONObject bizContent = new JSONObject();
        String no = UUID.randomUUID().toString();
        bizContent.put("id_type", idType);
        bizContent.put("id_no", ID);
        bizContent.put("id_type", "01");
        bizContent.put("id_no", patientDO.getIdcard());
        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;
        JSONObject jsonObject = new JSONObject();
        if ((JSONObject.parseObject(re.getRet_code()).toJSONString()).equalsIgnoreCase("0000")){
            patientDO.setRegister("1");
            String idCard = JSONObject.parseObject(re.getBiz_content()).getString("id_no");
            if (idCard!=null)
            {
                patientDO.setIdcard(idCard);
            }
            String userName = JSONObject.parseObject(re.getBiz_content()).getString("user_name");
            if (userName!=null)
            {
                patientDO.setName(userName);
            }
            String userSex = JSONObject.parseObject(re.getBiz_content()).getString("user_sex");
            if (userSex!=null){
                patientDO.setSex(Integer.valueOf(userName));
            }
            String mobilePhone = JSONObject.parseObject(re.getBiz_content()).getString("mobile_phone");
            if (mobilePhone!=null){
                patientDO.setMobile(mobilePhone);
            }
            String birthday = JSONObject.parseObject(re.getBiz_content()).getString("birthday");
            if (birthday!=null){
                patientDO.setBirthday(DateUtil.strToDate(birthday));
            }
            String telephone = JSONObject.parseObject(re.getBiz_content()).getString("telephone");
            if (telephone!=null){
                patientDO.setPhone(telephone);
            }
            String address = JSONObject.parseObject(re.getBiz_content()).getString("address");
            if (address!=null){
                patientDO.setAddress(address);
            }
            basePatientDao.save(patientDO);
            jsonObject.put("register","1");
            String ehealthCardId = JSONObject.parseObject(re.getBiz_content()).getString("ehealth_card_id");
            WlyyHttpLogDO logDO = new WlyyHttpLogDO();
            logDO.setCode("ehc.ehealthcard.getCodeUr");
            logDO.setName("获取多码融合展示码");
            logDO.setPatient(patientDO.getId());
            logDO.setRequest("ehealthCardId="+ehealthCardId);
            String codeUrl = mcfGetCodeUrl(ehealthCardId);
            if (codeUrl!=null){
                logDO.setResponse(codeUrl);
                logDO.setStatus("0");
                logDO.setCreateTime(DateUtil.getNowDate());
                wlyyHttpLogDao.save(logDO);
                jsonObject.put("codeUrl",codeUrl);
                return codeUrl;
            }
        }
        return null;
    }
    public MixEnvelop mcfQueryInfo(String ehealth_card_id ) throws Exception {

+ 2 - 0
svr/svr-internet-hospital/src/main/resources/application.yml

@ -228,6 +228,8 @@ wlyy:
qywx:
  url: 2
  id: 1
wx:
  id: xm_ykyy_wx # base库中,wx_wechat 的id字段
---
spring:
  profiles: jwprod