Parcourir la source

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

yeshijie il y a 4 ans
Parent
commit
89593865c9
17 fichiers modifiés avec 838 ajouts et 96 suppressions
  1. 169 21
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 44 0
      business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java
  3. 60 4
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  4. 196 1
      business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java
  5. 8 1
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java
  6. 57 42
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  7. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  8. 9 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  9. 2 2
      server/svr-authentication/pom.xml
  10. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/sync/BaseSyncDataEndpoint.java
  11. 4 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java
  12. 40 8
      svr/svr-base/src/main/java/com/yihu/jw/base/service/sync/BaseSyncDataService.java
  13. 86 10
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java
  14. 1 0
      svr/svr-base/src/main/resources/application.yml
  15. 9 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  16. 109 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  17. 42 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

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

@ -10,12 +10,13 @@ import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorPatientDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorVo;
import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
@ -74,6 +75,8 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
@ -217,6 +220,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private BasePatientMedicareCardDao patientMedicareCardDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private BasePatientWechatDao patientWechatDao;
    @Value("${demo.flag}")
@ -3044,7 +3051,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    "WHERE " +
                    "a.relation_code=b.id " +
                    "AND b.doctor='"+doctor+"' " +
                    "GROUP BY a.score_type";
                    "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
            List<Map<String,Object>> listscore = jdbcTemplate.queryForList(sqlscore);
    
            Double doctorScore = new Double("0");
@ -3226,6 +3233,45 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            wlyyOutpatientDO.setDoctorCancelType(cancelType);
            wlyyOutpatientDO.setDoctorCancelValue(cancelValue);
            description = "医生拒绝接诊";
            //系统消息 医生取消复诊
            SystemMessageDO messageDO = new SystemMessageDO();
            messageDO.setTitle("医生取消复诊");
            messageDO.setType("12");
            messageDO.setSender(wlyyOutpatientDO.getDoctor());
            messageDO.setSenderName(wlyyOutpatientDO.getDoctorName());
            messageDO.setRelationCode(wlyyOutpatientDO.getId());
            messageDO.setReceiver(wlyyOutpatientDO.getPatient());
            messageDO.setReceiverName(wlyyOutpatientDO.getPatientName());
            net.sf.json.JSONObject data = new net.sf.json.JSONObject();
            try {
                data.put("name",wlyyOutpatientDO.getPatientName());
                data.put("age",IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("gender",IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                data.put("question",wlyyOutpatientDO.getIcd10Name());
                String msg="";
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","9");
                   msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","16");
                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
                }
                data.put("msg",msg);
                messageDO.setData(data.toString());
                systemMessageService.saveMessage(messageDO);
            } catch (Exception e) {
                e.printStackTrace();
            }
            //推送消息到眼科通
            BasePatientDO patient = basePatientDao.findById(wlyyOutpatientDO.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                ykyyService.pushNotificationToYktPatient(patient.getYktId(),messageDO.getTitle(),data.get("msg").toString());
            }
        }
        outpatientDao.save(wlyyOutpatientDO);
@ -3727,7 +3773,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " d.outpatient_type AS \"outpatientType\"," +
                " a.total AS \"consultTotal\"," +
                " h.org_name AS \"orgName\"," +
                " h.org_code AS \"orgCode\"" +
                " h.org_code AS \"orgCode\"," +
                " follow.id AS followid "+
                " FROM " +
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id "+
@ -3739,6 +3786,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if ("0".equalsIgnoreCase(isAttention)) {
            sql += " join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient !='" + patientid + "' ";
        }
        if (StringUtils.isEmpty(isAttention)){
            sql+=" LEFT  JOIN base_doctor_patient_follow follow ON follow.patient='"+patientid+"' AND follow.doctor = d.id ";
        }
        if(StringUtils.isNotBlank(diseaseKey)){
            sql+=" left join wlyy_doctor_special_disease sp on d.id = sp.doctor_code ";
        }
