ALTER TABLE `zh_change_apply`
ADD `total_price` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '金额' AFTER `content`,
ADD `decimal` VARCHAR(255) NULL DEFAULT NULL COMMENT '小数位数设置JSON' AFTER `total_price`;

DROP TABLE IF EXISTS `zh_change_plan`;
CREATE TABLE `zh_change_plan`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `selected` tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择',
  `uid` int(11) NOT NULL COMMENT '发起人',
  `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '变更方案编号',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '变更工程名称',
  `in_time` datetime NOT NULL COMMENT '发起时间',
  `status` tinyint(2) NOT NULL COMMENT '方案状态',
  `times` tinyint(2) NOT NULL COMMENT '审批次数',
  `apply_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '变更申请编号',
  `org_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '原设计图名称',
  `peg` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '桩号',
  `new_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '图号',
  `c_new_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '变更图号',
  `design_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '变更设计名称',
  `class` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '工程变更类别',
  `quality` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '工程变更性质',
  `reason` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '变更原因',
  `content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '变更内容',
  `memo` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '方案描述',
  `total_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '金额',
  `decimal` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '小数位数设置JSON',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更方案表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for zh_change_plan_attachment
-- ----------------------------
DROP TABLE IF EXISTS `zh_change_plan_attachment`;
CREATE TABLE `zh_change_plan_attachment`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '方案id',
  `uid` int(11) NOT NULL COMMENT '上传者id',
  `filename` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名称',
  `fileext` varchar(5) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `upload_time` datetime NOT NULL COMMENT '上传时间',
  `extra_upload` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否为审核通过后再次上传的文件，0为否',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_cid`(`cpid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更立项附件表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for zh_change_plan_audit
-- ----------------------------
DROP TABLE IF EXISTS `zh_change_plan_audit`;
CREATE TABLE `zh_change_plan_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '方案id',
  `aid` int(11) NOT NULL COMMENT '审批人id',
  `order` int(11) NOT NULL COMMENT '审批顺序',
  `times` int(11) NOT NULL COMMENT '审批次数',
  `status` tinyint(1) NOT NULL COMMENT '审批状态',
  `begin_time` datetime NULL DEFAULT NULL COMMENT '开始审批时间',
  `end_time` datetime NULL DEFAULT NULL COMMENT '结束审批时间',
  `opinion` varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '审批意见',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更立项审批表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for zh_change_plan_list
-- ----------------------------
DROP TABLE IF EXISTS `zh_change_plan_list`;
CREATE TABLE `zh_change_plan_list`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '方案id',
  `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '清单编号',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '清单名称',
  `unit` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '单位',
  `unit_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '单价',
  `oamount` decimal(30, 8) NULL DEFAULT NULL COMMENT '原数量',
  `camount` decimal(30, 8) NULL DEFAULT NULL COMMENT '变更数量',
  `samount` decimal(30, 8) NULL DEFAULT NULL COMMENT '审批完成后变更数量',
  `audit_amount` varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '用户填的数目，json',
  `spamount` decimal(30, 8) NULL DEFAULT NULL COMMENT '审批流程中读取数量',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更方案清单表' ROW_FORMAT = Dynamic;

ALTER TABLE `zh_material` ADD `period` VARCHAR(255) NULL DEFAULT NULL COMMENT '调差周期' AFTER `s_order`;

ALTER TABLE `zh_tender`
ADD `c_apply_list_rule` VARCHAR(255) NULL DEFAULT NULL COMMENT '变更申请统一原设计数量读取规则' AFTER `pos_file`,
ADD `c_plan_list_rule` VARCHAR(255) NULL DEFAULT NULL COMMENT '变更方案统一原设计数量读取规则' AFTER `c_apply_list_rule`;

ALTER TABLE `zh_change` ADD `plan_code` VARCHAR(255) NULL DEFAULT NULL COMMENT '变更方案编号' AFTER `name`;

