|
@ -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
|
|
|
*/
|