update zh_rpt_cfg
set defined_content='{"ctrls":[{"ID":"Default","Wrap":"T","Shrink":"F","Horizon":"left","ShowZero":"T","Vertical":"bottom","CfgDispName":"默认","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Title","Wrap":"T","Shrink":"F","Horizon":"center","ShowZero":"T","Vertical":"center","CfgDispName":"标题","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Header","Wrap":"F","Shrink":"F","Horizon":"left","ShowZero":"T","Vertical":"center","CfgDispName":"表头","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Header_Right","Wrap":"F","Shrink":"F","Horizon":"right","ShowZero":"T","Vertical":"center","CfgDispName":"表头_右","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Footer","Wrap":"F","Shrink":"F","Horizon":"left","ShowZero":"T","Vertical":"center","CfgDispName":"表尾","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Footer_Right","Wrap":"F","Shrink":"F","Horizon":"right","ShowZero":"T","Vertical":"center","CfgDispName":"表尾_右","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Column","Wrap":"T","Shrink":"F","Horizon":"center","ShowZero":"F","Vertical":"center","CfgDispName":"表栏","CloseOutput":"F","ShrinkFirst":"F","FillAfterWrap":"T"},{"ID":"Column_Left","Wrap":"T","Shrink":"F","Horizon":"left","ShowZero":"F","Vertical":"center","CfgDispName":"表栏_左","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Column_Right","Wrap":"T","Shrink":"F","Horizon":"right","ShowZero":"F","Vertical":"center","CfgDispName":"表栏_右","CloseOutput":"F","ShrinkFirst":"F"},{"ID":"Content_Left","Wrap":"F","Shrink":"T","Horizon":"left","ShowZero":"F","Vertical":"bottom","CfgDispName":"正文内容","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Content_Right","Wrap":"F","Shrink":"T","Horizon":"right","ShowZero":"F","Vertical":"bottom","CfgDispName":"正文内容_右","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Content_Center","Wrap":"F","Shrink":"T","Horizon":"center","ShowZero":"F","Vertical":"bottom","CfgDispName":"正文内容_中","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"NewContent_Left","Wrap":"F","Shrink":"T","Horizon":"left","ShowZero":"F","Vertical":"center","CfgDispName":"正文内容(新)","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"NewContent_Right","Wrap":"F","Shrink":"T","Horizon":"right","ShowZero":"F","Vertical":"center","CfgDispName":"正文内容(新)_右","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"NewContent_Center","Wrap":"F","Shrink":"T","Horizon":"center","ShowZero":"F","Vertical":"center","CfgDispName":"正文内容(新)_中","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Currency","Wrap":"F","Shrink":"T","Horizon":"right","ShowZero":"F","Vertical":"center","CfgDispName":"金额型","CloseOutput":"F","ShrinkFirst":"T"},{"ID":"Left_Top","Wrap":"T","Shrink":"F","Horizon":"left","ShowZero":"T","Vertical":"top","CfgDispName":"上靠_左","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Center_Top","Wrap":"T","Shrink":"F","Horizon":"center","ShowZero":"T","Vertical":"top","CfgDispName":"上靠_中","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Right_Top","Wrap":"T","Shrink":"F","Horizon":"right","ShowZero":"T","Vertical":"top","CfgDispName":"上靠_右","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Left_Center","Wrap":"T","Shrink":"F","Horizon":"left","ShowZero":"T","Vertical":"center","CfgDispName":"中靠_左","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Center_Center","Wrap":"T","Shrink":"F","Horizon":"center","ShowZero":"T","Vertical":"center","CfgDispName":"中靠_中","CloseOutput":"T","ShrinkFirst":"F"},{"ID":"Right_Center","Wrap":"T","Shrink":"F","Horizon":"right","ShowZero":"T","Vertical":"center","CfgDispName":"中靠_右","CloseOutput":"T","ShrinkFirst":"F"}],"fonts":[{"ID":"ReportTitle_Main","Name":"宋体","FontBold":"T","FontAngle":"0","FontColor":"BLACK","FontHeight":"32","FontItalic":"F","CfgDispName":"主标题","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"ReportTitle_Vice_1","Name":"宋体","FontBold":"T","FontAngle":"0","FontColor":"BLACK","FontHeight":"22","FontItalic":"F","CfgDispName":"副标题","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"ReportTitle_Vice_2","Name":"宋体","FontBold":"T","FontAngle":"0","FontColor":"BLACK","FontHeight":"18","FontItalic":"F","CfgDispName":"副标题2","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"HeaderColumn","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"栏头","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"Header","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"表头","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"FooterColumn","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"栏尾","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"Footer","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"表尾","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"GrandTotal","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"总合计","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"SectionTotal","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"章合计","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"Content","Name":"宋体","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"正文内容","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"Content_Narrow","Name":"Arial Narrow","FontBold":"F","FontAngle":"0","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","CfgDispName":"正文内容-窄体","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"Header_V1","Name":"宋体","FontBold":"F","FontAngle":"90","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","FontStrikeOut":"F","FontUnderline":"F"},{"ID":"Header_V2","Name":"宋体","FontBold":"F","FontAngle":"-90","FontColor":"BLACK","FontHeight":"12","FontItalic":"F","FontStrikeOut":"F","FontUnderline":"F"}],"styles":[{"ID":"Default_None","CfgDispName":"空白","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Default","CfgDispName":"默认","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Default_Normal","CfgDispName":"正常","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_Underline","CfgDispName":"字符底线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_Left","CfgDispName":"左边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Label_Right","CfgDispName":"右边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Label_Top","CfgDispName":"上边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Label_LeftTop","CfgDispName":"左上边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Label_LeftBottom","CfgDispName":"左下边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_RightTop","CfgDispName":"右上边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Label_RightBottom","CfgDispName":"右下边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_TopBottom","CfgDispName":"上下边线","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_TopCover","CfgDispName":"上包围","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"0"}]},{"ID":"Label_BottomCover","CfgDispName":"下包围","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_LeftCover","CfgDispName":"左包围","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"Label_RightCover","CfgDispName":"右包围","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"1"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"1"}]},{"ID":"BORDER_ALL_AROUND","CfgDispName":"报表边框","border_style":[{"Color":"BLACK","Position":"Left","DashStyle":"SOLID","LineWeight":"2.0"},{"Color":"BLACK","Position":"Right","DashStyle":"SOLID","LineWeight":"2.0"},{"Color":"BLACK","Position":"Top","DashStyle":"SOLID","LineWeight":"2.0"},{"Color":"BLACK","Position":"Bottom","DashStyle":"SOLID","LineWeight":"2.0"}]}]}'
where userId='Administrator';

