|
@ -29,7 +29,7 @@ import java.util.*;
|
|
|
@Transactional
|
|
|
public class DoctorWorkTimeService extends BaseService {
|
|
|
|
|
|
static Object obj = new Object();
|
|
|
static Object obj = new Object();
|
|
|
@Autowired
|
|
|
private DoctorWorkTimeDao doctorWorkTimeDao;
|
|
|
@Autowired
|
|
@ -48,7 +48,7 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
public JSONObject findDoctorWorkTime(String doctor) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
Doctor doc = doctorDao.findByCode(doctor);
|
|
|
if(doc == null){
|
|
|
if (doc == null) {
|
|
|
throw new Exception("doctor not exist");
|
|
|
}
|
|
|
WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
|
|
@ -242,71 +242,79 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
json.put("status", "0");
|
|
|
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 (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 (currentEnd.length() == 4) {
|
|
|
currentEnd = "0" + currentEnd;
|
|
|
// 下午
|
|
|
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 (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", "医生当前接受咨询");
|
|
|
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", "医生当前不在工作时间");
|
|
|
}
|
|
|
} else {
|
|
|
json.put("status", "2");
|
|
|
json.put("msg", "医生当前不在工作时间");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -344,33 +352,41 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
json.put("status", "0");
|
|
|
json.put("times", 0);
|
|
|
} else {
|
|
|
if (result.get("workWeek") != null) {
|
|
|
WlyyDoctorWorkWeek workWeek = (WlyyDoctorWorkWeek)result.get("workWeek");
|
|
|
boolean flag = false;
|
|
|
|
|
|
if(StringUtils.isNotEmpty(workWeek.getMorning()) && workWeek.getMorning().equals("1")){
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(workWeek.getAfternoon()) && workWeek.getAfternoon().equals("1")){
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(workWeek.getNight()) && workWeek.getNight().equals("1")){
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
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("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
} else {
|
|
|
if (result.get("workWeek") != null) {
|
|
|
WlyyDoctorWorkWeek workWeek = (WlyyDoctorWorkWeek) result.get("workWeek");
|
|
|
boolean flag = false;
|
|
|
|
|
|
if (StringUtils.isNotEmpty(workWeek.getMorning()) && workWeek.getMorning().equals("1")) {
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(workWeek.getAfternoon()) && workWeek.getAfternoon().equals("1")) {
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(workWeek.getNight()) && workWeek.getNight().equals("1")) {
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
|
|
|
if(!flag){
|
|
|
if (!flag) {
|
|
|
json.put("status", "0");
|
|
|
json.put("times", 0);
|
|
|
}
|
|
|
} else {
|
|
|
json.put("status", "0");
|
|
|
json.put("times", 0);
|
|
|
}
|
|
|
} else {
|
|
|
json.put("status", "0");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -493,8 +509,8 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
JSONObject json = isDoctorWorkingToday(doc.getCode());
|
|
|
|
|
|
if (json.getString("status").equals("1")) {
|
|
|
DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doc.getCode(),date);
|
|
|
if(timesRemain == null) {
|
|
|
DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doc.getCode(), date);
|
|
|
if (timesRemain == null) {
|
|
|
timesRemain = new DoctorFamousConsultTimesRemain();
|
|
|
}
|
|
|
timesRemain.setDoctor(doc.getCode());
|