@ -3830,7 +3881,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);
        }
    
@ -4071,6 +4122,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("idcard",basePatientDO.getIdcard());
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("mobile",basePatientDO.getMobile());
        rs.put("photo",basePatientDO.getPhoto());
        rs.put("address",basePatientDO.getAddress());
        if (patientMedicareCardDO!=null){
            rs.put("ssc",patientMedicareCardDO.getCode());
        }else {
@ -4157,6 +4210,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("idcard",basePatientDO.getIdcard());
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("mobile",basePatientDO.getMobile());
        rs.put("photo",basePatientDO.getPhoto());
        rs.put("address",basePatientDO.getAddress());
        if (patientMedicareCardDO!=null){
            rs.put("ssc",patientMedicareCardDO.getCode());
        }else {
@ -4722,6 +4777,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            systemMessageService.saveMessage(systemMessageDO);
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                ykyyService.pushNotificationToYktPatient(patient.getYktId(),systemMessageDO.getTitle(),data.get("msg").toString());
            }
        }catch (Exception e){
            logger.error("sendOutPatientMes :"+e.toString());
            return null;
@ -4758,11 +4819,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            data.put("msg",msg);
            data.put("type",type);
            systemMessageDO.setData(data.toString());
            systemMessageService.saveMessage(systemMessageDO);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            ykyyService.pushNotificationToYktPatient(patient.getYktId(),systemMessageDO.getTitle(),data.get("msg").toString());
        }
    }
@ -5701,7 +5765,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());
@ -5716,7 +5780,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();
@ -5739,7 +5803,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) {
@ -5760,9 +5824,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            messageDO.setRelationCode(outpatientDO.getId()+","+wlyyPrescriptionDO.getId());
            messageDO.setReceiver(outpatientDO.getPatient());
            messageDO.setReceiverName(outpatientDO.getPatientName());
            JSONObject data = new JSONObject();
            try {
                JSONObject data = new JSONObject();
                data.put("name",outpatientDO.getPatientName());
                data.put("age", IdCardUtil.getAgeForIdcard(outpatientDO.getIdcard()));
                data.put("gender",IdCardUtil.getSexForIdcard_new(outpatientDO.getIdcard()));
@ -5771,9 +5834,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                data.put("msg",msg);
                messageDO.setData(data.toString());
                systemMessageService.saveMessage(messageDO);
            } catch (Exception e) {
                e.printStackTrace();
            }
            BasePatientDO patient = basePatientDao.findById(outpatientDO.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                ykyyService.pushNotificationToYktPatient(patient.getYktId(),messageDO.getTitle(),data.get("msg").toString());
            }
        }else{
            wlyyPrescriptionDO.setCheckStatus(status);
@ -6062,7 +6130,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");
@ -6088,16 +6161,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 {
@ -6129,7 +6230,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();
    }
@ -6405,6 +6510,49 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("address",baseOrgDO.getAddress());
        String distance = LatitudeUtils.getDistance(longitude, dimension, baseOrgDO.getLongitude(), baseOrgDO.getLatitude());
        rs.put("distance",distance);
        rs.put("longitude",baseOrgDO.getLongitude());
        rs.put("dimension",baseOrgDO.getLatitude());
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,rs);
    }
    public MixEnvelop selectByUrl(String prescriptionId,String wxId) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wxId);
        if (wxWechatDO==null){
            throw new Exception("微信配置不存在!");
        }
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
        if (prescriptionDO==null){
            throw new Exception("处方不存在!");
        }
        List<BasePatientWechatDo> patientWechatDos =patientWechatDao.findByWechatIdAndPatientId(wxId,prescriptionDO.getPatientCode());
        if (patientWechatDos==null||patientWechatDos.size()==0){
            throw new Exception("openid不存在!");
        }
        BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",prescriptionDO.getPatientCode(),"1");
        if (patientMedicareCardDO==null){
            throw new Exception("就诊卡不存在!");
        }
        String url = ylzPayService.createSicardPayUrl(wxWechatDO.getAppOriginId(),patientWechatDo.getOpenid(),patientMedicareCardDO.getCode(),"WX");
        com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(url);
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,object);
    }
    /**
     * 获取居民openId
     * @param patientCode
     * @return
     */
    public MixEnvelop findPatientOpenId(String patientCode) {
        BasePatientWechatDo basePatientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId, patientCode).get(0);
        if (basePatientWechatDo==null){
            return MixEnvelop.getError("居民不存在");
        }
        String openid = basePatientWechatDo.getOpenid();
        if (StringUtils.isEmpty(openid)){
            return MixEnvelop.getError("居民openID不存在");
        }
        return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find,openid);
    }
}

