/*Table structure for table `sys_dictionary` */

DROP TABLE IF EXISTS `sys_dictionary`;

CREATE TABLE `sys_dictionary` (
  `dict_id` INT(11) NOT NULL AUTO_INCREMENT,
  `dict_code` VARCHAR(20) NOT NULL COMMENT '字典编码',
  `dict_name` VARCHAR(50) NOT NULL COMMENT '字典名称',
  `dict_type` VARCHAR(20) NOT NULL COMMENT '字典类型',
  `parent_dict_id` INT(11) DEFAULT NULL COMMENT '父类型ID默认为0',
  `enable_state` CHAR(1) NOT NULL COMMENT '启用状态，1为启用，0禁用',
  `order_no` TINYINT(4) DEFAULT NULL COMMENT '排序值',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`dict_id`)
) ENGINE=INNODB COMMENT='数据字典';

/*Table structure for table `sys_resource` */

DROP TABLE IF EXISTS `sys_resource`;

CREATE TABLE `sys_resource` (
  `resource_id` INT(11) NOT NULL AUTO_INCREMENT,
  `resource_name` VARCHAR(50) NOT NULL COMMENT '名称',
  `resource_code` VARCHAR(80) DEFAULT NULL COMMENT '编码',
  `resource_type` CHAR(1) DEFAULT NULL COMMENT '资源类型(M菜单，B按钮)',
  `resource_url` VARCHAR(120) DEFAULT NULL COMMENT '菜单地址',
  `parent_resource_id` INT(11) DEFAULT NULL COMMENT '父ID',
  `is_show` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1显示，0不显示',
  `menu_order` TINYINT(4) DEFAULT NULL COMMENT '顺序',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`resource_id`),
  UNIQUE KEY `uk_name` (`resource_name`),
  UNIQUE KEY `uk_code` (`resource_code`)  
) ENGINE=INNODB COMMENT='系统资源（菜单项及按钮）';

/*Table structure for table `sys_role` */

DROP TABLE IF EXISTS `sys_role`;

CREATE TABLE `sys_role` (
  `role_id` INT(11) NOT NULL AUTO_INCREMENT,
  `role_name` VARCHAR(50) NOT NULL COMMENT '角色名称',
  `role_code` VARCHAR(20) DEFAULT NULL COMMENT '角色编号',
  `remark` VARCHAR(200) DEFAULT NULL COMMENT '说明',
  `is_default` VARCHAR(1) DEFAULT '0',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',  
  PRIMARY KEY (`role_id`),
  UNIQUE KEY `uk_name` (`role_name`),
  UNIQUE KEY `uk_code` (`role_code`)
) ENGINE=INNODB COMMENT='角色表';

/*Table structure for table `sys_role_resource` */

DROP TABLE IF EXISTS `sys_role_resource`;

CREATE TABLE `sys_role_resource` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `role_id` INT(11) NOT NULL,
  `resource_id` INT(11) NOT NULL,
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',  
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_role_resource` (`role_id`, `resource_id`)
) ENGINE=INNODB COMMENT='角色资源权限表';

/*Table structure for table `sys_user` */

DROP TABLE IF EXISTS `sys_user`;

CREATE TABLE `sys_user` (
  `user_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
  `login_name` VARCHAR(50) NOT NULL COMMENT '登录账号',
  `password` VARCHAR(128) DEFAULT NULL COMMENT '登录密码',
  `user_name` VARCHAR(50) DEFAULT NULL COMMENT '用户名称',
  `mobile_phone` VARCHAR(50) DEFAULT NULL COMMENT '手机',
  `status` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '状态1有效，0无效',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',  
  PRIMARY KEY (`user_id`),
  UNIQUE KEY `uk_login_name` (`login_name`)
) ENGINE=INNODB COMMENT='用户表';

/*Table structure for table `sys_user_role` */

DROP TABLE IF EXISTS `sys_user_role`;

