-- Create syntax for TABLE 'alarm_log'
CREATE TABLE `alarm_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `alarm_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `message` text COLLATE utf8mb4_unicode_ci,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  `priority` int DEFAULT '2',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create syntax for TABLE 'boxten_compen_main'
CREATE TABLE `boxten_compen_main` (
  `id` int NOT NULL,
  `num` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pjt_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `structure_dt` date DEFAULT NULL,
  `export_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rope_idntf` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rope_jojang` int DEFAULT NULL,
  `rope_bon` int DEFAULT NULL,
  `rope_qty` int DEFAULT NULL,
  `car_shackle` int DEFAULT NULL,
  `cwt_shackle` int DEFAULT NULL,
  `price` decimal(15,3) DEFAULT NULL,
  `cut_status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT '-',
  `surveying` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT '미등록',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create syntax for TABLE 'boxten_order_main'
CREATE TABLE `boxten_order_main` (
  `id` int NOT NULL COMMENT 'API 고유 ID',
  `pjt_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '프로젝트명',
  `num` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '관리번호',
  `spec` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '사양',
  `structure_dt` date DEFAULT NULL COMMENT '구조일',
  `export_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '출하유형',
  `cnt` int DEFAULT '1' COMMENT '수량',
  `model` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '모델명',
  `compen` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '컴펜세이팅 여부',
  `babbit` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT '-',
  `drum` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT '-',
  `swaging` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT '-',
  `pack_status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT '무' COMMENT '포장상태',
  `cut_status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT '무' COMMENT '절단상태',
  `surveying` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT '-' COMMENT '실측여부',
  `remark` text COLLATE utf8mb4_unicode_ci COMMENT '비고',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '최초 생성일',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '최종 수정일',
  PRIMARY KEY (`id`),
  KEY `idx_num` (`num`),
  KEY `idx_structure_dt` (`structure_dt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='box10 main 접수목록';

-- Create syntax for TABLE 'boxten_unmeasurement_main'
CREATE TABLE `boxten_unmeasurement_main` (
  `id` int NOT NULL COMMENT 'API 고유 ID',
  `pjt_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '프로젝트명',
  `num` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '관리번호',
  `spec` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '사양',
  `structure_dt` date DEFAULT NULL COMMENT '구조일',
  `before_dt` varchar(50) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '이전 예정일',
  `export_type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '출하유형',
  `cnt` int DEFAULT '1' COMMENT '수량',
  `model` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `compen` varchar(20) COLLATE utf8mb4_general_ci DEFAULT '무',
  `surveying` varchar(50) COLLATE utf8mb4_general_ci DEFAULT '미등록' COMMENT '실측 상태',
  `remark` text COLLATE utf8mb4_general_ci COMMENT '비고',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_num` (`num`),
  KEY `idx_pjt` (`pjt_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='box main(미실측)접수목록';

-- Create syntax for TABLE 'company_purchase'
CREATE TABLE `company_purchase` (
  `pk` int NOT NULL,
  `name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '거래처',
  `registration_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '사업자등록번호',
  `representative` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표자',
  `rep_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표번호',
  `manager_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '진성담당자',
  `manager_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '진성담당연락처',
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '거래처 이메일',
  `address` text COLLATE utf8mb4_unicode_ci COMMENT '거래처 주소',
  `point` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '지점',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '업데이트 시간',
  PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='업체목록(매입)';

-- Create syntax for TABLE 'company_sales'
CREATE TABLE `company_sales` (
  `pk` int NOT NULL,
  `name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '업체명',
  `registration_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '사업자등록번호',
  `representative` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표자',
  `rep_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '대표번호',
  `manager_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '담당자',
  `manager_number` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '담당자연락처',
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '담당이메일',
  `address` text COLLATE utf8mb4_unicode_ci COMMENT '거래처 주소',
  `point` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '지점',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '업데이트 시간',
  PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='업체목록(매출)';

-- Create syntax for TABLE 'compen_list'
CREATE TABLE `compen_list` (
  `id` int NOT NULL,
  `pjt_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `order_num` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `compen_dt` date DEFAULT NULL,
  `price` int DEFAULT NULL,
  `quantity` int DEFAULT NULL,
  `status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sync_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='JQPR/NC COMPEN 접수목록';

-- Create syntax for TABLE 'cutting_master'
CREATE TABLE `cutting_master` (
  `id` int NOT NULL,
  `num` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `unit_num_list` text COLLATE utf8mb4_unicode_ci,
  `company` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_cnt` int DEFAULT NULL,
  `idntf` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='작업지시현황';

-- Create syntax for TABLE 'cutting_jobs'
CREATE TABLE `cutting_jobs` (
  `no` int NOT NULL AUTO_INCREMENT,
  `job_id` int NOT NULL,
  `master_id` int DEFAULT NULL,
  `pjt_name` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `num` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `model` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meter` int DEFAULT NULL,
  `total_length` int DEFAULT NULL,
  `bon` int DEFAULT NULL,
  `rope_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `structure_dt` datetime DEFAULT NULL,
  `drum` tinyint(1) DEFAULT NULL,
  `swaging` tinyint(1) DEFAULT NULL,
  `bb` tinyint(1) DEFAULT NULL,
  `material_number` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tag_spec` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `table_type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tag_type` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shipment_dt` datetime DEFAULT NULL,
  PRIMARY KEY (`no`),
  KEY `master_id` (`master_id`),
  CONSTRAINT `cutting_jobs_ibfk_1` FOREIGN KEY (`master_id`) REFERENCES `cutting_master` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=447260 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='현장작업지시서';

-- Create syntax for TABLE 'erp_cutting_details_new'
CREATE TABLE `erp_cutting_details_new` (
  `no` int NOT NULL AUTO_INCREMENT,
  `job_id` int NOT NULL,
  `master_num` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `worker` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `material_type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `work_dt` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pjt_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `lot_no` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `meter` int DEFAULT NULL,
  `bon` int DEFAULT NULL,
  `item_num` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `total_length` int DEFAULT NULL,
  `rope_type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`no`)
) ENGINE=InnoDB AUTO_INCREMENT=156 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Create syntax for TABLE 'erp_cutting_master'
CREATE TABLE `erp_cutting_master` (
  `id` int NOT NULL,
  `master_num` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `unit_num_list` text COLLATE utf8mb4_unicode_ci,
  `company` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_cnt` int DEFAULT NULL,
  `idntf` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create syntax for TABLE 'erp_cutting_jobs'
CREATE TABLE `erp_cutting_jobs` (
  `no` int NOT NULL AUTO_INCREMENT,
  `job_id` int NOT NULL,
  `master_id` int DEFAULT NULL,
  `master_num` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pjt_name` varchar(200) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `num` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `model` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `meter` int DEFAULT NULL,
  `total_length` int DEFAULT NULL,
  `bon` int DEFAULT NULL,
  `rope_type` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `structure_dt` datetime DEFAULT NULL,
  `drum` tinyint(1) DEFAULT NULL,
  `material_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tag_spec` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `shipment_dt` datetime DEFAULT NULL,
  PRIMARY KEY (`no`),
  UNIQUE KEY `job_id` (`job_id`),
  KEY `master_id` (`master_id`),
  KEY `idx_master_num` (`master_num`),
  CONSTRAINT `fk_master` FOREIGN KEY (`master_id`) REFERENCES `erp_cutting_master` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2226752 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Create syntax for TABLE 'hmi_login_log'
CREATE TABLE `hmi_login_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `login_time` datetime DEFAULT NULL,
  `result` int DEFAULT NULL,
  `factory_name` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='터치로그인 로그기록';

-- Create syntax for TABLE 'hmi_user'
CREATE TABLE `hmi_user` (
  `user_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '로그인 ID',
  `user_pw` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '비밀번호 (ID와 동일)',
  `user_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '사용자 이름',
  `user_level` int DEFAULT '1' COMMENT '권한레벨 (1:일반, 9:관리자)',
  `is_active` int DEFAULT '1' COMMENT '활성상태 (1:사용, 0:중지)',
  `sync_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='사용자';

-- Create syntax for TABLE 'install_list'
CREATE TABLE `install_list` (
  `id` int NOT NULL,
  `num` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pjt_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `structure_dt` date DEFAULT NULL,
  `price` int DEFAULT NULL,
  `cut_status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pack_status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `main_rope_idntf` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `gov_rope_idntf` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sync_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='JQPR/NC MAIN 접수목록';

-- Create syntax for TABLE 'maintenance_list'
CREATE TABLE `maintenance_list` (
  `id` int NOT NULL,
  `pjt_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `drawing_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `due_dt` date DEFAULT NULL,
  `bon` int DEFAULT NULL,
  `meter` int DEFAULT NULL,
  `order_quantity` int DEFAULT NULL,
  `price` int DEFAULT NULL,
  `company_point` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `company_manager` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `sync_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='유지보수 협력사 접수목록';

-- Create syntax for TABLE 'mes_log'
CREATE TABLE `mes_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '설비명',
  `data_value` float DEFAULT NULL,
  `worker_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '사원코드',
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '동작시간',
  `last_update` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '최종 수정시간',
  `count` int DEFAULT '0' COMMENT '생산 수량',
  `ng` int DEFAULT '0' COMMENT '불량 수량',
  `cycle_time` float DEFAULT '0' COMMENT '사이클 시간(초)',
  `pull_count` int DEFAULT '0' COMMENT '끌기 횟수',
  `num` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '공사번호',
  `master_num` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'QR코드',
  `spec` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '스펙(JSON)',
  `wind_dur` int DEFAULT '0' COMMENT '권취 시간(초)',
  `cut_dur` int DEFAULT '0' COMMENT '절단 시간(초)',
  `pull_time` float DEFAULT '0' COMMENT '끌기 총시간',
  `pull_index` int DEFAULT '0' COMMENT '끌기 횟차',
  `pull_time_unit` float DEFAULT '0' COMMENT '끌기 횟차별 시간',
  `wind_start` datetime DEFAULT NULL,
  `wind_end` datetime DEFAULT NULL,
  `cut_start` datetime DEFAULT NULL,
  `cut_end` datetime DEFAULT NULL,
  `pull_time_detail` json DEFAULT NULL COMMENT '끌기 횟차별 시간 JSON',
  PRIMARY KEY (`id`),
  KEY `idx_device_time` (`device_id`,`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=429 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='설비생산 1싸이클 저장';

-- Create syntax for TABLE 'receiving_orders'
CREATE TABLE `receiving_orders` (
  `id` int NOT NULL,
  `num` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_worker` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `item_cnt` int DEFAULT NULL,
  `wrhs_dt` datetime DEFAULT NULL,
  `order_dt` datetime DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='로프)자재 입고 완료 목록';

-- Create syntax for TABLE 'rope_cancels'
CREATE TABLE `rope_cancels` (
  `id` int NOT NULL,
  `num` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `due_dt` date DEFAULT NULL,
  `order_dt` datetime DEFAULT NULL,
  `item_cnt` int DEFAULT NULL,
  `cancel_memo` text COLLATE utf8mb4_general_ci,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='로프)자재 발주 취소목록';

-- Create syntax for TABLE 'rope_orders'
CREATE TABLE `rope_orders` (
  `id` int NOT NULL,
  `num` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `due_dt` date DEFAULT NULL,
  `order_dt` datetime DEFAULT NULL,
  `item_cnt` int DEFAULT NULL,
  `status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='로프)자재 입고 완료 목록';

-- Create syntax for TABLE 'rope_stock'
CREATE TABLE `rope_stock` (
  `id` int NOT NULL,
  `spec` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `drawing_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `status` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `remaining_len` int DEFAULT '0',
  `lot_num` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `wrhs_dt` datetime DEFAULT NULL,
  `is_allocated` tinyint(1) DEFAULT '0',
  `created_dt` datetime DEFAULT NULL,
  `wrhs_location` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `purchase` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Create syntax for TABLE 'rope_used_list'
CREATE TABLE `rope_used_list` (
  `id` int NOT NULL,
  `material_number` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `used_dt` date DEFAULT NULL,
  `used_qty` int DEFAULT NULL,
  `memo` text COLLATE utf8mb4_general_ci,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='로프)사용완료 자재 현황';

-- Create syntax for TABLE 'sales_orders'
CREATE TABLE `sales_orders` (
  `id` int NOT NULL,
  `material_number` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `drawing_number` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `pjt_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `company_point` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `company_representative` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `company_manager` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `company_number` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `company_address` text COLLATE utf8mb4_general_ci,
  `meter` int DEFAULT NULL,
  `bon` int DEFAULT NULL,
  `total_amount` int DEFAULT NULL,
  `total_cnt` int DEFAULT NULL,
  `material_details` text COLLATE utf8mb4_general_ci,
  `material_properties` text COLLATE utf8mb4_general_ci,
  `delivery_dt` date DEFAULT NULL,
  `delivery_way` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `cargo` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `repayment_partner` varchar(100) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `number` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `drum` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `swaging` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `babette` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `get_off` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `unit_price` decimal(15,2) DEFAULT NULL,
  `memo` text COLLATE utf8mb4_general_ci,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='서비스 사업부 접수목록';

-- Create syntax for TABLE 'stop_log'
CREATE TABLE `stop_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_id` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `reason` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='설지정지사유저장';

-- Create syntax for TABLE 'sync_config'
CREATE TABLE `sync_config` (
  `task_key` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `task_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `interval_min` int DEFAULT '10',
  `last_run` datetime DEFAULT NULL,
  `status` varchar(20) COLLATE utf8mb4_general_ci DEFAULT 'IDLE',
  PRIMARY KEY (`task_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='DK 업데이트 시간정보';