+ 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{

+ 57 - 42
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -29,6 +29,7 @@ import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.dao.ConsultTeamDoctorDao;
@ -119,6 +120,9 @@ public class ImService {
	
	@Autowired
	public WxAccessTokenService wxAccessTokenService;
	@Autowired
	private YkyyService ykyyService;
	
	@Value("${im.data_base_name}")
	private String data_base_name;
@ -201,8 +205,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," +
@ -1350,48 +1356,7 @@ public class ImService {
//		String response = imUtil.sendTopicIM(consultTeam.getDoctor(), doctor.getName(), consult, "28", evalueContent.toString(),null);
//		String response = imUtil.sendImMsg(consultTeam.getDoctor(), doctor.getName(), session_id, "28", evalueContent.toString(),null);
		//保存系统消息服务评价
		SystemMessageDO messageDO = new SystemMessageDO();
		messageDO.setType("10");
		messageDO.setTitle("服务评价");
		messageDO.setSender(doctor.getId());
		messageDO.setSenderName(doctor.getName());
		messageDO.setRelationCode(consult);
		messageDO.setReceiver(patient.getId());
		messageDO.setReceiverName(patient.getName());
		net.sf.json.JSONObject data = new net.sf.json.JSONObject();
		data.put("name",patient.getName());
		data.put("age",IdCardUtil.getAgeForIdcard(patient.getIdcard()));
		data.put("gender",patient.getSex().toString());
		data.put("question",consultTeam.getSymptoms());
		if (cons.getType()!=null&&1==cons.getType()){
			String msg =patient.getName()+ ",您好!您有1条图文咨询已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","1");
		}
		if (cons.getType()!=null&&9==cons.getType()){
			String msg=patient.getName()+ ",您好!您有1条图文复诊已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","9");
		}
		if (cons.getType()!=null&&16==cons.getType()){
			String msg=patient.getName()+ ",您好!您有1条视频复诊已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","16");
		}
		if (cons.getType()!=null&&17==cons.getType()){
			String msg=patient.getName()+ ",您好!您有1条视频咨询已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","17");
		}
		messageDO.setData(data.toString());
		try {
			systemMessageService.saveMessage(messageDO);
		} catch (Exception e) {
			e.printStackTrace();
		}
		systemMsgEvaluation(doctor,patient,cons,consultTeam,consult,wxId);
		String endName = "";
		String endId = "";