CREATE TABLE `sys_user_role` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `user_id` INT(11) NOT NULL COMMENT '用户ID',
  `role_id` INT(11) NOT NULL COMMENT '角色ID',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_user_role` (`user_id`, `role_id`)
) ENGINE=INNODB COMMENT='用户角色';


/*Table structure for table `oa_department` */

DROP TABLE IF EXISTS `oa_department`;

CREATE TABLE `oa_department` (
  `dept_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '部门ID',
  `dept_name` VARCHAR(50) NOT NULL COMMENT '部门名称',
  `dept_code` VARCHAR(50) DEFAULT NULL COMMENT '部门编号',
  `parent_id` INT(11) DEFAULT NULL COMMENT '上级部门',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`dept_id`),
  UNIQUE KEY `uk_dept_name` (`dept_name`)
) ENGINE=INNODB COMMENT='部门表';

/*Table structure for table `oa_staff` */

DROP TABLE IF EXISTS `oa_staff`;

CREATE TABLE `oa_staff` (
  `staff_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '员工ID',
  `staff_no` VARCHAR(20) NOT NULL COMMENT '员工工号',
  `staff_name` VARCHAR(20) DEFAULT NULL COMMENT '员工姓名',
  `dept_id` INT(11) DEFAULT NULL COMMENT '部门ID',
  `is_worker` INT(11) NOT NULL DEFAULT 1 COMMENT '是否产线工人',
  `status` TINYINT(1) DEFAULT NULL COMMENT '状态1有效，0无效',
  `sex` VARCHAR(1) DEFAULT NULL COMMENT '性别，男 女',
  `post` VARCHAR(20) DEFAULT NULL COMMENT '职务',
  `email` VARCHAR(30) DEFAULT NULL COMMENT '邮件',
  `mobile_phone` VARCHAR(50) DEFAULT NULL COMMENT '手机',
  `inner_phone` VARCHAR(10) DEFAULT NULL COMMENT '内线电话',
  `outer_phone` VARCHAR(30) DEFAULT NULL COMMENT '外线电话',
  `home_phone` VARCHAR(30) DEFAULT NULL COMMENT '家庭电话',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`staff_id`),
  UNIQUE KEY `uk_staff_no` (`staff_no`)
) ENGINE=INNODB COMMENT='员工信息表';

/*Table structure for table `sys_visit_log` */

DROP TABLE IF EXISTS `sys_visit_log`;

CREATE TABLE `sys_visit_log` (
  `log_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `log_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '日志记录时间',
  `call_api` VARCHAR(50) DEFAULT NULL COMMENT '调用API',
  `api_desc` TEXT DEFAULT NULL COMMENT 'API描述',
  `user_id` INT(11) DEFAULT NULL COMMENT '来自用户',
  `device` VARCHAR(20) DEFAULT NULL COMMENT '来自设备',
  `remote_addr` VARCHAR(20) DEFAULT NULL COMMENT '设备地址',
  `remote_host` VARCHAR(20) DEFAULT NULL COMMENT '设备名称',
  `input_params` TEXT DEFAULT NULL COMMENT '输入参数',
  `error` INT(11) DEFAULT NULL COMMENT '调用结果',
  `time_consuming` INT(11) DEFAULT NULL COMMENT '调用耗时(毫秒)',
  `bak` TEXT DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`log_id`)
) ENGINE=INNODB COMMENT='系统API调用日志表';



/* ============================= */
/*  业务数据                     */
/* ============================= */
/*Table structure for table `fc_staff_device_binding` */

DROP TABLE IF EXISTS `fc_staff_device_binding`;

CREATE TABLE `fc_staff_device_binding` (
  `binding_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '绑定关系ID',
  `staff_no` VARCHAR(20) NOT NULL COMMENT '员工工号',
  `handheld_id` INT(11) NOT NULL COMMENT '手持机ID',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`binding_id`),
  UNIQUE KEY `uk_staff_handset` (`staff_no`, `handheld_id`)
) ENGINE=INNODB COMMENT='职员和手持机设备的绑定关系';


/*Table structure for table `fc_flow` */

DROP TABLE IF EXISTS `fc_flow`;

CREATE TABLE `fc_flow` (
  `flow_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '生产线ID',
  `flow_name` VARCHAR(100) NOT NULL COMMENT '生产线名称',
  `flow_place` VARCHAR(100) NOT NULL COMMENT '生产线地点',
  `master_staff_no` VARCHAR(20) NOT NULL COMMENT '负责人的员工工号',
  `flow_spots` INT(11) NOT NULL COMMENT '生产线工位数量',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`flow_id`)
) ENGINE=INNODB COMMENT='生产线信息';

/*Table structure for table `fc_spot` */

DROP TABLE IF EXISTS `fc_spot`;

CREATE TABLE `fc_spot` (
  `spot_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '工位ID',
  `flow_id` INT(11) NOT NULL COMMENT '生产线ID',
  `spot_name` VARCHAR(50) DEFAULT NULL COMMENT '工位名称',
  `order_num` INT(11) NOT NULL COMMENT '生产线内顺序',
  `ratio` INT(11) NOT NULL COMMENT '产能比例',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`spot_id`)
) ENGINE=INNODB COMMENT='生产工位表';


