|
@ -92,16 +92,6 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
map.put("workTime", workTime);
|
|
|
map.put("workWeek", workWeek);
|
|
|
|
|
|
if (doc.getIsFamous() == 1) {
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor, df.format(new Date()));
|
|
|
|
|
|
if (timesRemain == null) {
|
|
|
map.put("famousDoctorTimesRemain",workTime.getFamousConsultTimes());
|
|
|
} else {
|
|
|
map.put("famousDoctorTimesRemain",timesRemain.getTimesRemain());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return map;
|
|
|
}
|
|
@ -317,6 +307,70 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询名医当天是否接受咨询
|
|
|
*
|
|
|
* @param doctor
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject isDoctorWorkingToday(String doctor) throws Exception {
|
|
|
JSONObject json = new JSONObject();
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
|
|
|
|
|
if (week == 0) {
|
|
|
week = 7;
|
|
|
}
|
|
|
|
|
|
// 医生工作时间设置
|
|
|
Map<String, Object> result = findDoctorWeekWork(doctor, String.valueOf(week));
|
|
|
|
|
|
if (result.get("workTime") == null) {
|
|
|
// 医生未设置时,默认7*24小时工作
|
|
|
json.put("status", "1");
|
|
|
json.put("times", 0);
|
|
|
} else {
|
|
|
WlyyDoctorWorkTime doctorWorkTime = (WlyyDoctorWorkTime) result.get("workTime");
|
|
|
|
|
|
if (doctorWorkTime.getReceiveConsult().equals("0")) {
|
|
|
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.getMorning()) && workWeek.getMorning().equals("1")){
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(workWeek.getMorning()) && workWeek.getMorning().equals("1")){
|
|
|
json.put("status", "1");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
flag = true;
|
|
|
}
|
|
|
|
|
|
if(!flag){
|
|
|
json.put("status", "0");
|
|
|
json.put("times", 0);
|
|
|
}
|
|
|
} else {
|
|
|
json.put("status", "0");
|
|
|
json.put("times", doctorWorkTime.getFamousConsultTimes());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置名医咨询次数
|
|
|
*
|
|
@ -416,4 +470,25 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
public void consultTimesRemain(String date) {
|
|
|
try {
|
|
|
List<Doctor> doctors = doctorDao.findByIsFamous(1);
|
|
|
|
|
|
for (Doctor doc : doctors) {
|
|
|
JSONObject json = isDoctorWorkingToday(doc.getCode());
|
|
|
|
|
|
if (json.getString("status").equals("1")) {
|
|
|
DoctorFamousConsultTimesRemain timesRemain = new DoctorFamousConsultTimesRemain();
|
|
|
timesRemain.setDoctor(doc.getCode());
|
|
|
timesRemain.setConsultDate(date);
|
|
|
timesRemain.setTimesRemain(json.getInt("times"));
|
|
|
timesRemainDao.save(timesRemain);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|