Bladeren bron

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

mengkang 4 jaren geleden
bovenliggende
commit
f4264d7698

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

@ -3837,7 +3837,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
    
        if(StringUtils.isNotBlank(workingTime)){
            sql+=" AND wk.date = :workingTime ";
            sql+=" AND wk.work_date = :workingTime ";
            params.put("workingTime",workingTime);
        }
    
@ -5712,7 +5712,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            WlyyOutpatientDO outpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                try {
                    /*List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId,1);
                    List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId,1);
                    List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId,1);
                    DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
@ -5727,7 +5727,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        setInspectionParam(jsonData, doctorMappingDO, outpatientDO, wlyyPrescriptionDO, ins, outpatientDO.getIcd10());
                    }
                    Map<String,Object> map = sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);
                    if (map.get("code").toString().equalsIgnoreCase("0")){*/
                    if (map.get("code").toString().equalsIgnoreCase("0")){
                        //  * @param applyDepaName @param applyDoctorName
                        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
                        String patientCode = prescriptionDO.getPatientCode();
@ -5750,7 +5750,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        }
                        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patientCode,"1");
                        ylzPayService.msgPush("01",patientMedicareCardDO.getCode(),"01",patientDO.getMobile(),"03",userNo,userName,idcard,realerOrder,applyDepaName,applyDoctorName,recipeTime,free,"1");
                /*    }*/
                    }
                    //sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);
                } catch (Exception e) {
@ -6073,7 +6073,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    /**
     * 电子病历html
     * @param registerSn
     * @return
     * @throws Exception
     */
    public String readOutPatient(String registerSn) throws Exception {
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_URL");
@ -6099,16 +6104,44 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        XMLSerializer xmlSerializer = new XMLSerializer();
        net.sf.json.JSON json = xmlSerializer.read(returnValue);
        logger.info("返回json"+json);
        Object retInfo=  ((JSONObject) json).get("HtResponse");
        logger.info("retInfo:"+retInfo);
        if(retInfo!=null){
            JSONObject jsonObject = (JSONObject)retInfo;
            String content =jsonObject.getString("XML_CONT");
            Document doc = Jsoup.parse(content);
            Elements rows = doc.select("table[class=list]").get(0).select("tr");
        return json.toString();
    }
    /**
     * 电子病历xml
     * @param registerSn
     * @return
     * @throws Exception
     */
    public String readOutPatientXml(String registerSn) throws Exception {
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_URL");
        if (wlyyHospitalSysDictDO!=null){
            url = wlyyHospitalSysDictDO.getDictCode();
        }
        String xmlStr = "<?xml version=\"1.0\" encoding=\"GBK\"?>\n" +
                "<HtRequest>\n";
        xmlStr+="<REGISTER_SN>"+registerSn+"</REGISTER_SN>";
        String reqTime = DateUtil.dateToStr(new Date(),"yyyyMMddHHmmssSSS");
        xmlStr+="<REQ_TIME>"+reqTime+"</REQ_TIME>";
        xmlStr+="</HtRequest>";
        String returnValue = "";
        Map<String, String> params = new HashedMap();
        params.put("type","readOutPatientDetail");
        params.put("xmlStr",xmlStr);
        returnValue = com.yihu.jw.utils.WebserviceUtil.post(url,
                "http://business.htemr.haitaiinc.com",
                "manageOutRegister",
                params);
        return returnValue;
        logger.info("调用电子病历查询接口请求成功,返回值xmlstr:" + returnValue);
        XMLSerializer xmlSerializer = new XMLSerializer();
        net.sf.json.JSON json = xmlSerializer.read(returnValue);
        logger.info("返回json"+json);
        return json.toString();
    }
    public String writeOutPatient(String registerSn,String chiefComplaint,String hpi,String elapsemhis,String bodycheck,String assistanTcheck) throws Exception {
@ -6140,7 +6173,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                params);
        logger.info("调用电子病历写入接口请求成功,返回值xmlstr:" + returnValue);
        return returnValue;
        XMLSerializer xmlSerializer = new XMLSerializer();
        net.sf.json.JSON json = xmlSerializer.read(returnValue);
        logger.info("返回json"+json);
        return json.toString();
    }

+ 44 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java

@ -523,6 +523,50 @@ public class YkyyService {
    }
    /**
     * 推送眼科通居民消息
     * @param patientId 眼科通id对应patient表里的yktId
     * @param attach
     * @param pushcontent
     * @return
     */
    public String pushNotificationToYktPatient(String patientId,String attach,String pushcontent){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("patientId",patientId);
        jsonObject.put("attach",attach);
        jsonObject.put("pushcontent",pushcontent);
        String url = "http://www.yanketong.com:90/api/share/PushNotificationToPatient";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("推送眼科通消息:"+response);
        return response;
    }
    /**
     * 眼科通支付
     *
     * @param body
     * @param out_trade_no
     * @param total_fee
     * @param spbill_create_ip
     * @param notify_url
     * @return
     */
    public String getPayCDATA4Jkzl(String body,String out_trade_no,String total_fee,String spbill_create_ip,String notify_url){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("body",body);
        jsonObject.put("out_trade_no",out_trade_no);
        jsonObject.put("total_fee",total_fee);
        jsonObject.put("spbill_create_ip",spbill_create_ip);
        jsonObject.put("notify_url",notify_url);
        String url = "http://www.yanketong.com/api/Doctor/GetPayCDATA4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("眼科通支付:"+response);
        return response;
    }

+ 60 - 4
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -897,12 +897,12 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    /**
     *
     * @param traceNo
     * @param orderNo
     * @return
     */
    public BusinessOrderDO updatePayStatus(String traceNo) throws Exception {
        logger.info("入参:"+traceNo);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(traceNo);
    public BusinessOrderDO updatePayStatus(String orderNo) throws Exception {
        logger.info("入参:"+orderNo);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if (businessOrderDO==null){
            throw new Exception("查不到订单!");
        }
@ -949,4 +949,60 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        return object;
    }
    /**
     * 预交金支付
     * @param code
     * @param depositType
     * @param wechatId
     * @return
     * @throws Exception
     */
    public String ylzRechargeJson(String code,String depositType,String wechatId,String cardType,String cardNo) throws Exception {
        String response = null;
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if(wxWechatDO==null){
            throw new Exception("can't find wechat:the wxId is "+wechatId);
        }
        WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL");
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(code);
        if (businessOrderDO!=null){
            BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
            String idcard = "";
            String ssc = "";
            if (patientDO!=null){
                idcard = patientDO.getIdcard();
            }
            String openId = "";
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                openId = patientWechatDo.getOpenid();
            }
            String price = businessOrderDO.getPayPrice().toString();
            String notifyUrl = hospitalSysDictDO.getDictCode();
            response = ylzPayService.recharge("123456",businessOrderDO.getPatientName(),cardType,"01",cardNo,idcard,depositType,price,businessOrderDO.getOrderNo(),openId,patientDO.getName(),notifyUrl);
            if (depositType.equalsIgnoreCase("WX_QR")){
                JSONObject object = JSONObject.parseObject(response);
                if (object!=null){
                    JSONObject jsonObject = object.getJSONObject("param");
                    if (object.getString("respCode").equalsIgnoreCase("000000")){
                        InputStream qrcode = QrcodeUtil.createQrcode(jsonObject.getString("qrcode"),300,"jpg");
                        ByteToInputStream byteToInputStream = new ByteToInputStream();
                        String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                        jsonObject.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                        String traceNo = jsonObject.getString("traceNo");
                        businessOrderDO.setTraceNo(traceNo);
                        businessOrderDao.save(businessOrderDO);
                    }
                    response = object.toJSONString();
                }
            }
        }else {
            return "找不到订单!";
        }
        return response;
    }
}

