Преглед изворни кода

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
#	svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/XzzxCotroller.java
wangzhinan пре 4 година
родитељ
комит
18edcea85c

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -99,6 +99,7 @@ import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@ -258,6 +259,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private EnterpriseService enterpriseService;
    @Autowired
    private PrescriptionDiagnosisDao  prescriptionDiagnosisDao;
    @Autowired
    private XzyyPrescriptionService xzyyPrescriptionService;
@ -7484,6 +7487,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        wlyyPrescriptionDO.setSerialNo(outpatientDO.getAdmNo());
                        wlyyPrescriptionDO.setRealOrder(realOrder);
                    }
                    logger.info("进入处方签名");
                    //处方签名
                    xzyyPrescriptionService.SOF_SignDataWithExtraInfo(wlyyPrescriptionDO);
                    //同步电子病历
                    WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
                    if (prescriptionEmrDO != null) {
                        logger.info("电子病历签名");
                        xzyyPrescriptionService.SOF_SignDataWithExtraInfoEmr(wlyyPrescriptionDO);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

+ 181 - 8
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/XzyyPrescriptionService.java

@ -4,22 +4,21 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.ca.OauthCaConfigDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPatientRegisterDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PatientRegisterDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -58,6 +57,21 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OauthCaConfigDao oauthCaConfigDao;
    @Autowired
    private PrescriptionInfoDao infoDao;
    @Autowired
    private PrescriptionDiagnosisDao diagnosisDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionEmrDao prescriptionEmrDao;
    /**
     * 挂号接口
@ -219,4 +233,163 @@ public class XzyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        }
        return  object;
    }
    /**
     * 处方签名
     * @param prescriptionDO
     * @throws Exception
     */
    public void SOF_SignDataWithExtraInfo(WlyyPrescriptionDO prescriptionDO) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
        List<WlyyPrescriptionInfoDO> infoDOS = infoDao.findByPrescriptionId(prescriptionDO.getId(), 1);
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOS = diagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
        JSONObject object = new JSONObject();
        object.put("infos",infoDOS);
        object.put("registerSn",outpatientDO.getRegisterNo());
        object.put("diagnosiss",diagnosisDOS);
        JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
        String hashValue = null;
        String hashType = null;
        if (jsonObject.getString("status").equalsIgnoreCase("0")){
            JSONObject data = jsonObject.getJSONObject("data");
            hashValue= data.getString("hashValue");
            hashType = data.getString("hashType");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
        BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
        if (patientDO!=null&&doctorDO!=null){
            String patientName = patientDO.getName();
            Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
            String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
            String openId = doctorDO.getOpenid();
            String idcard = patientDO.getIdcard();
            if (hashType!=null&&hashValue!=null){
                JSONObject object1 = synRecipeInfo("2017070411003376","hash_004","2017070411003360",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
                if (object1.getString("status").equalsIgnoreCase("0")){
                    logger.info("西药处方签名成功"+object1);
                }
            }
        }
    }
    /**
     * 处方签名
     * @param prescriptionDO
     * @throws Exception
     */
    public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionDO prescriptionDO) throws Exception {
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
        WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionDO.getId());
        JSONObject object = new JSONObject();
        object.put("emr",prescriptionEmrDO);
        object.put("registerSn",outpatientDO.getRegisterNo());
        object.put("doctorName",outpatientDO.getDoctorName());
        object.put("patientName",outpatientDO.getPatientName());
        JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
        String hashValue = null;
        String hashType = null;
        if (jsonObject.getString("status").equalsIgnoreCase("0")){
            JSONObject data = jsonObject.getJSONObject("data");
            hashValue= data.getString("hashValue");
            hashType = data.getString("hashType");
        }
        BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient());
        BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
        if (patientDO!=null&&doctorDO!=null){
            String patientName = patientDO.getName();
            Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
            String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
            String openId = doctorDO.getOpenid();
            String idcard = patientDO.getIdcard();
            if (hashType!=null&&hashValue!=null){
                JSONObject object1 = synRecipeInfo("2017070411003376","hash_002","2017070411003360",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
                if (object1.getString("status").equalsIgnoreCase("0")){
                    logger.info("门诊病历签名成功"+object1);
                }
            }
        }
    }
    /**
     * 数据哈希计算接口
     * @param content
     * @return
     */
    public JSONObject computeDigestForAlg(String content){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/common/computeDigestForAlg";
            }
            JSONObject object = new JSONObject();
            object.put("originData",content);
            String response = httpClientUtil.sendPost(url,object.toJSONString());
            logger.info("数据哈希计算接口 :"+response);
            return JSONObject.parseObject(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /***
     * 数据签名接口
     * @param clientId 第三方厂商标识
     * @param templateId 模板ID签名数据摘要数据类型
     * @param clientSecret 第三方厂商秘钥
     * @param urId 签名流水ID
     * @param patientName 患者姓名
     * @param patientAge 患者年龄
     * @param patientSex 患者性别
     * @param patientCardType  证件类型
     * @param recipeTime 开具时间
     * @param hashValue Hash原文(从签名指纹接口结果中得到的)
     * @param hashType Hash算法(从签名指纹接口结果中得到的)
     * @return
     */
    public JSONObject synRecipeInfo(String clientId,String templateId,String clientSecret,String urId,String patientName,String patientAge,String patientSex,String patientCardType,String recipeTime,String hashValue,String hashType,String openId,String patientCard){
        try {
            OauthCaConfigDO oauthCaConfigDO = oauthCaConfigDao.findOne("oauth_ca_config");
            String url = "";
            if (oauthCaConfigDO!=null){
                url=oauthCaConfigDO.getUrl()+"/gateway/recipe/synRecipeInfo";
            }
            JSONObject object = new JSONObject();
            JSONObject msg = new JSONObject();
            JSONObject head = new JSONObject();
            head.put("clientId",clientId);
            head.put("templateId",templateId);
            head.put("clientSecret",clientSecret);
            head.put("selfSign",true);
            msg.put("head",head);
            JSONObject body = new JSONObject();
            body.put("urId",urId);
            body.put("patientName",patientName);
            body.put("patientAge",patientAge);
            body.put("patientSex",patientSex);
            body.put("patientCardType",patientCardType);
            body.put("recipeTime",recipeTime);
            body.put("hashValue",hashValue);
            body.put("hashType",hashType);
            body.put("patientCard",patientCard);
            body.put("openId",openId);
            msg.put("body",body);
            object.put("msg",msg);
            object.put("signType",4);
            logger.info("请求参数:"+object);
            String response = httpClientUtil.sendPost(url,object.toJSONString());
            logger.info("数据签名接口 :"+response);
            return JSONObject.parseObject(response);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}

+ 3 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -957,6 +957,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new InvalidRequestException("client_id is null");
        }
        String username = null;
        String openId= null;
        JSONObject rs = new JSONObject();
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            rs = oauthCaConfigSerivce.getQueryQRCode(qrcode);
@ -975,12 +976,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                return ObjEnvelop.getSuccess("error",rs);
            }
            username = jsonObject.getString("userIdcardNum");
            openId = jsonObject.getString("uniqueid");
            jsonObject.put("qrCodeStatus","LoginQrCodeBeenScan");
            rs.put("code",1000);
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(username)){
            BaseDoctorDO doctorDO = doctorDao.findByIdcard(username);
            doctorDO.setOpenid(openId);
            doctorDO.setCaFlag(1);
            doctorDao.save(doctorDO);
        }