Jelajahi Sumber

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

liubing 3 tahun lalu
induk
melakukan
fffe5d0926

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

@ -11348,11 +11348,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
       return doorServiceCount;
       return doorServiceCount;
    }
    }
    public MixEnvelop findJobCategory(){
    public MixEnvelop findJobCategory(){
        String sqlPid = "select id as \"id\",name as \"name\",pid as \"pid\" from base_job_category  where pid = 0 and del = 1";
        String sqlPid = "select id as \"id\",name as \"name\",code as \"code\",pid as \"pid\" from base_job_category  where pid = 0 and del = 1";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sqlPid);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sqlPid);
        if (list.size()>0){
        if (list.size()>0){
            for (Map<String,Object> map:list){
            for (Map<String,Object> map:list){
                String child = "select id as \"id\",name as \"name\",pid as \"pid\" from base_job_category  where del = 1";
                String child = "select id as \"id\",name as \"name\",code as \"code\",pid as \"pid\" from base_job_category  where del = 1";
                String pid = map.get("id").toString();
                String pid = map.get("id").toString();
                child+=" and pid = "+pid;
                child+=" and pid = "+pid;
                List<Map<String,Object>> childList = hibenateUtils.createSQLQuery(child);
                List<Map<String,Object>> childList = hibenateUtils.createSQLQuery(child);
@ -11690,14 +11690,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
            returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
            return returnMap;
            return returnMap;
        }else if (wechatId.equalsIgnoreCase("xm_tasy_wx")){
        }else if (wechatId.equalsIgnoreCase("xm_tasy_wx")){
            Double natFee = 8000.0;
            if(StringUtils.isNoneBlank(chargeAmount)){
                natFee= Double.parseDouble(chargeAmount)*100;
            }
            BasePatientDO  basePatientDO = basePatientDao.findById(patientId);
            BasePatientDO  basePatientDO = basePatientDao.findById(patientId);
            List<WlyyHospitalSysDictDO> tasyList = wlyyHospitalSysDictDao.findByDictName("natConfigList");
            List<WlyyHospitalSysDictDO> tasyList = wlyyHospitalSysDictDao.findByDictName("natConfigList");
            String deptCode = "0001";
            String deptCode = "0001";
            String staffNo = "0001";
            String staffNo = "0001";
            String staffName = "0001";
            String regDept="";
            String deptName="";
            String itemPrice="";
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:tasyList){
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:tasyList){
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"deptCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"deptCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    deptCode = wlyyHospitalSysDictDO.getDictValue();
                    deptCode = wlyyHospitalSysDictDO.getDictValue();
@ -11705,11 +11705,47 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"staffNo".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"staffNo".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    staffNo = wlyyHospitalSysDictDO.getDictValue();
                    staffNo = wlyyHospitalSysDictDO.getDictValue();
                }
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"regDept".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    regDept = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"deptName".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    deptName = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"staffName".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    staffName = wlyyHospitalSysDictDO.getDictValue();
                }
                if (StringUtils.isNoneBlank(wlyyHospitalSysDictDO.getDictValue())&&"itemPrice".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                    itemPrice = wlyyHospitalSysDictDO.getDictValue();
                }
            }
            Double natFee = 8000.0;
            if(StringUtils.isNoneBlank(itemPrice)){
                natFee= Double.parseDouble(itemPrice)*100;
            }
            //先预约号源
            Date format2 = null;
            format2 = new SimpleDateFormat("yyyy-MM-dd").parse(natTime);
            String shortDate = new SimpleDateFormat("yyyyMMdd").format(format2);
            System.out.println("yyyy-MM-dd转yyyyMMdd:"+shortDate);
            String regRes=tasyNatService.saveRegOrder(regDept,shortDate,pm,preNo,cardNo,mobile,name,"3");
            com.alibaba.fastjson.JSONObject regObj = com.alibaba.fastjson.JSONObject.parseObject(regRes);
            String HisSeqNo="";
            String orderNum="";
            if (regObj!=null){
                if ("true".equalsIgnoreCase(regObj.getString("success"))){
                    com.alibaba.fastjson.JSONObject dataObj = com.alibaba.fastjson.JSONObject.parseObject(regObj.getString("data"));
                    HisSeqNo=dataObj.getString("HisSeqNo").trim();
                    orderNum=dataObj.getString("OrderNumber").trim();
                }else {
                    returnMap.put("msg",regObj.getString("data"));
                    returnMap.put("status","-1");
                    return  returnMap;
                }
            }
            }
            //先进行核算检测预约
            //先进行核算检测预约
            String realOrder="";
            String realOrder="";
            String addressNow=provinceName+cityName+townName+streetName+address;
            String addressNow=provinceName+cityName+townName+streetName+address;
            String result = tasyNatService.initNatParams(preNo,name,mediaCard,addressNow,firstJobCode,secondJobCode);
            String result = tasyNatService.initNatParams(HisSeqNo,name,mediaCard,addressNow,firstJobCode,secondJobCode);
            Boolean flag = false;
            Boolean flag = false;
            if (StringUtils.isNoneBlank(result)){
            if (StringUtils.isNoneBlank(result)){
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
@ -11718,7 +11754,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    String returnCode = object.getString("ReturnCode");
                    String returnCode = object.getString("ReturnCode");
                    System.out.println("returnCode"+returnCode);
                    System.out.println("returnCode"+returnCode);
                    if ("0".equalsIgnoreCase(returnCode)){
                    if ("0".equalsIgnoreCase(returnCode)){
                        returnMap.put("msg",object.getString("returnMsg"));
                        returnMap.put("msg",object.getString("data"));
                        returnMap.put("status","-1");
                        returnMap.put("status","-1");
                        return  returnMap;
                        return  returnMap;
                    }else {
                    }else {
@ -11733,13 +11769,15 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if (flag){
            if (flag){
                logger.info("BaseNatAppointmentDO保存开始");
                logger.info("BaseNatAppointmentDO保存开始");
                BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
                BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
                baseNatAppointmentDO.setChargeAmount(chargeAmount);
                baseNatAppointmentDO.setChargeAmount(itemPrice);
                baseNatAppointmentDO.setMedicare(mediaCard);
                baseNatAppointmentDO.setMedicare(mediaCard);
                baseNatAppointmentDO.setRegisterNo(HisSeqNo);
                baseNatAppointmentDO.setName(name);
                baseNatAppointmentDO.setName(name);
                baseNatAppointmentDO.setCardNo(cardNo);
                baseNatAppointmentDO.setCardNo(cardNo);
                baseNatAppointmentDO.setCardType(cardType);
                baseNatAppointmentDO.setCardType(cardType);
                baseNatAppointmentDO.setAddress(address);
                baseNatAppointmentDO.setAddress(address);
                baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
                baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
                baseNatAppointmentDO.setOderNum(orderNum);
                baseNatAppointmentDO.setCityName(cityName);
                baseNatAppointmentDO.setCityName(cityName);
                baseNatAppointmentDO.setFirstJobCode(firstJobCode);
                baseNatAppointmentDO.setFirstJobCode(firstJobCode);
                baseNatAppointmentDO.setFirstJobName(firstJobName);
                baseNatAppointmentDO.setFirstJobName(firstJobName);
@ -11760,12 +11798,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                baseNatAppointmentDO.setChargeCode(chargeCode);
                baseNatAppointmentDO.setChargeCode(chargeCode);
                baseNatAppointmentDO.setWinNo(String.valueOf(winNo));
                baseNatAppointmentDO.setWinNo(String.valueOf(winNo));
                baseNatAppointmentDO.setDept(deptCode);
                baseNatAppointmentDO.setDept(deptCode);
                baseNatAppointmentDO.setDeptName("感染疾病科");
                baseNatAppointmentDO.setDeptName(deptName);
                baseNatAppointmentDO.setRealOrder(realOrder);
                baseNatAppointmentDO.setRealOrder(realOrder);
                baseNatAppointmentDO.setAmpm(pm);
                baseNatAppointmentDO.setAmpm(pm);
                baseNatAppointmentDO.setDoctorId(staffNo);
                baseNatAppointmentDO.setDoctorId(staffNo);
                baseNatAppointmentDO.setConsumer(consumer);
                baseNatAppointmentDO.setConsumer(consumer);
                //baseNatAppointmentDO.setDoctorName(map.get("doctorName").toString());
                baseNatAppointmentDO.setDoctorName(staffName);
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                logger.info("BaseNatAppointmentDO保存结束"+baseNatAppointmentDO.getId());
                logger.info("BaseNatAppointmentDO保存结束"+baseNatAppointmentDO.getId());
                //添加订单
                //添加订单
@ -11790,14 +11828,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
                if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
                    openId=basePatientWechatDo.get(0).getOpenid();
                    openId=basePatientWechatDo.get(0).getOpenid();
                }
                }
               /* //亿同支付创建订单
                //亿同支付创建订单
                com.alibaba.fastjson.JSONObject orderObj= new com.alibaba.fastjson.JSONObject();
                com.alibaba.fastjson.JSONObject orderObj= new com.alibaba.fastjson.JSONObject();
                orderObj.put("payType",1);
                orderObj.put("payType",1);
                orderObj.put("tradeNo",businessDO.getOrderNo());
                orderObj.put("tradeNo",businessDO.getOrderNo());
                orderObj.put("openId",openId);
                orderObj.put("openId",openId);
                orderObj.put("name",name);
                orderObj.put("name",name);
                orderObj.put("idNo",cardNo);
                orderObj.put("idNo",cardNo);
                orderObj.put("amount",chargeAmount);
                BigDecimal b = new BigDecimal(itemPrice);
                b=b.setScale(2, BigDecimal.ROUND_DOWN);
                System.out.println("amount"+b);
                orderObj.put("amount",b);
                String orderRes=tasyNatService.placeOrder(orderObj);
                String orderRes=tasyNatService.placeOrder(orderObj);
                if (StringUtils.isNoneBlank(orderRes)){
                if (StringUtils.isNoneBlank(orderRes)){
                    com.alibaba.fastjson.JSONObject jsonObject= JSON.parseObject(orderRes);
                    com.alibaba.fastjson.JSONObject jsonObject= JSON.parseObject(orderRes);
@ -11805,16 +11846,24 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        if("0".equalsIgnoreCase(jsonObject.getString("code"))){
                        if("0".equalsIgnoreCase(jsonObject.getString("code"))){
                            com.alibaba.fastjson.JSONObject dataObj= com.alibaba.fastjson.JSONObject.parseObject(jsonObject.getString("data"));
                            com.alibaba.fastjson.JSONObject dataObj= com.alibaba.fastjson.JSONObject.parseObject(jsonObject.getString("data"));
                            businessDO.setTraceNo(dataObj.getString("orderNo"));
                            businessDO.setTraceNo(dataObj.getString("orderNo"));
                            businessDO.setRematk(dataObj.toJSONString());
                            businessDO=businessOrderDao.save(businessDO);
                            businessDO=businessOrderDao.save(businessDO);
                        }
                        }
                    }
                    }
                }
                }
                tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),"hszftx",baseNatAppointmentDO.getName(),baseNatAppointmentDO.getId().toString());*/
                try {
                    tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),baseNatAppointmentDO.getName(),"hszftx",baseNatAppointmentDO.getId().toString());
                    tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),baseNatAppointmentDO.getName(),"hsyycg",baseNatAppointmentDO.getId().toString());
                }catch (Exception e){
                    e.printStackTrace();
                }
                logger.info("开单结束");
                logger.info("开单结束");
                returnMap.put("msg","预约成功");
                returnMap.put("msg","预约成功");
                returnMap.put("status","200");
                returnMap.put("status","200");
                returnMap.put("id",baseNatAppointmentDO.getId());
                returnMap.put("id",baseNatAppointmentDO.getId());
                returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
                returnMap.put("realOrder",baseNatAppointmentDO.getRealOrder());
                baseNatAppointmentDO.setIsSuccess("1");
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
            }else {
            }else {
                returnMap.put("msg","核酸开方失败");
                returnMap.put("msg","核酸开方失败");
                returnMap.put("status","-1");
                returnMap.put("status","-1");
@ -12211,14 +12260,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        }
                        }
                    }else if("xm_tasy_wx".equalsIgnoreCase(wechatId)){
                    }else if("xm_tasy_wx".equalsIgnoreCase(wechatId)){
                        baseNatAppointmentDO.setIsSuccess("-1");
                        baseNatAppointmentDO.setCancelReson("患者本人取消");
                        baseNatAppointmentDO.setCancelTime(new Date());
                        baseNatAppointmentDO.setCancelBy(patientId);
                        baseNatAppointmentDao.save(baseNatAppointmentDO);
                        if (StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
                        if (StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
                            logger.info("同步his订单状态"+baseNatAppointmentDO.getRealOrder());
                            logger.info("同步his订单状态"+baseNatAppointmentDO.getRealOrder());
                            tasyNatService.cancelNat(baseNatAppointmentDO.getRealOrder(),baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getName());
                            //取消号源
                            tasyNatService.cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                            tasyNatService.cancelNat(baseNatAppointmentDO.getRealOrder(),baseNatAppointmentDO.getMedicare(),baseNatAppointmentDO.getName());
                            baseNatAppointmentDO.setIsSuccess("-1");
                            baseNatAppointmentDO.setCancelReson("患者本人取消");
                            baseNatAppointmentDO.setCancelTime(new Date());
                            baseNatAppointmentDO.setCancelBy(patientId);
                            baseNatAppointmentDao.save(baseNatAppointmentDO);
                        }
                        }
                    }
                    }

