|
@ -4,10 +4,12 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
import com.yihu.wlyy.entity.doctor.schedule.DoctorFamousConsultTimesRemain;
|
|
import com.yihu.wlyy.entity.doctor.schedule.DoctorFamousConsultTimesRemain;
|
|
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
|
|
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
|
|
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
|
|
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
|
|
|
|
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorWorkTimeDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorWorkTimeDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorWorkWeekDao;
|
|
import com.yihu.wlyy.repository.doctor.DoctorWorkWeekDao;
|
|
import com.yihu.wlyy.repository.doctor.FamousDoctorTimesRemainDao;
|
|
import com.yihu.wlyy.repository.doctor.FamousDoctorTimesRemainDao;
|
|
|
|
import com.yihu.wlyy.repository.message.MessageNoticeSettingDao;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.ss.formula.eval.StringValueEval;
|
|
import org.apache.poi.ss.formula.eval.StringValueEval;
|
|
@ -39,6 +41,8 @@ public class DoctorWorkTimeService extends BaseService {
|
|
private DoctorDao doctorDao;
|
|
private DoctorDao doctorDao;
|
|
@Autowired
|
|
@Autowired
|
|
private FamousDoctorTimesRemainDao timesRemainDao;
|
|
private FamousDoctorTimesRemainDao timesRemainDao;
|
|
|
|
@Autowired
|
|
|
|
private MessageNoticeSettingDao messageNoticeSettingDao;
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
public void updateDoctorWorkTime(String doctorCode) {
|
|
public void updateDoctorWorkTime(String doctorCode) {
|
|
@ -730,5 +734,155 @@ public class DoctorWorkTimeService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public JSONObject isDoctorWorkingWhenConsult(String doctor,String doctorHealth) throws Exception {
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
|
|
|
|
|
if (week == 0) {
|
|
|
|
week = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断居民签约的全科医生是否关闭了"健康咨询在健管师邀请后参与"设置
|
|
|
|
MessageNoticeSetting messageNoticeSetting = messageNoticeSettingDao.findByUserAndType(doctor,"1");
|
|
|
|
if (messageNoticeSetting!=null){
|
|
|
|
//健管师推荐开启
|
|
|
|
if (messageNoticeSetting.getFamilyTopicSwitch()==1){
|
|
|
|
JSONObject doctorJson = doctorWork(doctor,week,calendar);
|
|
|
|
JSONObject doctorHealthJson = doctorWork(doctorHealth,week,calendar);
|
|
|
|
String doctorStatus = doctorJson.getString("status");
|
|
|
|
String doctorHealthStatus = doctorHealthJson.getString("status");
|
|
|
|
//两个都不接受咨询时,无法咨询
|
|
|
|
if ("0".equals(doctorStatus) && "0".equals(doctorHealthStatus)){
|
|
|
|
json.put("status", "0");
|
|
|
|
json.put("msg", "医生不接受咨询");
|
|
|
|
}
|
|
|
|
//两个其中有一个可以咨询时都可以咨询
|
|
|
|
if ("1".equals(doctorStatus) || "1".equals(doctorHealthStatus)){
|
|
|
|
json.put("status", "1");
|
|
|
|
json.put("msg", "医生当前接受咨询");
|
|
|
|
}
|
|
|
|
//如果全科和健管师都不在时间范围
|
|
|
|
if ("2".equals(doctorStatus) && "2".equals(doctorHealthStatus)){
|
|
|
|
json.put("status","2");
|
|
|
|
json.put("msg","全科医生和健管师当前都不在工作时间");
|
|
|
|
}
|
|
|
|
//健管师在工作时间,全科不在
|
|
|
|
if ("2".equals(doctorStatus) && "1".equals(doctorHealthStatus)){
|
|
|
|
json.put("status","3");
|
|
|
|
json.put("msg","全科医生当前不在工作时间");
|
|
|
|
}
|
|
|
|
//全科在工作时间,健管师不在
|
|
|
|
if ("1".equals(doctorStatus) && "2".equals(doctorHealthStatus)){
|
|
|
|
json.put("status","4");
|
|
|
|
json.put("msg","健管师当前不在工作时间");
|
|
|
|
}
|
|
|
|
}else {//健管师推荐关闭
|
|
|
|
json = doctorWork(doctorHealth,week,calendar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 医生时间设置
|
|
|
|
* @param doctorCode
|
|
|
|
* @param week
|
|
|
|
* @param calendar
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
private JSONObject doctorWork(String doctorCode,int week,Calendar calendar)throws Exception{
|
|
|
|
Map<String, Object> result = findDoctorWeekWork(doctorCode, String.valueOf(week));
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
if (result.get("workTime") == null) {
|
|
|
|
// 医生未设置时,默认7*24小时工作
|
|
|
|
json.put("status", "1");
|
|
|
|
json.put("msg", "医生当前接受咨询");
|
|
|
|
} else {
|
|
|
|
WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime) result.get("workTime");
|
|
|
|
|
|
|
|
if (doctorWorkTime.getReceiveConsult().equals("0")) {
|
|
|
|
// 医生设置不接受咨询
|
|
|
|
json.put("status", "0");
|
|
|
|
json.put("msg", "医生不接受咨询");
|
|
|
|
} else {
|
|
|
|
if (StringUtils.isEmpty(doctorWorkTime.getMorningBegin()) && StringUtils.isEmpty(doctorWorkTime.getMorningEnd())
|
|
|
|
&& StringUtils.isEmpty(doctorWorkTime.getAfternoonBegin()) && StringUtils.isEmpty(doctorWorkTime.getAfternoonEnd())
|
|
|
|
&& StringUtils.isEmpty(doctorWorkTime.getNightBegin()) && StringUtils.isEmpty(doctorWorkTime.getNightEnd())) {
|
|
|
|
// 医生未设置工作时间,默认7*24小时工作
|
|
|
|
json.put("status", "1");
|
|
|
|
json.put("msg", "医生当前接受咨询");
|
|
|
|
} else {
|
|
|
|
if (result.get("workWeek") != null) {
|
|
|
|
// 当前工作日已设置工作时间
|
|
|
|
int flag = 0;
|
|
|
|
WlyyDoctorWorkTime workTime = (WlyyDoctorWorkTime) result.get("workTime");
|
|
|
|
WlyyDoctorWorkWeek workWeek = (WlyyDoctorWorkWeek) result.get("workWeek");
|
|
|
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
|
|
|
int minute = calendar.get(Calendar.MINUTE);
|
|
|
|
String current = (hour < 10 ? ("0" + hour) : hour) + ":" + (hour < 10 ? ("0" + minute) : minute);
|
|
|
|
|
|
|
|
// 早上
|
|
|
|
if (workWeek.getMorning().equals("1")) {
|
|
|
|
String currentStart = workTime.getMorningBegin();
|
|
|
|
String currentEnd = workTime.getMorningEnd();
|
|
|
|
if (currentStart.length() == 4) {
|
|
|
|
currentStart = "0" + currentStart;
|
|
|
|
}
|
|
|
|
if (currentEnd.length() == 4) {
|
|
|
|
currentEnd = "0" + currentEnd;
|
|
|
|
}
|
|
|
|
if (current.compareTo(currentStart) >= 0 &&
|
|
|
|
current.compareTo(currentEnd) < 0) {
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 下午
|
|
|
|
if (workWeek.getAfternoon().equals("1")) {
|
|
|
|
String currentStart = workTime.getAfternoonBegin();
|
|
|
|
String currentEnd = workTime.getAfternoonEnd();
|
|
|
|
if (currentStart.length() == 4) {
|
|
|
|
currentStart = "0" + currentStart;
|
|
|
|
}
|
|
|
|
if (currentEnd.length() == 4) {
|
|
|
|
currentEnd = "0" + currentEnd;
|
|
|
|
}
|
|
|
|
if (current.compareTo(currentStart) >= 0 &&
|
|
|
|
current.compareTo(currentEnd) < 0) {
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 晚上
|
|
|
|
if (workWeek.getNight().equals("1")) {
|
|
|
|
String currentStart = workTime.getNightBegin();
|
|
|
|
String currentEnd = workTime.getNightEnd();
|
|
|
|
if (currentStart.length() == 4) {
|
|
|
|
currentStart = "0" + currentStart;
|
|
|
|
}
|
|
|
|
if (currentEnd.length() == 4) {
|
|
|
|
currentEnd = "0" + currentEnd;
|
|
|
|
}
|
|
|
|
if (current.compareTo(currentStart) >= 0 &&
|
|
|
|
current.compareTo(currentEnd) < 0) {
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag == 1) {
|
|
|
|
json.put("status", "1");
|
|
|
|
json.put("msg", "医生当前接受咨询");
|
|
|
|
} else {
|
|
|
|
json.put("status", "2");
|
|
|
|
json.put("msg", "医生当前不在工作时间");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
json.put("status", "2");
|
|
|
|
json.put("msg", "医生当前不在工作时间");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return json;
|
|
|
|
}
|
|
}
|
|
}
|