ALTER TABLE `zh_material_checklist` CHANGE `unit_price` `unit_price` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '单价';
ALTER TABLE `zh_material_checklist` CHANGE `quantity` `quantity` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '数量（工程量）';
ALTER TABLE `zh_material_checklist` CHANGE `total_price` `total_price` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '金额';

ALTER TABLE `zh_change` ADD `up_decimal` TINYINT(2) NULL DEFAULT NULL COMMENT '数量小数位数' AFTER `tp_decimal`;

ALTER TABLE `zh_rpt_custom_define`
ADD COLUMN `material_sum_select`  text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '用户定制信息 - 材差 - 多期汇总表' AFTER `stage_select`;

ALTER TABLE `zh_change`
ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择' AFTER `tid`;

ALTER TABLE `zh_change_project`
ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择' AFTER `tid`;

ALTER TABLE `zh_change_apply`
ADD COLUMN `selected`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '报表用，是否选择' AFTER `tid`;

CREATE TABLE `zh_change_apply`  (
  `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 NULL DEFAULT NULL COMMENT '申请名称(变更工程名称)',
  `in_time` datetime NOT NULL COMMENT '创建时间',
  `status` tinyint(2) NOT NULL COMMENT '申请状态',
  `times` tinyint(2) NOT NULL COMMENT '申请次数',
  `project_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '变更意向编号',
  `notice_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '通知书编号',
  `notice_uid` int(11) 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 '变更性质',
  `org_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '原工程造价(元)',
  `change_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '变更后工程造价(元)',
  `crease_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '工程造价增减(元)',
  `reason` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '变更原因',
  `org_content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '原设计情况描述',
  `site_content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '现场实际情况描述',
  `content` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '变更内容',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更申请表' ROW_FORMAT = Dynamic;

CREATE TABLE `zh_change_apply_attachment`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `caid` int(11) NOT NULL COMMENT '申请id',
  `type` tinyint(1) NULL DEFAULT NULL COMMENT '文件类型',
  `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`(`caid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更申请附件表' ROW_FORMAT = Dynamic;

CREATE TABLE `zh_change_apply_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `caid` 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;

CREATE TABLE `zh_change_project`  (
  `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 '审批次数',
  `type` tinyint(1) NOT 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 '图号',
  `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 '变更性质',
  `org_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '原工程造价(元)',
  `change_price` decimal(30, 8) NULL DEFAULT NULL COMMENT '预计变更造价(元)',
  `crease_price` decimal(30, 8) 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 '内容摘要',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更立项表' ROW_FORMAT = Dynamic;

CREATE TABLE `zh_change_project_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;

CREATE TABLE `zh_change_project_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;

CREATE TABLE `zh_change_project_xs_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `cpid` int(11) NOT NULL COMMENT '立项id',
  `aid` int(11) NOT NULL COMMENT '人员id',
  `for_aid` int(11) NOT NULL COMMENT '添加人id',
  `in_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `cpid`(`cpid`) USING BTREE,
  INDEX `tid`(`tid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '立项协审人' ROW_FORMAT = Dynamic;


ALTER TABLE `zh_change_apply`
ADD `total_price` DECIMAL(30,8) NULL DEFAULT NULL COMMENT '金额' AFTER `content`,
ADD `list_rule` VARCHAR(255) NULL DEFAULT NULL AFTER `total_price` COMMENT '原设计数量读取规则',
ADD `decimal` VARCHAR(255) NULL DEFAULT NULL COMMENT '小数位数设置JSON' AFTER `list_rule`;

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',
  `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 '金额',
  `list_rule` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci 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`;

