Преглед изворни кода

Merge branch 'dev' of lyr/patient-co-management into dev

chenweida пре 8 година
родитељ
комит
aca8266635

+ 81 - 8
src/main/java/com/yihu/wlyy/service/app/scheduling/DoctorWorkTimeService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.repository.doctor.DoctorWorkWeekDao;
import com.yihu.wlyy.repository.doctor.FamousDoctorTimesRemainDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.eval.StringValueEval;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -174,6 +175,24 @@ public class DoctorWorkTimeService extends BaseService {
            doctorWorkWeekDao.save(weeks);
        }
        if(doc.getIsFamous() != null && doc.getIsFamous() == 1){
            JSONObject json =  isDoctorWorkingToday(doctor);
            if(json.getString("status").equals("1")){
                DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor,
                        new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                if (timesRemain == null) {
                    timesRemain = new DoctorFamousConsultTimesRemain();
                    timesRemain.setDoctor(doctor);
                    timesRemain.setTimesRemain(doctorWorkTime.getFamousConsultTimes());
                    timesRemain.setConsultDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                    timesRemainDao.save(timesRemain);
                }
            }
        }
        return true;
    }
@ -187,13 +206,14 @@ public class DoctorWorkTimeService extends BaseService {
    public boolean setDoctorReceiveConsult(String doctor, String receiveConsult) throws Exception {
        try {
            WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
            Doctor doc = doctorDao.findByCode(doctor);
            if (doc == null) {
                throw new Exception("doctor not exist");
            }
            // 未有设置,则新建医生设置
            if (workTime == null) {
                Doctor doc = doctorDao.findByCode(doctor);
                if (doc == null) {
                    throw new Exception("doctor can not find");
                }
                workTime = new WlyyDoctorWorkTime();
                workTime.setDoctor(doctor);
                workTime.setDoctorName(doc.getName());
@ -205,6 +225,25 @@ public class DoctorWorkTimeService extends BaseService {
            workTime.setCzrq(new Date());
            doctorWorkTimeDao.save(workTime);
            if (doc.getIsFamous() != null && doc.getIsFamous() == 1) {
                JSONObject json = isDoctorWorkingToday(doctor);
                if (json.getString("status").equals("1")) {
                    DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor,
                            new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                    if (timesRemain == null) {
                        timesRemain = new DoctorFamousConsultTimesRemain();
                        timesRemain.setDoctor(doctor);
                        timesRemain.setTimesRemain(workTime.getFamousConsultTimes());
                        timesRemain.setConsultDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                        timesRemainDao.save(timesRemain);
                    }
                }
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
@ -403,17 +442,21 @@ public class DoctorWorkTimeService extends BaseService {
    public boolean setFamousDoctorConsultTimes(String doctor, int consultTimes) {
        try {
            WlyyDoctorWorkTime workTime = doctorWorkTimeDao.findDoctorWorkTime(doctor);
            Doctor doc = doctorDao.findByCode(doctor);
            int plus = 0;
            if (doc == null) {
                throw new Exception("doctor can not find");
            }
            // 未有设置,则新建医生设置
            if (workTime == null) {
                Doctor doc = doctorDao.findByCode(doctor);
                if (doc == null) {
                    throw new Exception("doctor can not find");
                }
                workTime = new WlyyDoctorWorkTime();
                workTime.setDoctor(doctor);
                workTime.setDoctorName(doc.getName());
                workTime.setReceiveConsult("1");
            } else {
                plus = consultTimes - workTime.getFamousConsultTimes();
            }
            // 设置名医咨询次数
@ -422,6 +465,34 @@ public class DoctorWorkTimeService extends BaseService {
            doctorWorkTimeDao.save(workTime);
            if (doc.getIsFamous() != null && doc.getIsFamous() == 1) {
                JSONObject json = isDoctorWorkingToday(doctor);
                if (json.getString("status").equals("1")) {
                    DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doctor,
                            new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                    if (timesRemain == null) {
                        timesRemain = new DoctorFamousConsultTimesRemain();
                        timesRemain.setDoctor(doctor);
                        timesRemain.setTimesRemain(consultTimes);
                        timesRemain.setConsultDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                    } else {
                        if (plus >= 0) {
                            timesRemain.setTimesRemain(workTime.getFamousConsultTimes() + plus);
                        } else {
                            if(workTime.getFamousConsultTimes() >= Math.abs(plus)){
                                timesRemain.setTimesRemain(workTime.getFamousConsultTimes() - Math.abs(plus));
                            }else{
                                timesRemain.setTimesRemain(0);
                            }
                        }
                    }
                    timesRemainDao.save(timesRemain);
                }
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
@ -512,6 +583,8 @@ public class DoctorWorkTimeService extends BaseService {
                    DoctorFamousConsultTimesRemain timesRemain = timesRemainDao.findByDoctorAndConsultDate(doc.getCode(), date);
                    if (timesRemain == null) {
                        timesRemain = new DoctorFamousConsultTimesRemain();
                    }else{
                        continue;
                    }
                    timesRemain.setDoctor(doc.getCode());
                    timesRemain.setConsultDate(date);