|
@ -28,6 +28,7 @@ import java.util.*;
|
|
|
@Transactional
|
|
|
public class DoctorWorkTimeService extends BaseService {
|
|
|
|
|
|
static Object obj = new Object();
|
|
|
@Autowired
|
|
|
private DoctorWorkTimeDao doctorWorkTimeDao;
|
|
|
@Autowired
|
|
@ -382,32 +383,33 @@ public class DoctorWorkTimeService extends BaseService {
|
|
|
*/
|
|
|
public boolean setDoctorCurrentConsultTimesRemain(String doctor) {
|
|
|
try {
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor, df.format(new Date()));
|
|
|
synchronized (obj) {
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor, df.format(new Date()));
|
|
|
|
|
|
if (timesRemain != null) {
|
|
|
int times = timesRemain.getTimesRemain();
|
|
|
if (timesRemain != null) {
|
|
|
int times = timesRemain.getTimesRemain();
|
|
|
|
|
|
if (times < 1) {
|
|
|
throw new Exception("consult-times-error:doctor does not have not consult times remain");
|
|
|
}
|
|
|
if (times < 1) {
|
|
|
throw new Exception("consult-times-error:doctor does not have not consult times remain");
|
|
|
}
|
|
|
|
|
|
timesRemain.setTimesRemain(times - 1);
|
|
|
timesRemainDao.save(timesRemain);
|
|
|
} else {
|
|
|
DoctorFamousConsultTimesRemain timesRemainNew = new DoctorFamousConsultTimesRemain();
|
|
|
WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
|
|
|
timesRemain.setTimesRemain(times - 1);
|
|
|
timesRemainDao.save(timesRemain);
|
|
|
} else {
|
|
|
DoctorFamousConsultTimesRemain timesRemainNew = new DoctorFamousConsultTimesRemain();
|
|
|
WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
|
|
|
|
|
|
if (workTime == null || workTime.getFamousConsultTimes() < 1) {
|
|
|
throw new Exception("consult-times-error:doctor does not have consult times setting");
|
|
|
}
|
|
|
if (workTime == null || workTime.getFamousConsultTimes() < 1) {
|
|
|
throw new Exception("consult-times-error:doctor does not have consult times setting");
|
|
|
}
|
|
|
|
|
|
timesRemainNew.setDoctor(doctor);
|
|
|
timesRemainNew.setConsultDate(df.format(new Date()));
|
|
|
timesRemainNew.setTimesRemain(workTime.getFamousConsultTimes() - 1);
|
|
|
timesRemainDao.save(timesRemainNew);
|
|
|
timesRemainNew.setDoctor(doctor);
|
|
|
timesRemainNew.setConsultDate(df.format(new Date()));
|
|
|
timesRemainNew.setTimesRemain(workTime.getFamousConsultTimes() - 1);
|
|
|
timesRemainDao.save(timesRemainNew);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|