+ 196 - 1
business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java

@ -11,6 +11,7 @@ import com.ylzinfo.onepay.sdk.HisOnepayClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ext.*;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -343,7 +344,201 @@ public class YlzPayService {
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.mmpay.msg.push", "互联网医院消息推送", "POST", null,JSON.toJSONString(jsonObject), object, error,logService.pushType);
        logService.saveHttpLog(isSuccess, "hop.mmpay.sicard.url", "互联网医院支付地址", "POST", null,JSON.toJSONString(jsonObject), object, error,logService.pushType);
        return object;
    }
//============================================预交金充值 start======================================================
    /**
     * 预交金充值支付
     *
     * @param operatorId 操作员编码
     * @param operatorName  操作员姓名
     * @param cardType 卡类型
     * @param accountType 账户类型
     * @param cardNo 卡号
     * @param idNo 身份证号
     * @param depositType 充值方式 WX_PUB
     * @param amount 充值金额
     * @param outChargeNo 商户充值业务流水号
     * @param userName 用户姓名
     * @param openId 微信公共号支付需入参openId
     * @return
     */
    public String recharge(String operatorId,String operatorName,String cardType,String accountType,String cardNo,String idNo,String depositType,String amount,String outChargeNo,String openId,String userName,String notifyUrl){
        Boolean isSuccess = true;
        String jsonObject = null;
        RechargeParams param = new RechargeParams();
        String error = null;
        try {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
            if(oauthYlzConfigDO==null){
                return "未找到支付配置文件";
            }
            String appId = oauthYlzConfigDO.getAppId();
            String appSecret = oauthYlzConfigDO.getAppKey();
            String onepayUrl = oauthYlzConfigDO.getUrl();
            String signType=oauthYlzConfigDO.getSignType();
            String encryptType = oauthYlzConfigDO.getEncType();
            HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setCardType(cardType);
            param.setAccountType(accountType);
            param.setCardNo(cardNo);
            param.setIdNo(idNo);
            param.setDepositType(depositType);
            param.setAmount(amount);
            param.setOutChargeNo(outChargeNo);
            param.setUserName(userName);
            Map<String, String> extra = new HashedMap();
            if(StringUtils.isNoneBlank(openId)){
                extra.put("openId",openId);
            }
		/*	String value = systemDictDao.findByDictNameAndCode("RETURN_URL","RETURN_URL");
			extra.put("returnUrl",value);*/
            extra.put("notifyUrl", notifyUrl);
            param.setExtra(extra);
            ResponseParams<RechargeResult> respnse = onepayClient.recharge(param);
            if (respnse.getRespCode().equals("000000")){
                jsonObject = JSON.toJSONString(respnse);
            }else {
                isSuccess = false;
                jsonObject = JSON.toJSONString(respnse);
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
            if (respnse!=null){
            }
        } catch (Exception e) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.recharge", "互联网预交金充值", "POST", null,JSON.toJSONString(param), jsonObject, error,logService.shoppatType);
        return jsonObject;
    }
    /**
     *
     * 预交金退款
     *
     * @param operatorId 操作者id
     * @param operatorName 操作者名字
     * @param cardType 卡类型
     * @param accountType 账号类型
     * @param cardNo 卡号
     * @param idNo 身份证号
     * @param amount 退款金额
     * @param outChargeNo 原充值订单号
     * @param userName 用户名字
     * @param withdrawMode 退款方式         0 现金退回1 原路退回2 银企转账3 医保自费退回
     * @param traceNo 平台交易跟踪号
     * @param outRefundNo 退款订单号
     * @return
     */
    public String refund(String operatorId,String operatorName,String cardType,String accountType,String cardNo,String idNo,String amount,String outChargeNo,String userName,String withdrawMode,String traceNo,String outRefundNo,String hisCustId){
        Boolean isSuccess = true;
        String jsonObject = null;
        RefundParams param = new RefundParams();
        String error = null;
        try {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
            if(oauthYlzConfigDO==null){
                return "未找到支付配置文件";
            }
            String appId = oauthYlzConfigDO.getAppId();
            String appSecret = oauthYlzConfigDO.getAppKey();
            String onepayUrl = oauthYlzConfigDO.getUrl();
            String signType=oauthYlzConfigDO.getSignType();
            String encryptType = oauthYlzConfigDO.getEncType();
            HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setOutChargeNo(outChargeNo);
            param.setCardType(cardType);
            param.setCardNo(cardNo);
            param.setAccountType(accountType);
            param.setAmount(amount);
            param.setWithdrawMode(withdrawMode);
            param.setOutChargeNo(outChargeNo);
            param.setTraceNo(traceNo);
            param.setOutRefundNo(outRefundNo);
            param.setHisCustId(hisCustId);
            param.setIdNo(idNo);
            param.setUserName(userName);
            ResponseParams<RefundResult> respnse = onepayClient.refund(param);
            if (respnse.getRespCode().equals("000000")){
                jsonObject = JSON.toJSONString(respnse);
            }else {
                jsonObject = JSON.toJSONString(respnse);
                isSuccess = false;
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
        } catch (Exception e) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.refund", "互联网预交金退款", "POST", null,JSON.toJSONString(param), jsonObject, error, logService.shoppatType);
        return jsonObject;
    }
    /**
     * 预交金查询余额
     *
     * @param operatorId
     * @param operatorName
     * @param termNo
     * @param tradeType
     * @param outTradeNo
     * @param traceNo
     * @return
     */
    public String ylzTradeQuery(String operatorId,String operatorName,String termNo,String tradeType,String outTradeNo,String traceNo){
        Boolean isSuccess = true;
        String jsonObject = null;
        TradeQueryParams param = new TradeQueryParams();
        String error = null;
        try {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
            if(oauthYlzConfigDO==null){
                return "未找到支付配置文件";
            }
            String appId = oauthYlzConfigDO.getAppId();
            String appSecret = oauthYlzConfigDO.getAppKey();
            String onepayUrl = oauthYlzConfigDO.getUrl();
            String signType=oauthYlzConfigDO.getSignType();
            String encryptType = oauthYlzConfigDO.getEncType();
            HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setTradeType(tradeType);
            param.setOutTradeNo(outTradeNo);
            param.setTraceNo(traceNo);
            ResponseParams<TradeQueryResult> respnse = onepayClient.tradeQuery(param);
            if (respnse.getRespCode().equals("000000")){
                jsonObject = JSON.toJSONString(respnse);
            }else {
                isSuccess = false;
                jsonObject = JSON.toJSONString(respnse);
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
        } catch (Exception e) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.query", "互联网预交金查询", "POST", null,JSON.toJSONString(param), jsonObject, error,logService.shoppatType);
        return jsonObject;
    }
//============================================预交金充值 end======================================================
}

+ 8 - 1
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -87,7 +87,14 @@ public class WechatInfoService {
            
            //中山医院互联网医院
            if("xm_zsyy_wx".equals(wxId)) {
                token = entranceService.getAccessToken("100033");
                String response = entranceService.getAccessToken("100033");
                net.sf.json.JSONObject object1 = net.sf.json.JSONObject.fromObject(response);
                if (null != object1&&null!=object1.get("respCode") && "00".equals(object1.get("respCode"))) {
                    token  = object1.getJSONObject("respEntity").getString("access_token");
                } else {
                    throw new Exception("获取ACCESSTOKEN失败");
                }
            }else if("xm_xzzx_wx".equals(wxId)){
                token = xzzxEntranceService.getXzToken();
            }else{

+ 2 - 0
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -201,8 +201,10 @@ public class ImService {
				"b.evaluate AS \"evaluate\"," +
				"d.name AS \"doctorName\"," +
				"d.photo AS \"doctorphoto\"," +
				"d.id AS \"doctorCode\"," +
				"d.job_title_name AS \"jobTitleName\", " +
				"h.dept_name AS \"deptName\", " +
				"h.org_name AS \"hospitalName\", " +
				"a.pay_status AS \"payStatus\" "+
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -19,13 +19,13 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
/*    @GeneratedValue(generator = "generator")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)*/
    @Column(name = "id", unique = true, nullable = false)
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
  /*  @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -435,6 +435,7 @@ public class BaseHospitalRequestMapping {
        public static final String attentionDoctor="/attentionDoctor";
        public static final String findAllAttentionDoctor="/findAllAttentionDoctor";
        public static final String findHisEmr="/findHisEmr";
        public static final String findHisEmrXml= "/findHisEmrXml";
        public static final String findTown="/findTown";

+ 2 - 2
server/svr-authentication/pom.xml

@ -93,7 +93,7 @@
        <!-- Redis  -->
        <!-- JdbcTemplate-->
        <dependency>
      <!--  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
@ -105,7 +105,7 @@
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
        </dependency>
        </dependency>-->
        <!-- JdbcTemplate-->
        <dependency>

+ 109 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -20,6 +20,7 @@ import com.yihu.jw.hospital.service.consult.SysDictService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
@ -31,9 +32,12 @@ import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.ylzinfo.onepay.sdk.OnepayClient;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.WebHook;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.SecurityUtil;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -100,6 +104,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private PayLogService logService;
@ -453,4 +459,107 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        return appId;
    }
    @RequestMapping(value = "/receiveNotify")
    @ApiOperation("支付回调")
    public String receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, IOException {
        response.setContentType("text/html;charset=utf-8");
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
        if(oauthYlzConfigDO==null){
            return "未找到支付配置文件";
        }
        String appId = oauthYlzConfigDO.getAppId();
        String appSecret = oauthYlzConfigDO.getAppKey();
        InputStream inputStream = request.getInputStream();
        logger.info("转换前的回调参数:"+inputStream);
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        // 回调参数:{"appId":"1A3VL0KVK0000B020A0A0000CC3F48AD","encryptData":"qPebDp0xBA/0qdr2lDvY2zBp2kB5em5GOr29y7o2WnHvm0tswnbyxDjCIUGI74yNGWFyCeJfeU5A\nK+Zr/yPs6nnsyzIFTSSljrKZCkzgbj3mjMax/3NzByfvE7R2MO+fljJUYqE93AvuRDc1wcdSUuKK\nmcryOvaU","encryptType":"DES","sign":"24635D0085CC72447657BD0713F0FB7C","signType":"MD5","timestamp":"20161018171127869","transType":"charge.success"}
        logger.info("回调参数:{}", params);
        if (StringUtil.isEmpty(params)) {
            response.getWriter().write("empty");
            return null;
        }
        // 参数转换
        ResponseParams<?> res = JSON.parseObject(params, ResponseParams.class);
        // 解密报文
        System.out.println("解密前报文:" + JSONObject.toJSONString(res.getEncryptData()));
        String decryptData;
        ResponseParams<WebHook> responseParams = new ResponseParams<WebHook>();
        WebHook webhook = new WebHook();
        try {
            decryptData = SecurityUtil.decrypt(res.getEncryptData(), res.getEncryptType(), appSecret, appId);
            System.out.println("解密后报文:" + decryptData);
            webhook = JSON.parseObject(decryptData, WebHook.class);
            // 参数转换
            responseParams.setAppId(appId);
            responseParams.setSign(res.getSign());
            responseParams.setSignType(res.getSignType());
            responseParams.setEncryptType(res.getEncryptType());
            responseParams.setTimestamp(res.getTimestamp());
            responseParams.setRespCode(res.getRespCode());
            responseParams.setRespMsg(res.getRespMsg());
            responseParams.setPageParams(res.getPageParams());
            responseParams.setTransType(res.getTransType());
            // 解密后设置param
            responseParams.setParam(webhook);
        } catch (Exception e1) {
            logger.error("解密回调报文错误");
            response.getWriter().write("ERROR:" + e1.getMessage());
        }
        OnepayClient payService = new OnepayClient("", appId, appSecret, res.getSignType(), res.getEncryptType());
        boolean isSuccess = false;
        String jsonObject = null;
        String error = null;
        try {
            // boolean isVerify = payService.verifyResponseSign(responseParams);
            boolean isVerify = payService.verifyResponseSign(responseParams);
            //boolean isVerify = true;
            isSuccess = true;
            jsonObject = isVerify+"";
            logger.info("验签结果:{}", isVerify);
            if (isVerify) {
                if (responseParams.getTransType().equalsIgnoreCase("charge.success")){
                    if (webhook!=null){
                        String outChargeNo = webhook.getOutChargeNo();
                        //im处方发消息
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(outChargeNo);
                        if (businessOrderDO.getStatus()!=1){
                            if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(businessOrderDO.getRelationCode());
                                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                                logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());
                                WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                                for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                                    JSONObject jsonObject1 = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                                    logger.info("wlyyPrescriptionInfoDO参数入参"+jsonObject1.toJSONString());
                                    WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject1,WlyyPrescriptionInfoVO.class);
                                    wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                                }
                                prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                                prescriptionVO.setPayStatus(1);
                                imService.pushPrescriptionImMessage(prescriptionVO);
                            }
                        }
                        businessOrderService.updatePayStatus(outChargeNo);
                    }
                }
                response.getWriter().write("SUCCESS");
            } else {
                response.getWriter().write("FAIL");
            }
        } catch (Exception e) {
            error = e.getMessage();
            response.getWriter().write(e.getMessage());
        }
        logService.saveHttpLog(isSuccess, "hop.trade.verifyResponseSign", "支付回调", "POST", null,JSON.toJSONString(responseParams), jsonObject, error,logService.shoppatType);
        return appId;
    }
}

+ 18 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -1586,6 +1586,24 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        }
    }
    /**
     * 查询his电子病历
     * @param registerSn
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.findHisEmrXml)
    @ApiOperation("查询电子病历")
    public ObjEnvelop findHisEmrXml(
            @ApiParam(name = "registerSn", value = "registerSn", required = true)
            @RequestParam(required = true)String registerSn) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.readOutPatientXml(registerSn));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.saveEmr)
    @ApiOperation("写入his电子病历")
    public ObjEnvelop findHisEmr(