Explorar o código

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

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
wangzhinan %!s(int64=4) %!d(string=hai) anos
pai
achega
a81a7e88b1
Modificáronse 13 ficheiros con 456 adicións e 532 borrados
  1. 4 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  2. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatAppointmentDao.java
  3. 18 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PayInfoNoticeService.java
  4. 307 442
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  5. 0 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  6. 1 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/MqSdkUtil.java
  7. 8 1
      business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java
  8. 3 3
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  9. 45 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java
  10. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  11. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  12. 45 30
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  13. 20 48
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -90,6 +90,10 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                }
                basePatientDO.setMobile(phoneNum);
            }
        }else{
            if(basePatientDO==null){
                basePatientDO = new BasePatientDO();
            }
        }
        Map<String,Object> resultMap = new HashMap<>();
        PatientMappingDO patientMappingDO = patientMappingDao.findByIdcard(idCard);

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

@ -13,6 +13,9 @@ public interface BaseNatAppointmentDao extends PagingAndSortingRepository<BaseNa
    @Query("from BaseNatAppointmentDO t where t.payStatus = 0 ")
    List<BaseNatAppointmentDO> findByPayStatus();
    @Query("from BaseNatAppointmentDO t where t.payStatus = 0 and t.isSuccess=1 and t.patientId=?1")
    List<BaseNatAppointmentDO> findPayStatusByPatientId(String patientId);
    @Query("select a from BaseNatAppointmentDO a where  a.realOrder =?1 ")
    List<BaseNatAppointmentDO> findByRealOrderList(String realOrder);

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

