浏览代码

计划免疫预约确认和取消增加微信模块消息和手机短信推送

huangwenjie 7 年之前
父节点
当前提交
afc5d935a5

+ 183 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneRegisterRecord.java

@ -0,0 +1,183 @@
package com.yihu.wlyy.entity.imm;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 计划免疫预约记录表
 * @author huangwenjie
 * @date 2018/1/28 17:26
 */
@Entity
@Table(name = "wlyy_child_immune_register_record")
public class ChildImmuneRegisterRecord  extends IdEntity {
	private String code;
	private String barCode;         //新生儿条码
	private String jwOrgcode;       //基卫机构编码
	private String orgCode;         //机构编码
	private String orgName;         //机构名称
	private String sectionType;     //坐诊类型:AM PM
	private Date startTime;         //号源日期
	private String ssc;             //挂号人社保卡
	private String idcard;          //挂号人身份证号
	private String name;            //挂号人姓名
	private String mobile;          //挂号人手机
	private Integer type;           //0为预约,1为取消预约
	private String familyCode;      //代预约的家人CODE
	private String familyName;      //代预约家人名称
	private String doctorCode;      //代预约的医生CODE
	private String doctorName;      //代预约的医生姓名
	private Date createTime;
	private Date updateTime;
	
	
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public String getBarCode() {
		return barCode;
	}
	
	public void setBarCode(String barCode) {
		this.barCode = barCode;
	}
	
	public String getJwOrgcode() {
		return jwOrgcode;
	}
	
	public void setJwOrgcode(String jwOrgcode) {
		this.jwOrgcode = jwOrgcode;
	}
	
	public String getOrgCode() {
		return orgCode;
	}
	
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	
	public String getOrgName() {
		return orgName;
	}
	
	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	
	public String getSectionType() {
		return sectionType;
	}
	
	public void setSectionType(String sectionType) {
		this.sectionType = sectionType;
	}
	