@ -1478,6 +1443,56 @@ public class ImService {
		return 1;
	}
	public void systemMsgEvaluation(BaseDoctorDO doctor,BasePatientDO patient,ConsultDo cons,ConsultTeamDo consultTeam ,String consult,String wxId){
		SystemMessageDO messageDO = new SystemMessageDO();
		messageDO.setType("10");
		messageDO.setTitle("服务评价");
		messageDO.setSender(doctor.getId());
		messageDO.setSenderName(doctor.getName());
		messageDO.setRelationCode(consult);
		messageDO.setReceiver(patient.getId());
		messageDO.setReceiverName(patient.getName());
		net.sf.json.JSONObject data = new net.sf.json.JSONObject();
		data.put("name",patient.getName());
		data.put("age",IdCardUtil.getAgeForIdcard(patient.getIdcard()));
		data.put("gender",patient.getSex().toString());
		data.put("question",consultTeam.getSymptoms());
		if (cons.getType()!=null&&1==cons.getType()){
			String msg =patient.getName()+ ",您好!您有1条图文咨询已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","1");
		}
		if (cons.getType()!=null&&9==cons.getType()){
			String msg=patient.getName()+ ",您好!您有1条图文复诊已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","9");
		}
		if (cons.getType()!=null&&16==cons.getType()){
			String msg=patient.getName()+ ",您好!您有1条视频复诊已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","16");
		}
		if (cons.getType()!=null&&17==cons.getType()){
			String msg=patient.getName()+ ",您好!您有1条视频咨询已结束,请及时对咨询医生进行评价。";
			data.put("msg",msg);
			data.put("type","17");
		}
		messageDO.setData(data.toString());
		try {
			systemMessageService.saveMessage(messageDO);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
			ykyyService.pushNotificationToYktPatient(patient.getYktId(),messageDO.getTitle(),data.get("msg").toString());
		}
	}
	
	/**
	 * 根据咨询CODE获取session_id

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

@ -25,7 +25,7 @@ public abstract class IntegerIdentityEntity implements Serializable {
//==========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;

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

@ -74,10 +74,15 @@ public class BaseHospitalRequestMapping {
         * 查询患者所有处方信息
         */
        public static final String findPatientAllPrescription = "/findPatientAllPrescription";
        /**
         * 查看取药地址
         */
        public static final String findDrugAddress = "/findDrugAddress";
        /**
         * 查询患者问诊信息
         */
        public static final String findPatientAllOutpatient = "/findPatientAllOutpatient";
        /**
@ -430,12 +435,16 @@ 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";
        public static final String findCommity="/findCommity";
        public static final String findProvince="/findProvince";
        public static final String findCity="/findCity";
        public static final String findPatientOpenId="/findPatientOpenId";
        public static final String selectByUrl="/selectByUrl";

+ 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>

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/sync/BaseSyncDataEndpoint.java

@ -48,7 +48,7 @@ public class BaseSyncDataEndpoint  extends EnvelopRestEndpoint {
                                           @RequestParam(value = "size") Integer size){
        try {
            return   baseSyncDataService.findAllSyncData(startTime,endTime,page,size);
            return   baseSyncDataService.findAllSyncData(startTime,endTime,page,size,wxId);
        }catch (Exception e){
            return PageEnvelop.getError(e.getMessage(),-1);
        }

+ 4 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -15,6 +15,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -31,6 +32,8 @@ public class WechatController extends EnvelopRestEndpoint {
    private WechatService wechatService;
    @Autowired
    private WxTemplateService wxTemplateService;
    @Value("${wechat.id}")
    private String wechatId;
    //====================微信与租户管理=======================
@ -48,7 +51,7 @@ public class WechatController extends EnvelopRestEndpoint {
                                                             @RequestParam(value = "page", required = true) Integer page,
                                                             @ApiParam(name = "size", value = "每页大小")
                                                             @RequestParam(value = "size", required = true) Integer size) {
        return wechatService.getWxWechatList(name, saasName, status, publicType, page, size);
        return wechatService.getWxWechatList(name, saasName, status, publicType, page, size,wechatId);
    }
    @PostMapping(value = BaseRequestMapping.WeChat.saveWxAndSaas)

+ 40 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/service/sync/BaseSyncDataService.java

@ -6,6 +6,7 @@ import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
@ -65,19 +66,50 @@ public class BaseSyncDataService extends BaseJpaService<BaseSyncDataDO, BaseSync
     * @param endTime
     * @return
     */
    public PageEnvelop findAllSyncData(String startTime, String endTime,Integer page,Integer size) {
    public PageEnvelop findAllSyncData(String startTime, String endTime,Integer page,Integer size,String wechatId) {
        StringBuffer sql= new StringBuffer("SELECT c.* FROM wlyy_data_sync c WHERE 1=1 ");
        StringBuffer sqlCount= new StringBuffer("SELECT COUNT(c.id) count FROM wlyy_data_sync c WHERE 1=1  ");
        if (StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            sql.append(" and c.complete_time BETWEEN ").append("'").append(startTime).append("'").append(" AND ").append("'").append(endTime).append("'");
            sqlCount.append(" and c.complete_time BETWEEN ").append("'").append(startTime).append("'").append(" AND ").append("'").append(endTime).append("'");
        }
        sql.append(" ORDER BY c.create_time DESC LIMIT ").append((page-1)*size).append(",").append(size);
        StringBuffer sqlCount= new StringBuffer();
        List<BaseSyncDataDO> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            sqlCount.append("SELECT COUNT(c.\"id\") AS count FROM wlyy_data_sync c WHERE 1=1  ");
//            AND  c."complete_time" BETWEEN to_date('2020-05-06 00:00:00','yyyy-mm-dd hh24:mi:ss') AND to_date('2020-08-06 00:00:00','yyyy-mm-dd hh24:mi:ss')
            sql.append("  AND  c.\"complete_time\" BETWEEN to_date('").append(startTime).append("00:00:00','yyyy-mm-dd hh24:mi:ss')  AND to_date('").append(endTime).append("23:59:59','yyyy-mm-dd hh24:mi:ss')");
            sqlCount.append("  AND  c.\"complete_time\" BETWEEN to_date('").append(startTime).append("00:00:00','yyyy-mm-dd hh24:mi:ss')  AND to_date('").append(endTime).append("23:59:59','yyyy-mm-dd hh24:mi:ss')");
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=sql;
            oracleSql+="ORDER BY c.\"create_time\" DESC";
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            logger.info("oracleSql="+oracleSql);
            list = jdbcTemplate.query(oracleSql, new BeanPropertyRowMapper<>(BaseSyncDataDO.class));
        }else {
            sqlCount.append("SELECT COUNT(c.id) AS count FROM wlyy_data_sync c WHERE 1=1  ");
            if (StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
                sql.append(" and c.complete_time BETWEEN ").append("'").append(startTime).append("'").append(" AND ").append("'").append(endTime).append("'");
                sqlCount.append(" and c.complete_time BETWEEN ").append("'").append(startTime).append("'").append(" AND ").append("'").append(endTime).append("'");
            }
            sql.append(" ORDER BY c.create_time DESC LIMIT ").append((page-1)*size).append(",").append(size);
            logger.info("sql="+sql);
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(BaseSyncDataDO.class));
        }
        List<BaseSyncDataDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(BaseSyncDataDO.class));
        logger.info("sqlCount="+sqlCount);
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sqlCount.toString());
        long count = Long.parseLong(mapList.get(0).get("count").toString());

