|  | @ -4,13 +4,19 @@ package com.yihu.jw.hospital.prescription.service;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.sun.org.apache.regexp.internal.RE;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
	
		
			
				|  |  | 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.httplog.dao.WlyyHttpLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.BaseNatAppointmentDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.dao.BusinessOrderDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.hospital.doctor.PersonInfoVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
	
		
			
				|  | @ -25,6 +31,7 @@ import nu.xom.Element;
 | 
	
		
			
				|  |  | import nu.xom.Elements;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.math.NumberUtils;
 | 
	
		
			
				|  |  | import org.apache.http.NameValuePair;
 | 
	
		
			
				|  |  | import org.apache.http.message.BasicNameValuePair;
 | 
	
		
			
				|  |  | import org.checkerframework.checker.units.qual.A;
 | 
	
	
		
			
				|  | @ -35,10 +42,8 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 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.net.URLEncoder;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional
 | 
	
	
		
			
				|  | @ -58,6 +63,10 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |     private BasePatientWechatDao basePatientWechatDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WxTemplateConfigDao wxTemplateConfigDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseNatAppointmentDao baseNatAppointmentDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BusinessOrderDao businessOrderDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String getOperateUrl(){
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -451,17 +460,17 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |             url=wlyyHospitalSysDictDO.getDictValue();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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("tradeNo", jsonObject.getString("tradeNo")));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("openId", jsonObject.getString("openId")));
 | 
	
		
			
				|  |  |         params.add(new BasicNameValuePair("name", jsonObject.getString("name")));
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  |         saveHttpLog("placeOrder",params.toString(),response,url);
 | 
	
		
			
				|  |  |         saveHttpLog("placeOrder",jsonObject.toString(),response,url);
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -472,12 +481,9 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |             url=wlyyHospitalSysDictDO.getDictValue();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  |         saveHttpLog("orderStatus",params.toString(),response,url);
 | 
	
		
			
				|  |  |         saveHttpLog("orderStatus",jsonObject.toString(),response,url);
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -488,22 +494,16 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |             url=wlyyHospitalSysDictDO.getDictValue();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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);
 | 
	
		
			
				|  |  |         saveHttpLog("tmpPush",params.toString(),response,url);
 | 
	
		
			
				|  |  |         saveHttpLog("tmpPush",jsonObject.toString(),response,url);
 | 
	
		
			
				|  |  |         return response;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public void  saveHttpLog(String name,String req,String res,String code){
 | 
	
		
			
				|  |  |         WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setRequest(req);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setName(name);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setCode(code);
 | 
	
		
			
				|  |  |         //wlyyHttpLogDO.setCode(code);
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyHttpLogDO.setResponse(res);
 | 
	
		
			
				|  |  |         wlyyHttpLogDao.save(wlyyHttpLogDO);
 | 
	
	
		
			
				|  | @ -513,13 +513,19 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |         String url="";
 | 
	
		
			
				|  |  |         String openId="";
 | 
	
		
			
				|  |  |         JSONObject key=new JSONObject();
 | 
	
		
			
				|  |  |         JSONObject first=new JSONObject();
 | 
	
		
			
				|  |  |         JSONObject key1=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);
 | 
	
		
			
				|  |  |         if (basePatientWechatDo!=null&&basePatientWechatDo.size()>0){
 | 
	
		
			
				|  |  |             openId=basePatientWechatDo.get(0).getOpenid();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ("hszfcg".equalsIgnoreCase(scene)){
 | 
	
		
			
				|  |  |         if ("hszfcgtx".equalsIgnoreCase(scene)){
 | 
	
		
			
				|  |  |             //开始发送模板消息
 | 
	
		
			
				|  |  |             logger.info("开始发送模板消息");
 | 
	
		
			
				|  |  |             List<WxTemplateConfigDO> wxTemplateConfigDO = wxTemplateConfigDao.findByWechatIdAndScene("xm_tasy_wx",scene);
 | 
	
	
		
			
				|  | @ -528,12 +534,27 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |                 wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             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());
 | 
	
		
			
				|  |  |             key2.put("value",wxTemplateConfigDO1.getKeyword1().replace("key1",name));
 | 
	
		
			
				|  |  |             key2.put("value",baseNatAppointmentD0.getChargeAmount());
 | 
	
		
			
				|  |  |             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("keyword2",key2);
 | 
	
		
			
				|  |  |             key.put("key3",key3);
 | 
	
		
			
				|  |  |             key.put("key4",key4);
 | 
	
		
			
				|  |  |             key.put("key5",key5);
 | 
	
		
			
				|  |  |             key.put("remark",remark);
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |             jsonObject.put("tempateId",wxTemplateConfigDO1.getTemplateId());//
 | 
	
		
			
				|  |  |             jsonObject.put("data",key);
 | 
	
	
		
			
				|  | @ -551,12 +572,27 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |                 wxTemplateConfigDO1 = wxTemplateConfigDO.get(0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             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());
 | 
	
		
			
				|  |  |             key2.put("value",wxTemplateConfigDO1.getKeyword1().replace("key1",name));
 | 
	
		
			
				|  |  |             key2.put("value",baseNatAppointmentD0.getDeptName());
 | 
	
		
			
				|  |  |             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.getCreateTime());
 | 
	
		
			
				|  |  |             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("keyword2",key2);
 | 
	
		
			
				|  |  |             key.put("key3",key3);
 | 
	
		
			
				|  |  |             key.put("key4",key4);
 | 
	
		
			
				|  |  |             key.put("key5",key5);
 | 
	
		
			
				|  |  |             key.put("remark",remark);
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |             jsonObject.put("tempateId",wxTemplateConfigDO1.getTemplateId());//
 | 
	
		
			
				|  |  |             jsonObject.put("data",key);
 | 
	
	
		
			
				|  | @ -565,15 +601,233 @@ public class TasyNatService {
 | 
	
		
			
				|  |  |             logger.info("核酸检测支付提醒模板消息推送param"+jsonObject.toString());
 | 
	
		
			
				|  |  |             String tmResilt= tmpPush(jsonObject);
 | 
	
		
			
				|  |  |             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",baseNatAppointmentD0.getAppointmentTime());
 | 
	
		
			
				|  |  |             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("key3",key3);
 | 
	
		
			
				|  |  |             key.put("key4",key4);
 | 
	
		
			
				|  |  |             key.put("remark",remark);
 | 
	
		
			
				|  |  |             JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |             jsonObject.put("tempateId",wxTemplateConfigDO1.getTemplateId());//
 | 
	
		
			
				|  |  |             jsonObject.put("data",key);
 | 
	
		
			
				|  |  |             jsonObject.put("openId",openId);
 | 
	
		
			
				|  |  |             jsonObject.put("url",url);
 | 
	
		
			
				|  |  |             logger.info("核酸检测预约成功模板消息推送param"+jsonObject.toString());
 | 
	
		
			
				|  |  |             String tmResilt= tmpPush(jsonObject);
 | 
	
		
			
				|  |  |             return tmResilt;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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("]]"));
 | 
	
		
			
				|  |  |         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("订单已支付");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return businessOrderDO.getRematk();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |