Parcourir la source

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

trick9191 il y a 7 ans
Parent
commit
b6bfb73803

+ 158 - 152
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorFeldsherTemplateJob.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientSchemeListDao;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -40,181 +41,186 @@ public class DoctorFeldsherTemplateJob implements Job {
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("DoctorFeldsherTemplateJob start ..........");
        try {
            //获取居民在监测方案的监测时间前30分钟未上传监测数据
            SimpleDateFormat formatHour = new SimpleDateFormat("HH:mm:ss");
            Date today = new Date();
            Calendar c=Calendar.getInstance();
            c.setTime(today);
            int weekday=c.get(Calendar.DAY_OF_WEEK);
            String jobRunning = systemDictDao.findByDictNameAndCode("JOB_RUNNING","DoctorFeldsherTemplateJob");
            if("1".equals(jobRunning)){
                //获取居民在监测方案的监测时间前30分钟未上传监测数据
                SimpleDateFormat formatHour = new SimpleDateFormat("HH:mm:ss");
                Date today = new Date();
                Calendar c=Calendar.getInstance();
                c.setTime(today);
                int weekday=c.get(Calendar.DAY_OF_WEEK);
            //查询当天医生设置的监测方案
            List<DoctorSchemeBloodSugger> patientCodeList = schemeListDao.findSuggerPatient((short)weekday);
            for (DoctorSchemeBloodSugger patientCodeLis : patientCodeList) {
                String schemecode = patientCodeLis.getCode();
                //查询当天医生设置的监测方案
                List<DoctorSchemeBloodSugger> patientCodeList = schemeListDao.findSuggerPatient((short)weekday);
                for (DoctorSchemeBloodSugger patientCodeLis : patientCodeList) {
                    String schemecode = patientCodeLis.getCode();
                short beforeBreakfast = patientCodeLis.getBeforeBreakfast();
                Time beforeBreakfastTime = patientCodeLis.getBeforeBreakfastTime();
                short afterBreakfast = patientCodeLis.getAfterBreakfast();
                Time afterBreakfastTime = patientCodeLis.getAfterBreakfastTime();
                short beforeLunch = patientCodeLis.getBeforeLunch();
                Time beforeLunchTime = patientCodeLis.getBeforeLunchTime();
                short afterLunch = patientCodeLis.getAfterLunch();
                Time afterLunchTime = patientCodeLis.getAfterLunchTime();
                short beforeDinner = patientCodeLis.getBeforeDinner();
                Time beforeDinnerTime = patientCodeLis.getBeforeDinnerTime();
                short afterDinner = patientCodeLis.getAfterDinner();
                Time afterDinnerTime = patientCodeLis.getAfterDinnerTime();
                short beforeSleep = patientCodeLis.getBeforeSleep();
                Time beforeSleepTime = patientCodeLis.getBeforeSleepTime();
                    short beforeBreakfast = patientCodeLis.getBeforeBreakfast();
                    Time beforeBreakfastTime = patientCodeLis.getBeforeBreakfastTime();
                    short afterBreakfast = patientCodeLis.getAfterBreakfast();
                    Time afterBreakfastTime = patientCodeLis.getAfterBreakfastTime();
                    short beforeLunch = patientCodeLis.getBeforeLunch();
                    Time beforeLunchTime = patientCodeLis.getBeforeLunchTime();
                    short afterLunch = patientCodeLis.getAfterLunch();
                    Time afterLunchTime = patientCodeLis.getAfterLunchTime();
                    short beforeDinner = patientCodeLis.getBeforeDinner();
                    Time beforeDinnerTime = patientCodeLis.getBeforeDinnerTime();
                    short afterDinner = patientCodeLis.getAfterDinner();
                    Time afterDinnerTime = patientCodeLis.getAfterDinnerTime();
                    short beforeSleep = patientCodeLis.getBeforeSleep();
                    Time beforeSleepTime = patientCodeLis.getBeforeSleepTime();
                String toDay = formatHour.format(today);
                long to = formatHour.parse(toDay).getTime();
                if (beforeBreakfast == 1) {
                    Time tempTime = Time.valueOf("00:00:00");
                    long tempTo = tempTime.getTime();
                    long from = beforeBreakfastTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,tempTime,beforeBreakfastTime,"早餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    String toDay = formatHour.format(today);
                    long to = formatHour.parse(toDay).getTime();
                    if (beforeBreakfast == 1) {
                        Time tempTime = Time.valueOf("00:00:00");
                        long tempTo = tempTime.getTime();
                        long from = beforeBreakfastTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,tempTime,beforeBreakfastTime,"早餐前");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (afterBreakfast == 1) {
                    long from = afterBreakfastTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeBreakfastTime,afterBreakfastTime,"早餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (afterBreakfast == 1) {
                        long from = afterBreakfastTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,beforeBreakfastTime,afterBreakfastTime,"早餐后");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (beforeLunch == 1) {
                    long from = beforeLunchTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterBreakfastTime,beforeLunchTime,"午餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (beforeLunch == 1) {
                        long from = beforeLunchTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,afterBreakfastTime,beforeLunchTime,"午餐前");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (afterLunch == 1) {
                    long from = afterLunchTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeLunchTime,afterLunchTime,"午餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (afterLunch == 1) {
                        long from = afterLunchTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,beforeLunchTime,afterLunchTime,"午餐后");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (beforeDinner == 1) {
                    long from = beforeDinnerTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterLunchTime,beforeDinnerTime,"晚餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (beforeDinner == 1) {
                        long from = beforeDinnerTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,afterLunchTime,beforeDinnerTime,"晚餐前");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (afterDinner == 1) {
                    long from = afterDinnerTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeDinnerTime,afterDinnerTime,"晚餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (afterDinner == 1) {
                        long from = afterDinnerTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,beforeDinnerTime,afterDinnerTime,"晚餐后");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (beforeSleep == 1) {
                    long from = beforeSleepTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterDinnerTime,beforeSleepTime,"睡前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (beforeSleep == 1) {
                        long from = beforeSleepTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,1,schemecode,afterDinnerTime,beforeSleepTime,"睡前");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
            }
            List<DoctorSchemeBloodPressure> patientCodes = schemeListDao.findPressurePatient((short)weekday);
            for (DoctorSchemeBloodPressure patientCodeLis : patientCodes) {
                String schemecode = patientCodeLis.getCode();
                List<DoctorSchemeBloodPressure> patientCodes = schemeListDao.findPressurePatient((short)weekday);
                for (DoctorSchemeBloodPressure patientCodeLis : patientCodes) {
                    String schemecode = patientCodeLis.getCode();
                short earlyMorning = patientCodeLis.getEarlyMorning();
                Time earlyMorningTime = patientCodeLis.getEarlyMorningTime();
                short morning = patientCodeLis.getMorning();
                Time morningTime = patientCodeLis.getMorningTime();
                short noon = patientCodeLis.getNoon();
                Time noonTime = patientCodeLis.getNoonTime();
                short afterNoon = patientCodeLis.getAfterNoon();
                Time afterNoonTime = patientCodeLis.getAfterNoonTime();
                short night = patientCodeLis.getNight();
                Time nightTime = patientCodeLis.getNightTime();
                    short earlyMorning = patientCodeLis.getEarlyMorning();
                    Time earlyMorningTime = patientCodeLis.getEarlyMorningTime();
                    short morning = patientCodeLis.getMorning();
                    Time morningTime = patientCodeLis.getMorningTime();
                    short noon = patientCodeLis.getNoon();
                    Time noonTime = patientCodeLis.getNoonTime();
                    short afterNoon = patientCodeLis.getAfterNoon();
                    Time afterNoonTime = patientCodeLis.getAfterNoonTime();
                    short night = patientCodeLis.getNight();
                    Time nightTime = patientCodeLis.getNightTime();
//                比较现在时间和监测时间《=30
                String toDay = formatHour.format(today);
                long to = formatHour.parse(toDay).getTime();
                if (earlyMorning == 1) {
                    Time tempTime = Time.valueOf("00:00:00");
                    long tempTo = tempTime.getTime();
                    long from = earlyMorningTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,tempTime,earlyMorningTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    String toDay = formatHour.format(today);
                    long to = formatHour.parse(toDay).getTime();
                    if (earlyMorning == 1) {
                        Time tempTime = Time.valueOf("00:00:00");
                        long tempTo = tempTime.getTime();
                        long from = earlyMorningTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,2,schemecode,tempTime,earlyMorningTime,"");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (morning == 1) {
                    long from = morningTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,earlyMorningTime,morningTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (morning == 1) {
                        long from = morningTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,2,schemecode,earlyMorningTime,morningTime,"");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (noon == 1) {
                    long from = noonTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,morningTime,noonTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (noon == 1) {
                        long from = noonTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,2,schemecode,morningTime,noonTime,"");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (afterNoon == 1) {
                    long from = afterNoonTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,noonTime,afterNoonTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (afterNoon == 1) {
                        long from = afterNoonTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,2,schemecode,noonTime,afterNoonTime,"");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
                if (night == 1) {
                    long from = nightTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,afterNoonTime,nightTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    if (night == 1) {
                        long from = nightTime.getTime();
                        int minutes = (int) ((from - to) / (1000 * 60));
                        try {
                            sendPatientHealth(minutes,2,schemecode,afterNoonTime,nightTime,"");
                        } catch (Exception e) {
                            e.printStackTrace();
                            continue;
                        }
                    }
                }
            }