CREATE TABLE IF NOT EXISTS "identity_diversion_record" (
    "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "dealer_id" varchar NOT NULL,
    "dealer_name" varchar NOT NULL,
    "batch_id" varchar NOT NULL,
    "goods_id" varchar NOT NULL,
    "goods_name" varchar NOT NULL,
    "scan_location" varchar NOT NULL,
    "scan_time" datetime NOT NULL,
    "diversion_state" varchar NOT NULL,
    "diversion_level" varchar,
    "status" varchar NOT NULL,
    "remarks" varchar,
    "belong_business_id" bigint NOT NULL,
    "belong_business_name" varchar NOT NULL,
    "tenant_id" bigint NOT NULL,
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "creator" varchar DEFAULT '',
    "updater" varchar DEFAULT '',
    PRIMARY KEY ("id")
) COMMENT '疑似窜货记录';
CREATE TABLE IF NOT EXISTS "identity_diversion_stats" (
    "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "dealer_id" varchar NOT NULL,
    "dealer_name" varchar NOT NULL,
    "batch_id" varchar NOT NULL,
    "goods_id" varchar NOT NULL,
    "goods_name" varchar NOT NULL,
    "num" int NOT NULL,
    "belong_business_id" bigint NOT NULL,
    "belong_business_name" varchar NOT NULL,
    "tenant_id" bigint NOT NULL,
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "creator" varchar DEFAULT '',
    "updater" varchar DEFAULT '',
    PRIMARY KEY ("id")
) COMMENT '窜货统计';
CREATE TABLE IF NOT EXISTS "identity_generate_record" (
    "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "generate_record_id" varchar NOT NULL,
    "rule_id" bigint NOT NULL,
    "code_rule_format" varchar,
    "code_type" varchar NOT NULL,
    "char_length" int NOT NULL,
    "char_type" varchar NOT NULL,
    "code_num" int NOT NULL,
    "operate_user" varchar,
    "operate_user_id" bigint,
    "state" varchar NOT NULL,
    "belong_business_id" bigint NOT NULL,
    "belong_business_name" varchar NOT NULL,
    "tenant_id" bigint NOT NULL,
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "creator" varchar DEFAULT '',
    "updater" varchar DEFAULT '',
    PRIMARY KEY ("id")
) COMMENT '标识码生成记录';
CREATE TABLE IF NOT EXISTS "identity_code" (
    "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "generate_record_id" varchar NOT NULL,
    "identity_code" varchar NOT NULL,
    "verfiy_code" varchar,
    "rule_id" bigint NOT NULL,
    "code_rule_format" varchar NOT NULL,
    "code_type" varchar NOT NULL,
    "char_length" int NOT NULL,
    "char_type" varchar NOT NULL,
    "batch_id" varchar NOT NULL,
    "batch_type" varchar NOT NULL,
    "goods_id" varchar,
    "goods_name" varchar,
    "dealer_name" varchar,
    "dealer_id" varchar,
    "belong_business_id" bigint NOT NULL,
    "belong_business_name" varchar NOT NULL,
    "tenant_id" bigint NOT NULL,
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    "scan_count" int,
    "limit_count" int,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "creator" varchar DEFAULT '',
    "updater" varchar DEFAULT '',
    PRIMARY KEY ("id")
) COMMENT '标识码';
CREATE TABLE IF NOT EXISTS "identity_scan_record" (
    "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "generate_record_id" varchar NOT NULL,
    "identity_url" varchar NOT NULL,
    "batch_id" varchar NOT NULL,
    "goods_id" varchar NOT NULL,
    "goods_name" varchar NOT NULL,
    "scan_ip" varchar,
    "batch_type" varchar NOT NULL,
    "scan_area" varchar,
    "scan_time" datetime,
    "scan_location" varchar,
    "belong_business_id" bigint NOT NULL,
    "belong_business_name" varchar NOT NULL,
    "tenant_id" bigint NOT NULL,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "creator" varchar DEFAULT '',
    "updater" varchar DEFAULT '',
    PRIMARY KEY ("id")
) COMMENT '扫码记录';
CREATE TABLE IF NOT EXISTS "identity_business_rule" (
    "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "business_id" varchar,
    "business_name" varchar,
    "code_rule_id" varchar NOT NULL,
    "code_rule_name" varchar,
    "code_type" varchar,
    "code_rule_format" varchar,
    "tenant_id" bigint NOT NULL,
    "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    "deleted" bit NOT NULL DEFAULT FALSE,
    "creator" varchar DEFAULT '',
    "updater" varchar DEFAULT '',
    PRIMARY KEY ("id")
) COMMENT '码规则';
