SET FOREIGN_KEY_CHECKS=0;

CREATE TABLE IF NOT EXISTS `t_process_in_calculation`  (
  `calculation_id` int(11) NOT NULL AUTO_INCREMENT,
  `data_id` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `affair_id` int(11) NOT NULL,
  `tagIds` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `calculation_key` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `calculation_time` datetime(0) NOT NULL,
  `product_id` int(11) NOT NULL,
  `product_color` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `product_color_number` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `sale_object` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `product_width` decimal(14, 2) NOT NULL,
  `product_height` decimal(14, 2) NOT NULL,
  `machining_price` decimal(15, 3) NOT NULL,
  `calculation_condition` varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `actual_in_storehouse_quantity` decimal(22, 2) NOT NULL,
  `call_time` datetime(0) NOT NULL,
  PRIMARY KEY (`calculation_id`, `data_id`) USING BTREE,
  INDEX `call_time`(`call_time`) USING BTREE,
  INDEX `data_id`(`data_id`) USING BTREE,
  INDEX `affair_id`(`affair_id`, `calculation_time`, `calculation_condition`, `tagIds`, `calculation_key`, `product_id`, `product_color`, `sale_object`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

CREATE TABLE IF NOT EXISTS `t_process_out_calculation`  (
  `calculation_id` int(11) NOT NULL AUTO_INCREMENT,
  `data_id` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `affair_id` int(11) NOT NULL,
  `tagIds` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `calculation_condition` varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `calculation_time` datetime(0) NOT NULL,
  `machining_price` decimal(15, 3) NOT NULL,
  `machining_quantity` decimal(15, 2) NOT NULL,
  `machining_total_amount` decimal(15, 3) NOT NULL,
  `out_storehouse_quantity` decimal(22, 2) NOT NULL,
  `from_data_id` varchar(25) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `is_complete` int(1) NOT NULL DEFAULT 0,
  `call_time` datetime(0) NOT NULL,
  PRIMARY KEY (`calculation_id`, `data_id`, `from_data_id`) USING BTREE,
  INDEX `call_time`(`call_time`) USING BTREE,
  INDEX `affair_id`(`affair_id`, `calculation_time`, `calculation_condition`, `tagIds`, `from_data_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS=1;