ALTER TABLE `zh_sum_load_history`
ADD COLUMN `cover`  tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '覆盖数据' AFTER `load_time`;

CREATE TABLE `zh_pay_attachment` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `tid` int(11) unsigned NOT NULL COMMENT '标段id',
  `sid` int(11) unsigned NOT NULL COMMENT '期id',
  `pid` int(11) NOT NULL COMMENT '合同支付id',
  `uid` int(11) unsigned NOT NULL COMMENT '用户id',
  `filename` varchar(255) CHARACTER SET utf16 NOT NULL COMMENT '文件名',
  `fileext` varchar(10) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(30) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(500) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `in_time` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `renew` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否审批通过后上传',
  `username` varchar(10) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '用户名',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `zh_change_audit_list` ADD `mx_id` VARCHAR(50) NULL DEFAULT NULL COMMENT '计量单元id' AFTER `gcl_id`;

ALTER TABLE `zh_change_audit_list` CHANGE `gcl_id` `gcl_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '台账对应id（非准确）';

-- 估概预标准
INSERT INTO `calculation`.`zh_permission` (`id`, `name`, `controller`, `action`, `pid`, `icon_class`, `create_time`, `isshow`) VALUES ('72', '估概预标准', 'budget', 'all', '44', '', '0', '1');

ALTER TABLE `zh_project`
ADD COLUMN `budget`  varchar(100) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '估概预标准-id列表(\',\'分隔)' AFTER `valuation`;

CREATE TABLE `zh_budget_std` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '估概预标准id',
  `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '名称',
  `gu_chapter_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '估算-项目节-id列表('',''分隔)',
  `gu_template_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '估算-新建模板-id列表('',''分隔)',
  `gai_chapter_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '概算-项目节-id列表('',''分隔)',
  `gai_template_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '概算-新建模板-id列表('',''分隔)',
  `yu_chapter_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '预算-项目节-id列表('',''分隔)',
  `yu_template_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '预算-新建模板-id列表('',''分隔)',
  `yu_bills_id` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT '预算-工程量清单-id列表('',''分隔)',
  `in_time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='估概预标准列表';

CREATE TABLE `zh_change_ledger`  (
  `id` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '自增id',
  `tender_id` int(10) NOT NULL COMMENT '标段id',
  `ledger_id` int(10) NOT NULL COMMENT '节点id',
  `ledger_pid` int(10) NOT NULL COMMENT '父节点id',
  `level` tinyint(4) NOT NULL COMMENT '层级',
  `order` mediumint(4) NOT NULL DEFAULT 0 COMMENT '同级排序',
  `full_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '层级定位辅助字段parent.full_path.ledger_id',
  `is_leaf` tinyint(1) NOT NULL COMMENT '是否叶子节点，界面显示辅助字段',
  `code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '节点编号',
  `b_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `unit` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '单位',
  `source` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '添加源',
  `remark` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '备注',
  `quantity` decimal(24, 8) NULL DEFAULT NULL COMMENT '数量',
  `unit_price` decimal(24, 8) NULL DEFAULT NULL COMMENT '单价',
  `total_price` decimal(24, 8) NULL DEFAULT NULL COMMENT '金额',
  `drawing_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图册号',
  `memo` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
  `dgn_qty1` decimal(24, 8) NULL DEFAULT NULL COMMENT '设计数量1',
  `dgn_qty2` decimal(24, 8) NULL DEFAULT NULL COMMENT '设计数量2',
  `deal_qty` decimal(24, 8) NULL DEFAULT NULL COMMENT '签约 - 数量',
  `deal_tp` decimal(24, 8) NULL DEFAULT NULL COMMENT '签约 - 金额',
  `sgfh_qty` decimal(24, 8) NULL DEFAULT NULL COMMENT '施工复核 - 数量',
  `sgfh_tp` decimal(24, 8) NULL DEFAULT NULL COMMENT '施工复核 - 金额',
  `sjcl_qty` decimal(24, 8) NULL DEFAULT NULL COMMENT '设计错漏 - 数量',
  `sjcl_tp` decimal(24, 8) NULL DEFAULT NULL COMMENT '设计错漏 - 金额',
  `qtcl_qty` decimal(24, 8) NULL DEFAULT NULL COMMENT '其他错漏 - 数量',
  `qtcl_tp` decimal(24, 8) NULL DEFAULT NULL COMMENT '其他错漏 - 金额',
  `node_type` int(4) UNSIGNED NULL DEFAULT 0 COMMENT '节点类别',
  `crid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'create_revise_id(uuid)',
  `is_tp` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '总额计量',
  `sgfh_expr` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '施工复核-公式',
  `sjcl_expr` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '设计错漏-公式',
  `qtcl_expr` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '其他错漏 - 公式',
  `gxby_status` tinyint(4) NULL DEFAULT -1 COMMENT '工序报验-状态',
  `gxby_limit` int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限，0不受限，1受限',
  `gxby_ratio` decimal(6, 4) NOT NULL DEFAULT 0.0000 COMMENT '允许计量比例，-1表示不限制',
  `dagl_status` tinyint(4) NULL DEFAULT -1 COMMENT '档案管理-状态',
  `dagl_limit` int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限，0不受限，1受限',
  `dagl_ratio` decimal(6, 4) NOT NULL DEFAULT 0.0000 COMMENT '允许计量比例，-1表示不限制',
  `dagl_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接',
  `check_calc` tinyint(1) NULL DEFAULT 1 COMMENT '是否检查计算',
  `ex_memo1` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注1',
  `ex_memo2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注2',
  `ex_memo3` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注3',
  `ccid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'create_change_id(uuid)',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_tender_id`(`tender_id`) USING BTREE,
  INDEX `idx_template_pid`(`ledger_pid`) USING BTREE,
  INDEX `idx_level`(`level`) USING BTREE,
  INDEX `idx_full_path`(`tender_id`, `full_path`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '变更新增部位--台账分解数据';

CREATE TABLE `zh_change_pos`  (
  `id` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `tid` int(11) NOT NULL COMMENT '标段id',
  `lid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '台账id',
  `name` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `drawing_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图册号',
  `quantity` decimal(30, 8) NULL DEFAULT NULL COMMENT '数量',
  `add_stage` int(11) NOT NULL COMMENT '新增期数',
  `add_times` int(11) NOT NULL COMMENT '创建于第几次审核',
  `add_user` int(11) NOT NULL COMMENT '创建人id',
  `sgfh_qty` decimal(24, 8) NULL DEFAULT NULL COMMENT '施工复核 - 数量',
  `sjcl_qty` decimal(30, 8) NULL DEFAULT NULL COMMENT '设计错漏 - 数量',
  `qtcl_qty` decimal(30, 8) NULL DEFAULT NULL COMMENT '其他错漏 - 数量',
  `crid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'create_revise_id(uuid)',
  `in_time` datetime NULL DEFAULT NULL COMMENT '新增时间',
  `porder` int(11) UNSIGNED NOT NULL DEFAULT 1,
  `position` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '位置',
  `sgfh_expr` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '施工复核-公式',
  `sjcl_expr` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '设计错漏-公式',
  `qtcl_expr` varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '其他错漏-公式',
  `real_qty` decimal(24, 8) NULL DEFAULT 0.00000000 COMMENT '实际使用数量',
  `gxby_status` int(4) NULL DEFAULT -1 COMMENT '工序报验-状态',
  `gxby_limit` int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限，0不受限，1受限',
  `gxby_ratio` decimal(6, 4) NOT NULL DEFAULT 0.0000 COMMENT '允许计量比例，-1表示不限制',
  `dagl_status` int(4) NULL DEFAULT -1 COMMENT '档案管理-状态',
  `dagl_limit` int(4) NOT NULL DEFAULT 0 COMMENT '计量是否受限，0不受限，1受限',
  `dagl_ratio` decimal(6, 4) NOT NULL DEFAULT 0.0000 COMMENT '允许计量比例，-1表示不限制',
  `dagl_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '档案管理-查看链接',
  `ex_memo1` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注1',
  `ex_memo2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注2',
  `ex_memo3` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注3',
  `ccid` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'create_change_id(uuid)',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `tid`(`tid`) USING BTREE,
  INDEX `tlid`(`tid`, `lid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '变更新增部位--部位明细';