+ 389 - 46
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TasyNatService.java

@ -4,41 +4,36 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatAppointmentDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.doctor.PersonInfoVO;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.utils.date.DateUtil;
import net.sf.json.xml.XMLSerializer;
import net.sf.json.xml.XMLSerializer;
import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Elements;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.checkerframework.checker.units.qual.A;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
@Service
@Transactional
@Transactional
@ -58,6 +53,10 @@ public class TasyNatService {
    private BasePatientWechatDao basePatientWechatDao;
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private BaseNatAppointmentDao baseNatAppointmentDao;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    public String getOperateUrl(){
    public String getOperateUrl(){
@ -66,6 +65,13 @@ public class TasyNatService {
        String url = list.get(0).getDictCode();
        String url = list.get(0).getDictCode();
        return url;
        return url;
    }
    }
    public String gethsQueryDataWS(){
        List<WlyyHospitalSysDictDO> list =  wlyyHospitalSysDictDao.findByDictName("hdrQueryDataWSUrl");
        String url = list.get(0).getDictCode();
        return url;
    }
    public String getTaszWebServiceInfo(String api, Map<String,String> params, String url)throws Exception{
    public String getTaszWebServiceInfo(String api, Map<String,String> params, String url)throws Exception{
        logger.info("url"+url);
        logger.info("url"+url);
@ -79,6 +85,7 @@ public class TasyNatService {
        return WebserviceUtil.post(url,xzzxNamespace,api,params);
        return WebserviceUtil.post(url,xzzxNamespace,api,params);
    }
    }
    /**
    /**
     * 线上注册
     * 线上注册
     * @return
     * @return
@ -451,17 +458,17 @@ public class TasyNatService {
            url=wlyyHospitalSysDictDO.getDictValue();
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        }
        System.out.println(url);
        System.out.println(url);
        List<NameValuePair> params = new ArrayList<>();
        /*List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("payType", jsonObject.getString("payType")));
        params.add(new BasicNameValuePair("payType", jsonObject.getString("payType")));
        params.add(new BasicNameValuePair("tradeNo", jsonObject.getString("tradeNo")));
        params.add(new BasicNameValuePair("tradeNo", jsonObject.getString("tradeNo")));
        params.add(new BasicNameValuePair("openId", jsonObject.getString("openId")));
        params.add(new BasicNameValuePair("openId", jsonObject.getString("openId")));
        params.add(new BasicNameValuePair("name", jsonObject.getString("name")));
        params.add(new BasicNameValuePair("name", jsonObject.getString("name")));
        params.add(new BasicNameValuePair("idNo", jsonObject.getString("idNo")));
        params.add(new BasicNameValuePair("idNo", jsonObject.getString("idNo")));
        params.add(new BasicNameValuePair("amount", jsonObject.getString("amount")));
        System.out.println(params.toString());
        String response = httpClientUtil.post(url,params ,"UTF-8");
        params.add(new BasicNameValuePair("amount", jsonObject.getString("amount")));*/
        System.out.println(jsonObject.toString());
        String response = httpClientUtil.postBody(url,jsonObject);
        System.out.println("res"+response);
        System.out.println("res"+response);
        saveHttpLog("placeOrder",params.toString(),response,url);
        saveHttpLog("placeOrder",jsonObject.toString(),response,url);
        return response;
        return response;
    }
    }
@ -472,12 +479,9 @@ public class TasyNatService {
            url=wlyyHospitalSysDictDO.getDictValue();
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        }
        System.out.println(url);
        System.out.println(url);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("orderNo", jsonObject.getString("orderNo")));
        System.out.println(params.toString());
        String response = httpClientUtil.post(url,params ,"UTF-8");
        String response = httpClientUtil.postBody(url,jsonObject);
        System.out.println("res"+response);
        System.out.println("res"+response);
        saveHttpLog("orderStatus",params.toString(),response,url);
        saveHttpLog("orderStatus",jsonObject.toString(),response,url);
        return response;
        return response;
    }
    }
