一个关于工作日和非工作日的表格 表设计如下: CREATE TABLE special_work_rest_day ( HWDAY varchar(10) COMMENT '具体日期', DAYTYPE varchar(1) COMMENT '参数类型 1休息 2工作', STATUS varchar(1) COMMENT '状态 0不可用 1 可用' default '0', INPUTDATE varchar(10) COMMENT '登记日期', INPUTUSERID varchar(10) COMMENT '登记人', PRIMARY KEY (HWDAY) ) comment='非正常工作休息日表'; 正常的工作日只需要判断当天是否是周一到周五, 正常的休息日只需要判断当天是否是周六或者周日 只有那些特殊的日子(工作日变成了休息日,休息日变成了工作日)才需要特别的记录在表中。 判断某天是否是工作日 从表中查询这天的信息,如果是空的,就通过查询当前时间是周一到周五,还是周六周日来判断 一般情况下,因为数据量比较小,而且是不变的,可以将数据全部缓存起来只读,这样就不必每次查询数据库。 如下是2022需要特别记录的日子 -- 2022年 -- 元旦 insert into special_work_rest_day values ('2022-01-03','1','1','2021-10-26','ccy'); -- 春节 insert into special_work_rest_day values ('2022-01-29','2','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-01-30','2','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-01-31','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-02-01','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-02-02','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-02-03','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-02-04','1','1','2021-10-26','ccy'); --清明节 insert into special_work_rest_day values ('2022-04-02','2','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-04-04','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-04-05','1','1','2021-10-26','ccy'); --劳动节 insert into special_work_rest_day values ('2022-04-24','2','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-05-02','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-05-03','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-05-04','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-05-07','2','1','2021-10-26','ccy'); --端午节 insert into special_work_rest_day values ('2022-06-03','1','1','2021-10-26','ccy'); --中秋节 insert into special_work_rest_day values ('2022-09-12','1','1','2021-10-26','ccy'); --国庆节 insert into special_work_rest_day values ('2022-10-03','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-10-04','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-10-05','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-10-06','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-10-07','1','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-10-08','2','1','2021-10-26','ccy'); insert into special_work_rest_day values ('2022-10-09','2','1','2021-10-26','ccy'); commit;