/*
 Navicat Premium Data Transfer

 Source Server         : 192.168.9.245
 Source Server Type    : MySQL
 Source Server Version : 50744
 Source Host           : 192.168.9.245:3306
 Source Schema         : irrigation_water_price

 Target Server Type    : MySQL
 Target Server Version : 50744
 File Encoding         : 65001

 Date: 10/10/2024 14:43:02
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;


-- ----------------------------
-- Table structure for t_billing_record
-- ----------------------------
DROP TABLE IF EXISTS `t_billing_record`;
CREATE TABLE `t_billing_record`  (
                                     `id` bigint(20) NOT NULL COMMENT '主键ID',
                                     `water_user_id` bigint(20) NOT NULL COMMENT '用水户ID',
                                     `type` tinyint(4) NULL DEFAULT 0 COMMENT '类型:1-扣款 2-退款',
                                     `billing_amount` decimal(14, 2) NOT NULL COMMENT '扣款金额(元)',
                                     `billing_time` datetime(0) NOT NULL COMMENT '扣款日期',
                                     `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                     `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                     `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                     `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                     PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用水户账户扣款记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_charge_template
-- ----------------------------
DROP TABLE IF EXISTS `t_charge_template`;
CREATE TABLE `t_charge_template`  (
                                      `id` bigint(20) NOT NULL COMMENT '主键ID',
                                      `template_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '模板名称',
                                      `charge_type` tinyint(4) NOT NULL COMMENT '计费类型:0-非阶梯;1-阶梯',
                                      `template_type` tinyint(4) NOT NULL COMMENT '模板类型:0-按亩收费;1-按方收费',
                                      `price` decimal(14, 2) NULL DEFAULT NULL COMMENT '非阶梯模板价格',
                                      `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                      `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                      `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                      `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                      PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '水费定价模板表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_charge_template_step
-- ----------------------------
DROP TABLE IF EXISTS `t_charge_template_step`;
CREATE TABLE `t_charge_template_step`  (
                                           `id` bigint(20) NOT NULL COMMENT '主键ID',
                                           `template_id` bigint(20) NOT NULL COMMENT '水费定价模板ID',
                                           `level` int(2) NOT NULL COMMENT '阶梯等级:1-第一阶梯..以此类推',
                                           `min_count` decimal(14, 3) NULL DEFAULT NULL COMMENT '区间左边界',
                                           `max_count` decimal(14, 3) NULL DEFAULT NULL COMMENT '区间右边界',
                                           `price` decimal(14, 2) NULL DEFAULT NULL COMMENT '价格',
                                           `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                           `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                           `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                           `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                           PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '水费定价阶梯表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_crops
-- ----------------------------
DROP TABLE IF EXISTS `t_crops`;
CREATE TABLE `t_crops`  (
                            `id` bigint(20) NOT NULL COMMENT '主键ID',
                            `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '作物名称',
                            `color` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '颜色',
                            `irrigation_coefficient` decimal(4, 2) NULL DEFAULT NULL COMMENT '灌溉系数',
                            `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                            `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                            `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                            `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                            PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '农作物表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_global_config
-- ----------------------------
DROP TABLE IF EXISTS `t_global_config`;
CREATE TABLE `t_global_config`  (
                                    `id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '主键ID',
                                    `keyword` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置键',
                                    `content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置值',
                                    `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配置描述',
                                    `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                    `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                    `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                    `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统配置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_map_draw
-- ----------------------------
DROP TABLE IF EXISTS `t_map_draw`;
CREATE TABLE `t_map_draw`  (
                               `id` bigint(20) NOT NULL COMMENT '主键id',
                               `massif_id` bigint(20) NOT NULL COMMENT '地块ID',
                               `draw_type` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '绘图类型:point-点;line-线;face-面',
                               `draw_color` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '绘图颜色',
                               `point_lng` decimal(9, 6) NULL DEFAULT NULL COMMENT '点经度',
                               `point_lat` decimal(8, 6) NULL DEFAULT NULL COMMENT '点纬度',
                               `line_position` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '线定位点经纬度',
                               `length` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '线长度',
                               `face_position` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '面定位点经纬度',
                               `area` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '面积',
                               `start_long` decimal(9, 6) NULL DEFAULT NULL COMMENT '起点经度',
                               `start_lat` decimal(8, 6) NULL DEFAULT NULL COMMENT '起点纬度',
                               `end_long` decimal(9, 6) NULL DEFAULT NULL COMMENT '终点经度',
                               `end_lat` decimal(8, 6) NULL DEFAULT NULL COMMENT '终点纬度',
                               `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                               `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                               `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                               `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                               PRIMARY KEY (`id`) USING BTREE,
                               UNIQUE INDEX `index_massif_id`(`massif_id`) USING BTREE COMMENT '地块ID索引'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'GIS绘制表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_massif_crops
-- ----------------------------
DROP TABLE IF EXISTS `t_massif_crops`;
CREATE TABLE `t_massif_crops`  (
                                   `id` bigint(20) NOT NULL COMMENT '主键ID',
                                   `massif_id` bigint(20) NOT NULL COMMENT '地块ID',
                                   `crops_id` bigint(20) NULL DEFAULT NULL COMMENT '作物ID',
                                   `start_time` datetime(0) NULL DEFAULT NULL COMMENT '种植周期:开始时间',
                                   `end_time` datetime(0) NULL DEFAULT NULL COMMENT '种植周期:结束时间',
                                   `grow_month` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '种植月份',
                                   `grow_year` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '种植年份',
                                   `crops_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '种植面积',
                                   `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                   `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                   `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                   `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                   PRIMARY KEY (`id`) USING BTREE,
                                   INDEX `UNION_INDEX`(`grow_year`, `massif_id`) USING BTREE COMMENT '年份、地块ID 联合索引'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '地块作物配置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_massif_file
-- ----------------------------
DROP TABLE IF EXISTS `t_massif_file`;
CREATE TABLE `t_massif_file`  (
                                  `id` bigint(20) NOT NULL COMMENT '主键ID',
                                  `massif_id` bigint(20) NOT NULL COMMENT '地块ID',
                                  `file_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件名称',
                                  `file_size` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件大小',
                                  `file_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件类型',
                                  `file_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件路径',
                                  `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                  `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                  `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                  `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '地块文件管理表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_massif_info
-- ----------------------------
DROP TABLE IF EXISTS `t_massif_info`;
CREATE TABLE `t_massif_info`  (
                                  `id` bigint(20) NOT NULL COMMENT '主键ID',
                                  `unit_id` bigint(20) NOT NULL COMMENT '所属单位ID',
                                  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '地块名称，不为空，唯一',
                                  `code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地块编码，可为空，唯一',
                                  `owner_water_user_id` bigint(20) NOT NULL COMMENT '产权户ID',
                                  `use_water_user_id` bigint(20) NOT NULL COMMENT '使用户ID',
                                  `price_status` tinyint(4) NULL DEFAULT 0 COMMENT '定价状态:0-未定价 1-已定价 2-已失效',
                                  `price_active_year` int(10) NULL DEFAULT NULL COMMENT '有效时间(年)',
                                  `price_template_id` bigint(20) NULL DEFAULT NULL COMMENT '水费定价模板ID',
                                  `price_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '定价总额(元)',
                                  `province` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '省份',
                                  `city` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '市',
                                  `county` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '县',
                                  `area` decimal(8, 2) NULL DEFAULT NULL COMMENT '地块面积',
                                  `massif_type_id` bigint(20) NULL DEFAULT NULL COMMENT '地块类型:1-旱田 2-水田',
                                  `crop_id` bigint(20) NULL DEFAULT NULL COMMENT '作物ID',
                                  `irrigation_type` tinyint(4) NULL DEFAULT NULL COMMENT '灌溉方式:1-地面灌溉 2-喷灌 3-滴灌 4-渗灌 5-渠灌',
                                  `irrigation_id` bigint(20) NULL DEFAULT NULL COMMENT '所属灌区ID',
                                  `chan_id` bigint(20) NULL DEFAULT NULL COMMENT '所属渠系ID',
                                  `img_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '工程图片',
                                  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '产权范围说明',
                                  `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                  `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                  `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                  `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '工程-地块信息表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_massif_payment
-- ----------------------------
DROP TABLE IF EXISTS `t_massif_payment`;
CREATE TABLE `t_massif_payment`  (
                                     `id` bigint(20) NOT NULL COMMENT '主键ID',
                                     `massif_id` bigint(20) NOT NULL COMMENT '地块ID',
                                     `payment_year` int(10) NULL DEFAULT NULL COMMENT '台账年份',
                                     `pay_status` tinyint(4) NULL DEFAULT 0 COMMENT '缴费状态:0-未缴费 1-部分缴费 2-已缴费',
                                     `massif_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '地块面积(亩)',
                                     `due_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '应缴水费(元)',
                                     `pay_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '已缴水费(元)',
                                     `unpay_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '未缴水费(元)',
                                     `pay_time` datetime(0) NULL DEFAULT NULL COMMENT '最近缴交时间',
                                     `massif_type_id` bigint(20) NOT NULL COMMENT '地块类型',
                                     `use_water_user_id` bigint(20) NOT NULL COMMENT '使用户ID',
                                     `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                     `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                     `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                     `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                     PRIMARY KEY (`id`) USING BTREE,
                                     INDEX `UNION_INDEX`(`payment_year`, `use_water_user_id`) USING BTREE COMMENT '年份、用水户ID 联合索引'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '地块缴费台账' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_massif_price_record
-- ----------------------------
DROP TABLE IF EXISTS `t_massif_price_record`;
CREATE TABLE `t_massif_price_record`  (
                                          `id` bigint(20) NOT NULL COMMENT '主键ID',
                                          `massif_id` bigint(20) NOT NULL COMMENT '地块ID',
                                          `price_template_id` bigint(20) NOT NULL COMMENT '水费定价模板ID',
                                          `price_active_year` int(10) NULL DEFAULT NULL COMMENT '有效时间(年)',
                                          `price_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '定价总额(元)',
                                          `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
                                          `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                          `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                          `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                          `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '地块水费定价记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_massif_type
-- ----------------------------
DROP TABLE IF EXISTS `t_massif_type`;
CREATE TABLE `t_massif_type`  (
                                  `id` bigint(20) NOT NULL COMMENT '主键ID',
                                  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '名称',
                                  `irrigation_coefficient` decimal(4, 2) NULL DEFAULT NULL COMMENT '灌溉系数',
                                  `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                  `application_id` bigint(20) NULL DEFAULT NULL COMMENT '应用ID',
                                  `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                  `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '地块类型表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_notice
-- ----------------------------
DROP TABLE IF EXISTS `t_notice`;
CREATE TABLE `t_notice`  (
                             `id` bigint(20) NOT NULL COMMENT 'id',
                             `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '标题',
                             `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '内容',
                             `type` tinyint(1) NULL DEFAULT NULL COMMENT '0平台公告 1用水户公告',
                             `unit_id` bigint(20) NULL DEFAULT NULL COMMENT '单位ID 0代表所有单位',
                             `tenant_id` bigint(20) NOT NULL COMMENT '租户id',
                             `application_id` bigint(20) NOT NULL COMMENT '应用id',
                             `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                             `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '公告信息' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `t_operation_log`;
CREATE TABLE `t_operation_log`  (
                                    `id` bigint(20) NOT NULL COMMENT '主键ID',
                                    `request_ip` varchar(225) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '请求者ip',
                                    `user_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作用户',
                                    `request_url` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT '请求url',
                                    `request_time` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '请求耗时',
                                    `operation_type` tinyint(2) NULL DEFAULT NULL COMMENT '操作类型',
                                    `operation_type_desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作类型描述',
                                    `message` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作内容',
                                    `request_body` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT '请求参数',
                                    `tenant_id` bigint(20) NULL DEFAULT NULL COMMENT '租户id',
                                    `application_id` bigint(20) NULL DEFAULT NULL COMMENT '应用id',
                                    `request_user_id` bigint(20) NULL DEFAULT NULL COMMENT '请求用户id',
                                    `create_at` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
                                    `update_at` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
                                    PRIMARY KEY (`id`) USING BTREE,
                                    INDEX `INDEX_OPERATION_USER_ID`(`request_user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统日志' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_pay_record
-- ----------------------------
DROP TABLE IF EXISTS `t_pay_record`;
CREATE TABLE `t_pay_record`  (
                                 `id` bigint(20) NOT NULL COMMENT '主键ID',
                                 `water_user_id` bigint(20) NOT NULL COMMENT '用水户ID',
                                 `pay_type` tinyint(4) NULL DEFAULT 0 COMMENT '缴费方式:0-预收水费 1-本年实收 2-往年实收',
                                 `pay_year` int(10) NULL DEFAULT NULL COMMENT '缴费年份',
                                 `pay_amount` decimal(14, 2) NOT NULL COMMENT '预收金额(元)',
                                 `pay_time` datetime(0) NOT NULL COMMENT '收费日期',
                                 `pay_user_name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '缴费人',
                                 `phone_num` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系电话',
                                 `payment_type` tinyint(4) NULL DEFAULT NULL COMMENT '支付方式:0-微信支付 1-支付宝支付 2-银行卡支付 3-现金支付 4-其他',
                                 `file_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '缴费凭据',
                                 `operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
                                 `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                 `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                 `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                 `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '水费收取缴费记录' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_apply
-- ----------------------------
DROP TABLE IF EXISTS `t_water_apply`;
CREATE TABLE `t_water_apply`  (
                                  `id` bigint(20) NOT NULL COMMENT '主键ID',
                                  `unit_id` bigint(20) NOT NULL COMMENT '所属单位ID',
                                  `apply_number` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '申请编号',
                                  `status` tinyint(4) NULL DEFAULT 0 COMMENT '审核状态:0-待审核 1-已通过 2-已拒绝',
                                  `water_user_id` bigint(20) NOT NULL COMMENT '用水户ID',
                                  `chan_id` bigint(20) NOT NULL COMMENT '所属渠系ID',
                                  `total_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '地块总面积(亩)',
                                  `apply_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '申请用水量/m³',
                                  `approve_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '核定用水量/m³',
                                  `audit_user_id` bigint(20) NULL DEFAULT NULL COMMENT '审核员ID',
                                  `start_time` datetime(0) NULL DEFAULT NULL COMMENT '用水周期:开始时间',
                                  `end_time` datetime(0) NULL DEFAULT NULL COMMENT '用水周期:结束时间',
                                  `type` tinyint(4) NULL DEFAULT 2 COMMENT '用水周期类型:1-月 2-年',
                                  `apply_year` int(10) NULL DEFAULT NULL COMMENT '申请年份',
                                  `audit_time` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                                  `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                  `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                  `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                  `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用水申请记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_apply_massif_rel
-- ----------------------------
DROP TABLE IF EXISTS `t_water_apply_massif_rel`;
CREATE TABLE `t_water_apply_massif_rel`  (
                                             `id` bigint(20) NOT NULL COMMENT '主键ID',
                                             `apply_id` bigint(20) NULL DEFAULT NULL COMMENT '申请ID',
                                             `massif_id` bigint(20) NOT NULL COMMENT '地块ID',
                                             `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                             `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                             `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                             `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用水申请关联地块表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_saving_incentive
-- ----------------------------
DROP TABLE IF EXISTS `t_water_saving_incentive`;
CREATE TABLE `t_water_saving_incentive`  (
                                             `id` bigint(20) NOT NULL COMMENT '主键ID',
                                             `unit_id` bigint(20) NOT NULL COMMENT '所属单位ID',
                                             `record_year` int(10) NULL DEFAULT NULL COMMENT '年份',
                                             `total_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '地块面积(亩)',
                                             `approve_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '核定用水量',
                                             `use_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '已用水量',
                                             `remain_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '剩余用水量',
                                             `water_saving_percent` decimal(14, 2) NULL DEFAULT NULL COMMENT '节水系数',
                                             `subsidy_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '补贴金额(元)',
                                             `approve_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '核定金额(元)',
                                             `status` tinyint(4) NULL DEFAULT 0 COMMENT '审核状态:0-待审核 1-已通过 2-已拒绝',
                                             `audit_user_id` bigint(20) NULL DEFAULT NULL COMMENT '审核员ID',
                                             `audit_time` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                                             `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                             `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                             `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                             `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '节水奖励表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_saving_record
-- ----------------------------
DROP TABLE IF EXISTS `t_water_saving_record`;
CREATE TABLE `t_water_saving_record`  (
                                          `id` bigint(20) NOT NULL COMMENT '主键ID',
                                          `unit_id` bigint(20) NOT NULL COMMENT '所属单位ID',
                                          `chan_id` bigint(20) NULL DEFAULT NULL COMMENT '所属渠系ID',
                                          `record_year` int(10) NULL DEFAULT NULL COMMENT '年份',
                                          `total_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '地块面积(亩)',
                                          `approve_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '核定用水量',
                                          `use_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '已用水量',
                                          `remain_water_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '剩余用水量',
                                          `water_saving_percent` decimal(14, 2) NULL DEFAULT NULL COMMENT '节水系数',
                                          `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                          `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                          `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                          `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                          PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '节水记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_saving_subsidy
-- ----------------------------
DROP TABLE IF EXISTS `t_water_saving_subsidy`;
CREATE TABLE `t_water_saving_subsidy`  (
                                           `id` bigint(20) NOT NULL COMMENT '主键ID',
                                           `water_user_id` bigint(20) NOT NULL COMMENT '用水户ID',
                                           `unit_id` bigint(20) NOT NULL COMMENT '所属单位ID',
                                           `apply_number` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '申请编号',
                                           `subsidy_year` int(10) NULL DEFAULT NULL COMMENT '补贴年份',
                                           `subsidy_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '补贴面积(亩)',
                                           `subsidy_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '补贴金额(元)',
                                           `approve_subsidy_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '核定金额(元)',
                                           `status` tinyint(4) NULL DEFAULT 0 COMMENT '申请状态:0-待审核 1-已通过 2-已拒绝',
                                           `audit_user_id` bigint(20) NULL DEFAULT NULL COMMENT '审核员ID',
                                           `audit_time` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                                           `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                           `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                           `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                           `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                           PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '精准补贴表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_user
-- ----------------------------
DROP TABLE IF EXISTS `t_water_user`;
CREATE TABLE `t_water_user`  (
                                 `id` bigint(20) NOT NULL COMMENT '主键ID',
                                 `unit_id` bigint(20) NOT NULL COMMENT '所属单位ID',
                                 `type` tinyint(4) NOT NULL COMMENT '账户类型:1-个人 2-村委会',
                                 `code` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账户编号',
                                 `name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账户名称',
                                 `balance_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '账户余额(元)',
                                 `nick_name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称或联系人',
                                 `phone_num` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '联系电话',
                                 `id_num` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '身份证号',
                                 `legal_nick_name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '法定代表人',
                                 `legal_phone_num` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '法定代表人电话',
                                 `address` varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地址',
                                 `water_licence` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用水许可证',
                                 `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                 `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                 `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                 `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                 PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用水户表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_water_user_payment
-- ----------------------------
DROP TABLE IF EXISTS `t_water_user_payment`;
CREATE TABLE `t_water_user_payment`  (
                                         `id` bigint(20) NOT NULL COMMENT '主键ID',
                                         `water_user_id` bigint(20) NOT NULL COMMENT '用水户ID',
                                         `payment_year` int(10) NULL DEFAULT NULL COMMENT '台账年份',
                                         `total_area` decimal(14, 2) NULL DEFAULT NULL COMMENT '地块面积(亩)',
                                         `pay_status` tinyint(4) NULL DEFAULT 0 COMMENT '缴费状态:0-未缴费 1-部分缴费 2-已缴费',
                                         `due_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '应缴水费(元)',
                                         `pay_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '已缴水费(元)',
                                         `unpay_amount` decimal(14, 2) NULL DEFAULT NULL COMMENT '未缴水费(元)',
                                         `pay_time` datetime(0) NULL DEFAULT NULL COMMENT '最近缴交时间',
                                         `water_user_type` tinyint(4) NOT NULL COMMENT '账户类型:1-个人 2-村委会',
                                         `tenant_id` bigint(20) NOT NULL COMMENT '租户ID',
                                         `application_id` bigint(20) NOT NULL COMMENT '应用ID',
                                         `create_at` datetime(0) NOT NULL COMMENT '创建时间',
                                         `update_at` datetime(0) NOT NULL COMMENT '更新时间',
                                         PRIMARY KEY (`id`) USING BTREE,
                                         INDEX `UNION_INDEX`(`payment_year`, `water_user_id`) USING BTREE COMMENT '年份、用水户ID 联合索引'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用水户缴费台账' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table Records
-- ----------------------------
INSERT INTO `t_massif_type`(`id`, `name`, `irrigation_coefficient`, `tenant_id`, `create_at`, `update_at`) VALUES (1, '旱田', 0.50, 0, '2024-09-05 14:46:35', '2024-09-05 14:46:35');
INSERT INTO `t_massif_type`(`id`, `name`, `irrigation_coefficient`, `tenant_id`, `create_at`, `update_at`) VALUES (2, '水田', 1.00, 0, '2024-09-05 14:46:35', '2024-09-05 14:46:35');

INSERT INTO `t_global_config`(`id`, `keyword`, `content`, `description`, `tenant_id`, `application_id`, `create_at`, `update_at`) VALUES ('1', 'INCENTIVE_COEFFICIENT_20_UNDER', '0.02', '节水奖励-节水基数20%（含20%）以下，每立方米奖励金额', 0, 588480720217833472, '2024-09-18 17:16:54', '2024-09-18 17:16:56');
INSERT INTO `t_global_config`(`id`, `keyword`, `content`, `description`, `tenant_id`, `application_id`, `create_at`, `update_at`) VALUES ('2', 'INCENTIVE_COEFFICIENT_20_ABOVE', '0.03', '节水奖励-节水基数20%以上，每立方米奖励金额', 0, 588480720217833472, '2024-09-18 17:16:54', '2024-09-18 17:16:56');
INSERT INTO `t_global_config`(`id`, `keyword`, `content`, `description`, `tenant_id`, `application_id`, `create_at`, `update_at`) VALUES ('3', 'SUBSIDY_COEFFICIENT', '2', '精准奖励-每亩补贴金额', 0, 588480720217833472, '2024-09-18 17:16:54', '2024-09-18 17:16:56');

SET FOREIGN_KEY_CHECKS = 1;