@ -488,22 +492,16 @@ public class TasyNatService {
            url=wlyyHospitalSysDictDO.getDictValue();
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        }
        System.out.println(url);
        System.out.println(url);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("tempateId", jsonObject.getString("tempateId")));
        params.add(new BasicNameValuePair("url", jsonObject.getString("url")));
        params.add(new BasicNameValuePair("openId", jsonObject.getString("openId")));
        params.add(new BasicNameValuePair("data", jsonObject.getJSONObject("data").toString()));
        System.out.println(params.toString());
        String response = httpClientUtil.post(url,params ,"UTF-8");
        String response = httpClientUtil.postBody(url,jsonObject);
        System.out.println("res"+response);
        System.out.println("res"+response);
        saveHttpLog("tmpPush",params.toString(),response,url);
        saveHttpLog("tmpPush",jsonObject.toString(),response,url);
        return response;
        return response;
    }
    }
    public void  saveHttpLog(String name,String req,String res,String code){
    public void  saveHttpLog(String name,String req,String res,String code){
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
        wlyyHttpLogDO.setRequest(req);
        wlyyHttpLogDO.setRequest(req);
        wlyyHttpLogDO.setName(name);
        wlyyHttpLogDO.setName(name);
        wlyyHttpLogDO.setCode(code);
        //wlyyHttpLogDO.setCode(code);
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setCreateTime(new Date());
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDO.setResponse(res);
        wlyyHttpLogDao.save(wlyyHttpLogDO);
        wlyyHttpLogDao.save(wlyyHttpLogDO);
@ -513,13 +511,19 @@ public class TasyNatService {
        String url="";
        String url="";
        String openId="";
        String openId="";
        JSONObject key=new JSONObject();
        JSONObject key=new JSONObject();
        JSONObject first=new JSONObject();
        JSONObject key1=new JSONObject();
        JSONObject key1=new JSONObject();
        JSONObject key2=new JSONObject();
        JSONObject key2=new JSONObject();
        JSONObject key3=new JSONObject();
        JSONObject key4=new JSONObject();
        JSONObject key5=new JSONObject();
        JSONObject remark=new JSONObject();
        BaseNatAppointmentDO baseNatAppointmentD0 = baseNatAppointmentDao.findOne(Integer.valueOf(relationCode));
        List<BasePatientWechatDo> basePatientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",patient);
        List<BasePatientWechatDo> basePatientWechatDo = basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",patient);
        if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
        if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
            openId=basePatientWechatDo.get(0).getOpenid();
            openId=basePatientWechatDo.get(0).getOpenid();
        }
        }
        if ("hszfcg".equalsIgnoreCase(scene)){
        if ("hszfcgtx".equalsIgnoreCase(scene)){
            //开始发送模板消息
            //开始发送模板消息
            logger.info("开始发送模板消息");
            logger.info("开始发送模板消息");
            List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
            List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
@ -528,16 +532,31 @@ public class TasyNatService {
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
            }
            }
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            key1.put("value",wxTemplateConfigDO1.getKeyword1().replace("key1",name));
            first.put("value",wxTemplateConfigDO1.getFirst());
            first.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("value",baseNatAppointmentD0.getDoctorName());
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",wxTemplateConfigDO1.getKeyword1().replace("key1",name));
            key2.put("value",baseNatAppointmentD0.getChargeAmount());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",wxTemplateConfigDO1.getKeyword3());
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",baseNatAppointmentD0.getDoctorName());
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
            key5.put("value",baseNatAppointmentD0.getVoucherNo());
            key5.put("color",wxTemplateConfigDO1.getKeyword6());
            remark.put("value",wxTemplateConfigDO1.getRemark());
            remark.put("color",wxTemplateConfigDO1.getKeyword6());
            key.put("first",first);
            key.put("keyword1",key1);
            key.put("keyword1",key1);
            key.put("keyword2",key2);
            key.put("keyword2",key2);
            key.put("keyword3",key3);
            key.put("keyword4",key4);
            key.put("keyword5",key5);
            key.put("remark",remark);
            JSONObject jsonObject = new JSONObject();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("tempateId",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("template_id",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("data",key);
            jsonObject.put("data",key);
            jsonObject.put("openId",openId);
            jsonObject.put("touser",openId);
            jsonObject.put("url",url);
            jsonObject.put("url",url);
            logger.info("核酸检测支付成功模板消息推送param"+jsonObject.toString());
            logger.info("核酸检测支付成功模板消息推送param"+jsonObject.toString());
            String tmResilt= tmpPush(jsonObject);
            String tmResilt= tmpPush(jsonObject);
@ -551,29 +570,353 @@ public class TasyNatService {
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
            }
            }
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            key1.put("value",wxTemplateConfigDO1.getKeyword1().replace("key1",name));
            first.put("value",wxTemplateConfigDO1.getFirst());
            first.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("value",name);
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",wxTemplateConfigDO1.getKeyword1().replace("key1",name));
            key2.put("value",baseNatAppointmentD0.getDeptName());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",wxTemplateConfigDO1.getKeyword3());
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",baseNatAppointmentD0.getDoctorName());
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
            key5.put("value", DateUtil.formatDate(baseNatAppointmentD0.getCreateTime(),"yyyy-MM-dd hh:mm:ss"));
            key5.put("color",wxTemplateConfigDO1.getKeyword6());
            remark.put("value",wxTemplateConfigDO1.getRemark());
            remark.put("color",wxTemplateConfigDO1.getKeyword6());
            key.put("first",first);
            key.put("keyword1",key1);
            key.put("keyword1",key1);
            key.put("keyword2",key2);
            key.put("keyword2",key2);
            key.put("keyword3",key3);
            key.put("keyword4",key4);
            key.put("keyword5",key5);
            key.put("remark",remark);
            JSONObject jsonObject = new JSONObject();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("tempateId",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("template_id",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("data",key);
            jsonObject.put("data",key);
            jsonObject.put("openId",openId);
            jsonObject.put("touser",openId);
            jsonObject.put("url",url);
            jsonObject.put("url",url);
            logger.info("核酸检测支付提醒模板消息推送param"+jsonObject.toString());
            logger.info("核酸检测支付提醒模板消息推送param"+jsonObject.toString());
            String tmResilt= tmpPush(jsonObject);
            String tmResilt= tmpPush(jsonObject);
            return tmResilt;
            return tmResilt;
        } else if ("hsyycg".equalsIgnoreCase(scene)) {
            //开始发送模板消息
            logger.info("开始发送模板消息");
            List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
            WxTemplateConfigDO wxTemplateConfigDO1 = new WxTemplateConfigDO();
            if (wxTemplateConfigDO!=null&&wxTemplateConfigDO.size()>0){
                wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
            }
            url=wxTemplateConfigDO1.getUrl()+relationCode;
            first.put("value",wxTemplateConfigDO1.getFirst().replace("key1",name));
            first.put("color",wxTemplateConfigDO1.getKeyword6());
            key1.put("value",name);
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",baseNatAppointmentD0.getInspectionName());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",DateUtil.formatDate(baseNatAppointmentD0.getAppointmentTime(),"yyyy-MM-dd hh:mm:ss"));
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",wxTemplateConfigDO1.getKeyword4());
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
            remark.put("value",wxTemplateConfigDO1.getRemark());
            remark.put("color",wxTemplateConfigDO1.getKeyword6());
            key.put("first",first);
            key.put("keyword1",key1);
            key.put("keyword2",key2);
            key.put("keyword3",key3);
            key.put("keyword4",key4);
            key.put("remark",remark);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("template_id",wxTemplateConfigDO1.getTemplateId());//
            jsonObject.put("data",key);
            jsonObject.put("touser",openId);
            jsonObject.put("url",url);
            logger.info("核酸检测预约成功模板消息推送param"+jsonObject.toString());
            String tmResilt= tmpPush(jsonObject);
            return tmResilt;
        }
        }
        return "";
        return "";
    }
    }
    //查询排班部门
    public String departMent(String ApplyType){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("DepartMentUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?ApplyType="+ApplyType;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("departMent",ApplyType,response,url);
        return response;
    }
    //保存预约
    public String saveRegOrder(String DepartId,String OrderDate,String OrderTime,String OrderID,String HisID,String Tel,
                               String HisName,String ApplyType){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("saveNatOrderUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?DepartId="+DepartId+"&OrderDate="+OrderDate+"&OrderTime="+OrderTime+"&OrderID="+OrderID
                +"&HisID="+HisID+"&Tel="+Tel+"&HisName="+HisName+"&ApplyType="+ApplyType;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("saveRegOrder",url,response,url);
        return response;
    }
    //取消预约
    public String cancleOrder(String HisID,String HisSeqNo,String OrderNumber) throws Exception{
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("CancleOrderUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?HisID="+HisID+"&HisSeqNo="+HisSeqNo+"&OrderNumber="+OrderNumber;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("cancleOrder",url,response,url);
        return response;
    }
    //查询排班医生
    public String GetDoctorWorkDate(String ApplyType,String DepartId){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("GetDoctorWorkDateUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?ApplyType="+ApplyType+"&DepartId="+DepartId;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("departMent",url,response,url);
        return response;
    }
    //预约查询
    public String GetOrderInfo(String HisID,String ApplyType){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("GetOrderInfoUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?ApplyType="+ApplyType+"&HisID="+HisID;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("departMent",url,response,url);
        return response;
    }
    //获取号源
    public String GetOrderSource(String DepartId,String DoctorId,String QueryDate,String ApplyType,String IsAll,String QueryTime){
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("GetOrderSourceUrl");
        if (wlyyHospitalSysDictDO!=null){
            url=wlyyHospitalSysDictDO.getDictValue();
        }
        url+="?DepartId="+DepartId+"&DoctorId="+DoctorId+"&QueryDate="+QueryDate+"&ApplyType="+ApplyType+"&IsAll="+IsAll+"&QueryTime="+QueryTime;
        System.out.println(url);
        String response = httpClientUtil.get(url,"UTF-8");
        System.out.println("res"+response);
        saveHttpLog("GetOrderInfo",url,response,url);
        return response;
    }
    //查询患者就诊卡
    public String findHisPatientCard(String idcard) throws Exception{
        String api = "QuerySickInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(idcard)){
            condition += "<IdNo>"+idcard+"</IdNo>";
            condition += "<IdType>100</IdType>";
        }
    public static void main(String[] args) throws Exception{
        String xml="<StringResponse><StringValue><![CDATA[<?xml version=\"1.0\" encoding=\"utf-8\"?><root><ReturnCode>1</ReturnCode><hisTradeNo>599907010</hisTradeNo><ReturnMsg></ReturnMsg></root>]]></StringValue></StringResponse>";
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("QuerySickInfo params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        System.out.println(xml);
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("QuerySickInfo json:"+json);
        return json;
    }
    public JSONArray findPatientCard(String patient) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        String idcard="";
        if (basePatientDO!=null){
            idcard=basePatientDO.getIdcard();
        }
        String res = findHisPatientCard(idcard);
        JSONArray jsonArray = new JSONArray();
        if (StringUtils.isNoneBlank(res)){
            JSONObject jsonObject = JSON.parseObject(res);
            jsonArray.add(jsonObject);
            return jsonArray;
        }
        return null;
    }
    //病人单据状态查询
    public String QueryApplyInfo(String nullahNumber) throws Exception{
        String api = "QueryApplyInfo";
        String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";
        String condition ="";
        if (StringUtils.isNoneBlank(nullahNumber)){
            condition += "<NullahNumber>"+nullahNumber+"</NullahNumber>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<root>"+condition+"</root>";
        Map<String,String> params = new HashedMap();
        params.put("msgHeader",msgHeader);
        params.put("msgBody",msgBody);
        logger.info("QueryApplyInfo params:"+params.toString());
        String xml = getTaszWebServiceInfo("CallInterface",params,getOperateUrl());
        xml=xml.substring(xml.indexOf("<root>"),xml.lastIndexOf("]]"));
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("QueryApplyInfo json:"+json);
        return json;
    }
    public void savePayStatusByHis(String patientId) throws Exception {
        List<BaseNatAppointmentDO> baseNatAppointmentDOList = baseNatAppointmentDao.findPayStatusByPatientId(patientId);
        for (BaseNatAppointmentDO baseNatAppointmentDO:baseNatAppointmentDOList){
                String res = QueryApplyInfo(baseNatAppointmentDO.getRealOrder());
                JSONObject jsonObject = JSON.parseObject(res);
                if (jsonObject!=null){
                    if (jsonObject.getString("ReturnCode").equalsIgnoreCase("1")){
                        String voucherNo = jsonObject.getString("ApplyNo");
                        baseNatAppointmentDO.setVoucherNo(voucherNo);
                        if ("已扣费".equalsIgnoreCase(jsonObject.getString("Status"))){
                            baseNatAppointmentDO.setPayStatus("1");
                        }
                        baseNatAppointmentDao.save(baseNatAppointmentDO);
                    }
                }
            }
    }
    public String selectByRelationCode(String relationCode) throws  Exception{
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        if (NumberUtils.isDigits(relationCode) ){
            BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(Integer.valueOf(relationCode));
            if (baseNatAppointmentDO!=null&&"-1".equalsIgnoreCase(baseNatAppointmentDO.getIsSuccess())){
                throw new Exception("订单已取消");
            }
            if (businessOrderDO!=null&&businessOrderDO.getStatus()==1){
                throw new Exception("订单已支付");
            }
            String openId="";
            List<BasePatientWechatDo> wechatList=basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",baseNatAppointmentDO.getConsumer());
            if (wechatList!=null&&wechatList.size()>0){
                openId=wechatList.get(0).getOpenid();
            }
            businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
            com.alibaba.fastjson.JSONObject orderObj= new com.alibaba.fastjson.JSONObject();
            orderObj.put("payType",1);
            orderObj.put("tradeNo",businessOrderDO.getOrderNo());
            orderObj.put("openId",openId);
            orderObj.put("name",baseNatAppointmentDO.getName());
            orderObj.put("idNo",baseNatAppointmentDO.getCardNo());
            BigDecimal b = new BigDecimal(baseNatAppointmentDO.getChargeAmount());
            b=b.setScale(2, BigDecimal.ROUND_DOWN);
            System.out.println("amount"+b);
            orderObj.put("amount",b);
            //重新下单
            String orderRes=placeOrder(orderObj);
            if (StringUtils.isNoneBlank(orderRes)){
                com.alibaba.fastjson.JSONObject jsonObject= JSON.parseObject(orderRes);
                if (jsonObject!=null){
                    if("0".equalsIgnoreCase(jsonObject.getString("code"))){
                        com.alibaba.fastjson.JSONObject dataObj= com.alibaba.fastjson.JSONObject.parseObject(jsonObject.getString("data"));
                        businessOrderDO.setTraceNo(dataObj.getString("orderNo"));
                        businessOrderDO.setRematk(dataObj.toJSONString());
                        businessOrderDO=businessOrderDao.save(businessOrderDO);
                    }
                }
            }
        }
        return businessOrderDO.getRematk();
    }
    public String getNatResult(String patientId) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findById(patientId);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.MONTH, -6);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = sdf.format(c.getTime());
        String idcard="";
        String hospitalOid="";
        String wsCode="";
        if (basePatientDO!=null){
            idcard=basePatientDO.getIdcard();
        }
        List<WlyyHospitalSysDictDO> list = wlyyHospitalSysDictDao.findByDictName("hdrQueryDataParam");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:list){
            if ("hospitalOid".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                hospitalOid=wlyyHospitalSysDictDO.getDictValue();
            }
            if ("wsCode".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                wsCode=wlyyHospitalSysDictDO.getDictValue();
            }
        }
        String res=hdrQueryDataWS(idcard,wsCode,hospitalOid,dateStr);
        return res;
    }
    //病人单据状态查询
    public String hdrQueryDataWS(String idcard,String wsCode,String oid,String time) throws Exception{
        /*String api = "hdrQueryDataWS";*/
        /*String msgHeader ="<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
                "<root> " +
                "   <serverName>"+api+"</serverName>  " +
                "   <format>xml</format>" +
                "   <callOperator>"+operator+"</callOperator> " +
                "   <certificate>"+key+"</certificate> " +
                "</root>";*/
        String msg="<HOSPITAL_OID>"+oid+"</HOSPITAL_OID>";
        if (StringUtils.isNoneBlank()){
            msg+="<ID_CARD>"+idcard+"</ID_CARD>";
        }
        if (StringUtils.isNoneBlank(wsCode)){
            msg+="<WS_CODE>"+wsCode+"</WS_CODE>";
        }
        String condition ="";
        if (StringUtils.isNoneBlank(time)){
            condition+="<CONDITION><ELEM NAME=\"LAB_ITEM_NAME\" VALUE=\"核酸\" OPERATOR=\"like\"></ELEM>" +
                    "<ELEM NAME=\"REPORT_TIME\" VALUE=\""+time+"\" OPERATOR=\"&gt;=\"></ELEM></CONDITION>";
        }
        String msgBody ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<MSG>"+msg+condition+"</MSG>";
        Map<String,String> params = new HashedMap();
        params.put("msg",msgBody);
        logger.info("hdrQueryDataWS params:"+params.toString());
        String xml = getTaszWebServiceInfo("hdrQueryDataWS",params,gethsQueryDataWS());
        xml=xml.substring(xml.indexOf("<ArrayList>"),xml.lastIndexOf("]]"));
        XMLSerializer xmlSerializer = new XMLSerializer();
        String json = xmlSerializer.read(xml).toString();
        logger.info("hdrQueryDataWS json:"+json);
        return json;
    }
    }
}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNatAppointmentDO.java

@ -59,6 +59,15 @@ public class BaseNatAppointmentDO extends IntegerIdentityEntity {
    private String hospitalFlag;
    private String hospitalFlag;
    private String consumer;
    private String consumer;
    private String consumerName;
    private String consumerName;
    private String oderNum;
    public String getOderNum() {
        return oderNum;
    }
    public void setOderNum(String oderNum) {
        this.oderNum = oderNum;
    }
    public String getConsumer() {
    public String getConsumer() {
        return consumer;
        return consumer;

+ 4 - 4
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java

@ -34,7 +34,7 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private String relationCode;//业务关联code
    private String relationCode;//业务关联code
    private String relationName;//业务关联名称
    private String relationName;//业务关联名称
    private String description;//支付备注
    private String description;//支付备注
    private String rematk;//病人描述
    private String remark;//病人描述
    private Integer payType;//支付类型1微信2支付宝3易联众支付
    private Integer payType;//支付类型1微信2支付宝3易联众支付
    private Double payPrice;//支付金额
    private Double payPrice;//支付金额
    private Date payTime;//支付时间
    private Date payTime;//支付时间
@ -261,11 +261,11 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    @Column(name = "remark")
    @Column(name = "remark")
    public String getRematk() {
    public String getRematk() {
        return rematk;
        return remark;
    }
    }
    public void setRematk(String rematk) {
        this.rematk = rematk;
    public void setRematk(String remark) {
        this.remark = remark;
    }
    }
    @Column(name = "yk_order_no")
    @Column(name = "yk_order_no")

+ 15 - 15
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -697,22 +697,22 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
     * @return
     * @return
     */
     */
    private String getClientName(String clientType){
    private String getClientName(String clientType){
        String result = "";
        switch (clientType){
            case "app":
                result = "APP";
                break;
            case "wx":
                result = "微信公众号";
                break;
            case "pad":
                result = "多媒体平板";
                break;
            case "pc":
                result = "脑端";
                break;
        if(StringUtils.isBlank(clientType)){
            return "";
        }
        }
        return result;
        if("app".equals(clientType)){
            return "APP";
        }
        if("wx".equals(clientType)){
            return "微信公众号";
        }
        if("pad".equals(clientType)){
            return "多媒体平板";
        }
        if("pc".equals(clientType)){
            return "电脑脑端";
        }
        return "";
    }
    }
    /**
    /**

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

@ -1298,12 +1298,15 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            BasePatientDO patientDO = oauthWjwConfigService.savePatient(result);
            logger.info("授权进来1");
            if(patientDO == null){
            if(patientDO == null){
                return ObjEnvelop.getError("授权登录失败!");
                return ObjEnvelop.getError("授权登录失败!");
            }
            }
            logger.info("授权进来2");
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
            logger.info("授权进来3");
            Map<String, String> parameters = new HashedMap();
            Map<String, String> parameters = new HashedMap();
            parameters.put("username",patientDO.getIdcard());
            parameters.put("username",patientDO.getIdcard());

+ 25 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/service/OauthWjwConfigService.java

@ -3,9 +3,12 @@ package com.yihu.jw.security.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.BasePatientWechatDao;
import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.dao.patient.WlyyPatientFamilyMemberDao;
import com.yihu.jw.security.model.PatientWechat;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
@ -20,9 +23,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.net.URLDecoder;
import java.util.Date;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.UUID;
import org.springframework.util.Base64Utils;
import org.springframework.util.Base64Utils;
import javax.sound.midi.MidiDevice;
/**
/**
 * Created by Trick on 2020/2/24.
 * Created by Trick on 2020/2/24.
 */
 */
@ -36,6 +42,8 @@ public class OauthWjwConfigService {
    private BasePatientDao basePatientDao;
    private BasePatientDao basePatientDao;
    @Autowired
    @Autowired
    private WlyyPatientFamilyMemberDao familyMemberDao;
    private WlyyPatientFamilyMemberDao familyMemberDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    public BasePatientDO savePatient(String data)throws Exception{
    public BasePatientDO savePatient(String data)throws Exception{
        logger.info("savePatient :"+data);
        logger.info("savePatient :"+data);
@ -52,6 +60,7 @@ public class OauthWjwConfigService {
            String userSex = info.getString("userSex");
            String userSex = info.getString("userSex");
            String userIdNo = info.getString("userIdNo");
            String userIdNo = info.getString("userIdNo");
            String dType = info.getString("dType");
            String dType = info.getString("dType");
            String openId = info.getString("openid");
            if(StringUtils.isNotBlank(userIdNo)){
            if(StringUtils.isNotBlank(userIdNo)){
@ -84,6 +93,7 @@ public class OauthWjwConfigService {
                String pw = userIdNo.substring(userIdNo.length()-6);
                String pw = userIdNo.substring(userIdNo.length()-6);
                patient.setIdcard(userIdNo);
                patient.setIdcard(userIdNo);
                patient.setCardType("01");
                patient.setName(name);
                patient.setName(name);
                patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient.setSalt(salt);
                patient.setSalt(salt);
@ -112,8 +122,22 @@ public class OauthWjwConfigService {
                    basePatientFamilyMemberDO.setFamilyMember(patient.getId());
                    basePatientFamilyMemberDO.setFamilyMember(patient.getId());
                    familyMemberDao.save(basePatientFamilyMemberDO);
                    familyMemberDao.save(basePatientFamilyMemberDO);
                }
                }
                List<BasePatientWechatDo> patientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId("xm_tasy_wx",patient.getId());
                if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                    BasePatientWechatDo basePatientWechatDo = patientWechatDos.get(0);
                    basePatientWechatDo.setOpenid(openId);
                }else {
                    BasePatientWechatDo patientWechatDo = new BasePatientWechatDo();
                    patientWechatDo.setOpenid(openId);
                    patientWechatDo.setCreateTime(new Date());
                    patientWechatDo.setPatientId(patient.getId());
                    patientWechatDo.setWechatId("xm_tasy_wx");
                    patientWechatDo.setSaasId("prod");
                    basePatientWechatDao.save(patientWechatDo);
                }
                return basePatientDO;
                return patient;
            }
            }
            return null;
            return null;

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -56,6 +56,17 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @GetMapping(value = "fingLoginLog")
    @ApiOperation(value = "获取登录记录")
    public ListEnvelop fingLoginLog(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
        try {
            return success(statisticsService.fingLoginLog(page,size));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "realTimeData")
    @GetMapping(value = "realTimeData")
    @ApiOperation(value = "大屏实时数据")
    @ApiOperation(value = "大屏实时数据")
    public ObjEnvelop realTimeData() {
    public ObjEnvelop realTimeData() {

+ 16 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -19,6 +19,7 @@ import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
@ -439,7 +440,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @return
     * @return
     */
     */
    public List<Map<String,Object>> findChild(String name,String residentialArea,String limit,JSONObject json){
    public List<Map<String,Object>> findChild(String name,String residentialArea,String limit,JSONObject json){
        String sql = "SELECT id,name,photo from base_patient WHERE archive_type = 2 and del = '1' ";
        String sql = "SELECT id,name,photo,idcard,CAST(IFNULL(birthday,'') AS char ) birthday,residential_area residentialArea,sex  from base_patient WHERE archive_type = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
            sql+= " and name like '%"+name+"%' ";
        }
        }
@ -455,6 +456,10 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            Integer count = jdbcTemplate.queryForObject(sqlCount+filter,Integer.class);
            Integer count = jdbcTemplate.queryForObject(sqlCount+filter,Integer.class);
            map.put("online",json.containsKey(paientId));
            map.put("online",json.containsKey(paientId));
            map.put("doorCoach",count);
            map.put("doorCoach",count);
            String idcardNo = map.get("idcard") + "";
            Date birthday = DateUtil.strToDate(map.get("birthday").toString());
            Integer age = IdCardUtil.getAgeByIdcardOrBirthday(idcardNo,birthday);
            map.put("age",age);
        }
        }
        return list;
        return list;
    }
    }
@ -468,20 +473,27 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @return
     * @return
     */
     */
    public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,JSONObject json){
    public List<Map<String,Object>> findOld(String name,String residentialArea,String limit,JSONObject json){
        String sql = "SELECT id,name,photo from base_patient WHERE archive_type = 1 and del = '1' ";
        String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ", GROUP_CONCAT(DISTINCT d.category_code) deviceFlag from base_patient a " +
                " LEFT JOIN wlyy_patient_device d on d.`user`=a.id  WHERE a.archive_type = 1 and a.del = '1' ";
        if(!StringUtil.isBlank(name)){
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
            sql+= " and name like '%"+name+"%' ";
        }
        }
        if(!StringUtil.isBlank(residentialArea)){
        if(!StringUtil.isBlank(residentialArea)){
            sql+= " and residential_area = '"+residentialArea+"' ";
            sql+= " and residential_area = '"+residentialArea+"' ";
        }
        }
        sql+=limit;
        sql += " GROUP BY a.id,a.name,a.photo,a.idcard,a.birthday,a.residential_area,a.sex ";
        sql += limit;
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>>  list = jdbcTemplate.queryForList(sql);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
        String sqlEmergency= "SELECT COUNT(*) from base_emergency_assistance_order where `status` = 0";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 7 ";
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 7 ";
        for (Map<String,Object> map:list){
        for (Map<String,Object> map:list){
            String paientId = map.get("id").toString();
            String paientId = map.get("id").toString();
            String idcardNo = map.get("idcard") + "";
            Date birthday = DateUtil.strToDate(map.get("birthday").toString());
            Integer age = IdCardUtil.getAgeByIdcardOrBirthday(idcardNo,birthday);
            map.put("age",age);
            String filter = " and patient = '"+paientId+"'";
            String filter = " and patient = '"+paientId+"'";
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
@ -503,7 +515,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @return
     * @return
     */
     */
    public List<Map<String,Object>> findHelper(String name,String limit,JSONObject json){
    public List<Map<String,Object>> findHelper(String name,String limit,JSONObject json){
        String sql = "SELECT id,name,photo from base_doctor WHERE doctor_level = 2 and del = '1' ";
        String sql = "SELECT id,name,photo,sex from base_doctor WHERE doctor_level = 2 and del = '1' ";
        if(!StringUtil.isBlank(name)){
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
            sql+= " and name like '%"+name+"%' ";
        }
        }

+ 44 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -8,6 +8,7 @@ import com.yihu.jw.care.vo.NumVo;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.im.util.ImUtil;
@ -18,6 +19,7 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
@ -160,6 +162,48 @@ public class StatisticsService {
        return json;
        return json;
    }
    }
    /**
     * 获取登录记录
     * @param page
     * @param size
     * @return
     */
    public List<String> fingLoginLog(Integer page,Integer size){
        List<String> result = new ArrayList<>();
        String sql = "select * from base_login_log order by create_time desc limit "+ (page-1)*size+","+size;
        List<BaseLoginLogDO> loginLogDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseLoginLogDO.class));
        for (BaseLoginLogDO log:loginLogDOs) {
            String content = log.getName() + "登录云照护平台 登录终端:" + getClientName(log.getClientType())
                    + " " + DateUtil.dateToStrLong(log.getCreateTime());
            result.add(content);
        }
        return result;
    }
    /**
     * app,wx,pad,pc
     * @param clientType
     * @return
     */
    private String getClientName(String clientType){
        if(StringUtils.isBlank(clientType)){
            return "";
        }
        if("app".equals(clientType)){
            return "APP";
        }
        if("wx".equals(clientType)){
            return "微信公众号";
        }
        if("pad".equals(clientType)){
            return "多媒体平板";
        }
        if("pc".equals(clientType)){
            return "电脑脑端";
        }
        return "";
    }
    /**
    /**
     * 平台人员实时统计
     * 平台人员实时统计
     */
     */

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

@ -81,8 +81,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONArray;
import net.sf.json.xml.XMLSerializer;
import org.apache.axis.utils.StringUtils;
import org.apache.axis.utils.StringUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.time.DateUtils;
import org.apache.http.NameValuePair;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.jasper.tagplugins.jstl.core.Url;
import org.apache.jasper.tagplugins.jstl.core.Url;
@ -97,8 +99,10 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
@ -1493,6 +1497,9 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            @ApiParam(name = "appletCode", value = "appletCode", required = false)
            @ApiParam(name = "appletCode", value = "appletCode", required = false)
            @RequestParam(value = "appletCode",required = false)String appletCode) throws Exception {
            @RequestParam(value = "appletCode",required = false)String appletCode) throws Exception {
        try {
        try {
            if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
               return ObjEnvelop.getSuccess("操作成功",tasyNatService.selectByRelationCode(relationCode));
            }
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,tradeType,wxId,payFlag,appletCode));
            return ObjEnvelop.getSuccess("ok",businessOrderService.selectOrderByRelationCode(relationCode,tradeType,wxId,payFlag,appletCode));
        } catch (Exception e) {
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
@ -1834,6 +1841,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        try {
        try {
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                prescriptionService.savePayStatusByHis(patientId);
                prescriptionService.savePayStatusByHis(patientId);
            }else if (wxId.equalsIgnoreCase("xm_tasy_wx")){
                tasyNatService.savePayStatusByHis(patientId);
            }
            }
            logger.info("同步数据成功");
            logger.info("同步数据成功");
            return  prescriptionService.getNatRecords(patientId,id,payStatus,appointmentTime,isSuccess,page,pageSize);
            return  prescriptionService.getNatRecords(patientId,id,payStatus,appointmentTime,isSuccess,page,pageSize);
@ -2276,6 +2285,16 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            if ("tmpPush".equalsIgnoreCase(api)){
            if ("tmpPush".equalsIgnoreCase(api)){
                return success("操作成功",tasyNatService.tmpPush(jsonObject));
                return success("操作成功",tasyNatService.tmpPush(jsonObject));
            }
            }
            if ("CancleOrder".equalsIgnoreCase(api)){
                return success("操作成功",tasyNatService.cancleOrder(jsonObject.getString("HisID"),jsonObject.getString("no"),jsonObject.getString("OrderNumber")));
            }
            if ("GetOrderInfo".equalsIgnoreCase(api)){
                return success("操作成功",tasyNatService.GetOrderInfo(jsonObject.getString("HisID"),jsonObject.getString("ApplyType")));
            }
            if ("hdrQueryDataWS".equalsIgnoreCase(api)){
                System.out.println("111");
                return success("操作成功",tasyNatService.hdrQueryDataWS(jsonObject.getString("idcard"),jsonObject.getString("wsCode"),jsonObject.getString("oid"),jsonObject.getString("time")));
            }
            return success("");
            return success("");
        } catch (Exception e){
        } catch (Exception e){
            return  failedException(e);
            return  failedException(e);
@ -2319,10 +2338,17 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                                chargeObj.put("icCardNo",baseNatAppointmentDO.getMedicare());
                                chargeObj.put("icCardNo",baseNatAppointmentDO.getMedicare());
                                chargeObj.put("patientName",baseNatAppointmentDO.getName());
                                chargeObj.put("patientName",baseNatAppointmentDO.getName());
                                //调用扣费接口
                                //调用扣费接口
                                tasyNatService.ChargenucleicBill(chargeObj);
                                tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),"hszfcg",baseNatAppointmentDO.getName(),baseNatAppointmentDO.getId().toString());
                                String feeRes=tasyNatService.ChargenucleicBill(chargeObj);
                                JSONObject feeObj = JSONObject.parseObject(feeRes);
                                if (feeObj!=null){
                                    if ("1".equalsIgnoreCase(feeObj.getString("ReturnCode"))){
                                        String voucherNo = feeObj.getString("ApplyNo");
                                        baseNatAppointmentDO.setVoucherNo(voucherNo);
                                    }
                                }
                                baseNatAppointmentDO.setPayStatus("1");
                                baseNatAppointmentDO.setPayStatus("1");
                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                                tasyNatService.sendWxtemplateMessaeg(baseNatAppointmentDO.getConsumer(),"hszfcgtx",baseNatAppointmentDO.getName(),baseNatAppointmentDO.getId().toString());
                            }
                            }
                            return "SUCCESS";
                            return "SUCCESS";
                    }
                    }