/*Table structure for table `ep_config` */

DROP TABLE IF EXISTS `ep_config`;

CREATE TABLE `ep_config` (
  `ep_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '采集机ID',
  `flow_id` INT(11) NOT NULL COMMENT '生产线ID',
  `spots` INT(11) NOT NULL COMMENT '工位数量',
  `extra` TEXT COMMENT '设置选项',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`ep_id`)
) ENGINE=INNODB COMMENT='采集设置';

/*Table structure for table `ep_board_spot` */

DROP TABLE IF EXISTS `ep_board_spot`;

CREATE TABLE `ep_board_spot` (
  `combine_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '对应关系编码',
  `ep_id` INT(11) NOT NULL COMMENT '采集机ID',
  `spot_id` INT(11) NOT NULL COMMENT '工位ID',
  `board_id` INT(11) NOT NULL COMMENT '控制板ID',
  `arg` INT(11) COMMENT '附加参数',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`combine_id`),
  UNIQUE KEY `uk_board` (`ep_id`, `spot_id`, `board_id`)
) ENGINE=INNODB COMMENT='采集点对应';


/*Table structure for table `ep_state` */

DROP TABLE IF EXISTS `ep_state`;

CREATE TABLE `ep_state` (
  `ep_id` INT(11) NOT NULL COMMENT '采集机ID',
  `spot_data` TEXT NOT NULL COMMENT '工位数据',
  `spot_worker` TEXT NOT NULL COMMENT '工人产量数据',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`ep_id`)
) ENGINE=INNODB COMMENT='采集状态';

/*Table structure for table `ep_system` */

DROP TABLE IF EXISTS `ep_system`;

CREATE TABLE `ep_system` (
  `data_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '数据ID',
  `ep_id` INT(11) NOT NULL COMMENT '采集机Id',
  `cpu` TEXT NOT NULL COMMENT 'CPU使用',
  `memory` TEXT NOT NULL COMMENT '内存使用',
  `processes` TEXT COMMENT '进程信息',
  `os` TEXT NOT NULL COMMENT '操作系统',
  `runtime` TEXT COMMENT '运行环境',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`data_id`)
) ENGINE=INNODB COMMENT='采集机运行状态';

/*Table structure for table `fc_sector` */

DROP TABLE IF EXISTS `fc_sector`;

CREATE TABLE `fc_sector` (
  `sector_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '工序ID',
  `sector_name` VARCHAR(200) NOT NULL COMMENT '工序名称',
  `flow_id` INT(11) NOT NULL COMMENT '生产线ID',
  `sector_order` INT(11) NOT NULL COMMENT '产线内顺序',
  `counter` INT(11) DEFAULT '1' COMMENT '计数方法',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`sector_id`)
) ENGINE=INNODB COMMENT='工序定义';

/*Table structure for table `fc_sector_spot` */

DROP TABLE IF EXISTS `fc_sector_spot`;

