|
@ -1,240 +1,85 @@
|
|
|
//package com.yihu.wlyy.service.app.prenatalInspector;
|
|
|
//
|
|
|
//import com.yihu.wlyy.entity.patient.Patient;
|
|
|
//import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
//import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
|
|
|
//import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
|
|
|
//import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPreCard;
|
|
|
//import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
//import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanDao;
|
|
|
//import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanLibraryDao;
|
|
|
//import com.yihu.wlyy.repository.patient.PrenatalInspectorPreCardDao;
|
|
|
//import com.yihu.wlyy.service.BaseService;
|
|
|
//import com.yihu.wlyy.service.app.sign.FamilyContractService;
|
|
|
//import com.yihu.wlyy.task.PushMsgTask;
|
|
|
//import com.yihu.wlyy.util.DateUtil;
|
|
|
//import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
//import org.apache.commons.lang3.StringUtils;
|
|
|
//import org.json.JSONArray;
|
|
|
//import org.json.JSONObject;
|
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
//import org.springframework.stereotype.Component;
|
|
|
//import org.springframework.transaction.annotation.Transactional;
|
|
|
//
|
|
|
//import java.util.ArrayList;
|
|
|
//import java.util.Date;
|
|
|
//import java.util.List;
|
|
|
//
|
|
|
///**
|
|
|
// * Created by yeshijie on 2017/6/6.
|
|
|
// */
|
|
|
//@Component
|
|
|
//@Transactional(rollbackFor = Exception.class)
|
|
|
//public class PrenatalInspectorPreCardService extends BaseService {
|
|
|
//
|
|
|
// @Autowired
|
|
|
// private PrenatalInspectorPreCardDao prenatalInspectorPreCardDao;
|
|
|
// @Autowired
|
|
|
// private PrenatalInspectorPlanLibraryDao prenatalInspectorPlanLibraryDao;
|
|
|
// @Autowired
|
|
|
// private PrenatalInspectorPlanDao prenatalInspectorPlanDao;
|
|
|
// @Autowired
|
|
|
// private WeiXinAccessTokenUtils accessTokenUtils;
|
|
|
// @Autowired
|
|
|
// private PatientDao patientDao;
|
|
|
// @Autowired
|
|
|
// private FamilyContractService familyContractService;
|
|
|
//
|
|
|
// /**
|
|
|
// * 待产检计划
|
|
|
// * @param code
|
|
|
// * @return
|
|
|
// */
|
|
|
// public JSONArray planList(String code){
|
|
|
// JSONArray jsonArray = new JSONArray();
|
|
|
// List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByCode(code);
|
|
|
// for (PrenatalInspectorPlan plan:planList){
|
|
|
// JSONObject json = new JSONObject();
|
|
|
// json.put("checkItem",plan.getCheckItem());
|
|
|
// json.put("name",plan.getName());
|
|
|
// json.put("thisFoucs",plan.getThisFocus());
|
|
|
// json.put("thisNote",plan.getThisNote());
|
|
|
// if(plan.getInspectionTime()==null){
|
|
|
// json.put("inspectionTime","");
|
|
|
// }else {
|
|
|
// json.put("inspectionTime",DateUtil.dateToStrShort(plan.getInspectionTime()));
|
|
|
// }
|
|
|
// json.put("inspectionEndTime",DateUtil.dateToStrShort(plan.getInspectionEndTime()));
|
|
|
// json.put("inspectionStartTime",DateUtil.dateToStrShort(plan.getInspectionStartTime()));
|
|
|
//
|
|
|
//
|
|
|
// jsonArray.put(json);
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// return jsonArray;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 预建卡列表-孕检计划
|
|
|
// * @param patient
|
|
|
// * @return
|
|
|
// */
|
|
|
// public JSONArray preCardList(String patient){
|
|
|
// JSONArray jsonArray = new JSONArray();
|
|
|
// List<PrenatalInspectorPreCard> preCards = prenatalInspectorPreCardDao.findByPatient(patient);
|
|
|
// for (PrenatalInspectorPreCard preCard:preCards){
|
|
|
// JSONObject json = new JSONObject();
|
|
|
// json.put("code",preCard.getCode());
|
|
|
// json.put("dueDate",DateUtil.dateToStrShort(preCard.getDueDate()));//预产期
|
|
|
// Date date = new Date();
|
|
|
// Long dueDateDay = DateUtil.getDays(preCard.getDueDate(),date);
|
|
|
// if(dueDateDay>0){
|
|
|
// json.put("dueDateWeek",getWeek(dueDateDay.intValue()));//距离预产期周数
|
|
|
// json.put("dueDateDay",getDay(dueDateDay.intValue()));//距离预产期周数的余数
|
|
|
// Long pregnancyDay = DateUtil.getDays(date,preCard.getLastMenstrualDate());
|
|
|
// int week = getWeek(pregnancyDay.intValue());
|
|
|
// int day = getDay(pregnancyDay.intValue());
|
|
|
// String preDay = day==0?(week+"周"):(week+"周"+day+"天");//怀孕时间
|
|
|
// json.put("status",preDay);
|
|
|
// }else {
|
|
|
// json.put("dueDateWeek",0);//距离预产期周数
|
|
|
// json.put("dueDateDay",0);//距离预产期周数的余数
|
|
|
// json.put("status",preCard.getStatus());
|
|
|
// }
|
|
|
//
|
|
|
// json.put("hospitalName",preCard.getHospitalName());//预约床位医院
|
|
|
// json.put("orderBedTime",preCard.getOrderBedTime());//预约床位时间
|
|
|
//
|
|
|
// jsonArray.put(json);
|
|
|
// }
|
|
|
//
|
|
|
// return jsonArray;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 把天数换算成周数
|
|
|
// * @param day
|
|
|
// * @return
|
|
|
// */
|
|
|
// private int getWeek(Integer day){
|
|
|
// return day/7;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 把天数换算成周数的余数
|
|
|
// * @param day
|
|
|
// * @return
|
|
|
// */
|
|
|
// private int getDay(Integer day){
|
|
|
// return day%7;
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 新建产检预建卡
|
|
|
// */
|
|
|
// @Transactional
|
|
|
// public void addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard){
|
|
|
// //1、保存预建卡
|
|
|
// Date date = new Date();
|
|
|
// Date lastMenstrualDate = preCard.getLastMenstrualDate();
|
|
|
// preCard.setDel("1");
|
|
|
// preCard.setCode(getCode());
|
|
|
// preCard.setCzrq(date);
|
|
|
// preCard.setDueDate(DateUtil.getDueDate(preCard.getLastMenstrualDate()));//预产期
|
|
|
// preCard.setStatus("0");
|
|
|
// preCard.setEffective("");
|
|
|
// preCard.setInspectionPhase("1");//检查阶段
|
|
|
// prenatalInspectorPreCardDao.save(preCard);
|
|
|
//
|
|
|
// String patient = preCard.getPatient();
|
|
|
//
|
|
|
// //2、生成待产检计划
|
|
|
// Long days = DateUtil.getDays(date,lastMenstrualDate);
|
|
|
// List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
|
|
|
// List<PrenatalInspectorPlan> plans = new ArrayList<>();
|
|
|
// PrenatalInspectorPlan plan = null;
|
|
|
// for (PrenatalInspectorPlanLibrary library:libraries){
|
|
|
// plan = new PrenatalInspectorPlan();
|
|
|
// plan.setInspectionPhase(library.getInspectionPhase());
|
|
|
// plan.setStatus("0");
|
|
|
// plan.setPatient(patient);
|
|
|
// plan.setCzrq(date);
|
|
|
// plan.setCheckItem(library.getCheckItem());
|
|
|
// plan.setInspectionCode(preCard.getCode());
|
|
|
// plan.setInspectionEndTime(DateUtil.getPrenatalInspectorDate(lastMenstrualDate,library.getEndDay().intValue()));
|
|
|
// plan.setInspectionStartTime(DateUtil.getPrenatalInspectorDate(lastMenstrualDate,library.getStartDay().intValue()));
|
|
|
// plan.setName(library.getName());
|
|
|
// plan.setThisFocus(library.getThisFocus());
|
|
|
// plan.setThisNote(library.getThisNote());
|
|
|
//
|
|
|
// if("1".equals(plan.getInspectionPhase())){
|
|
|
// SignFamily jiating = familyContractService.findByPatientByType(patient, 2);
|
|
|
// if(jiating!=null){
|
|
|
// plan.setSignHospital(jiating.getHospital());
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// plans.add(plan);
|
|
|
// }
|
|
|
// if (plans.size()>0){
|
|
|
// prenatalInspectorPlanDao.save(plans);
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
// /**
|
|
|
// * 产检提醒(1预约提醒,2就诊提醒)
|
|
|
// * 1、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前7天(保证居民可自行预约),发出产检预约提醒通知。点击该消息,进入预约页面
|
|
|
// * 2、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前1天,发出产检就诊提醒,提醒居民就诊。点击该消息,进入预约记录页面
|
|
|
// */
|
|
|
// public void sendPrenatalInspectorRemind(){
|
|
|
// System.out.println("产检计划---running");
|
|
|
// List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findWxTipList();
|
|
|
// for (PrenatalInspectorPlan plan:planList){
|
|
|
// try {
|
|
|
// Patient patient = patientDao.findByCode(plan.getPatient());
|
|
|
// String openId = patient.getOpenid();
|
|
|
// String name = patient.getName();
|
|
|
// String patientCode = patient.getCode();
|
|
|
// if(StringUtils.isNotBlank(openId)){
|
|
|
// Long day = DateUtil.getDays(plan.getInspectionTime(),DateUtil.getNowDateShort());
|
|
|
// JSONObject json = new JSONObject();
|
|
|
// if(day==7){
|
|
|
// //产检提醒
|
|
|
// json.put("remark","产检内容以医生实际检查为准。点击进行预约");
|
|
|
// json.put("first",name+",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
|
|
|
// if("1".equals(plan.getInspectionPhase())){
|
|
|
// if(StringUtils.isNotBlank(plan.getSignHospital())){
|
|
|
// json.put("url","wdyy/html/hospital-dept.html?openid="+openId+"&toUser="+patientCode+"&toName="+name+"&hospitalId="+plan.getSignHospital());
|
|
|
// }else {
|
|
|
// json.put("url","wdyy/html/appointment-register.html?openid="+openId+"&toUser="+patientCode+"&toName="+name+"&orderType=1");
|
|
|
// }
|
|
|
// }else {
|
|
|
// json.put("url","wdyy/html/appointment-register.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
|
|
|
// }
|
|
|
//
|
|
|
// json.put("keyword1","产检提醒");
|
|
|
// String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
|
|
|
// json.put("keyword2",keyword2);
|
|
|
// PushMsgTask.getInstance().sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
|
|
|
// }else if(day==1){
|
|
|
// //产检就诊提醒
|
|
|
// json.put("remark","产检内容以医生实际检查为准。点击查看预约记录");
|
|
|
// json.put("first",name+",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
|
|
|
// json.put("url","wdyy/html/my-appointment.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
|
|
|
// json.put("keyword1","产检就诊提醒");
|
|
|
// String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
|
|
|
// json.put("keyword2",keyword2);
|
|
|
// PushMsgTask.getInstance().sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
|
|
|
// }
|
|
|
// }
|
|
|
// }catch (Exception e){
|
|
|
// System.out.println("微信提醒发送失败");
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
//}
|
|
|
package com.yihu.wlyy.service.app.prenatalInspector;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.sign.FamilyContractService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by yeshijie on 2017/6/6.
|
|
|
*/
|
|
|
@Component
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public class PrenatalInspectorPreCardService extends BaseService {
|
|
|
|
|
|
@Autowired
|
|
|
private PrenatalInspectorPlanDao prenatalInspectorPlanDao;
|
|
|
@Autowired
|
|
|
private WeiXinAccessTokenUtils accessTokenUtils;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private FamilyContractService familyContractService;
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 产检提醒(1预约提醒,2就诊提醒)
|
|
|
* 1、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前7天(保证居民可自行预约),发出产检预约提醒通知。点击该消息,进入预约页面
|
|
|
* 2、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前1天,发出产检就诊提醒,提醒居民就诊。点击该消息,进入预约记录页面
|
|
|
*/
|
|
|
public void sendPrenatalInspectorRemind(){
|
|
|
System.out.println("产检计划---running");
|
|
|
List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findWxTipList();
|
|
|
for (PrenatalInspectorPlan plan:planList){
|
|
|
try {
|
|
|
Patient patient = patientDao.findByCode(plan.getPatient());
|
|
|
String openId = patient.getOpenid();
|
|
|
String name = patient.getName();
|
|
|
String patientCode = patient.getCode();
|
|
|
if(StringUtils.isNotBlank(openId)){
|
|
|
Long day = DateUtil.getDays(plan.getInspectionTime(),DateUtil.getNowDateShort());
|
|
|
JSONObject json = new JSONObject();
|
|
|
if(day==7){
|
|
|
//产检提醒
|
|
|
json.put("remark","产检内容以医生实际检查为准。点击进行预约");
|
|
|
json.put("first",name+",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
|
|
|
json.put("url","wdyy/html/appointment-register.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
|
|
|
|
|
|
json.put("keyword1","产检提醒");
|
|
|
String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
|
|
|
json.put("keyword2",keyword2);
|
|
|
pushMsgTask.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
|
|
|
}else if(day==1){
|
|
|
//产检就诊提醒
|
|
|
json.put("remark","产检内容以医生实际检查为准。点击查看预约记录");
|
|
|
json.put("first",name+",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
|
|
|
json.put("url","wdyy/html/my-appointment.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
|
|
|
json.put("keyword1","产检就诊提醒");
|
|
|
String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
|
|
|
json.put("keyword2",keyword2);
|
|
|
pushMsgTask.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
System.out.println("微信提醒发送失败");
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|