@ -2333,6 +2359,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        }
        }
        return  "failed";
        return  "failed";
    }
    }
    @GetMapping("/saveNatAppointment")
    @GetMapping("/saveNatAppointment")
    @ApiOperation(value = "核酸检测预约接口")
    @ApiOperation(value = "核酸检测预约接口")
    public Envelop saveNatAppointment(@ApiParam(name = "chargeAmount", value = "chargeAmount")
    public Envelop saveNatAppointment(@ApiParam(name = "chargeAmount", value = "chargeAmount")
@ -2401,4 +2428,101 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
            return Envelop.getError(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
        }
    }
    }
    @GetMapping("/BS10142")
    public ListEnvelop BS10142(
            @ApiParam(name = "deptCode", value = "deptCode")
            @RequestParam(value = "deptCode",required = false)String deptCode,
            @ApiParam(name = "docCode", value = "docCode")
            @RequestParam(value = "docCode",required = false)String docCode,
            @ApiParam(name = "chargeType", value = "chargeType")
            @RequestParam(value = "chargeType",required = false)String chargeType) throws Exception {
        if("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            return success(entranceService.BS10142(deptCode,docCode,chargeType,false));
        }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            String res=tasyNatService.departMent(deptCode);
            String dept="";
            JSONObject deptres = JSON.parseObject(res);
            if (deptres!=null){
                if (deptres.getString("success").equalsIgnoreCase("true")){
                    JSONObject data = JSON.parseObject(deptres.getString("data"));
                    dept=data.getString("Dept");
                    com.alibaba.fastjson.JSONArray jsonArray1 = JSON.parseArray(dept);
                    if (jsonArray1!=null&&jsonArray1.size()>0){
                        JSONObject jsonObject = jsonArray1.getJSONObject(0);
                        dept=jsonObject.getString("Id");
                        System.out.println(dept);
                    }
                    String json=tasyNatService.GetDoctorWorkDate("3",dept);
                    JSONObject jsonObject = JSON.parseObject(json);
                    jsonObject.put("dept",dept);
                    com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
                    jsonArray.add(jsonObject);
                    return success(jsonArray);
                }else {
                    return ListEnvelop.getError("获取部门编码失败");
                }
            }else {
                return ListEnvelop.getError("无效部门");
            }
        }else {
            return ListEnvelop.getError("未开放");
        }
    }
    @GetMapping("/BS10143")
    public ListEnvelop BS10143(@ApiParam(name = "day", value = "day")
                               @RequestParam(value = "day",required = false)String day,
                               @ApiParam(name = "dept", value = "dept")
                               @RequestParam(value = "dept",required = false)String dept,
                               @ApiParam(name = "doctor", value = "doctor")
                               @RequestParam(value = "doctor",required = false)String doctor,
                               @ApiParam(name = "IsAll", value = "IsAll")
                               @RequestParam(value = "IsAll",required = false)String IsAll,
                               @ApiParam(name = "pm", value = "pm")
                               @RequestParam(value = "pm",required = false)String pm) throws Exception {
        if("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            return success(entranceService.BS10143(day,pm,false));
        }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            String res=tasyNatService.GetOrderSource(dept,doctor,day,"3",IsAll,pm);
            String xml="";
            if (!StringUtils.isEmpty(res)){
                JSONObject jsonObject = JSON.parseObject(res);
                System.out.println("====="+jsonObject.getString("success"));
                if (jsonObject!=null&&jsonObject.getString("success").equalsIgnoreCase("true")){
                    xml=jsonObject.getString("data");
                    XMLSerializer xmlSerializer = new XMLSerializer();
                    String json = xmlSerializer.read(xml).toString();
                    JSONObject jsonObjectRes = JSON.parseObject(json);
                    com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
                    jsonArray.add(jsonObjectRes);
                    return success(jsonArray);
                }
            }
            return ListEnvelop.getError("查询失败");
        }else {
            return ListEnvelop.getError("未开放");
        }
    }
    @GetMapping("/DepartMent")
    public Envelop DepartMent(
            @ApiParam(name = "DepartMent", value = "DepartMent")
            @RequestParam(value = "DepartMent",required = false)String DepartMent) throws Exception {
        return success("查询成功",tasyNatService.departMent(DepartMent));
    }
    @GetMapping("/hdrQueryData")
    public MixEnvelop hdrQueryData(
            @ApiParam(name = "patient", value = "patient")
            @RequestParam(value = "patient",required = false)String patient) throws Exception {
        try {
            return MixEnvelop.getSuccess("查询成功",tasyNatService.getNatResult(patient));
        }catch (Exception e){
            return failedMixEnvelopException(e);
        }
    }
}
}

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

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.endpoint.prescription;
package com.yihu.jw.hospital.endpoint.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.area.service.BaseCityService;
import com.yihu.jw.area.service.BaseCityService;
@ -49,6 +50,7 @@ import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -132,6 +134,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private EntranceService entranceService;
    private EntranceService entranceService;
    @Autowired
    @Autowired
    private BaseOperateLogService baseOperateLogService;
    private BaseOperateLogService baseOperateLogService;
    @Autowired
    private TasyNatService tasyNatService;
    @Value("${qywx.id}")
    @Value("${qywx.id}")
    private String qywxId;
    private String qywxId;