ALTER TABLE `zh_project_account`
ADD COLUMN `self_category_level`  varchar(255) NOT NULL DEFAULT '' AFTER `invalid_time`;

ALTER TABLE `zh_project_account`
ADD COLUMN `show_revise_invalid`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否显示，台账修订作废' AFTER `self_category_level`;

ALTER TABLE `zh_project` ADD `payment_setting` JSON NULL DEFAULT NULL COMMENT '支付审批模块设置' AFTER `fun_set`;

CREATE TABLE `zh_payment_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 COLLATE utf16_general_ci NOT NULL COMMENT '文件名',
  `fileext` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件后缀',
  `filesize` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
  `filepath` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
  `in_time` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `renew` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否审批通过后上传',
  `username` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '用户名',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '支付审批详情附件表';

CREATE TABLE `zh_payment_detail`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增',
  `tender_id` int(11) NOT NULL COMMENT '标段id',
  `tr_id` int(11) NOT NULL COMMENT '标段报表id（tender_rpt）',
  `type` tinyint(2) NOT NULL DEFAULT 0 COMMENT '详情类型，0为报表审批表单，1为安全生产费',
  `uid` int(11) NOT NULL COMMENT '创建者id',
  `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '审批状态',
  `order` int(11) NOT NULL COMMENT '期数',
  `times` tinyint(4) NOT NULL COMMENT '审批次数',
  `s_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '日期',
  `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '编号',
  `report_json` json NULL COMMENT '报表json',
  `in_time` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '支付审批详情表';

