init.sql 38.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757

-- 一下是测试业务初始化
-- Storage库存微服务的数据库业务初始化
DROP DATABASE IF EXISTS project_storage;
CREATE DATABASE project_storage;
USE project_storage;
CREATE TABLE `storage`
(
    `id`             bigint(11) unsigned NOT NULL AUTO_INCREMENT,
    `commodity_code` varchar(255) DEFAULT NULL,
    `count`          int(11)      DEFAULT '0',
    `create_time`    datetime     DEFAULT NULL,
    `update_time`    datetime     DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `commodity_code` (`commodity_code`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 2
  DEFAULT CHARSET = utf8;
INSERT INTO `storage`
VALUES ('1', '1', '100', '2022-08-07 22:48:29', '2022-08-14 13:49:05');

-- Account账户微服务的数据库业务初始化
DROP DATABASE IF EXISTS project_account;
CREATE DATABASE project_account;
USE project_account;
CREATE TABLE `account`
(
    `id`          bigint(11) unsigned NOT NULL AUTO_INCREMENT,
    `user_id`     varchar(255) DEFAULT NULL,
    `money`       int(11)      DEFAULT '0',
    `create_time` datetime     DEFAULT NULL,
    `update_time` datetime     DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 2
  DEFAULT CHARSET = utf8;
INSERT INTO `account`
VALUES ('1', 'admin', '3', '2022-08-07 22:53:01', '2022-08-14 13:49:05');

-- Order订单微服务的数据库业务初始化
DROP DATABASE IF EXISTS project_order;
CREATE DATABASE project_order;
USE project_order;
CREATE TABLE `order`
(
    `id`             bigint(11) unsigned NOT NULL AUTO_INCREMENT,
    `user_id`        varchar(255) DEFAULT NULL,
    `commodity_code` varchar(255) DEFAULT NULL,
    `count`          int(11)      DEFAULT NULL,
    `money`          int(11)      DEFAULT '0',
    `create_time`    datetime     DEFAULT NULL,
    `update_time`    datetime     DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 16
  DEFAULT CHARSET = utf8;

-- 点赞业务的数据库初始化
DROP DATABASE IF EXISTS project_praise;
CREATE DATABASE project_praise;
USE project_praise;
CREATE TABLE `item`
(
    `id`          bigint(11) unsigned NOT NULL AUTO_INCREMENT,
    `praise`      int(11)  DEFAULT NULL,
    `create_time` datetime DEFAULT NULL,
    `update_time` datetime DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 2
  DEFAULT CHARSET = utf8;
INSERT INTO `item`
VALUES ('1', '0', '2022-08-14 00:33:50', '2022-08-14 14:07:34');
-- Storage库存微服务的数据库Seata初始化
USE project_storage;
CREATE TABLE `undo_log`
(
    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
    `branch_id`     bigint(20)   NOT NULL,
    `xid`           varchar(100) NOT NULL,
    `context`       varchar(128) NOT NULL,
    `rollback_info` longblob     NOT NULL,
    `log_status`    int(11)      NOT NULL,
    `log_created`   datetime     NOT NULL,
    `log_modified`  datetime     NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

-- Storage库存微服务的数据库Seata初始化
USE project_account;
CREATE TABLE `undo_log`
(
    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
    `branch_id`     bigint(20)   NOT NULL,
    `xid`           varchar(100) NOT NULL,
    `context`       varchar(128) NOT NULL,
    `rollback_info` longblob     NOT NULL,
    `log_status`    int(11)      NOT NULL,
    `log_created`   datetime     NOT NULL,
    `log_modified`  datetime     NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

-- Storage库存微服务的数据库Seata初始化
USE project_order;
CREATE TABLE `undo_log`
(
    `id`            bigint(20)   NOT NULL AUTO_INCREMENT,
    `branch_id`     bigint(20)   NOT NULL,
    `xid`           varchar(100) NOT NULL,
    `context`       varchar(128) NOT NULL,
    `rollback_info` longblob     NOT NULL,
    `log_status`    int(11)      NOT NULL,
    `log_created`   datetime     NOT NULL,
    `log_modified`  datetime     NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;
  

-- 项目数据库业务初始化
DROP DATABASE IF EXISTS project;
CREATE DATABASE project;
USE project;
/*
 Navicat Premium Data Transfer

 Source Server         : 项目mysql
 Source Server Type    : MySQL
 Source Server Version : 50732
 Source Host           : 127.0.0.1:33060
 Source Schema         : dituhui

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

 Date: 23/03/2021 16:45:58
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for resource
-- ----------------------------
DROP TABLE IF EXISTS `resource`;
CREATE TABLE `resource`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `extra` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户自定义条件',
  `team_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '团队id',
  `description` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '资源表 用户对某种具体权限或者功能的描述' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of resource
-- ----------------------------
INSERT INTO `resource` VALUES ('40288ac97698799901769879c6b90000', '资源一', '1', '40288ac9768e57d101768e5808610000', NULL, NULL, '2020-12-25 05:58:06', NULL, '2020-12-25 05:58:06');

-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `team_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '团队id',
  `group_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色组id',
  `extra` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色自定义条件',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES ('40288ac97697eca5017697ecd1010000', '角色1', '40288ac9768e57d101768e5808610000', NULL, '1', NULL, '2020-12-25 03:24:08', NULL, '2020-12-25 03:24:08');

-- ----------------------------
-- Table structure for role_group
-- ----------------------------
DROP TABLE IF EXISTS `role_group`;
CREATE TABLE `role_group`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `description` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
  `team_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '团队id',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色组表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for role_resource
-- ----------------------------
DROP TABLE IF EXISTS `role_resource`;
CREATE TABLE `role_resource`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `role_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色id',
  `resource_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '资源id',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '角色资源表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of role_resource
-- ----------------------------
INSERT INTO `role_resource` VALUES ('40288ac976987de90176987e19120000', '40288ac97697eca5017697ecd1010000', '40288ac97698799901769879c6b90000', NULL, NULL, NULL, NULL);

-- ----------------------------
-- Table structure for team
-- ----------------------------
DROP TABLE IF EXISTS `team`;
CREATE TABLE `team`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '名称',
  `expire_date` datetime(0) NULL DEFAULT NULL COMMENT '到期时间',
  `contract` int(11) NULL DEFAULT NULL COMMENT '是否签约 0试用,1正式',
  `app_key` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'ak',
  `secret` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密钥',
  `logo` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '公司图标',
  `business` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属行业',
  `province` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属省',
  `city` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属市',
  `county` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '所属区县',
  `size` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '人数',
  `address` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '公司地址',
  `charter` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '营业执照',
  `extra` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '团队自定义条件',
  `admin_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '创始人用户id',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `udx_app_key`(`app_key`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '团队表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of team
-- ----------------------------
INSERT INTO `team` VALUES ('40288ac97673e23f017673e26ed90001', '地图王者的团队', '2020-12-25 03:26:28', 1, 'ddeea077a9dc4bd6923a1636868d49da', '42e9da45bd6e4953afc1772d4e980eb8', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '40288ac97673e23f017673e26e3c0000', NULL, '2020-12-18 03:26:28', NULL, '2021-01-12 05:53:54');
INSERT INTO `team` VALUES ('40288ac9768e57d101768e5808610000', '测试团队002', '2020-12-22 16:00:00', 1, '384bbf0ebbb54f93be1b2d86fe5f0c5b', '645db57162d84610845fcaa9b66f6b2e', NULL, '002团队', '四川省', '成都市', '高新区', '1000', '新川科技园成都超图大厦', NULL, NULL, '', NULL, '2020-12-23 06:45:03', NULL, '2020-12-23 08:13:34');

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `account` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '账号',
  `password` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
  `nickname` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '昵称',
  `email` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
  `phone` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话',
  `sex` int(11) NULL DEFAULT NULL COMMENT '性别 0 女,1男',
  `avatar` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像',
  `LAST_LOGIN_TIME` datetime(0) NULL DEFAULT NULL COMMENT '最后登录时间',
  `extra` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户自定义条件',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('40288ac97673e23f017673e26e3c0000', '18600707187', '25f9e794323b453885f5181f1b624d0b', '地图王者', '18600707187', '18600707187', 1, NULL, NULL, NULL, NULL, '2020-12-18 03:26:28', NULL, '2020-12-18 08:55:22');
INSERT INTO `user` VALUES ('40288ac97675068b017675072afe0000', '18600707186', '25f9e794323b453885f5181f1b624d0b', '地图旅行者', NULL, '18600707186', 1, NULL, NULL, NULL, NULL, '2020-12-18 08:46:13', NULL, '2020-12-18 08:46:13');

-- ----------------------------
-- Table structure for user_role
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户id',
  `role_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色id',
  `team_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '团队id',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户角色关系表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for user_team
-- ----------------------------
DROP TABLE IF EXISTS `user_team`;
CREATE TABLE `user_team`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
  `user_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户id',
  `team_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '团队id',
  `status` int(11) NULL DEFAULT NULL COMMENT '状态 1:正常,0:冻结状态,2:删除',
  `CREATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
  `CREATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `UPDATED_BY` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
  `UPDATED_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户所属团队表 ' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user_team
-- ----------------------------
INSERT INTO `user_team` VALUES ('40288ac97673e23f017673e26ee20002', '40288ac97673e23f017673e26e3c0000', '40288ac97673e23f017673e26ed90001', 1, NULL, '2020-12-18 03:26:28', NULL, '2020-12-18 03:26:28');
INSERT INTO `user_team` VALUES ('40288ac97675068b0176750737070001', '40288ac97675068b017675072afe0000', '40288ac97673e23f017673e26ed90001', 1, NULL, '2020-12-18 08:46:16', NULL, '2020-12-18 08:46:16');

SET FOREIGN_KEY_CHECKS = 1;





/*  初始化bsh业务表 */
DROP DATABASE IF EXISTS `saas_aftersale_test`;
CREATE DATABASE `saas_aftersale_test`;
USE `saas_aftersale_test`;

/*Table structure for table `district` */

/*  临时兼容order表,后期去掉 */
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order`
(
    `id`             bigint(11) unsigned NOT NULL AUTO_INCREMENT,
    `user_id`        varchar(255) DEFAULT NULL,
    `commodity_code` varchar(255) DEFAULT NULL,
    `count`          int(11)      DEFAULT NULL,
    `money`          int(11)      DEFAULT '0',
    `create_time`    datetime     DEFAULT NULL,
    `update_time`    datetime     DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 16
  DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `district`;

CREATE TABLE `district` (
  `district_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '大区ID',
  `district_name` varchar(20) NOT NULL COMMENT '大区名称',
  `citycode_list` json NOT NULL COMMENT '所有管辖城市列表,配置好一般不变',
  `status` tinyint(1) DEFAULT '1' COMMENT '帐号状态(0无效 1有效)',
  `district_addr` varchar(50) NOT NULL COMMENT '大区地址(非关键信息)',
  `district_city_name` varchar(20) NOT NULL DEFAULT '' COMMENT '大区所在城市(非关键信息)',
  `update_user` varchar(20) DEFAULT '' COMMENT '创建人',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`district_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='大区表,管理线条、维护组织架构、数据权限类信息';

/*Data for the table `district` */

/*Table structure for table `engineer` */

DROP TABLE IF EXISTS `engineer`;

CREATE TABLE `engineer` (
  `engineer_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '工作队ID',
  `subsection_id` int(11) DEFAULT '0' COMMENT '归属分部',
  `username` varchar(50) NOT NULL COMMENT '工程师姓名',
  `engineer_code` varchar(50) NOT NULL DEFAULT '' COMMENT '工程师工号',
  `cosmos_id` varchar(50) DEFAULT NULL COMMENT '原cosmos id',
  `gender` varchar(5) DEFAULT '男' COMMENT '性别',
  `birth` varchar(10) NOT NULL COMMENT '出生年份',
  `phone` varchar(25) NOT NULL COMMENT '手机号码',
  `addr` varchar(50) NOT NULL COMMENT '手机号码',
  `kind` tinyint(1) DEFAULT '1' COMMENT '类型(1全职 2兼职)',
  `grade` varchar(20) DEFAULT NULL COMMENT '职级,c2,c1...',
  `marketing_score` int(11) DEFAULT '0' COMMENT '营销指数',
  `vehicle` tinyint(1) DEFAULT '0' COMMENT '交通工具,1电动车 2摩托车 3公交车 4自驾',
  `vehicle_no` varchar(20) DEFAULT NULL COMMENT '摩托车、汽车的车牌号,便于计算限行',
  `bean_status` tinyint(1) DEFAULT NULL COMMENT 'bean帐号状态(0无效 1有效)',
  `status` tinyint(1) DEFAULT '1' COMMENT '帐号状态(0无效 1有效)',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`engineer_id`) USING BTREE,
  UNIQUE KEY `un_ecode` (`engineer_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工程师基本信息表,执行线条';

/*Data for the table `engineer` */

/*Table structure for table `engineer_business` */

DROP TABLE IF EXISTS `engineer_business`;

CREATE TABLE `engineer_business` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '工作队ID',
  `engineer_id` int(11) DEFAULT NULL COMMENT '技术员ID',
  `max_num` int(11) DEFAULT NULL COMMENT '每日最大单量',
  `max_minute` int(11) DEFAULT NULL COMMENT '每日有效工作时长-分钟',
  `work_addr` varchar(50) NOT NULL COMMENT '首选工作地点',
  `work_lati` varchar(20) NOT NULL COMMENT '首选工作地点纬度',
  `work_longi` varchar(20) NOT NULL COMMENT '首选工作地点经度',
  `priority` tinyint(4) DEFAULT NULL COMMENT '派单优先级,数据越大优先级越高,低优先级的要跟踪工作质量',
  `departure` tinyint(4) NOT NULL DEFAULT '0' COMMENT '常规出发地,1配件仓,2住址',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工程师业务属性配置表,执行线条';

/*Data for the table `engineer_business` */

/*Table structure for table `engineer_skill` */

DROP TABLE IF EXISTS `engineer_skill`;

CREATE TABLE `engineer_skill` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '工作队ID',
  `engineer_id` int(11) DEFAULT NULL COMMENT '技术员ID',
  `product_service_id` int(11) DEFAULT NULL COMMENT '产品服务类别ID',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工程师技能表,执行线条';

/*Data for the table `engineer_skill` */

/*Table structure for table `fleet` */

DROP TABLE IF EXISTS `fleet`;

CREATE TABLE `fleet` (
  `fleet_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '工作队ID',
  `fleet_name` varchar(20) NOT NULL COMMENT '工作队名称',
  `subsection_id` int(11) DEFAULT '0' COMMENT '归属分部',
  `group_id` int(11) DEFAULT '0' COMMENT '归属小组',
  `warehouse_id` tinyint(1) DEFAULT NULL COMMENT '取件配件仓',
  `wrokdays` varchar(30) DEFAULT '1,2,3,4,5,6,7' COMMENT '工作日,1表示星期一,2表示星期二',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`fleet_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作队表,执行线条,小组内部分工作队';

/*Data for the table `fleet` */

/*Table structure for table `fleet_engineer` */

DROP TABLE IF EXISTS `fleet_engineer`;

CREATE TABLE `fleet_engineer` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '工作队ID',
  `fleet_id` int(11) DEFAULT NULL COMMENT '工作队ID',
  `engineer_id` int(11) DEFAULT NULL COMMENT '技术员ID',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作队-技术员关联表,执行线条';

/*Data for the table `fleet_engineer` */

/*Table structure for table `group` */

DROP TABLE IF EXISTS `group`;

CREATE TABLE `group` (
  `group_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '小组ID',
  `group_name` varchar(20) NOT NULL COMMENT '小组名称',
  `district_id` int(11) DEFAULT '0' COMMENT '归属大区',
  `subsection_id` int(11) DEFAULT '0' COMMENT '归属分部',
  `office_addr` varchar(100) NOT NULL DEFAULT '' COMMENT '办公地址',
  `office_lati` varchar(20) NOT NULL COMMENT '办公地址纬度',
  `office_longi` varchar(20) NOT NULL COMMENT '办公地址经度',
  `group_city_code` varchar(20) NOT NULL COMMENT '小组所在城市Id',
  `kind` tinyint(1) DEFAULT '1' COMMENT '类型(1分站,2外围,3小组,4网点,5自保点)',
  `category` tinyint(1) DEFAULT '1' COMMENT '类型(1自有,2加盟)',
  `warehouse_id` tinyint(1) DEFAULT '0' COMMENT '取件配件仓',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`group_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小组表,执行线条,管理服务执行相关的业务架构';

/*Data for the table `group` */

/*Table structure for table `layer` */

DROP TABLE IF EXISTS `layer`;

CREATE TABLE `layer` (
  `layer_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '区块ID',
  `layer_name` varchar(20) NOT NULL COMMENT '区块名称',
  `subsection_id` int(11) DEFAULT '0' COMMENT '归属分部',
  `group_id` int(11) DEFAULT '0' COMMENT '归属小组',
  `city_code` varchar(20) NOT NULL COMMENT '所在城市Id',
  `area_data` json DEFAULT NULL COMMENT '面数据',
  `kind` tinyint(1) DEFAULT '1' COMMENT '类型(1自然行政片区,2自定义片区)',
  `fleet_id` int(11) DEFAULT '0' COMMENT '关联小队id',
  `tags` json DEFAULT NULL COMMENT '图标标签,[基础图层,GGN]',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`layer_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区块表/区划表,执行线条';

/*Data for the table `layer` */

/*Table structure for table `order` */

DROP TABLE IF EXISTS `order`;

CREATE TABLE `order` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `order_id` varchar(50) NOT NULL COMMENT '预约单Id',
  `customer_name` varchar(50) NOT NULL COMMENT '客户姓名',
  `customer_phone` varchar(20) NOT NULL COMMENT '客户联系电话',
  `customer_city` varchar(20) NOT NULL COMMENT '客户所在省市',
  `customer_addr` varchar(100) NOT NULL COMMENT '客户详细地址',
  `brand` varchar(20) NOT NULL COMMENT '设备品牌',
  `kind` varchar(20) NOT NULL COMMENT '设备类别',
  `service` varchar(20) NOT NULL COMMENT '设备所需服务',
  `describe` varchar(20) NOT NULL DEFAULT '' COMMENT '客户描述',
  `priority` tinyint(1) DEFAULT '0' COMMENT '优先级(0一般 1紧急)',
  `wanted_time_desc` varchar(50) DEFAULT '' COMMENT '客户意向时间,周末上午',
  `schedule_time` datetime DEFAULT NULL COMMENT '预约时间',
  `strict_time` int(11) DEFAULT '0' COMMENT '时间要求(0弹性 1严格时间)',
  `layer_id` int(11) DEFAULT NULL COMMENT '地址解析+技能匹配的图层编号 ',
  `source` varchar(10) DEFAULT '' COMMENT '预约渠道,400,小程序,JD',
  `tags` varchar(50) NOT NULL COMMENT '预约单标签,紧急/重型',
  `status` tinyint(1) DEFAULT '0' COMMENT '预约单状态(0待处理 1待派工 ...)',
  `sub_status` tinyint(1) DEFAULT '0' COMMENT '预约单状态(0待处理 1已出发 ...)',
  `district_id` int(11) DEFAULT '0' COMMENT '归属大区',
  `subsection_id` int(11) DEFAULT '0' COMMENT '归属分部',
  `group_id` int(11) DEFAULT '0' COMMENT '归属小组',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_orderid` (`order_id`),
  KEY `idx_cname` (`customer_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='预约单基本信息表,执行线条';

/*Data for the table `order` */

/*Table structure for table `order_history` */

DROP TABLE IF EXISTS `order_history`;

CREATE TABLE `order_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `order_id` varchar(50) NOT NULL COMMENT '预约单Id',
  `suborder_id` varchar(50) NOT NULL COMMENT '子工单Id',
  `act` varchar(50) DEFAULT '' COMMENT '操作,指派,规划路线',
  `desc` varchar(100) NOT NULL COMMENT '操作描述',
  `order_status` varchar(20) NOT NULL COMMENT '操作后预约单状态,待派工',
  `order_status_change` varchar(20) NOT NULL COMMENT '预约单状态变更,待处理>待派工',
  `sub_order_status` varchar(20) NOT NULL COMMENT '预约单状态变更,',
  `sub_order_status_change` varchar(20) NOT NULL COMMENT '预约单状态变更,无>待处理',
  `engineer_id` int(11) NOT NULL COMMENT '工程师',
  `engineer_name` varchar(20) NOT NULL COMMENT '工程师姓名',
  `engineer_group_id` int(11) NOT NULL COMMENT '工程师组id',
  `engineer_group_name` varchar(100) NOT NULL COMMENT '工程师组id',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='预约单/子工单状态变更表,执行线条';

/*Data for the table `order_history` */

/*Table structure for table `product_service` */

DROP TABLE IF EXISTS `product_service`;

CREATE TABLE `product_service` (
  `product_service_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '小组ID',
  `kind` varchar(20) DEFAULT '' COMMENT '产品类别',
  `service` varchar(20) DEFAULT '' COMMENT '服务类型',
  `brand` varchar(20) NOT NULL DEFAULT '' COMMENT '品牌',
  `take_time` int(11) DEFAULT '0' COMMENT '所需工时(分钟)',
  `take_engineer` int(11) DEFAULT '0' COMMENT '所需人数',
  `tag` varchar(50) NOT NULL DEFAULT '' COMMENT '图层标签',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`product_service_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品服务类别表,执行线条';

/*Data for the table `product_service` */

/*Table structure for table `sub_order` */

DROP TABLE IF EXISTS `sub_order`;

CREATE TABLE `sub_order` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `order_id` varchar(50) NOT NULL COMMENT '预约单Id',
  `suborder_id` varchar(50) NOT NULL COMMENT '子工单Id',
  `main_sub` varchar(20) DEFAULT '1' COMMENT '多人单标识(1主单 2副单)',
  `engineer_id` int(11) NOT NULL COMMENT '工程师Id',
  `engineer_username` varchar(20) NOT NULL COMMENT '工程师姓名',
  `engineer_phone` varchar(20) NOT NULL COMMENT '工程师电话',
  `engineer_age` int(11) NOT NULL COMMENT '工程师年龄',
  `engineer_group_id` int(11) NOT NULL COMMENT '工程师组id',
  `engineer_group_name` varchar(100) NOT NULL COMMENT '工程师组id',
  `is_workshop` int(11) DEFAULT '0' COMMENT '是否车间单(0否 1是)',
  `schedule_time` datetime DEFAULT NULL COMMENT '预约上门时间',
  `actual_time` datetime DEFAULT NULL COMMENT '实际上门时间',
  `start_time` datetime DEFAULT NULL COMMENT '开始服务时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束服务时间',
  `status` tinyint(1) DEFAULT '0' COMMENT '预约单状态(0待处理 1已出发 ...)',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='预约单的子工单基本信息表,执行线条';

/*Data for the table `sub_order` */

/*Table structure for table `subsection` */

DROP TABLE IF EXISTS `subsection`;

CREATE TABLE `subsection` (
  `subsection_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '分部ID',
  `subsection_name` varchar(20) NOT NULL COMMENT '分部名称',
  `district_id` int(11) DEFAULT '0' COMMENT '归属大区',
  `office_addr` varchar(50) NOT NULL DEFAULT '' COMMENT '办公地址',
  `office_lati` varchar(20) NOT NULL COMMENT '办公地址纬度',
  `office_longi` varchar(20) NOT NULL COMMENT '办公地址经度',
  `citycode_list` json NOT NULL COMMENT '分部管辖城市列表',
  `kind` tinyint(1) DEFAULT '1' COMMENT '类型(0无分站分部 1有分站分部)',
  `layer_id` varchar(50) DEFAULT NULL COMMENT '区划图层id,嵌入saas字段',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`subsection_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分部表,管理线条、管理组织架构、数据权限类信息';

/*Data for the table `subsection` */

/*Table structure for table `sys_user` */

DROP TABLE IF EXISTS `sys_user`;

CREATE TABLE `sys_user` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
  `phone` varchar(20) NOT NULL COMMENT '登录用户名',
  `username` varchar(30) NOT NULL COMMENT '姓名',
  `password` varchar(80) DEFAULT '' COMMENT '密码',
  `org_id` int(11) DEFAULT NULL COMMENT '关联组织Id,大区id,分部id',
  `org_name` varchar(50) DEFAULT NULL COMMENT '关联组织名称',
  `status` tinyint(1) DEFAULT '1' COMMENT '帐号状态(0无效 1有效)',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统用户信息表';

/*Data for the table `sys_user` */

/*Table structure for table `task_run_log` */

DROP TABLE IF EXISTS `task_run_log`;

CREATE TABLE `task_run_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增长主键',
  `task_detail` varchar(150) NOT NULL DEFAULT '' COMMENT 'task详细名称',
  `description` varchar(200) DEFAULT NULL COMMENT 'task描述',
  `payload` json DEFAULT NULL COMMENT '上下文参数',
  `status` varchar(10) DEFAULT NULL COMMENT '执行状态',
  `result` json DEFAULT NULL COMMENT '详细结果',
  `caller` varchar(30) DEFAULT NULL COMMENT '调用方',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `idx` (`task_detail`),
  KEY `idx_name` (`task_detail`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='操作日志表';

/*Data for the table `task_run_log` */

/*Table structure for table `task_stat` */

DROP TABLE IF EXISTS `task_stat`;

CREATE TABLE `task_stat` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增长主键',
  `name` varchar(100) NOT NULL COMMENT '任务名称',
  `desc` varchar(200) NOT NULL COMMENT '任务描述',
  `tags` varchar(50) DEFAULT NULL COMMENT '标签, eg:合伙人,V1',
  `sql_type` varchar(50) DEFAULT NULL COMMENT 'sql类型, sql_execute 单表/联表更新,sql_stat统计写入其它表,sql_query_minmax_alarm查询到的最大最小值邮件告警',
  `sql` varchar(2000) DEFAULT NULL COMMENT '待执行的sql',
  `aim_table` varchar(100) DEFAULT NULL COMMENT '上面语句查询结果要写入的表, bi_day',
  `aim_table_uniq_column` varchar(100) DEFAULT NULL COMMENT '写入表的 unique column,用于insert或update, 不写则使用查询语句结果的首列做为唯一判重列 ',
  `min` varchar(11) DEFAULT NULL COMMENT 'sql_query_minmax_alarm类型的最小值',
  `max` varchar(11) DEFAULT NULL COMMENT 'sql_query_minmax_alarm的最大值',
  `alarm_to` varchar(100) DEFAULT NULL COMMENT 'sql_query_minmax_alarm的告警人邮箱列表,如mail1,mail2',
  `schedule` varchar(50) DEFAULT NULL COMMENT '任务策略, "1 9 * * ?", @every 30s, ...',
  `disabled` tinyint(1) DEFAULT '0' COMMENT '是否禁用',
  `remark` varchar(200) DEFAULT NULL COMMENT '备注',
  `create_id` varchar(50) DEFAULT NULL COMMENT '创建人',
  `update_id` varchar(50) DEFAULT NULL COMMENT '更新人',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sql更新/统计类任务';

/*Data for the table `task_stat` */

/*Table structure for table `warehouse` */

DROP TABLE IF EXISTS `warehouse`;

CREATE TABLE `warehouse` (
  `warehouse_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '配件仓ID',
  `warehouse_name` varchar(20) NOT NULL COMMENT '配件仓名称',
  `subsection_id` int(11) DEFAULT '0' COMMENT '归属分部',
  `city_code` varchar(20) NOT NULL COMMENT '所在城市Id',
  `addr` varchar(100) NOT NULL COMMENT '配件仓',
  `addr_lati` varchar(20) NOT NULL COMMENT '办公地址纬度',
  `addr_longi` varchar(20) NOT NULL COMMENT '办公地址经度',
  `arrive_time` varchar(10) DEFAULT '' COMMENT '配件到达时间',
  `cutoff_time` varchar(10) DEFAULT '' COMMENT '配件到达时间',
  `kind` tinyint(1) DEFAULT '1' COMMENT '类型(1分部仓-可分发,2小组仓-快递柜)',
  `manager_name` varchar(10) DEFAULT '' COMMENT '管理员姓名',
  `namager_phone` varchar(20) DEFAULT '' COMMENT '管理员手机号码',
  `memo` varchar(100) DEFAULT '' COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`warehouse_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配件仓表,执行线条';

/*Data for the table `warehouse` */

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;