@ -362,7 +366,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                       @RequestParam(value = "patient", required = true)String patient)throws Exception {
                                       @RequestParam(value = "patient", required = true)String patient)throws Exception {
        try {
        try {
            return success(prescriptionService.findPatientCard(patient));
            if ("xm_zsyy_wx".equalsIgnoreCase(wxId)){
                return success(prescriptionService.findPatientCard(patient));
            }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
                return success(tasyNatService.findPatientCard(patient));
            }else {
                return ListEnvelop.getError("暂未开放");
            }
        }catch (Exception e) {
        }catch (Exception e) {
            return failedListEnvelopException(e);
            return failedListEnvelopException(e);
        }
        }
@ -2873,14 +2883,73 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "docCode",required = false)String docCode,
            @RequestParam(value = "docCode",required = false)String docCode,
            @ApiParam(name = "chargeType", value = "chargeType")
            @ApiParam(name = "chargeType", value = "chargeType")
            @RequestParam(value = "chargeType",required = false)String chargeType) throws Exception {
            @RequestParam(value = "chargeType",required = false)String chargeType) throws Exception {
        return success(entranceService.BS10142(deptCode,docCode,chargeType,demoFlag));
        if("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            return success(entranceService.BS10142(deptCode,docCode,chargeType,demoFlag));
        }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            String res=tasyNatService.departMent(deptCode);
            String dept="";
            JSONObject deptres = JSON.parseObject(res);
            if (deptres!=null){
                if (deptres.getString("success").equalsIgnoreCase("true")){
                    JSONObject data = JSON.parseObject(deptres.getString("data"));
                    dept=data.getString("Dept");
                    JSONArray jsonArray1 = JSON.parseArray(dept);
                    if (jsonArray1!=null&&jsonArray1.size()>0){
                        JSONObject jsonObject = jsonArray1.getJSONObject(0);
                        dept=jsonObject.getString("Id");
                        System.out.println(dept);
                    }
                    String json=tasyNatService.GetDoctorWorkDate("3",dept);
                    JSONObject jsonObject = JSON.parseObject(json);
                    jsonObject.put("dept",dept);
                    com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
                    jsonArray.add(jsonObject);
                    return success(jsonArray);
                }else {
                    return ListEnvelop.getError("获取部门编码失败");
                }
            }else {
                return ListEnvelop.getError("无效部门");
            }
        }else {
            return ListEnvelop.getError("未开放");
        }
    }
    }
    @GetMapping("/BS10143")
    @GetMapping("/BS10143")
    public ListEnvelop BS10143(@ApiParam(name = "day", value = "day")
    public ListEnvelop BS10143(@ApiParam(name = "day", value = "day")
                               @RequestParam(value = "day",required = false)String day,
                               @RequestParam(value = "day",required = false)String day,
                               @ApiParam(name = "dept", value = "dept")
                               @RequestParam(value = "dept",required = false)String dept,
                               @ApiParam(name = "doctor", value = "doctor")
                                   @RequestParam(value = "doctor",required = false)String doctor,
                               @ApiParam(name = "IsAll", value = "IsAll")
                                   @RequestParam(value = "IsAll",required = false)String IsAll,
                               @ApiParam(name = "pm", value = "pm")
                               @ApiParam(name = "pm", value = "pm")
                               @RequestParam(value = "pm",required = false)String pm) throws Exception {
                               @RequestParam(value = "pm",required = false)String pm) throws Exception {
        return success(entranceService.BS10143(day,pm,demoFlag));
        if("xm_zsyy_wx".equalsIgnoreCase(wxId)){
            return success(entranceService.BS10143(day,pm,false));
        }else if ("xm_tasy_wx".equalsIgnoreCase(wxId)){
            String res=tasyNatService.GetOrderSource(dept,doctor,day,"3",IsAll,pm);
            String xml="";
            if (!org.apache.axis.utils.StringUtils.isEmpty(res)){
                JSONObject jsonObject = JSON.parseObject(res);
                System.out.println("====="+jsonObject.getString("success"));
                if (jsonObject!=null&&jsonObject.getString("success").equalsIgnoreCase("true")){
                    xml=jsonObject.getString("data");
                    XMLSerializer xmlSerializer = new XMLSerializer();
                    String json = xmlSerializer.read(xml).toString();
                    JSONObject jsonObjectRes = JSON.parseObject(json);
                    com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
                    jsonArray.add(jsonObjectRes);
                    return success(jsonArray);
                }
            }
            return ListEnvelop.getError("查询失败");
        }else {
            return ListEnvelop.getError("未开放");
        }
    }
    }
    @GetMapping("/BS10144")
    @GetMapping("/BS10144")
    public Envelop BS10144(@ApiParam(name = "deptCode", value = "deptCode")
    public Envelop BS10144(@ApiParam(name = "deptCode", value = "deptCode")