	public Date getStartTime() {
		return startTime;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	
	public String getSsc() {
		return ssc;
	}
	
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	
	public String getIdcard() {
		return idcard;
	}
	
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public Integer getType() {
		return type;
	}
	
	public void setType(Integer type) {
		this.type = type;
	}
	
	public String getFamilyCode() {
		return familyCode;
	}
	
	public void setFamilyCode(String familyCode) {
		this.familyCode = familyCode;
	}
	
	public String getFamilyName() {
		return familyName;
	}
	
	public void setFamilyName(String familyName) {
		this.familyName = familyName;
	}
	
	public String getDoctorCode() {
		return doctorCode;
	}
	
	public void setDoctorCode(String doctorCode) {
		this.doctorCode = doctorCode;
	}
	
	public String getDoctorName() {
		return doctorName;
	}
	
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	
	public Date getCreateTime() {
		return createTime;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public Date getUpdateTime() {
		return updateTime;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneRegisterRecordDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.imm;
import com.yihu.wlyy.entity.imm.ChildImmuneRegisterRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 计划免疫预约记录
 * @author huangwenjie
 * @date 2018/1/28 19:21
 */
public interface ChildImmuneRegisterRecordDao extends PagingAndSortingRepository<ChildImmuneRegisterRecord, Long>,
		JpaSpecificationExecutor<ChildImmuneRegisterRecord> {
}

+ 6 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java

@ -3,10 +3,16 @@ package com.yihu.wlyy.service.third.guahao;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.AccessToken;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -37,13 +43,10 @@ public class ImmuneService {
	@Autowired
	private HttpClientUtil httpClientUtil;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private HospitalMappingDao hospitalMappingDao;
	@Autowired
	private HospitalDao hospitalDao;
	
	
	/**
	 * 计免:获取免疫接种儿童信息
	 * @param barcode 新生儿条码

+ 282 - 28
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java

@ -1,9 +1,17 @@
package com.yihu.wlyy.web.patient.booking;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.imm.ChildImmuneRegisterRecord;
import com.yihu.wlyy.entity.imm.ChildInfo;
import com.yihu.wlyy.entity.message.SMS;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.imm.ChildImmuneRegisterRecordDao;
import com.yihu.wlyy.repository.message.SMSDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.imm.ChildInfoService;
@ -12,14 +20,23 @@ import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
import com.yihu.wlyy.service.third.guahao.ImmuneService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.zysoft.BookingController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -27,8 +44,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 预约挂号
@ -38,6 +55,9 @@ import java.util.Map;
@RequestMapping(value = "/patient/guahao")
@Api(description = "预约挂号接口-居民端")
public class PatientBookingController extends WeixinBaseController{
    
    private static final Logger logger = LoggerFactory.getLogger(PatientBookingController.class);
    
    @Autowired
    private GuahaoXMService guahaoXM;
    @Autowired
@ -56,6 +76,16 @@ public class PatientBookingController extends WeixinBaseController{
    private ChildInfoService childInfoService;
    @Autowired
    private ImmuneService immuneService;
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private com.yihu.wlyy.util.HttpClientUtil HttpClientUtil;
    @Autowired
    private SMSDao smsDao;
    @Autowired
    private ChildImmuneRegisterRecordDao childImmuneRegisterRecordDao;
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
@ -212,11 +242,11 @@ public class PatientBookingController extends WeixinBaseController{
    @ObserverRequired
    @ApiOperation("计免:获取免疫接种号源")
    public String GetOrgNumberList (@ApiParam(name="orgId",value="机构编码-ZONECODE",defaultValue = "350206")
                                    @RequestParam String orgId,
                                    @RequestParam(value = "orgId", required = true) String orgId ,
                                    @ApiParam(name="ScheduleId",value="排班ID",defaultValue = "350211B10402017080901")
                                    @RequestParam String ScheduleId,
                                    @RequestParam(value = "ScheduleId", required = true) String ScheduleId,
                                    @ApiParam(name="amorpm",value="上午或者下午",defaultValue = "AM")
                                    @RequestParam String amorpm){
                                    @RequestParam(value = "amorpm", required = true) String amorpm){
        
        try{
            com.alibaba.fastjson.JSONArray result = immuneService.GetOrgNumberList(orgId,ScheduleId,amorpm);
@ -232,24 +262,120 @@ public class PatientBookingController extends WeixinBaseController{
    @ObserverRequired
    @ApiOperation("计免:免疫接种确认预约")
    public String RegisterImmune (@ApiParam(name="BarCode",value="新生儿条形编码",defaultValue = "")
                                      @RequestParam String BarCode,
                                      @RequestParam(value = "BarCode", required = true) String BarCode,
                                  @ApiParam(name="OrgCode",value="机构编码",defaultValue = "")
                                      @RequestParam String OrgCode,
                                      @RequestParam(value = "OrgCode", required = true) String OrgCode,
                                  @ApiParam(name="SectionType",value="坐诊类型:取号源的TIME",defaultValue = "")
                                      @RequestParam String SectionType,
                                      @RequestParam(value = "SectionType", required = true) String SectionType,
                                  @ApiParam(name="strStart",value="日期:取号源的START_TIME",defaultValue = "")
                                      @RequestParam String strStart,
                                      @RequestParam(value = "strStart", required = true) String strStart,
                                  @ApiParam(name="SSID",value="新生儿社保卡号",defaultValue = "")
                                      @RequestParam String SSID,
                                      @RequestParam(value = "SSID", required = true) String SSID,
                                  @ApiParam(name="PatientName",value="新生儿姓名",defaultValue = "")
                                      @RequestParam String PatientName,
                                      @RequestParam(value = "PatientName", required = true) String PatientName,
                                  @ApiParam(name="PatientID",value="新生儿身份证号",defaultValue = "")
                                      @RequestParam String PatientID,
                                      @RequestParam(value = "PatientID", required = true) String PatientID,
                                  @ApiParam(name="PatientPhone",value="市民手机号:代预约人的手机号",defaultValue = "")
                                      @RequestParam String PatientPhone){
                                      @RequestParam(value = "PatientPhone", required = true) String PatientPhone){
        
        try{
            immuneService.RegisterImmune(BarCode,OrgCode,SectionType,strStart,SSID,PatientName,PatientID,PatientPhone);
    
            //预约发送微信消息
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            Date START_TIME_VO = dateFormat.parse(strStart);
            String date = DateUtil.dateToStrLong(START_TIME_VO);//开始时间-前端展示用
    
            Patient p = patientService.findByCode(getRepUID());
            String hospitalcode = hospitalMappingDao.getCodeByMapping(OrgCode, "1");
            Hospital hospital = hospitalDao.findByCode(hospitalcode);
    
            String msg = "您成功为"+PatientName+"预约了" + hospital.getName() + "的计划免疫 "+date+" 的号源!";
            // 推送消息给微信端
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", "");
            json.put("toUser", p.getCode());
            json.put("represented",p.getCode());//被代理人
            json.put("id", "");
            json.put("date", date);
            json.put("orgCode", hospitalcode);
            json.put("orgName", "-");
            json.put("doctorName", "-");
            json.put("deptName", "-");
            json.put("remark", p.getName() + ",您好!" + msg);
    
            //本地保存计划免疫预约记录
            ChildImmuneRegisterRecord childImmuneRegisterRecord = new ChildImmuneRegisterRecord();
            childImmuneRegisterRecord.setCode(UUID.randomUUID().toString());
            childImmuneRegisterRecord.setBarCode(BarCode);
            childImmuneRegisterRecord.setCreateTime(new Date());
            childImmuneRegisterRecord.setUpdateTime(new Date());
            childImmuneRegisterRecord.setFamilyCode(p.getCode());
            childImmuneRegisterRecord.setFamilyName(p.getName());
            childImmuneRegisterRecord.setMobile(PatientPhone);
            childImmuneRegisterRecord.setSsc(SSID);
            childImmuneRegisterRecord.setIdcard(PatientID);
            childImmuneRegisterRecord.setName(PatientName);
            childImmuneRegisterRecord.setOrgCode(hospitalcode);
            childImmuneRegisterRecord.setOrgName(hospital.getName());
            childImmuneRegisterRecord.setJwOrgcode(OrgCode);
            childImmuneRegisterRecord.setSectionType(SectionType);
            childImmuneRegisterRecord.setStartTime(START_TIME_VO);
            childImmuneRegisterRecord.setType(0);//0为预约,1为取消预约
            childImmuneRegisterRecord = childImmuneRegisterRecordDao.save(childImmuneRegisterRecord);
            
    
            //判断是否判定openId,有没有发则查找家人发送
            if(org.apache.commons.lang3.StringUtils.isNotBlank(p.getOpenid())){
                // 添加到发送队列
                pushMsgTask.putWxMsg(getAccessToken(), 6, p.getOpenid(), p.getName(), json);
            }
    
            //发送代理人
            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(),p.getOpenid());
            if(jsonArray!=null&&jsonArray.length()>0){
                for (int i = 0;i<jsonArray.length();i++){
                    JSONObject j  = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    JSONObject data = json;
                    data.remove("toUser");
                    data.put("toUser",member.getCode());
                    //String first = (String) json.get("first");
                    data.remove("first");
                    data.put("first",weiXinOpenIdUtils.getTitleMes(p,j.getInt("relation"),p.getName()));
                    pushMsgTask.putWxMsg(getAccessToken(), 6, member.getOpenid(), p.getName(), data);
                }
            }
    
            //发送短信消息
            //调用总部发送信息的接口
            String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, p.getMobile()), "GBK");
            JSONObject r = toJson(result);
            SMS sms = new SMS();
            sms.setContent(msg);
            sms.setCaptcha(null);
            Date dateMsg = new Date();
            sms.setDeadline(dateMsg);
            sms.setCzrq(dateMsg);
            sms.setMobile(p.getMobile());
            sms.setIp(NetworkUtil.getIpAddress(request));
            sms.setType(6);
            if (r == null) {
                // 发送失败
                logger.error("短信发送失败!");
                sms.setStatus(0);
                //throw new Exception("短信发送失败!");
            } else if (r.getInt("result") != 0) {
                sms.setStatus(0);
                smsDao.save(sms);
                return r.getString("description");
            } else {
                //发送成功,保存到数据库
                sms.setStatus(1);
            }
            smsDao.save(sms);
            BusinessLogs.info(BusinessLogs.BusinessType.appointment, getUID(), p.getCode(), new JSONObject(childImmuneRegisterRecord));
            
            return write(200, "预约成功");
        }catch (Exception e){
            error(e);
@ -262,24 +388,117 @@ public class PatientBookingController extends WeixinBaseController{
    @ObserverRequired
    @ApiOperation("计免:免疫接种取消预约")
    public String UnResRegisterImmune (@ApiParam(name="BarCode",value="新生儿条形编码",defaultValue = "")
                                  @RequestParam String BarCode,
                                  @ApiParam(name="OrgCode",value="机构编码",defaultValue = "")
                                  @RequestParam String OrgCode,
                                  @ApiParam(name="SectionType",value="坐诊类型:取号源的TIME",defaultValue = "")
                                  @RequestParam String SectionType,
                                  @ApiParam(name="strStart",value="日期:取号源的START_TIME",defaultValue = "")
                                  @RequestParam String strStart,
                                  @ApiParam(name="SSID",value="新生儿社保卡号",defaultValue = "")
                                  @RequestParam String SSID,
                                  @ApiParam(name="PatientName",value="新生儿姓名",defaultValue = "")
                                  @RequestParam String PatientName,
                                  @ApiParam(name="PatientID",value="新生儿身份证号",defaultValue = "")
                                  @RequestParam String PatientID,
                                  @ApiParam(name="PatientPhone",value="市民手机号:代预约人的手机号",defaultValue = "")
                                  @RequestParam String PatientPhone){
                                           @RequestParam(value = "BarCode", required = true) String BarCode,
                                       @ApiParam(name="OrgCode",value="机构编码",defaultValue = "")
                                           @RequestParam(value = "OrgCode", required = true) String OrgCode,
                                       @ApiParam(name="SectionType",value="坐诊类型:取号源的TIME",defaultValue = "")
                                           @RequestParam(value = "SectionType", required = true) String SectionType,
                                       @ApiParam(name="strStart",value="日期:取号源的START_TIME",defaultValue = "")
                                           @RequestParam(value = "strStart", required = true) String strStart,
                                       @ApiParam(name="SSID",value="新生儿社保卡号",defaultValue = "")
                                           @RequestParam(value = "SSID", required = true) String SSID,
                                       @ApiParam(name="PatientName",value="新生儿姓名",defaultValue = "")
                                           @RequestParam(value = "PatientName", required = true) String PatientName,
                                       @ApiParam(name="PatientID",value="新生儿身份证号",defaultValue = "")
                                           @RequestParam(value = "PatientID", required = true) String PatientID,
                                       @ApiParam(name="PatientPhone",value="市民手机号:代预约人的手机号",defaultValue = "")
                                           @RequestParam(value = "PatientPhone", required = true) String PatientPhone){
        
        try{
            immuneService.UnResRegisterImmune(BarCode,OrgCode,SectionType,strStart,SSID,PatientName,PatientID,PatientPhone);
    
            //预约发送微信消息
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            Date START_TIME_VO = dateFormat.parse(strStart);
            String date = DateUtil.dateToStrLong(START_TIME_VO);//开始时间-前端展示用
    
            Patient p = patientService.findByCode(getRepUID());
            String hospitalcode = hospitalMappingDao.getCodeByMapping(OrgCode, "1");
            Hospital hospital = hospitalDao.findByCode(hospitalcode);
    
            String msg = "您已取消了为"+PatientName+"预约的" + hospital.getName() + "的计划免疫 "+date+" 的挂号!";
            // 推送消息给微信端
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", "");
            json.put("toUser", p.getCode());
            json.put("represented",p.getCode());//被代理人
            json.put("name", p.getName());
            json.put("date", date);
            json.put("doctorName", "-");
            json.put("orgName", hospital.getName());
            json.put("remark", p.getName() + ",您好!" + msg);
    
            //本地保存计划免疫预约记录
            ChildImmuneRegisterRecord childImmuneRegisterRecord = new ChildImmuneRegisterRecord();
            childImmuneRegisterRecord.setCode(UUID.randomUUID().toString());
            childImmuneRegisterRecord.setBarCode(BarCode);
            childImmuneRegisterRecord.setCreateTime(new Date());
            childImmuneRegisterRecord.setUpdateTime(new Date());
            childImmuneRegisterRecord.setFamilyCode(p.getCode());
            childImmuneRegisterRecord.setFamilyName(p.getName());
            childImmuneRegisterRecord.setMobile(PatientPhone);
            childImmuneRegisterRecord.setSsc(SSID);
            childImmuneRegisterRecord.setIdcard(PatientID);
            childImmuneRegisterRecord.setName(PatientName);
            childImmuneRegisterRecord.setOrgCode(hospitalcode);
            childImmuneRegisterRecord.setOrgName(hospital.getName());
            childImmuneRegisterRecord.setJwOrgcode(OrgCode);
            childImmuneRegisterRecord.setSectionType(SectionType);
            childImmuneRegisterRecord.setStartTime(START_TIME_VO);
            childImmuneRegisterRecord.setType(1);//0为预约,1为取消预约
            childImmuneRegisterRecord = childImmuneRegisterRecordDao.save(childImmuneRegisterRecord);
    
    
            //判断是否判定openId,有没有发则查找家人发送
            if(org.apache.commons.lang3.StringUtils.isNotBlank(p.getOpenid())){
                // 添加到发送队列
                pushMsgTask.putWxMsg(getAccessToken(), 7, p.getOpenid(), p.getName(), json);
            }
    
            //发送代理人
            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(),p.getOpenid());
            if(jsonArray!=null&&jsonArray.length()>0){
                for (int i = 0;i<jsonArray.length();i++){
                    JSONObject j  = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    JSONObject data = json;
                    data.remove("toUser");
                    data.put("toUser",member.getCode());
                    //String first = (String) json.get("first");
                    data.remove("first");
                    data.put("first",weiXinOpenIdUtils.getTitleMes(p,j.getInt("relation"),p.getName()));
                    pushMsgTask.putWxMsg(getAccessToken(), 7, member.getOpenid(), p.getName(), data);
                }
            }
    
            //发送短信消息
            //调用总部发送信息的接口
//            String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, p.getMobile()), "GBK");
//            JSONObject r = toJson(result);
//            SMS sms = new SMS();
//            sms.setContent(msg);
//            sms.setCaptcha(null);
//            Date dateMsg = new Date();
//            sms.setDeadline(dateMsg);
//            sms.setCzrq(dateMsg);
//            sms.setMobile(p.getMobile());
//            sms.setIp(NetworkUtil.getIpAddress(request));
//            sms.setType(6);
//            if (r == null) {
//                // 发送失败
//                logger.error("短信发送失败!");
//                sms.setStatus(0);
//                //throw new Exception("短信发送失败!");
//            } else if (r.getInt("result") != 0) {
//                sms.setStatus(0);
//                smsDao.save(sms);
//                return r.getString("description");
//            } else {
//                //发送成功,保存到数据库
//                sms.setStatus(1);
//            }
//            smsDao.save(sms);
//            BusinessLogs.info(BusinessLogs.BusinessType.appointment, getUID(), p.getCode(), new JSONObject(childImmuneRegisterRecord));
            return write(200, "取消预约成功");
        }catch (Exception e){
            error(e);
@ -303,6 +522,41 @@ public class PatientBookingController extends WeixinBaseController{
        }
    }
    
    
    /**
     * 发送短信参数
     */
    private List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
        params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
        params.add(new BasicNameValuePair("Password", SystemConf.getInstance().getSmsPassword()));
        params.add(new BasicNameValuePair("MessageContent", content));
        params.add(new BasicNameValuePair("UserNumber", mobile));
        params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
        params.add(new BasicNameValuePair("ScheduleTime", ""));
        params.add(new BasicNameValuePair("f", "1"));
        return params;
    }
    
    private JSONObject toJson(String result) {
        JSONObject json = new JSONObject();
        try {
            String[] temps = result.split("&");
            for (String temp : temps) {
                if (temp.split("=").length != 2) {
                    continue;
                }
                String key = temp.split("=")[0];
                String value = temp.split("=")[1];
                json.put(key, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
    
    /**
     *-----------------计划免疫预约相关接口--------------END
     */