CREATE TABLE `fc_sector_spot` (
  `combine_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '关系ID',
  `sector_id` INT(11) NOT NULL COMMENT '工序ID',
  `spot_id` INT(11) NOT NULL COMMENT '工位ID',
  `spot_order` INT(11) NOT NULL COMMENT '工序内工位顺序',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`combine_id`)
) ENGINE=INNODB AUTO_INCREMENT=1 COMMENT='工序内部';



/*Table structure for table `fc_spot_extra` */

DROP TABLE IF EXISTS `fc_spot_extra`;

CREATE TABLE `fc_spot_extra` (
  `spot_id` INT(11) NOT NULL COMMENT '工位ID',
  `spot_period` INT(11) NOT NULL COMMENT '工位统计周期',
  `spot_threshold_failnum` INT(11) NOT NULL COMMENT '坏品数阈值',
  `spot_threshold_failrate` DECIMAL(10,0) NOT NULL COMMENT '坏品率阈值',
  `spot_threshold_min_output` INT(11) NOT NULL COMMENT '产能阈值',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`spot_id`)
) ENGINE=INNODB COMMENT='工位统计信息';

/*Table structure for table `fc_system_event` */

DROP TABLE IF EXISTS `fc_system_event`;

CREATE TABLE `fc_system_event` (
  `sysev_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '事件记录ID',
  `event_type` INT(11) NOT NULL COMMENT '事件类型',
  `event_level` INT(11) NOT NULL COMMENT '事件严重等级',
  `event_title` VARCHAR(300) DEFAULT NULL COMMENT '事件标题',
  `event_detail` VARCHAR(1000) DEFAULT NULL COMMENT '事件详情',
  `event_status` INT(11) NOT NULL COMMENT '事件状态',
  `time_point` BIGINT(20) NOT NULL COMMENT '发生时间',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`sysev_id`)
) ENGINE=INNODB COMMENT='系统事件';

/*Table structure for table `fc_work_period` */

DROP TABLE IF EXISTS `fc_work_period`;

CREATE TABLE `fc_work_period` (
  `period_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '时间段ID',
  `period_name` VARCHAR(100) NOT NULL COMMENT '时间段名称',
  `start_second` INT(11) NOT NULL COMMENT '开始时间',
  `end_second` INT(11) NOT NULL COMMENT '结束时间',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`period_id`)
) ENGINE=INNODB COMMENT='工作时间段信息';

/*Table structure for table `fc_work_schedule` */

DROP TABLE IF EXISTS `fc_work_schedule`;

CREATE TABLE `fc_work_schedule` (
  `schedule_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '班次ID',
  `work_day` DATE NOT NULL COMMENT '班次日期',
  `start_time` DATETIME NOT NULL COMMENT '实际开始',
  `end_time` DATETIME NOT NULL COMMENT '实际结束',
  `period_id` INT(11) NOT NULL COMMENT '工作时间段ID',
  `flow_id` INT(11) NOT NULL COMMENT '生产线ID',
  `start_uid` INT(11) NOT NULL COMMENT '上班操作人',
  `end_uid` INT(11) NOT NULL COMMENT '下班操作人',
  `status` INT(11) NOT NULL COMMENT '班次状态',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`schedule_id`)
) ENGINE=INNODB COMMENT='班次信息';

/*Table structure for table `fc_work_schedule_event` */

DROP TABLE IF EXISTS `fc_work_schedule_event`;

CREATE TABLE `fc_work_schedule_event` (
  `event_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '事件记录ID',
  `schedule_id` INT(11) NOT NULL COMMENT '班次ID',
  `evtype` INT(11) NOT NULL COMMENT '事件类型',
  `period_id` INT(11) NOT NULL COMMENT '时间段ID',
  `worker_no` VARCHAR(20) NOT NULL COMMENT '工人工号',
  `spot_id` INT(11) NOT NULL COMMENT '工位ID',
  `occurance_time` DATETIME NOT NULL COMMENT '实际发生时间',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`event_id`)
) ENGINE=INNODB AUTO_INCREMENT=1 COMMENT='工作上下班信息';





/*Table structure for table `fc_work_raw` */

DROP TABLE IF EXISTS `fc_work_raw`;

CREATE TABLE `fc_work_raw` (
  `raw_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '原始数据ID',
  `schedule_id` INT(11) NOT NULL DEFAULT '0' COMMENT '班次ID',
  `board_id` INT(11) NOT NULL COMMENT '控制板ID',
  `timing` BIGINT(20) NOT NULL COMMENT '时间点',
  `handheld_id` INT(11) NOT NULL COMMENT '手持机ID',
  `pass_num` INT(11) NOT NULL COMMENT '合格品数量',
  `total_num` INT(11) NOT NULL COMMENT '总计数量',
  `hand_pass` INT(11) NOT NULL COMMENT '手持合格数',
  `hand_total` INT(11) NOT NULL COMMENT '手持总计数',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`raw_id`),
  KEY `idx_handheld_id` (`handheld_id`),
  KEY `idx_board_id` (`board_id`)
) ENGINE=INNODB COMMENT='原始工作量数据';



/*Table structure for table `fc_bi_factory_daily` */