+ 86 - 10
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -27,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
/**
 * Created by trick on 2017/5/20
@ -62,7 +63,7 @@ public class WechatService {
    //====================微信与租户管理=======================
    public MixEnvelop getWxWechatList(String name,String saasName,Integer status,Integer publicType,Integer page,Integer size){
    public MixEnvelop getWxWechatList(String name,String saasName,Integer status,Integer publicType,Integer page,Integer size,String wechatId){
        String sql = "SELECT " +
                " w.id AS \"id\", " +
@ -72,7 +73,7 @@ public class WechatService {
                " w.public_type AS \"publicType\"," +
                " w.token AS \"token\"," +
                " w.enc_type AS \"encType\"," +
                " w.type as \"type\"," +
//                " w.type as \"type\"," +
                " w.app_id AS \"appId\"," +
                " w.app_secret AS \"appSecret\"," +
                " w.app_origin_id AS \"appOriginId\"," +
@ -106,8 +107,35 @@ public class WechatService {
        if (StringUtils.isNotBlank(saasName)) {
            sql += " AND bs.`name` like '%" + saasName + "%'";
        }
        sql += " LIMIT " + (page - 1) * size + "," + size + "";
        List<WxWechatVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxWechatVO.class));
        List<WxWechatVO> list =null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=sql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
            list = jdbcTemplate.query(oracleSql, new BeanPropertyRowMapper(WxWechatVO.class));
        }else {
            sql += " LIMIT " + (page - 1) * size + "," + size + "";
            Logger.getAnonymousLogger().info("sql="+sql);
            list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxWechatVO.class));
        }
        if(list!=null&&list.size()>0){
            for(WxWechatVO wx :list){
@ -146,7 +174,7 @@ public class WechatService {
    public List<WxSaasVO> getWxSaasVOs(String id){
        String sql ="SELECT " +
                " bs.`name` AS \"saasName\", " +
                " bs.name AS \"saasName\", " +
                " bs.id AS \"saasid\"" +
                " FROM " +
                " wx_wechat_saas s " +
@ -370,8 +398,33 @@ public class WechatService {
        if(StringUtils.isNotBlank(scene)){
            sql+= " AND g.scene = '"+scene+"' ORDER BY g.scene ASC ";
        }
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxGraphicMessageVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxGraphicMessageVO.class));
        List<WxReplySceneVO> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=sql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            list = jdbcTemplate.query(oracleSql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        }else {
            sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxGraphicMessageVO.class));
        }
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
    }
@ -492,7 +545,7 @@ public class WechatService {
                " s.wechat_id AS \"wechatId\"," +
                " s.scene AS \"scene\", " +
                " s.status as \"status\", " +
                " s.id as \"id\", " +
//                " s.id as \"id\", " +
                " s.content as \"content\", " +
                " s.app_origin_id AS \"appOriginId\", " +
                " s.event as \"event\", " +
@ -514,9 +567,32 @@ public class WechatService {
        if(status!=null){
            sql += " AND s.status = "+status;
        }
        sql+=" ORDER BY s.create_time DESC LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxReplySceneVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        List<WxReplySceneVO> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=sql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            list = jdbcTemplate.query(oracleSql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        }else {
            sql+=" ORDER BY s.create_time DESC LIMIT  " + (page - 1) * size + "," + size + "";
            list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        }
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
    }

+ 1 - 0
svr/svr-base/src/main/resources/application.yml

@ -293,6 +293,7 @@ hospital:
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
#  id: xm_ykyy_wx
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:

+ 9 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -14,6 +14,7 @@ import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
@ -97,7 +98,10 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private ConsultDao consultDao;
	
	@Autowired
	private YkyyService ykyyService;
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	
@ -440,6 +444,10 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
				data.put("msg",msg);
				systemMessageDO.setData(data.toString());
				systemMessageService.saveMessage(systemMessageDO);
				BasePatientDO patientDO = basePatientDao.findById(patient);
				if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
					ykyyService.pushNotificationToYktPatient(patientDO.getYktId(),systemMessageDO.getTitle(),data.get("msg").toString());
				}
			}
			//发送系统消息

+ 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;
    }
}

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

@ -34,12 +34,9 @@ import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -1586,6 +1583,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(
@ -1697,5 +1712,29 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        List<BaseCityDO> baseCitys = baseCityService.search(fields, filters, sorts);
        return success(baseCitys, BaseCityVO.class);
    }
    /**
     * 获取诊间支付url
     * @param prescriptionId
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.selectByUrl)
    @ApiOperation("获取诊间支付url")
    public ObjEnvelop selectByUrl(
            @ApiParam(name = "prescriptionId", value = "prescriptionId", required = true)
            @RequestParam(required = true)String prescriptionId) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.selectByUrl(prescriptionId,wxId));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findPatientOpenId)
    @ApiOperation(value = "获取居民OpenId")
    public MixEnvelop findCity (
            @ApiParam(name = "patientCode", value = "居民code")
            @RequestParam(value = "patientCode", required = false) String patientCode) throws Exception {
      return   prescriptionService.findPatientOpenId(patientCode);
    }
}