CREATE TABLE `zh_payment_detail_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `tender_id` int(11) NOT NULL COMMENT '标段id',
  `tr_id` int(11) NOT NULL COMMENT '标段表单关联id',
  `td_id` 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 AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '材料调差审批表';

CREATE TABLE `zh_payment_folder`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '项目id',
  `uid` int(11) NOT NULL COMMENT '创建人id',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '名称',
  `parent_id` int(11) NOT NULL DEFAULT 0 COMMENT '父节点，默认为0',
  `parent_path` varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '' COMMENT '层级定位辅助字段，父节点id集合',
  `level` int(11) NOT NULL COMMENT '层级',
  `order` int(11) NOT NULL DEFAULT 0 COMMENT '同级排序',
  `is_leaf` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否为子节点',
  `had_tender` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否存在标段或子目录下存在标段',
  `in_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '支付审批目录表';

CREATE TABLE `zh_payment_permission_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '项目id',
  `groupid` int(11) NULL DEFAULT NULL COMMENT '用户组id',
  `uid` int(11) NULL DEFAULT NULL COMMENT '用户id',
  `permission_json` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '权限json字符串',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '支付审批用户权限表';

CREATE TABLE `zh_payment_rpt_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tender_id` int(11) NOT NULL COMMENT '标段id',
  `tr_id` int(11) NOT NULL COMMENT '标段报表关联id',
  `td_id` int(11) NOT NULL COMMENT '详情id',
  `uid` int(11) NOT NULL COMMENT '用户id',
  `signature_index` tinyint(3) NOT NULL COMMENT '签名序号，区分签名位置',
  `signature_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '报表角色',
  `signature_msg` json NULL COMMENT '签章的内容json',
  `sign_time` datetime NULL DEFAULT NULL COMMENT '签字内容最后确定时间',
  `in_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '支付审批报表表单角色表';

CREATE TABLE `zh_payment_shenpi_audit`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tid` int(11) NOT NULL COMMENT '标段id',
  `tr_id` int(11) NOT NULL COMMENT '标段报表关联id（tender_rpt）',
  `sp_status` tinyint(4) NOT NULL COMMENT '所选审批流程状态',
  `audit_id` int(11) NOT NULL COMMENT '审批人id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '审批流程人设置表';

CREATE TABLE `zh_payment_tender`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '项目id',
  `uid` int(11) NOT NULL COMMENT '创建者id',
  `folder_id` int(11) NOT NULL COMMENT '目录id',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '标段名称',
  `in_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '支付审批标段表';

CREATE TABLE `zh_payment_tender_rpt`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tender_id` int(11) NOT NULL COMMENT '标段id',
  `rpt_id` int(11) NOT NULL COMMENT '报表id，从rpt_node取',
  `rpt_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT '报表名称，防止报表删除后无法读取到旧数据',
  `type` tinyint(2) NOT NULL DEFAULT 0 COMMENT '模块类型，0为表单，1为安全生产费',
  `uid` int(11) NULL DEFAULT NULL COMMENT '上报人id',
  `create_uid` int(11) NULL DEFAULT NULL COMMENT '创建者id',
  `sp_status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '审批流状态，默认为授权审批流',
  `rpt_audit` json NULL COMMENT '报表签名人员对应的表单人员json',
  `report_items_json` json NULL COMMENT '报表信息json',
  `is_del` tinyint(1) NOT NULL DEFAULT 0 COMMENT '报表是否已删除',
  `is_first` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否未配置角色',
  `is_change` tinyint(1) NOT NULL DEFAULT 0 COMMENT '判断报表是否有变动过，当新建详情时更新这个值为0(用来判断是否删除详情)',
  `in_time` datetime NOT NULL COMMENT '入库时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci COMMENT = '标段报表关联及审批流程设置表';

-- 很重要！！！！
-- 请在该sql语句上方添加下一版本升级所需sql
UPDATE `zh_sub_project` p LEFT JOIN `zh_budget` b ON p.budget_id = b.id SET p.std_id = IFNULL(b.std_id, 0);
UPDATE `zh_sub_project` p LEFT JOIN `zh_budget_std` bs ON p.std_id = bs.id SET p.std_name = IFNULL(bs.name, '');

-- index
ALTER TABLE `zh_material_bills_history` ADD INDEX `idx_mbid_mid_mspread` (`mb_id`, `mid`, `m_spread`);