DROP TABLE IF EXISTS `fc_bi_factory_daily`;

CREATE TABLE `fc_bi_factory_daily` (
  `data_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '数据标识',
  `pass_num` INT(11) NOT NULL COMMENT '合格品数量',
  `fc_day` DATE NOT NULL COMMENT '记录日期',
  `fail_num` INT(11) NOT NULL COMMENT '坏品数量',
  `fail_rate` INT(11) NOT NULL COMMENT '坏品率',
  `avg_due` INT(11) NOT NULL COMMENT '平均堆积数',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`data_id`)
) ENGINE=INNODB COMMENT='全厂按日统计';

/*Table structure for table `fc_bi_flow_daily` */

DROP TABLE IF EXISTS `fc_bi_flow_daily`;

CREATE TABLE `fc_bi_flow_daily` (
  `data_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '统计ID',
  `flow_id` INT(11) NOT NULL COMMENT '生产线ID',
  `fc_day` DATE NOT NULL COMMENT '记录日期',
  `fail_num` INT(11) NOT NULL COMMENT '坏品数量',
  `fail_rate` INT(11) NOT NULL COMMENT '坏品率',
  `avg_due` INT(11) NOT NULL COMMENT '平均堆积数',
  `pass_num` INT(11) NOT NULL COMMENT '合格品数量',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`data_id`)
) ENGINE=INNODB COMMENT='产线按日统计';

/*Table structure for table `fc_bi_worker_daily` */

DROP TABLE IF EXISTS `fc_bi_worker_daily`;

CREATE TABLE `fc_bi_worker_daily` (
  `data_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '统计数据ID',
  `worker_id` INT(11) NOT NULL COMMENT '员工ID',
  `fc_day` DATE NOT NULL COMMENT '记录日期',
  `fail_num` INT(11) NOT NULL COMMENT '坏品数量',
  `fail_rate` INT(11) NOT NULL COMMENT '坏品率',
  `avg_due` INT(11) NOT NULL COMMENT '平均堆积数',
  `pass_num` INT(11) NOT NULL COMMENT '合格品数量',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`data_id`)
) ENGINE=INNODB COMMENT='按日统计';


/*Table structure for table `fc_work_schedule_load` */

DROP TABLE IF EXISTS `fc_work_schedule_load`;

CREATE TABLE `fc_work_schedule_load` (
  `load_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '班次产量ID',
  `schedule_id` INT(11) NOT NULL COMMENT '班次ID',
  `spot_id` INT(11) NOT NULL COMMENT '工位ID',
  `user_id` INT(11) NOT NULL COMMENT '员工ID',
  `pass_num` INT(11) NOT NULL COMMENT '合格数量',
  `fail_num` INT(11) NOT NULL COMMENT '坏品数量',
  `due` INT(11) NOT NULL COMMENT '堆积数量',
  `time_point` BIGINT(20) NOT NULL COMMENT '时间点',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`load_id`)
) ENGINE=INNODB COMMENT='班次产量信息';

/*Table structure for table `fc_work_schedule_outcome` */

DROP TABLE IF EXISTS `fc_work_schedule_outcome`;

CREATE TABLE `fc_work_schedule_outcome` (
  `outcome_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '产能数据ID',
  `schedule_id` INT(4) NOT NULL COMMENT '班次ID',
  `spot_id` INT(11) NOT NULL COMMENT '工位ID',
  `worker_id` INT(11) NOT NULL COMMENT '员工ID',
  `pass_num` INT(11) NOT NULL COMMENT '合格数量',
  `fail_num` INT(11) NOT NULL COMMENT '坏品数量',
  `avg_due` INT(11) NOT NULL COMMENT '平均堆积数量',
  `updated_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`outcome_id`)
) ENGINE=INNODB COMMENT='产能数据结算';

DROP TABLE IF EXISTS `fc_bi_board_daily`;

CREATE TABLE fc_bi_board_daily(
  data_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '数据id',
  flow_id INT(11) NOT NULL COMMENT '产线id',
  board_id INT(11) NOT NULL COMMENT '板子id',
  fc_day DATE NOT NULL,
  pass_num INT(11) NOT NULL,
  fail_num INT(11) NOT NULL,
  updated_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
)ENGINE=INNODB COMMENT='板子当日统计';
