-- 产线工作日历 / 产线休息时间（若库中尚无表，可手工执行；库已存在时请跳过）
SET FOREIGN_KEY_CHECKS = 0;

CREATE TABLE IF NOT EXISTS `ShopCalendarWorkCtr` (
  `RecID` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `Domain` varchar(8) DEFAULT NULL COMMENT '域名',
  `ProdLine` varchar(32) NOT NULL COMMENT '生产线',
  `WeekDay` varchar(8) NOT NULL COMMENT '星期',
  `ShiftsStart1` decimal(13,4) DEFAULT NULL COMMENT '班次1开始(小数小时)',
  `ShiftsHours1` decimal(13,4) DEFAULT NULL COMMENT '班次1时长',
  `ShiftsStart2` decimal(13,4) DEFAULT NULL,
  `ShiftsHours2` decimal(13,4) DEFAULT NULL,
  `Ufld1` varchar(255) DEFAULT NULL,
  `IsActive` bit(1) NOT NULL DEFAULT b'1',
  `CreateUser` varchar(64) DEFAULT NULL,
  `UpdateUser` varchar(64) DEFAULT NULL,
  `CreateTime` datetime DEFAULT NULL,
  `UpdateTime` datetime DEFAULT NULL,
  `BusinessID` bigint NOT NULL DEFAULT 0,
  PRIMARY KEY (`RecID`),
  KEY `ix_scwc_line_day` (`ProdLine`,`WeekDay`,`IsActive`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='产线工作日历';

CREATE TABLE IF NOT EXISTS `QualityLineWorkDetail` (
  `RecID` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `Domain` varchar(8) DEFAULT NULL,
  `Site` varchar(12) DEFAULT NULL,
  `ProdLine` varchar(32) NOT NULL,
  `WorkShift` varchar(32) DEFAULT NULL,
  `Line` varchar(32) DEFAULT NULL,
  `RestTimePoint` datetime DEFAULT NULL,
  `RestTime` decimal(18,4) DEFAULT NULL,
  `Descr1` varchar(255) DEFAULT NULL,
  `Descr2` varchar(255) DEFAULT NULL,
  `Period` varchar(32) DEFAULT NULL,
  `EndDateTime` datetime DEFAULT NULL,
  `IsActive` bit(1) NOT NULL DEFAULT b'1',
  `CreateUser` varchar(64) DEFAULT NULL,
  `UpdateUser` varchar(64) DEFAULT NULL,
  `CreateTime` datetime DEFAULT NULL,
  `UpdateTime` datetime DEFAULT NULL,
  `BusinessID` bigint NOT NULL DEFAULT 0,
  PRIMARY KEY (`RecID`),
  KEY `ix_qlwd_line` (`ProdLine`,`IsActive`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='产线休息时间';

SET FOREIGN_KEY_CHECKS = 1;
