基于config表过滤表中的记录

juud5qan  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(306)

我有两个表:时隙表和配置表。我有配置表中的控制时隙表。
配置表中的记录

GuidelineId   GuidelineName  WeekDay    ClinicNumber    ProviderNumber  TimeStart   TimeEnd  PatientsPermitted  enabled 
  1          Guideline 1       NULL       34               NULL         6:30:00    10:59:00      2                1         
  2          Guideline 2       5          34               179          7:30:00    11:59:00      3                1

笔记

Weekday  0 Monday
             1 Tuesday,
             2 Wednesday, 
             3 Thursday
             4 Friday 
             5 Saturday 
             6 Sunday.

PatientsPermitted :No patients permitted per day

时隙表中的记录

sID,   StartSlot,              EndSlot,     WeekDay,     Valid, 
1,   2020-08-01 08:30:00, 2020-08-01 09:10:00,   5,         0 
2,   2020-08-01 09:10:00, 2020-08-01 09:50:00,   5,         0
3,   2020-08-01 10:40:00, 2020-08-01 11:20:00,   5,         0
4,   2020-08-01 11:20:00, 2020-08-01 12:00:00,   5,         0
5,   2020-08-01 15:20:00, 2020-08-01 16:00:00,   5,         0
9,   2020-08-01 16:00:00, 2020-08-01 16:40:00,   5,         0
7,   2020-08-06 08:30:00, 2020-08-06 09:10:00,   3,         0
8,   2020-08-06 09:10:00, 2020-08-06 09:50:00,   3,         0
9,   2020-08-06 09:50:00, 2020-08-06 10:30:00,   3,         0
10,  2020-08-06 12:00:00, 2020-08-06 12:40:00,   3,         0
11,  2020-08-06 14:00:00, 2020-08-06 14:40:00,   3,         0
12,  2020-08-06 14:40:00, 2020-08-06 15:20:00,   3,         0
13,  2020-08-11 08:30:00, 2020-08-06 09:10:00,   2,         0
14,  2020-08-11 09:10:00, 2020-08-06 09:50:00,   2,         0
15,  2020-08-11 09:50:00, 2020-08-06 10:30:00,   2,         0
16,  2020-08-11 12:00:00, 2020-08-06 12:40:00,   2,         0
17,  2020-08-11 14:00:00, 2020-08-06 14:40:00,   2,         0
18,  2020-08-11 14:40:00, 2020-08-06 15:20:00,   2,         0

配置表用于控制时隙表中的时隙。根据配置表,有效时隙更新为true
准则1
如果采用准则1,则记录

sID,   StartSlot,              EndSlot,     WeekDay,    Valid, 
    1,   2020-08-01 08:30:00, 2020-08-01 09:10:00,   5,         1
    2,   2020-08-01 09:10:00, 2020-08-01 09:50:00,   5,         1
    3,   2020-08-01 10:40:00, 2020-08-01 11:20:00,   5,         0
    4,   2020-08-01 11:20:00, 2020-08-01 12:00:00,   5,         0
    5,   2020-08-01 15:20:00, 2020-08-01 16:00:00,   5,         0
    9,   2020-08-01 16:00:00, 2020-08-01 16:40:00,   5,         0
    7,   2020-08-06 08:30:00, 2020-08-06 09:10:00,   3,         1
    8,   2020-08-06 09:10:00, 2020-08-06 09:50:00,   3,         1
    9,   2020-08-06 09:50:00, 2020-08-06 10:30:00,   3,         0
    10,  2020-08-06 12:00:00, 2020-08-06 12:40:00,   3,         0
    11,  2020-08-06 14:00:00, 2020-08-06 14:40:00,   3,         0
    12,  2020-08-06 14:40:00, 2020-08-06 15:20:00,   3,         0
    13,  2020-08-11 08:30:00, 2020-08-06 09:10:00,   2,         1
    14,  2020-08-11 09:10:00, 2020-08-06 09:50:00,   2,         1
    15,  2020-08-11 09:50:00, 2020-08-06 10:30:00,   2,         0
    16,  2020-08-11 12:00:00, 2020-08-06 12:40:00,   2,         0
    17,  2020-08-11 14:00:00, 2020-08-06 14:40:00,   2,         0
    18,  2020-08-11 14:40:00, 2020-08-06 15:20:00,   2,         0

如果采用准则2,则记录

sID,   StartSlot,              EndSlot,     WeekDay,       Valid, 
        1,   2020-08-01 08:30:00, 2020-08-01 09:10:00,   5,         1
        2,   2020-08-01 09:10:00, 2020-08-01 09:50:00,   5,         1
        3,   2020-08-01 10:40:00, 2020-08-01 11:20:00,   5,         1
        4,   2020-08-01 11:20:00, 2020-08-01 12:00:00,   5,         0
        5,   2020-08-01 15:20:00, 2020-08-01 16:00:00,   5,         0
        9,   2020-08-01 16:00:00, 2020-08-01 16:40:00,   5,         0
        7,   2020-08-06 08:30:00, 2020-08-06 09:10:00,   3,         0
        8,   2020-08-06 09:10:00, 2020-08-06 09:50:00,   3,         0
        9,   2020-08-06 09:50:00, 2020-08-06 10:30:00,   3,         0
        10,  2020-08-06 12:00:00, 2020-08-06 12:40:00,   3,         0
        11,  2020-08-06 14:00:00, 2020-08-06 14:40:00,   3,         0
        12,  2020-08-06 14:40:00, 2020-08-06 15:20:00,   3,         0
        13,  2020-08-11 08:30:00, 2020-08-06 09:10:00,   2,         0
        14,  2020-08-11 09:10:00, 2020-08-06 09:50:00,   2,         0
        15,  2020-08-11 09:50:00, 2020-08-06 10:30:00,   2,         0
        16,  2020-08-11 12:00:00, 2020-08-06 12:40:00,   2,         0
        17,  2020-08-11 14:00:00, 2020-08-06 14:40:00,   2,         0
        18,  2020-08-11 14:40:00, 2020-08-06 15:20:00,   2,         0

下面的代码我正在尝试

UPDATE TimeSlots S INNER JOIN Guideline G  ON S.WeekDay = IFNULL(G.WeekDay,S.WeekDay)
        SET 
         S.valid=1
        WHERE S.valid=0       
        AND
        ( (TIME(S.StartSlot) >= G.StartTime AND TIME(S.StartSlot) <= G.EndTime) );

我可以得到特定日期的时间段如何实现patientspermited有人能帮我吗,我还想实现多个工作日在配置表目前空意味着所有0到6天的星期天

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题