@ -71,6 +71,24 @@ public class PayInfoNoticeService {
        return null;
    }
    public String pushMessagePayBefore(String patient,String doctorName,String orderNo,String id,String total,String title,String url,String realOrder){
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO!=null){
            String userName = patientDO.getName();
            String idcard = patientDO.getIdcard();
            String phone = patientDO.getMobile();
            if (!StringUtils.isNotBlank(url)){
                url = "https://hlwyy.xmzsh.com/hlwyy/ims-wx/#/nucleicTest/detail?id="+id;
            }
            String remark = "结算方式:微信结算 \r\n" +
                    "发票流水号:"+realOrder+"\r\n"+
                    "点击查看核酸预约开单信息";
            return paySuccessNotice(userName,idcard,phone,title,url,doctorName,total,"0",total,orderNo,remark);
        }
        return null;
    }
    /**
     * 支付成功提醒
     * @param userName 用户名 (不能为空)

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

@ -78,12 +78,9 @@ import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.utils.CheckSumBuilder;
import com.yihu.jw.utils.GenerateUserSig;
import com.yihu.jw.utils.PinYinUtils;
import com.yihu.jw.utils.*;
import com.yihu.jw.utils.Pkis.PKIService_PortType;
import com.yihu.jw.utils.Pkis.PKIService_ServiceLocator;
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;
@ -274,6 +271,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private YxTokenMappingDao yxTokenMappingDao;
    @Autowired
    private BaseNatAppointmentDao baseNatAppointmentDao;
    @Autowired
    private PayInfoNoticeService payInfoNoticeService;
@ -8265,7 +8264,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        if ("0".equals(rsCode)) {
                            free = res.getString("@total_charge");
                        }
                        ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1");
                        ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1","WX_PUB");
                    }else {
                        throw new Exception(map.get("mes").toString());
                    }
@ -8363,7 +8362,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                                if ("0".equals(rsCode)) {
                                    free = res.getString("@total_charge");
                                }*/
                                ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, "", "");
                                ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, "", "","WX_PUB");
                            }
                        }
                    } catch (Exception e) {
@ -10458,207 +10457,254 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return null;
    }
    public Map saveNatAppointment(String mediaCard,String patientId,String name,String cardNo,String cardType,String mobile,
                                   String firstJobCode,String firstJobName,String secondJobCode,String secondJobName,String natTime,String address,String provinceName,String cityName,String townName,String streetName,String pm) throws Exception {
        BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
        baseNatAppointmentDO.setMedicare(mediaCard);
        baseNatAppointmentDO.setName(name);
        baseNatAppointmentDO.setCardNo(cardNo);
        baseNatAppointmentDO.setCardType(cardType);
        baseNatAppointmentDO.setAddress(address);
        baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
        baseNatAppointmentDO.setCityName(cityName);
        baseNatAppointmentDO.setFirstJobCode(firstJobCode);
        baseNatAppointmentDO.setFirstJobName(firstJobName);
        baseNatAppointmentDO.setSecondJobCode(secondJobCode);
        baseNatAppointmentDO.setSecondJobName(secondJobName);
        baseNatAppointmentDO.setProvinceName(provinceName);
        baseNatAppointmentDO.setTownName(townName);
        baseNatAppointmentDO.setStreetName(streetName);
        baseNatAppointmentDO.setPatientId(patientId);
        baseNatAppointmentDO.setIsSuccess("0");
        baseNatAppointmentDO.setPayStatus("0");
        baseNatAppointmentDO.setCreateTime(new Date());
        baseNatAppointmentDO.setMobile(mobile);
        baseNatAppointmentDO.setInspectionCode("鼻/咽拭子");
        baseNatAppointmentDO.setInspectionName("鼻/咽拭子");
        baseNatAppointmentDO.setIcdCode("Z00.000");
        baseNatAppointmentDO.setChargeCode("361322");
        baseNatAppointmentDO.setWinNo("6");
        baseNatAppointmentDO.setDept("3150000");
        baseNatAppointmentDO.setDeptName("感染疾病科");
        baseNatAppointmentDO.setAmpm(pm);
        baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                                   String firstJobCode,String firstJobName,String secondJobCode,String secondJobName,String natTime,String address,String provinceName,String cityName,String townName,String streetName,String pm,String pushChannel,String pushFlag) throws Exception {
        Map returnMap = new HashMap();
        net.sf.json.JSONObject jsondate = new JSONObject();
        jsondate.put("checkPart","鼻/咽拭子");
        jsondate.put("cardNo",mediaCard);
        jsondate.put("chargeFlag","2");
        jsondate.put("chargeCode","361322");
        jsondate.put("icdCode","Z00.000");
        jsondate.put("socialNo",cardNo);
        jsondate.put("tellPhone",mobile);
        jsondate.put("address1",provinceName);
        jsondate.put("address2",cityName);
        jsondate.put("address3",townName);
        jsondate.put("address4",streetName);
        jsondate.put("address5",2);
        jsondate.put("area",address);
        jsondate.put("winNo",6);
        jsondate.put("target",2);
        jsondate.put("quantity",1);
        Map<String,Object> map = findRandomDoctor();
        net.sf.json.JSONObject rs = new JSONObject();
        if (map!=null){
            //先进行核算检测预约
            String result = entranceService.BS10144("3150000","0001",natTime,mediaCard,name,cardNo,mobile,pm,demoFlag);
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
            logger.info("核酸检测预约结束"+result);
            Boolean flag = false;
            if (object!=null){
                com.alibaba.fastjson.JSONObject jsonObject = object.getJSONObject("MsgInfo");
                String Msg = jsonObject.getString("Msg");
                if (Msg.contains("Error")){
                    throw new Exception(Msg);
                }else {
                    flag = true;
        if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
            net.sf.json.JSONObject jsondate = new JSONObject();
            jsondate.put("checkPart","鼻/咽拭子");
            jsondate.put("cardNo",mediaCard);
            jsondate.put("chargeFlag","2");
            jsondate.put("chargeCode","361322");
            jsondate.put("icdCode","Z00.000");
            jsondate.put("socialNo",cardNo);
            jsondate.put("tellPhone",mobile);
            jsondate.put("address1",provinceName);
            jsondate.put("address2",cityName);
            jsondate.put("address3",townName);
            jsondate.put("address4",streetName);
            jsondate.put("address5",2);
            jsondate.put("area",address);
            jsondate.put("winNo",6);
            jsondate.put("target",2);
            jsondate.put("quantity",1);
            Map<String,Object> map = findRandomDoctor();
            net.sf.json.JSONObject rs = new JSONObject();
            if (map!=null){
                //先进行核算检测预约
                String result = entranceService.BS10144("3150000","0001",natTime,mediaCard,name,cardNo,mobile,pm,demoFlag);
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                logger.info("核酸检测预约结束"+result);
                Boolean flag = false;
                if (object!=null){
                    com.alibaba.fastjson.JSONObject jsonObject = object.getJSONObject("MsgInfo");
                    String Msg = jsonObject.getString("Msg");
                    if (Msg.contains("Error")){
                        returnMap.put("msg",Msg);
                        returnMap.put("status","-1");
                        return  returnMap;
                    }else {
                        flag = true;
                    }
                }
            }
            if (flag){
                try {
                    rs = entranceService.BS10111(mediaCard, map.get("doctorMappingCode").toString(), map.get("deptCode").toString(), "31", "6", demoFlag);
                    net.sf.json.JSONObject res = rs.getJSONObject("resquest");
                    logger.info("挂号结果 res: " + res.toString());
                    String rsCode = res.getString("@RESULT");
                    if ("0".equals(rsCode)) {
                        //存储挂号号
                        // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
                        String serialNo = (String) res.get("@serial_no");
                        String conNo = (String) res.get("@times");
                        String xtgzh = (String) res.get("@xtgzh");
                        String realOrder = (String) res.get("@real_order");
                        logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
                        jsondate.put("serialNo",serialNo);
                        jsondate.put("dept",map.get("deptCode").toString());
                        jsondate.put("doctor",map.get("doctorMappingCode").toString());
                        baseNatAppointmentDO.setRegisterNo(serialNo);
                        //保存日志
                        WlyyHttpLogDO log = new WlyyHttpLogDO();
                        log.setCode("registerOutPatient");
                        log.setName("挂号");
                        log.setPatient(patientId);
                        log.setDoctor(map.get("doctorCode").toString());
                        log.setResponse(rs.toString());
                        log.setStatus(rsCode);
                        log.setCreateTime(new Date());
                        wlyyHttpLogDao.save(log);
                if (flag){
                    BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
                    baseNatAppointmentDO.setMedicare(mediaCard);
                    baseNatAppointmentDO.setName(name);
                    baseNatAppointmentDO.setCardNo(cardNo);
                    baseNatAppointmentDO.setCardType(cardType);
                    baseNatAppointmentDO.setAddress(address);
                    baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
                    baseNatAppointmentDO.setCityName(cityName);
                    baseNatAppointmentDO.setFirstJobCode(firstJobCode);
                    baseNatAppointmentDO.setFirstJobName(firstJobName);
                    baseNatAppointmentDO.setSecondJobCode(secondJobCode);
                    baseNatAppointmentDO.setSecondJobName(secondJobName);
                    baseNatAppointmentDO.setProvinceName(provinceName);
                    baseNatAppointmentDO.setTownName(townName);
                    baseNatAppointmentDO.setStreetName(streetName);
                    baseNatAppointmentDO.setPatientId(patientId);
                    baseNatAppointmentDO.setIsSuccess("0");
                    baseNatAppointmentDO.setPayStatus("0");
                    baseNatAppointmentDO.setCreateTime(new Date());
                    baseNatAppointmentDO.setMobile(mobile);
                    baseNatAppointmentDO.setInspectionCode("鼻/咽拭子");
                    baseNatAppointmentDO.setInspectionName("鼻/咽拭子");
                    baseNatAppointmentDO.setIcdCode("Z00.000");
                    baseNatAppointmentDO.setChargeCode("361322");
                    baseNatAppointmentDO.setWinNo("6");
                    baseNatAppointmentDO.setDept("3150000");
                    baseNatAppointmentDO.setDeptName("感染疾病科");
                    baseNatAppointmentDO.setAmpm(pm);
                    baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                    try {
                        rs = entranceService.BS10111(mediaCard, map.get("doctorMappingCode").toString(), map.get("deptCode").toString(), "31", "6", demoFlag);
                        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
                        logger.info("挂号结果 res: " + res.toString());
                        String rsCode = res.getString("@RESULT");
                        if ("0".equals(rsCode)) {
                            //存储挂号号
                            // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
                            String serialNo = (String) res.get("@serial_no");
                            String conNo = (String) res.get("@times");
                            String xtgzh = (String) res.get("@xtgzh");
                            String realOrder = (String) res.get("@real_order");
                            logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
                            jsondate.put("serialNo",serialNo);
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            baseNatAppointmentDO.setRegisterNo(serialNo);
                            //保存日志
                            WlyyHttpLogDO log = new WlyyHttpLogDO();
                            log.setCode("registerOutPatient");
                            log.setName("挂号");
                            log.setPatient(patientId);
                            log.setDoctor(map.get("doctorCode").toString());
                            log.setResponse(rs.toString());
                            log.setStatus(rsCode);
                            log.setCreateTime(new Date());
                            wlyyHttpLogDao.save(log);
                        } else if ("-2".equals(rsCode)) {
                            String serialNo = (String) res.get("@serial_no");
                            String xtgzh = (String) res.get("@xtgzh");
                            String realOrder = (String) res.get("@real_order");
                            String conNo = (String) res.get("@times");
                            jsondate.put("serialNo",serialNo);
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
                            //保存日志
                            WlyyHttpLogDO log = new WlyyHttpLogDO();
                            log.setCode("registerOutPatient");
                            log.setName("挂号");
                            log.setPatient(patientId);
                            log.setDoctor(map.get("doctorCode").toString());
                            log.setResponse(rs.toString());
                            log.setStatus(rsCode);
                            log.setCreateTime(new Date());
                            wlyyHttpLogDao.save(log);
                        }else {
                            returnMap.put("msg","请求挂号失败");
                            returnMap.put("status","-1");
                            returnMap.put("id",baseNatAppointmentDO.getId());
                            return returnMap;
                        }
                        baseNatAppointmentDO.setDoctorId(map.get("doctorMappingCode").toString());
                        baseNatAppointmentDO.setDoctorName(map.get("doctorName").toString());
                    } else if ("-2".equals(rsCode)) {
                        String serialNo = (String) res.get("@serial_no");
                        String xtgzh = (String) res.get("@xtgzh");
                        String realOrder = (String) res.get("@real_order");
                        String conNo = (String) res.get("@times");
                        jsondate.put("serialNo",serialNo);
                        jsondate.put("dept",map.get("deptCode").toString());
                        jsondate.put("doctor",map.get("doctorMappingCode").toString());
                        logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    logger.info("开单开始");
                    logger.info("saveNatAppointment params:"+jsondate.toString());
                    com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray();
                    array.add(jsondate);
                    try {
                        JSONObject jsonObject  = entranceService.BS10112(array.toString(),demoFlag);
                        //判断返回结果
                        String prers = jsonObject.getString("@RESULT");
                        //保存日志
                        WlyyHttpLogDO log = new WlyyHttpLogDO();
                        log.setCode("registerOutPatient");
                        log.setName("挂号");
                        log.setCode("saveNatAppointment");
                        log.setName("核酸检测开方");
                        log.setPatient(patientId);
                        log.setDoctor(map.get("doctorCode").toString());
                        log.setResponse(rs.toString());
                        log.setStatus(rsCode);
                        log.setResponse(jsonObject.toString());
                        log.setRequest(jsondate.toString());
                        log.setCreateTime(new Date());
                        wlyyHttpLogDao.save(log);
                    }else {
                        returnMap.put("msg","请求挂号失败");
                        returnMap.put("status","-1");
                        returnMap.put("id",baseNatAppointmentDO.getId());
                        return returnMap;
                    }
                    baseNatAppointmentDO.setDoctorId(map.get("doctorMappingCode").toString());
                    baseNatAppointmentDO.setDoctorName(map.get("doctorName").toString());
                        if ("0".equals(prers)) {
                            String realOrder = jsonObject.getString("@real_order");
                            String voucherNo = jsonObject.getString("@xtgzh0");
                            baseNatAppointmentDO.setRealOrder(realOrder);
                            baseNatAppointmentDO.setIsSuccess("1");
                            baseNatAppointmentDO.setVoucherNo(voucherNo);
                            baseNatAppointmentDO =baseNatAppointmentDao.save(baseNatAppointmentDO);
                            logger.info("模板消息推送标识pushFlag"+pushFlag);
                            if (!StringUtils.isNoneBlank(pushFlag)){
                                String recipeTime = DateUtil.dateToStr(new Date(), "yyyyMMddHHmmss");
                                String applyDepaName = map.get("deptName").toString();
                                String applyDoctorName = map.get("doctorName").toString();
                                BasePatientDO patientDO = basePatientDao.findById(patientId);
                                String userName = null;
                                String idcard = null;
                                if (patientDO != null) {
                                    userName = patientDO.getName();
                                    idcard = patientDO.getIdcard();
                                }
                                String hisId = patientMappingService.findHisPatNoByPatient(patientId,mediaCard);
                                logger.info("cardNo:" + cardNo);
                                JSONObject jsonObject1 =entranceService.BS15054(hisId,realOrder,demoFlag);
                                net.sf.json.JSONObject res = jsonObject1.getJSONObject("resquest");
                                logger.info("获取待结算数据 res: " + res.toString());
                                String rsCode = res.getString("@RESULT");
                                String free= 0+"";
                                if ("0".equals(rsCode)) {
                                    free = res.getString("@total_charge");
                                }
                                ylzPayService.msgPush("01", mediaCard, "01", patientDO.getMobile(), "00", hisId, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1",pushChannel);
                            }else {
                } catch (Exception e) {
                    e.printStackTrace();
                }
                logger.info("开单开始");
                logger.info("saveNatAppointment params:"+jsondate.toString());
                com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray();
                array.add(jsondate);
                try {
                    JSONObject jsonObject  = entranceService.BS10112(array.toString(),demoFlag);
                    //判断返回结果
                    String prers = jsonObject.getString("@RESULT");
                    //保存日志
                    WlyyHttpLogDO log = new WlyyHttpLogDO();
                    log.setCode("saveNatAppointment");
                    log.setName("核酸检测开方");
                    log.setPatient(patientId);
                    log.setDoctor(map.get("doctorCode").toString());
                    log.setResponse(jsonObject.toString());
                    log.setRequest(jsondate.toString());
                    log.setCreateTime(new Date());
                    wlyyHttpLogDao.save(log);
                    if ("0".equals(prers)) {
                        String realOrder = jsonObject.getString("@real_order");
                        String voucherNo = jsonObject.getString("@xtgzh0");
                        baseNatAppointmentDO.setRealOrder(realOrder);
                        baseNatAppointmentDO.setIsSuccess("1");
                        baseNatAppointmentDO.setVoucherNo(voucherNo);
                        baseNatAppointmentDO =baseNatAppointmentDao.save(baseNatAppointmentDO);
                        String recipeTime = DateUtil.dateToStr(new Date(), "yyyyMMddHHmmss");
                        String applyDepaName = map.get("deptName").toString();
                        String applyDoctorName = map.get("doctorName").toString();
                        BasePatientDO patientDO = basePatientDao.findById(patientId);
                        String userName = null;
                        String idcard = null;
                        if (patientDO != null) {
                            userName = patientDO.getName();
                            idcard = patientDO.getIdcard();
                        }
                        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientId);
                        String userNo = null;
                        if (patientMappingDO != null) {
                            userNo = patientMappingDO.getMappingCode();
                        }
                  /*          String title="您在厦门大学附属中山医院有一笔交易已支付完成!";
                            String pushPayLog = payInfoNoticeService.pushPrescriptionPayAndHsjc(baseNatAppointmentDO.getPatientId(),baseNatAppointmentDO.getDoctorName(),waitPayDetailVO.getVoucherNo(),natAppointmentDO.getId()+"",fee,title,null,waitPayDetailVO.getRecipeNo());
*/
                            }
                        logger.info("cardNo:" + cardNo);
                        JSONObject jsonObject1 =entranceService.BS15054(patientMappingDO.getMappingCode(),realOrder,demoFlag);
                        net.sf.json.JSONObject res = jsonObject1.getJSONObject("resquest");
                        logger.info("获取待结算数据 res: " + res.toString());
                        String rsCode = res.getString("@RESULT");
                        String free= 0+"";
                        if ("0".equals(rsCode)) {
                            free = res.getString("@total_charge");
                        }
                        ylzPayService.msgPush("01", mediaCard, "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1");
                        /*//成功后发送模板消息
                        sendNatWxTemplat(name,cardNo,mobile,natTime,realOrder,"natAppointmentRemind");*/
                    }else{
                        returnMap.put("msg","核酸检测开方失败");
                        returnMap.put("status","-1");
                        returnMap.put("id",baseNatAppointmentDO.getId());
                        return returnMap;
                        }else{
                            returnMap.put("msg","核酸检测开方失败");
                            returnMap.put("status","-1");
                            returnMap.put("id",baseNatAppointmentDO.getId());
                            return returnMap;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
                    returnMap.put("msg","预约成功");
                    returnMap.put("status","200");
                    returnMap.put("id",baseNatAppointmentDO.getId());
                    returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
                }
            }
            return returnMap;
        }else if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
            BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
            baseNatAppointmentDO.setMedicare(mediaCard);
            baseNatAppointmentDO.setName(name);
            baseNatAppointmentDO.setCardNo(cardNo);
            baseNatAppointmentDO.setCardType(cardType);
            baseNatAppointmentDO.setAddress(address);
            baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
            baseNatAppointmentDO.setCityName(cityName);
            baseNatAppointmentDO.setFirstJobCode(firstJobCode);
            baseNatAppointmentDO.setFirstJobName(firstJobName);
            baseNatAppointmentDO.setSecondJobCode(secondJobCode);
            baseNatAppointmentDO.setSecondJobName(secondJobName);
            baseNatAppointmentDO.setProvinceName(provinceName);
            baseNatAppointmentDO.setTownName(townName);
            baseNatAppointmentDO.setStreetName(streetName);
            baseNatAppointmentDO.setPatientId(patientId);
            baseNatAppointmentDO.setIsSuccess("0");
            baseNatAppointmentDO.setPayStatus("0");
            baseNatAppointmentDO.setCreateTime(new Date());
            baseNatAppointmentDO.setMobile(mobile);
            baseNatAppointmentDO.setInspectionCode("鼻/咽拭子");
            baseNatAppointmentDO.setInspectionName("鼻/咽拭子");
            baseNatAppointmentDO.setIcdCode("Z00.000");
            baseNatAppointmentDO.setChargeCode("361322");
            baseNatAppointmentDO.setWinNo("6");
            baseNatAppointmentDO.setDept("3150000");
            baseNatAppointmentDO.setDeptName("感染疾病科");
            baseNatAppointmentDO.setAmpm(pm);
            baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
            returnMap.put("msg","预约成功");
            returnMap.put("status","200");
            returnMap.put("id",baseNatAppointmentDO.getId());
            returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
            return returnMap;
        }
        return returnMap;
    }
    public MixEnvelop getNatRecords(String patientId,String id,String payStatus,String appointmentTime, String isSuccess,Integer page ,Integer pageSize){
        try {
            savePayStatusByHis(patientId);
            logger.info("同步结束");
        } catch (Exception e) {
            e.printStackTrace();
        }
        String sql = "select t.name as \"name\"," +
                "t.card_no as \"cardNo\"," +
                "t.card_type as \"cardType\"," +
@ -10700,6 +10746,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        sql+=" order by t.appointment_time desc ";
        List<Map<String ,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        List<Map<String ,Object>> listCount = hibenateUtils.createSQLQuery(sql);
        logger.info("查询数据"+sql);
        MixEnvelop mixnvelop = new MixEnvelop();
        if (listCount!=null&&listCount.size()>0){
            mixnvelop.setCurrPage(page);
@ -10712,6 +10759,33 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    public void savePayStatusByHis(String patientId) throws Exception {
        List<BaseNatAppointmentDO> baseNatAppointmentDOList = baseNatAppointmentDao.findPayStatusByPatientId(patientId);
        for (BaseNatAppointmentDO baseNatAppointmentDO:baseNatAppointmentDOList){
            String hisId = patientMappingService.findHisPatNoByPatient(patientId,baseNatAppointmentDO.getMedicare());
            logger.info("cardNo:" + baseNatAppointmentDO.getMedicare());
            JSONObject jsonObject1 =entranceService.BS15054(hisId,baseNatAppointmentDO.getRealOrder(),demoFlag);
            net.sf.json.JSONObject res = jsonObject1.getJSONObject("resquest");
            logger.info("获取待结算数据 res: " + res.toString());
            String rsCode = res.getString("@RESULT");
            String free= 0+"";
            String settleFlag = "";
            if ("0".equals(rsCode)) {
                free = res.getString("@total_charge");
                settleFlag = res.getString("@settle_flag");
                if (StringUtils.isNoneBlank(settleFlag)&&settleFlag.equalsIgnoreCase("Y")){
                    baseNatAppointmentDO.setPayStatus("1");
                }
                if (StringUtils.isNoneBlank(free)&&free.equalsIgnoreCase("0")){
                    baseNatAppointmentDO.setPayStatus("1");
                }
                baseNatAppointmentDao.save(baseNatAppointmentDO);
            }
        }
    }
    public List<Map<String,Object>> findBaseAddress(String addressFlag,String parentName){
        String sql="";
        if ("1".equalsIgnoreCase(addressFlag)){
@ -10805,267 +10879,58 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        return res;
    }
    //先调预约核酸检测的接口
    public Map natAppointment(String mediaCard,String patientId,String name,String cardNo,String cardType,String mobile,
                                  String firstJobCode,String firstJobName,String secondJobCode,String secondJobName,String natTime,String address,String provinceName,String cityName,String townName,String streetName) throws Exception {
        BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
        baseNatAppointmentDO.setMedicare(mediaCard);
        baseNatAppointmentDO.setName(name);
        baseNatAppointmentDO.setCardNo(cardNo);
        baseNatAppointmentDO.setCardType(cardType);
        baseNatAppointmentDO.setAddress(address);
        baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDate(natTime,"yyyy-MM-dd hh:mm:ss"));
        baseNatAppointmentDO.setCityName(cityName);
        baseNatAppointmentDO.setFirstJobCode(firstJobCode);
        baseNatAppointmentDO.setFirstJobName(firstJobName);
        baseNatAppointmentDO.setSecondJobCode(secondJobCode);
        baseNatAppointmentDO.setSecondJobName(secondJobName);
        baseNatAppointmentDO.setProvinceName(provinceName);
        baseNatAppointmentDO.setTownName(townName);
        baseNatAppointmentDO.setStreetName(streetName);
        baseNatAppointmentDO.setPatientId(patientId);
        baseNatAppointmentDO.setIsSuccess("0");
        baseNatAppointmentDO.setPayStatus("0");
        baseNatAppointmentDO.setCreateTime(new Date());
        baseNatAppointmentDO.setMobile(mobile);
        baseNatAppointmentDO.setInspectionCode("鼻/咽拭子");
        baseNatAppointmentDO.setInspectionName("鼻/咽拭子");
        baseNatAppointmentDO.setIcdCode("Z00.000");
        baseNatAppointmentDO.setChargeCode("361322");
        baseNatAppointmentDO.setWinNo("6");
        baseNatAppointmentDO.setDept("3150000");
        baseNatAppointmentDO.setDeptName("感染疾病科");
        baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
        Map<String,Object> returnMap = new HashMap();
        //先进行核算检测预约
        String result = entranceService.BS10144("3150000","0001",natTime,mediaCard,name,cardNo,mobile,demoFlag);
        com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
        logger.info("核酸检测预约结束"+result);
        if (object!=null){
            com.alibaba.fastjson.JSONObject jsonObject = object.getJSONObject("MsgInfo");
            String Msg = jsonObject.getString("Msg");
            if (Msg.contains("Error")){
                throw new Exception(Msg);
            }else {
                baseNatAppointmentDO.setIsSuccess("1");
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                returnMap.put("id",baseNatAppointmentDO.getId());
                returnMap.put("msg","预约成功");
            }
        }else {
            returnMap.put("id",baseNatAppointmentDO.getId());
            returnMap.put("msg","预约失败");
        }
        return  returnMap;
    }
    //预约核酸成功后通过订单id去挂号生成订单
    public Map<String,Object> registerAndNatPre(Integer id) throws Exception{
        BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(id);
        Map<String,Object> map = findRandomDoctor();
        Map<String,Object> returnMap = new HashMap<>();
        if (baseNatAppointmentDO!=null){
            net.sf.json.JSONObject jsondate = new JSONObject();
            jsondate.put("checkPart","鼻/咽拭子");
            jsondate.put("cardNo",baseNatAppointmentDO.getMedicare());
            jsondate.put("chargeFlag","2");
            jsondate.put("chargeCode","361322");
            jsondate.put("icdCode","Z00.000");
            jsondate.put("socialNo",baseNatAppointmentDO.getCardNo());
            jsondate.put("tellPhone",baseNatAppointmentDO.getMobile());
            jsondate.put("address1",baseNatAppointmentDO.getProvinceName());
            jsondate.put("address2",baseNatAppointmentDO.getCityName());
            jsondate.put("address3",baseNatAppointmentDO.getTownName());
            jsondate.put("address4",baseNatAppointmentDO.getStreetName());
            jsondate.put("address5","");
            jsondate.put("area",baseNatAppointmentDO.getAddress());
            jsondate.put("winNo","6");
            jsondate.put("target","1");
            jsondate.put("quantity","1");
            if("1".equalsIgnoreCase(baseNatAppointmentDO.getIsSuccess())){
                logger.info("挂号开始");
                String date = DateUtil.dateToStr(new Date(), "yyyy-MM-dd");
                if (map!=null){
                    List<WlyyPatientRegisterDO> patientRegisterDOs = patientRegisterDao.findByPatientAndDateAndDoctorAndDel(baseNatAppointmentDO.getPatientId(), date,map.get("doctorCode").toString() ,1);
                    net.sf.json.JSONObject rs = new JSONObject();
                    if (patientRegisterDOs != null && patientRegisterDOs.size() > 0) {
                        WlyyPatientRegisterDO registerDO = patientRegisterDOs.get(0);
                        //判断是否已经挂号,如果已经挂号
                        if (StringUtils.isNotBlank(registerDO.getConNo()) && StringUtils.isNotBlank(registerDO.getRegisterNo())) {
                            net.sf.json.JSONObject res = new JSONObject();
                            res.put("@RESULT", "0");
                            logger.info("已经挂号 res: " + res.toString());
                            jsondate.put("serialNo",registerDO.getRegisterNo());
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            baseNatAppointmentDO.setDoctorId(map.get("doctorMappingCode").toString());
                        }else {
                            returnMap.put("msg","已经挂号的数据有误");
                            returnMap.put("status","-1");
                            returnMap.put("id",baseNatAppointmentDO.getId());
                            return returnMap;
                        }
                    }else {
                        rs = entranceService.BS10111(baseNatAppointmentDO.getMedicare(), map.get("doctorMappingCode").toString(), map.get("deptCode").toString(), "31", "6", demoFlag);
                        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
                        logger.info("挂号结果 res: " + res.toString());
                        String rsCode = res.getString("@RESULT");
                        if ("0".equals(rsCode)) {
                            //存储挂号号
                            // {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
                            String serialNo = (String) res.get("@serial_no");
                            String conNo = (String) res.get("@times");
                            String xtgzh = (String) res.get("@xtgzh");
                            String realOrder = (String) res.get("@real_order");
                            logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
                            jsondate.put("serialNo",serialNo);
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            //存储就诊记录
                            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
                            // 存储挂号医生与挂号科室
                            registerDO.setDoctor(map.get("doctorCode").toString());
                            registerDO.setDoctorName(map.get("doctorName").toString());
                            registerDO.setDept(map.get("deptCode").toString());
                            registerDO.setDeptName(map.get("deptName").toString());
                            registerDO.setRealOrder(realOrder);
                            registerDO.setXtgzh(xtgzh);
                            registerDO.setPatient(baseNatAppointmentDO.getPatientId());
                            registerDO.setPatientName(baseNatAppointmentDO.getName());
                            //挂号流水号与挂号次数
                            registerDO.setRegisterNo(serialNo);
                            registerDO.setConNo(conNo);
                            registerDO.setCreateTime(new Date());
                            registerDO.setDel(1);
                            registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                            patientRegisterDao.save(registerDO);
                            //保存日志
                            WlyyHttpLogDO log = new WlyyHttpLogDO();
                            log.setCode("registerNat");
                            log.setName("挂号");
                            log.setPatient(baseNatAppointmentDO.getPatientId());
                            log.setDoctor(map.get("doctorCode").toString());
                            log.setResponse(rs.toString());
                            log.setStatus(rsCode);
                            log.setCreateTime(new Date());
                            wlyyHttpLogDao.save(log);
                        } else if ("-2".equals(rsCode)) {
                            String serialNo = (String) res.get("@serial_no");
                            String xtgzh = (String) res.get("@xtgzh");
                            String realOrder = (String) res.get("@real_order");
                            String conNo = (String) res.get("@times");
                            jsondate.put("serialNo",serialNo);
                            jsondate.put("dept",map.get("deptCode").toString());
                            jsondate.put("doctor",map.get("doctorMappingCode").toString());
                            logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
                            //存储就诊记录
                            WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
                            registerDO.setDoctor(map.get("doctorCode").toString());
                            registerDO.setDoctorName(map.get("doctorName").toString());
                            registerDO.setDept(map.get("deptCode").toString());
                            registerDO.setDeptName(map.get("deptName").toString());
                            registerDO.setRealOrder(realOrder);
                            registerDO.setXtgzh(xtgzh);
                            registerDO.setPatient(baseNatAppointmentDO.getPatientId());
                            registerDO.setPatientName(baseNatAppointmentDO.getName());
                            registerDO.setRegisterNo(serialNo);
                            registerDO.setConNo(conNo);
                            registerDO.setCreateTime(new Date());
                            registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                            patientRegisterDao.save(registerDO);
                            //保存日志
                            WlyyHttpLogDO log = new WlyyHttpLogDO();
                            log.setCode("registerOutPatient");
                            log.setName("挂号");
                            log.setPatient(baseNatAppointmentDO.getPatientId());
                            log.setDoctor(map.get("doctorCode").toString());
                            log.setResponse(rs.toString());
                            log.setStatus(rsCode);
                            log.setCreateTime(new Date());
                            wlyyHttpLogDao.save(log);
                        }else {
                            returnMap.put("msg","请求挂号失败");
                            returnMap.put("status","-1");
                            returnMap.put("id",baseNatAppointmentDO.getId());
                            return returnMap;
                        }
                        baseNatAppointmentDO.setDoctorId(map.get("doctorMappingCode").toString());
                    }
                    logger.info("开单开始");
                    logger.info("NatPre params:"+jsondate.toString());
                    com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray();
                    array.add(jsondate);
                    try {
                        JSONObject jsonObject  = entranceService.BS10112(array.toString(),demoFlag);
                        //判断返回结果
                        String prers = jsonObject.getString("@RESULT");
                        //保存日志
                        WlyyHttpLogDO log = new WlyyHttpLogDO();
                        log.setCode("NatAppointment");
                        log.setName("核酸检测开方");
                        log.setPatient(baseNatAppointmentDO.getPatientId());
                        log.setDoctor(map.get("doctorCode").toString());
                        log.setResponse(jsonObject.toString());
                        log.setRequest(jsondate.toString());
                        log.setCreateTime(new Date());
                        wlyyHttpLogDao.save(log);
                        if ("0".equals(prers)) {
                            String realOrder = jsonObject.getString("@real_order");
                            baseNatAppointmentDO.setRealOrder(realOrder);
                            baseNatAppointmentDao.save(baseNatAppointmentDO);
                            String recipeTime = DateUtil.dateToStr(new Date(), "yyyyMMddHHmmss");
                            String applyDepaName = map.get("deptName").toString();
                            String voucherNo = jsonObject.getString("@xtgzh0");
                            String applyDoctorName = map.get("doctorName").toString();
                            BasePatientDO patientDO = basePatientDao.findById(baseNatAppointmentDO.getPatientId());
                            String userName = null;
                            String idcard = null;
                            if (patientDO != null) {
                                userName = patientDO.getName();
                                idcard = patientDO.getIdcard();
                            }
                            PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(baseNatAppointmentDO.getPatientId());
                            String userNo = null;
                            if (patientMappingDO != null) {
                                userNo = patientMappingDO.getMappingCode();
                            }
                        /*JSONObject jsonObject1 =entranceService.BS15054(patientMappingDO.getMappingCode(),realOrder,demoFlag);
                        net.sf.json.JSONObject res = jsonObject1.getJSONObject("resquest");
                        logger.info("获取待结算数据 res: " + res.toString());
                        String rsCode = res.getString("@RESULT");*/
                            String free= 80+"";
                        /*if ("0".equals(rsCode)) {
                            free = res.getString("@total_charge");
                        }*/
                            ylzPayService.msgPush("01", baseNatAppointmentDO.getMedicare(), "01", patientDO.getMobile(), "00", userNo, userName, idcard, voucherNo, applyDepaName, applyDoctorName, recipeTime, free, "1");
                        /*//成功后发送模板消息
                        sendNatWxTemplat(name,cardNo,mobile,natTime,realOrder,"natAppointmentRemind");*/
                        }else{
                            returnMap.put("msg","核酸检测开方失败");
                            returnMap.put("status","-1");
                            returnMap.put("id",baseNatAppointmentDO.getId());
                            return returnMap;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    returnMap.put("msg","预约成功");
                    returnMap.put("status","200");
                    returnMap.put("id",baseNatAppointmentDO.getId());
                }else {
                    returnMap.put("msg","医生映射表找不到对应信息");
                    returnMap.put("status","-1");
                    returnMap.put("id",baseNatAppointmentDO.getId());
                }
            }else{
                returnMap.put("msg","该单状态出错:"+baseNatAppointmentDO.getIsSuccess());
                returnMap.put("status","-1");
                returnMap.put("id",baseNatAppointmentDO.getId());
            }
    public String sendAlipayMessage(String patientId,String code,String fee,String redirdctUrl,String reserverTime,String realorder) throws Exception {
        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
      /*  ⽀付提醒通知:
        code: 通知代码,⽀付提醒为“2” open_id:⽀付宝⽤户ID user_name: 姓名 order_id: 订单号
        create_time: 订单创建时间 fee: ⾦额 url:通知详情跳转链接*/
        /*预约成功通知:
        code: 通知代码,预约为“4” open_id: ⽀付宝⽤户ID user_name: 姓名 unit_name: 科室名
        doctor_name: 医⽣名 order_time: 预约时间 order_no: 预约号*/
        /* ⽀付成功通知:
        code:通知代码,⽀付成功为“3” open_id:⽀付宝⽤户ID first: 您好,恭喜⽀付成功! fee: ⾦额
        fee_type_name: 费⽤类型 url: 通知详情跳转链接 remark: 备注,以\n换⾏*/
        BasePatientDO patientDO = basePatientDao.findById(patientId);
        if (code.equalsIgnoreCase("3")){
            jsonObject.put("code",code);
            jsonObject.put("open_id",patientDO.getAlipayId());
            jsonObject.put("first",patientDO.getName()+"您好,您有一笔交易支付成功!支付明细如下:");
            jsonObject.put("fee_type_name","核酸预约申请");
            jsonObject.put("fee",fee);
            jsonObject.put("url",redirdctUrl);
            String remark = "发票流水号:"+realorder+"\n" +
                    "点击查看核酸预约开单信息\n" ;
            jsonObject.put("remark",remark);
        }else if (code.equalsIgnoreCase("13")){
           /* code: 通知代码,预约为“13” open_id: ⽀付宝⽤户ID first: 第⼀⾏ keyword1: 第⼆⾏ keyword2: 第三⾏
            remark: 备注 url: 详情链接*/
            jsonObject.put("code",code);
            jsonObject.put("open_id",patientDO.getAlipayId());
            jsonObject.put("first","尊敬的用户"+patientDO.getName()+",您已完成线上自助核酸检测预约申请");
            jsonObject.put("keyword1",DateUtil.getStringDate());
            jsonObject.put("keyword2","申请人:"+patientDO.getName()+"\n" +
                    "预约时间:"+reserverTime+"\n" +
                    "发票流水号:"+realorder+"");
            String remark = "1、请您持核酸预约申请信息和发票流水号、医保卡/就诊卡/电子健康卡,准时至我院五号楼北侧(急诊部后侧)核酸检测点领取标本试管窗口绑定检测。\n" +
                    "2、核酸检测标本采集24小时后出具报告。请关注厦门大学附属中山医院微信公众号查询;如需打印,请至厦门大学附属中山医院核酸检测点自助机打印。";
            jsonObject.put("remark",remark);
            jsonObject.put("url",redirdctUrl);
        }
        String url = "https://xmzsyyfwc.xmpbinfo.cn/weixin/1/notification/push/nucleictest";
        logger.info("jsonObject"+jsonObject.toJSONString());
        String encdata = AES.encrypt("3bdc154ed1e44a9c9f44451a16d8e0aa",jsonObject.toJSONString());
        Map<String, String> params = new HashedMap();
        params.put("encdata",encdata);
        String reponse = httpClientUtil.httpPost(url,params);
        logger.info("支付宝模板消息"+reponse);
        return reponse;
        }
        return returnMap;
    }
}

+ 0 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -1906,7 +1906,6 @@ public class EntranceService {
            sbs.append("</Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
            logger.info("resp"+resp);
        }
        return ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
@ -1937,7 +1936,6 @@ public class EntranceService {
            sbs.append("</Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRow(resp);
            logger.info("resp"+resp);
        }
        return ConvertUtil.convertListEnvelopInBodyRow(resp);
    }
@ -1973,7 +1971,6 @@ public class EntranceService {
            sbs.append("</Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRowBS10144(resp);
            logger.info("resp"+resp);
        }
        return resp;
    }
@ -2008,7 +2005,6 @@ public class EntranceService {
            sbs.append("</Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
            resp = MqSdkUtil.putReqAndGetRespByQueryStr(sbs.toString(), fid);
            resp = MqSdkUtil.xml2jsonArrayRootRowBS10144(resp);
            logger.info("resp"+resp);
        }
        return resp;

+ 1 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/MqSdkUtil.java

@ -135,7 +135,7 @@ public class MqSdkUtil {
            msgId = queueTools.putMsg(queueManager, xmlNodeName, reqMsg);
            // 获取响应消息
            respMsg = queueTools.getMsgById(queueManager, xmlNodeName, msgId, 1200000000);
            log.info("respMsg=="+respMsg);
            log.info("respMsg=="+reqMsg);
            return respMsg;
        } catch (MQException e) {
            // 2033表示队列中没有消息
@ -244,7 +244,6 @@ public class MqSdkUtil {
    public static String xml2jsonArrayRootRow(String xmlString) throws Exception {
        XMLSerializer xmlSerializer = new XMLSerializer();
        JSON json = xmlSerializer.read(xmlString);
        log.info("json"+json.toString());
        Object retInfo=  ((JSONObject) json).get("RetInfo");
        Object retCode= ((JSONObject) retInfo).get("RetCode");
        if(retCode.equals("1")){

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

@ -252,10 +252,11 @@ public class YlzPayService {
     * @param recipeTime
     * @param fee
     * @param recipeNum
     * @param pushChannel
     * @return
     */
    public String msgPush(String cardType,String cardNo,String accountType,String contactNumber,String feeType,String userNo,String userName,String idNo,String voucherNo,
                          String applyDepaName,String applyDoctorName,String recipeTime,String fee,String recipeNum){
                          String applyDepaName,String applyDoctorName,String recipeTime,String fee,String recipeNum,String pushChannel){
        String object  = null;
        Boolean isSuccess = true;
        String error = null;
@ -283,6 +284,12 @@ public class YlzPayService {
            jsonObject.put("applyDepaName",applyDepaName);//申请科室名称
            jsonObject.put("applyDoctorName",applyDoctorName);//申请医生姓名
            jsonObject.put("recipeTime",recipeTime);//处方时间yyyyMMddHHmmss
            if (StringUtils.isNoneBlank(pushChannel)){
                jsonObject.put("pushChannel",pushChannel);//推送渠道
            }else {
                jsonObject.put("pushChannel","WX_PUB");//推送渠道
            }
            if (StringUtils.isNoneBlank(fee)){
                Double free = Double.parseDouble(fee);
                jsonObject.put("fee",free);//总费用

+ 3 - 3
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -119,7 +119,7 @@ public class HttpClientUtil {
     * @return
     * @throws Exception
     */
    public  String httpPost(String url, Map<String, String> params) throws Exception {
    public static String httpPost(String url, Map<String, String> params) throws Exception {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
@ -185,7 +185,7 @@ public class HttpClientUtil {
     *            POST参数。
     * @return 所代表远程资源的响应结果
     */
    public  String sendPost(String url, String param) {
    public static  String sendPost(String url, String param) {
        StringBuffer buffer = new StringBuffer();
        PrintWriter out = null;
        BufferedReader in = null;
@ -230,7 +230,7 @@ public class HttpClientUtil {
        return buffer.toString();
    }
    
    public  String postBody(String url, com.alibaba.fastjson.JSONObject params) {
    public static   String postBody(String url, com.alibaba.fastjson.JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");

+ 45 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java

@ -6,6 +6,7 @@ import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.RegisterService;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.hospital.register.RegisterAmVO;
@ -43,6 +44,8 @@ public class MqSdkController extends EnvelopRestEndpoint {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private YlzPayService ylzPayService;
    @GetMapping(value = "/BS15017")
    @ApiOperation(value = "固定入参:门诊余额查询")
@ -479,6 +482,48 @@ public class MqSdkController extends EnvelopRestEndpoint {
            return ObjEnvelop.getError(object1.get("respMsg").toString());
        }
    }
    @GetMapping(value = "/ylzPushMessage")
    @ApiOperation(value = "易慧")
    public Envelop ylzPushMessage(@ApiParam(name = "cardType", value = "卡类型")
                           @RequestParam(value = "cardType", required = false) String cardType,
                           @ApiParam(name = "cardNo", value = "社保卡")
                           @RequestParam(value = "cardNo", required = false) String cardNo,
                           @ApiParam(name = "accountType", value = "预约时间")
                           @RequestParam(value = "accountType", required = false) String accountType,
                           @ApiParam(name = "contactNumber", value = "社保卡")
                           @RequestParam(value = "contactNumber", required = false) String contactNumber,
                           @ApiParam(name = "patientName", value = "患者姓名")
                           @RequestParam(value = "patientName", required = false) String patientName,
                           @ApiParam(name = "feeType", value = "患者身份证")
                           @RequestParam(value = "feeType", required = false) String feeType,
                           @ApiParam(name = "userNo", value = "患者手机号")
                           @RequestParam(value = "userNo", required = false) String userNo,
                           @ApiParam(name = "userName", value = "userName")
                           @RequestParam(value = "userName", required = false) String userName,
                            @ApiParam(name = "idNo", value = "idNo")
                            @RequestParam(value = "idNo", required = false) String idNo,
                            @ApiParam(name = "voucherNo", value = "voucherNo")
                            @RequestParam(value = "voucherNo", required = false) String voucherNo,
                            @ApiParam(name = "applyDepaName", value = "applyDepaName")
                            @RequestParam(value = "applyDepaName", required = false) String applyDepaName,
                            @ApiParam(name = "applyDoctorName", value = "applyDoctorName")
                            @RequestParam(value = "applyDoctorName", required = false) String applyDoctorName,
                            @ApiParam(name = "recipeTime", value = "recipeTime")
                            @RequestParam(value = "recipeTime", required = false) String recipeTime,
                              @ApiParam(name = "fee", value = "fee")
                                  @RequestParam(value = "fee", required = false) String fee,
                              @ApiParam(name = "recipeNum", value = "recipeNum")
                                  @RequestParam(value = "recipeNum", required = false) String recipeNum,
                                  @ApiParam(name = "pushChannel", value = "pushChannel")
                                      @RequestParam(value = "pushChannel", required = false) String pushChannel) throws Exception{
        //String deptCode,String docCode,String startTime,String sSID,String patientName,String patientID,String patientPhone
        String   obj = ylzPayService.msgPush(cardType,cardNo,accountType,contactNumber,feeType,userNo,userName,idNo,voucherNo,
                applyDepaName,applyDoctorName,recipeTime,fee,recipeNum,pushChannel);
        return success(obj);
    }
    @GetMapping(value = "/getUserInfoByOpenid")
    @ApiOperation(value = "获取用户信息")
    public ObjEnvelop getUserInfoByOpenid(

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

@ -533,7 +533,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
                    }
					if (!free.equalsIgnoreCase("0")){
						ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");
						ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1","WX_PUB");
					}
					logger.info("发送诊查费支付模板消息end");
				}

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

@ -693,7 +693,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
				}
				if (!free.equalsIgnoreCase("0")){
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1");
					ylzPayService.msgPush("01", cardNo, "01", patientDO.getMobile(), "00", userNo, userName, idcard, outpatientDO.getXtgzh(), outpatientDO.getDeptName(), outpatientDO.getDoctorName(), date, free, "1","WX_PUB");
				}
				logger.info("发送诊查费支付模板消息end");
			}

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

@ -883,6 +883,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                        JSONObject object = param.getJSONObject("externalMap");
                        String cardNo = object.getString("cardNo");
                        String traceNo = object.getString("traceNo");
                        String channelId = object.getString("channelId");
                        String result = ylzPayService.querySettledRecord(cardNo,null,null,"onlineRecordDetail",null,traceNo,"1","10000");
                        JSONObject jsonObjectTotal = JSONObject.parseObject(result);
                        logger.info("查询在线结算处方信息"+jsonObjectTotal);
@ -948,38 +949,52 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                    //判断检查订单
                                    List<BaseNatAppointmentDO> baseNatAppointmentDOS = baseNatAppointmentDao.findByRealOrderList(waitPayDetailVO.getRecipeNo());
                                    for (BaseNatAppointmentDO natAppointmentDO:baseNatAppointmentDOS){
                                        if (channelId.contains("WX")){
//发送支付成功通知
                                            String pushPayLog = null;
                                            String fee = waitPayDetailVO.getFee();
                                            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                                String title="您在厦门大学附属中山医院有一笔交易已支付完成!";
                                                pushPayLog = payInfoNoticeService.pushPrescriptionPayAndHsjc(natAppointmentDO.getPatientId(),natAppointmentDO.getDoctorName(),waitPayDetailVO.getVoucherNo(),natAppointmentDO.getId()+"",fee,title,null,waitPayDetailVO.getRecipeNo());
                                            }
                                            //发送预约成功通知
                                            String name= natAppointmentDO.getName();
                                            String idcard = natAppointmentDO.getCardNo();
                                            String mobile = natAppointmentDO.getMobile();
                                            String url = "https://hlwyy.xmzsh.com/hlwyy/ims-wx/#/nucleicTest/detail?id="+natAppointmentDO.getId();
                                            String date = DateUtil.dateToStrLong(natAppointmentDO.getAppointmentTime());
                                            String first = "尊敬的用户"+name+",您已完成线上自助核酸检测预约申请";
                                            String contentMsg = "申请人:"+name+"\r\n 预约时间:"+date+" \r\n发票流水号:"+waitPayDetailVO.getRecipeNo();
                                            String remark="1、请您持核酸预约申请信息和发票流水号、医保卡/就诊卡/电子健康卡,准时至我院五号楼北侧(急诊部后侧)核酸检测点领取标本试管窗口绑定检测。\r\n" +
                                                    "2、核酸检测标本采集24小时后出具报告。请关注厦门大学附属中山医院微信公众号查询;如需打印,请至厦门大学附属中山医院核酸检测点自助机打印。";
                                            String responseMsg="";
                                            if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                                                responseMsg = entranceService.ehospitalNotice(
                                                        name,
                                                        idcard,
                                                        mobile,
                                                        first,
                                                        url,
                                                        contentMsg,
                                                        remark);
                                                logger.info("中山发送模板消息返回结果="+responseMsg);
                                                System.out.println("结束发送模板消息");
                                            }
                                        }else if (channelId.contains("ALI")){
                                            if (natAppointmentDO.getPayStatus().equalsIgnoreCase("0")){
                                                logger.info("支付宝发送模板消息开始111");
                                                String url = "https://hlwyy.xmzsh.com/hlwyy/ims-wx/#/nucleicTest/detail?id="+natAppointmentDO.getId();
                                                String date = DateUtil.dateToStrLong(natAppointmentDO.getAppointmentTime());
                                                prescriptionService.sendAlipayMessage(natAppointmentDO.getPatientId(),"3",waitPayDetailVO.getFee(),url,date,waitPayDetailVO.getRecipeNo());
                                                logger.info("支付宝发送模板消息结束1111");
                                                logger.info("支付宝发送模板消息结束22222");
                                                prescriptionService.sendAlipayMessage(natAppointmentDO.getPatientId(),"13",waitPayDetailVO.getFee(),url,date,waitPayDetailVO.getRecipeNo());
                                                logger.info("支付宝发送模板消息结束2222222");
                                            }
                                        }
                                        natAppointmentDO.setPayStatus("1");
                                        baseNatAppointmentDao.save(natAppointmentDO);
                                        //发送支付成功通知
                                        String pushPayLog = null;
                                        String fee = waitPayDetailVO.getFee();
                                        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                                            String title="您在厦门大学附属中山医院有一笔交易已支付完成!";
                                            pushPayLog = payInfoNoticeService.pushPrescriptionPayAndHsjc(natAppointmentDO.getPatientId(),natAppointmentDO.getDoctorName(),waitPayDetailVO.getVoucherNo(),natAppointmentDO.getId()+"",fee,title,null,waitPayDetailVO.getRecipeNo());
                                        }
                                        //发送预约成功通知
                                        String name= natAppointmentDO.getName();
                                        String idcard = natAppointmentDO.getCardNo();
                                        String mobile = natAppointmentDO.getMobile();
                                        String url = "https://hlwyy.xmzsh.com/hlwyy/ims-wx/#/nucleicTest/detail?id="+natAppointmentDO.getId();
                                        String date = DateUtil.dateToStrLong(natAppointmentDO.getAppointmentTime());
                                        String first = "尊敬的用户"+name+",您已完成线上自助核酸检测开单预约";
                                        String contentMsg = "申请人:"+name+"\r\n 预约时间:"+date+" \r\n发票流水号:"+waitPayDetailVO.getRecipeNo();
                                        String remark="1、请您持核酸开单预约信息和发票流水号、医保卡/就诊卡/电子健康卡,提前5分钟至我院五号楼北侧(急诊部后侧)核酸检测点领取标本试管窗口绑定检测。\r\n" +
                                                "2、核酸检测标本采集24小时后出具报告。请关注厦门大学附属中山医院微信公众号查询;如需打印,请至厦门大学附属中山医院核酸检测点自助机打印。";
                                        String responseMsg="";
                                        if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
                                            responseMsg = entranceService.ehospitalNotice(
                                                    name,
                                                    idcard,
                                                    mobile,
                                                    first,
                                                    url,
                                                    contentMsg,
                                                    remark);
                                            logger.info("中山发送模板消息返回结果="+responseMsg);
                                            System.out.println("结束发送模板消息");
                                        }
                                    }
                                }

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

@ -2584,66 +2584,38 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                      @ApiParam(name = "streetName", value = "streetName")
                                          @RequestParam(value = "streetName",required = false)String streetName,
                                      @ApiParam(name = "pm", value = "pm")
                                          @RequestParam(value = "pm",required = false)String pm){
                                          @RequestParam(value = "pm",required = false)String pm,
                                      @ApiParam(name = "pushChannel", value = "pushChannel")
                                          @RequestParam(value = "pushChannel",required = false)String pushChannel,
                                      @ApiParam(name = "pushFlag", value = "pushFlag")
                                          @RequestParam(value = "pushFlag",required = false)String pushFlag){
        try {
            return success(prescriptionService.saveNatAppointment(mediaCard,patientId,name,cardNo,cardType,mobile,firstJobCode,firstJobName,secondJobCode,secondJobName,natTime,address,provinceName,cityName,townName,streetName,pm));
            return success(prescriptionService.saveNatAppointment(mediaCard,patientId,name,cardNo,cardType,mobile,firstJobCode,firstJobName,secondJobCode,secondJobName,natTime,address,provinceName,cityName,townName,streetName,pm,pushChannel,pushFlag));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping("/natAppointment")
    @ApiOperation(value = "核酸检测预约接口New")
    public Envelop natAppointment(@ApiParam(name = "mediaCard", value = "mediaCard")
                                      @RequestParam(value = "mediaCard",required = false)String mediaCard,
                                      @ApiParam(name = "patientId", value = "patientId")
                                      @RequestParam(value = "patientId",required = false)String patientId,
                                      @ApiParam(name = "name", value = "name")
                                      @RequestParam(value = "name",required = false)String name,
                                      @ApiParam(name = "cardNo", value = "cardNo")
                                      @RequestParam(value = "cardNo",required = false)String cardNo,
                                      @ApiParam(name = "cardType", value = "cardType")
                                      @RequestParam(value = "cardType",required = false)String cardType,
                                      @ApiParam(name = "mobile", value = "mobile")
                                      @RequestParam(value = "mobile",required = false)String mobile,
                                      @ApiParam(name = "firstJobCode", value = "firstJobCode")
                                      @RequestParam(value = "firstJobCode",required = false)String firstJobCode,
                                      @ApiParam(name = "firstJobName", value = "firstJobName")
                                      @RequestParam(value = "firstJobName",required = false)String firstJobName,
                                      @ApiParam(name = "secondJobCode", value = "secondJobCode")
                                      @RequestParam(value = "secondJobCode",required = false)String secondJobCode,
                                      @ApiParam(name = "secondJobName", value = "secondJobName")
                                      @RequestParam(value = "secondJobName",required = false)String secondJobName,
                                      @ApiParam(name = "natTime", value = "natTime")
                                      @RequestParam(value = "natTime",required = false)String natTime,
                                      @ApiParam(name = "address", value = "address")
                                      @RequestParam(value = "address",required = false)String address,
                                      @ApiParam(name = "provinceName", value = "provinceName")
                                      @RequestParam(value = "provinceName",required = false)String provinceName,
                                      @ApiParam(name = "cityName", value = "cityName")
                                      @RequestParam(value = "cityName",required = false)String cityName,
                                      @ApiParam(name = "townName", value = "townName")
                                      @RequestParam(value = "townName",required = false)String townName,
                                      @ApiParam(name = "streetName", value = "streetName")
                                      @RequestParam(value = "streetName",required = false)String streetName){
    @GetMapping("/sendAlipayMessage")
    public Envelop sendAlipayMessage(@ApiParam(name = "code", value = "code")
                           @RequestParam(value = "code",required = false)String code,
                           @ApiParam(name = "patientId", value = "patientId")
                           @RequestParam(value = "patientId",required = false)String patientId,
                           @ApiParam(name = "fee", value = "fee")
                           @RequestParam(value = "fee",required = false)String fee,
                           @ApiParam(name = "redirdctUrl", value = "redirdctUrl")
                           @RequestParam(value = "redirdctUrl",required = false)String redirdctUrl,
                          @ApiParam(name = "realorder", value = "realorder")
                          @RequestParam(value = "realorder",required = false)String realorder,
                          @ApiParam(name = "reserverTime", value = "reserverTime")
                          @RequestParam(value = "reserverTime",required = false)String reserverTime) throws Exception {
        try {
            return success(prescriptionService.natAppointment(mediaCard,patientId,name,cardNo,cardType,mobile,firstJobCode,firstJobName,secondJobCode,secondJobName,natTime,address,provinceName,cityName,townName,streetName));
            return success(prescriptionService.sendAlipayMessage(patientId,code,fee,redirdctUrl,reserverTime,realorder));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping("/registerAndNatPre")
    @ApiOperation(value = "核酸检测挂号接口New")
    public Envelop registerAndNatPre(@ApiParam(name = "id", value = "id")
                           @RequestParam(value = "id",required = false)Integer id) throws Exception {
        try {
            return success(prescriptionService.registerAndNatPre(id));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
}