CREATE TABLE "public"."hs_asset_extension" (
                                               "id" uuid NOT NULL,
                                               "bg_images" varchar(100000) COLLATE "pg_catalog"."default",
                                               "logo_icon" varchar(255) COLLATE "pg_catalog"."default",
                                               "logo_images" varchar(1000000) COLLATE "pg_catalog"."default",
                                               "created_user" uuid,
                                               "created_time" int8 NOT NULL,
                                               "updated_time" varchar(255) COLLATE "pg_catalog"."default",
                                               "updated_user" uuid,
                                               "tenant_id" uuid NOT NULL,
                                               CONSTRAINT "hs_asset_extension_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_asset_extension"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."hs_asset_extension"."id" IS '资产标识';

COMMENT ON COLUMN "public"."hs_asset_extension"."bg_images" IS '背景图片';




CREATE TABLE "public"."hs_customer_extension" (
                                                  "id" uuid NOT NULL,
                                                  "logo_icon" varchar(2000000) COLLATE "pg_catalog"."default",
                                                  "logo_images" varchar(1000000) COLLATE "pg_catalog"."default",
                                                  "remark" varchar(1000) COLLATE "pg_catalog"."default",
                                                  "tenant_id" uuid NOT NULL,
                                                  "updated_time" varchar(255) COLLATE "pg_catalog"."default",
                                                  "updated_user" uuid,
                                                  "created_time" varchar(255) COLLATE "pg_catalog"."default",
                                                  "created_user" uuid,
                                                  CONSTRAINT "hs_customer_extension_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_customer_extension"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."hs_customer_extension"."id" IS '客户标识（工厂标识）';



CREATE TABLE "public"."hs_device_electric" (
                                               "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                               "updated_time" int8,
                                               "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                               "tenant_id" uuid,
                                               "factory_id" uuid,
                                               "peak" varchar(255) COLLATE "pg_catalog"."default",
                                               "device_id" uuid,
                                               "valley" varchar(255) COLLATE "pg_catalog"."default",
                                               "day_used" varchar(255) COLLATE "pg_catalog"."default",
                                               "time" int8,
                                               "id" uuid NOT NULL,
                                               "created_time" int8,
                                               "group_id" uuid,
                                               "workshop_id" uuid,
                                               "gateway_id" uuid,
                                               CONSTRAINT "hs_device_electric_pkey" PRIMARY KEY ("id"),
                                               CONSTRAINT "uk_device_electric" UNIQUE ("device_id", "time")
)
;

ALTER TABLE "public"."hs_device_electric"
    OWNER TO "postgres";

CREATE INDEX "idx_device_electric_device" ON "public"."hs_device_electric" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_electric_factory" ON "public"."hs_device_electric" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_electric"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_electric"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_electric"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_electric"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_electric"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_electric"."peak" IS '峰用电';

COMMENT ON COLUMN "public"."hs_device_electric"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_electric"."valley" IS '谷用电';

COMMENT ON COLUMN "public"."hs_device_electric"."day_used" IS '总日用电';

COMMENT ON COLUMN "public"."hs_device_electric"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_electric"."id" IS 'Id';

COMMENT ON COLUMN "public"."hs_device_electric"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_electric"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_electric"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_electric"."gateway_id" IS '网关id';



CREATE TABLE "public"."hs_device_electric_hour" (
                                                    "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                                    "updated_time" int8,
                                                    "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                                    "tenant_id" uuid,
                                                    "factory_id" uuid,
                                                    "peak" varchar(255) COLLATE "pg_catalog"."default",
                                                    "device_id" uuid,
                                                    "valley" varchar(255) COLLATE "pg_catalog"."default",
                                                    "hour_used" varchar(255) COLLATE "pg_catalog"."default",
                                                    "time" int8,
                                                    "id" uuid NOT NULL,
                                                    "created_time" int8,
                                                    "hour_time" int8,
                                                    "value" varchar(255) COLLATE "pg_catalog"."default",
                                                    "group_id" uuid,
                                                    "workshop_id" uuid,
                                                    "gateway_id" uuid,
                                                    CONSTRAINT "hs_device_electric_hour_pkey" PRIMARY KEY ("id"),
                                                    CONSTRAINT "uk_device_electric_hour" UNIQUE ("device_id", "hour_time")
)
;

ALTER TABLE "public"."hs_device_electric_hour"
    OWNER TO "postgres";

CREATE INDEX "idx_device_electric_hour_device" ON "public"."hs_device_electric_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_electric_hour_factory" ON "public"."hs_device_electric_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_electric_hour"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."peak" IS '峰用电';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."valley" IS '谷用电';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."hour_used" IS '小时用电';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."hour_time" IS '小时';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."value" IS '值';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_electric_hour"."gateway_id" IS '网关id';





CREATE TABLE "public"."hs_device_extension" (
                                                "id" uuid NOT NULL,
                                                "workshop_id" uuid,
                                                "group_id" uuid,
                                                "picture" varchar(10000000) COLLATE "pg_catalog"."default",
                                                "icon" varchar(255) COLLATE "pg_catalog"."default",
                                                "created_user" uuid,
                                                "updated_time" int8,
                                                "updated_user" uuid,
                                                "comment" varchar(255) COLLATE "pg_catalog"."default",
                                                "sn" varchar(255) COLLATE "pg_catalog"."default",
                                                "device_type" varchar(255) COLLATE "pg_catalog"."default",
                                                "created_time" int8,
                                                "factory_id" uuid,
                                                "tenant_id" uuid NOT NULL,
                                                CONSTRAINT "hs_device_ extension_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_device_extension"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."hs_device_extension"."id" IS '设备标识';

COMMENT ON COLUMN "public"."hs_device_extension"."workshop_id" IS '车间标识';

COMMENT ON COLUMN "public"."hs_device_extension"."group_id" IS '分组标识';

COMMENT ON COLUMN "public"."hs_device_extension"."picture" IS '图片';

COMMENT ON COLUMN "public"."hs_device_extension"."icon" IS '图标';

COMMENT ON COLUMN "public"."hs_device_extension"."comment" IS '备注';

COMMENT ON COLUMN "public"."hs_device_extension"."device_type" IS '设备类型';

COMMENT ON COLUMN "public"."hs_device_extension"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_extension"."factory_id" IS '工厂标识(客户标识)';

COMMENT ON TABLE "public"."hs_device_extension" IS '设备信息扩展表';




CREATE TABLE "public"."hs_device_gas" (
                                          "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                          "updated_time" int8,
                                          "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                          "tenant_id" uuid,
                                          "factory_id" uuid,
                                          "device_id" uuid,
                                          "day_used" varchar(255) COLLATE "pg_catalog"."default",
                                          "time" int8,
                                          "id" uuid NOT NULL,
                                          "created_time" int8,
                                          "group_id" uuid,
                                          "workshop_id" uuid,
                                          "gateway_id" uuid,
                                          CONSTRAINT "hs_device_gas_pkey" PRIMARY KEY ("id"),
                                          CONSTRAINT "uk_device_gas" UNIQUE ("device_id", "time")
)
;

ALTER TABLE "public"."hs_device_gas"
    OWNER TO "postgres";

CREATE INDEX "idx_device_gas_device" ON "public"."hs_device_gas" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_gas_factory" ON "public"."hs_device_gas" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_gas"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_gas"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_gas"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_gas"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_gas"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_gas"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_gas"."day_used" IS '总日用水';

COMMENT ON COLUMN "public"."hs_device_gas"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_gas"."id" IS 'Id';

COMMENT ON COLUMN "public"."hs_device_gas"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_gas"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_gas"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_gas"."gateway_id" IS '网关id';




CREATE TABLE "public"."hs_device_gas_hour" (
                                               "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                               "updated_time" int8,
                                               "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                               "tenant_id" uuid,
                                               "factory_id" uuid,
                                               "device_id" uuid,
                                               "hour_used" varchar(255) COLLATE "pg_catalog"."default",
                                               "time" int8,
                                               "id" uuid NOT NULL,
                                               "created_time" int8,
                                               "hour_time" int8,
                                               "value" varchar(255) COLLATE "pg_catalog"."default",
                                               "group_id" uuid,
                                               "workshop_id" uuid,
                                               "gateway_id" uuid,
                                               CONSTRAINT "hs_device_gas_hour_pkey" PRIMARY KEY ("id"),
                                               CONSTRAINT "uk_device_gas_hour" UNIQUE ("device_id", "hour_time")
)
;

ALTER TABLE "public"."hs_device_gas_hour"
    OWNER TO "postgres";

CREATE INDEX "idx_device_gas_hour_device" ON "public"."hs_device_gas_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_gas_hour_factory" ON "public"."hs_device_gas_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_gas_hour"."value" IS '值';

COMMENT ON COLUMN "public"."hs_device_gas_hour"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_gas_hour"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_gas_hour"."gateway_id" IS '网关id';





CREATE TABLE "public"."hs_device_switch" (
                                             "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                             "updated_time" int8,
                                             "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                             "tenant_id" uuid,
                                             "factory_id" uuid,
                                             "device_id" uuid,
                                             "time" int8,
                                             "id" uuid NOT NULL,
                                             "created_time" int8,
                                             "off_line_time" int8,
                                             "group_id" uuid,
                                             "workshop_id" uuid,
                                             "gateway_id" uuid,
                                             "off_switch_time" int8,
                                             "on_switch_time" int8,
                                             CONSTRAINT "hs_device_switch_pkey" PRIMARY KEY ("id"),
                                             CONSTRAINT "uk_device_switch" UNIQUE ("device_id", "time")
)
;

ALTER TABLE "public"."hs_device_switch"
    OWNER TO "postgres";

CREATE INDEX "idx_device_switch_device" ON "public"."hs_device_switch" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_switch_factory" ON "public"."hs_device_switch" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_switch"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_switch"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_switch"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_switch"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_switch"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_switch"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_switch"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_switch"."id" IS 'Id';

COMMENT ON COLUMN "public"."hs_device_switch"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_switch"."off_line_time" IS '离线时长';

COMMENT ON COLUMN "public"."hs_device_switch"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_switch"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_switch"."gateway_id" IS '网关id';

COMMENT ON COLUMN "public"."hs_device_switch"."off_switch_time" IS '停机时长';

COMMENT ON COLUMN "public"."hs_device_switch"."on_switch_time" IS '开机时长';





CREATE TABLE "public"."hs_device_switch_hour" (
                                                  "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                                  "updated_time" int8,
                                                  "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                                  "tenant_id" uuid,
                                                  "device_id" uuid,
                                                  "hour_time" int8,
                                                  "time" int8,
                                                  "id" uuid NOT NULL,
                                                  "created_time" int8,
                                                  "factory_id" uuid,
                                                  "group_id" uuid,
                                                  "workshop_id" uuid,
                                                  "gateway_id" uuid,
                                                  "off_line_time" int8,
                                                  "off_switch_time" int8,
                                                  "on_switch_time" int8,
                                                  CONSTRAINT "hs_device_switch_hour_pkey" PRIMARY KEY ("id"),
                                                  CONSTRAINT "uk_device_switch_hour" UNIQUE ("device_id", "hour_time")
)
;

ALTER TABLE "public"."hs_device_switch_hour"
    OWNER TO "postgres";

CREATE INDEX "idx_device_switch_hour_device" ON "public"."hs_device_switch_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_switch_hour_factory" ON "public"."hs_device_switch_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_switch_hour"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."hour_time" IS '小时';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."id" IS 'Id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."factory_id" IS '工厂Id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."gateway_id" IS '网关id';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."off_line_time" IS '离线时长';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."off_switch_time" IS '停机时长';

COMMENT ON COLUMN "public"."hs_device_switch_hour"."on_switch_time" IS '开机时长';





CREATE TABLE "public"."hs_device_switch_trend" (
                                                   "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                                   "updated_time" int8,
                                                   "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                                   "tenant_id" uuid,
                                                   "factory_id" uuid,
                                                   "device_id" uuid,
                                                   "id" uuid NOT NULL,
                                                   "created_time" int8,
                                                   "group_id" uuid,
                                                   "workshop_id" uuid,
                                                   "gateway_id" uuid,
                                                   "status" varchar(255) COLLATE "pg_catalog"."default",
                                                   "start_time" int8,
                                                   "end_time" int8,
                                                   CONSTRAINT "hs_device_switch_trend_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_device_switch_trend"
    OWNER TO "postgres";

CREATE INDEX "idx_device_switch_trend" ON "public"."hs_device_switch_trend" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "start_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_switch_trend"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."id" IS 'Id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."gateway_id" IS '网关id';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."status" IS '状态(OFF_LINE, OFF_SWITCH, ON_SWITCH)';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."start_time" IS '开始时间';

COMMENT ON COLUMN "public"."hs_device_switch_trend"."end_time" IS '结束时间';






CREATE TABLE "public"."hs_device_ts" (
                                         "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                         "updated_time" int8,
                                         "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                         "tenant_id" uuid,
                                         "factory_id" uuid,
                                         "device_id" uuid,
                                         "num" int8,
                                         "time" int8,
                                         "id" uuid NOT NULL,
                                         "created_time" int8,
                                         "group_id" uuid,
                                         "workshop_id" uuid,
                                         "gateway_id" uuid,
                                         CONSTRAINT "hs_device_ts_pkey" PRIMARY KEY ("id"),
                                         CONSTRAINT "uk_device_ts" UNIQUE ("device_id", "time")
)
;

ALTER TABLE "public"."hs_device_ts"
    OWNER TO "postgres";

CREATE INDEX "idx_device_ts_device" ON "public"."hs_device_ts" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_ts_factory" ON "public"."hs_device_ts" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_ts"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_ts"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_ts"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_ts"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_ts"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_ts"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_ts"."num" IS '数量';

COMMENT ON COLUMN "public"."hs_device_ts"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_ts"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_ts"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_ts"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_ts"."gateway_id" IS '网关id';





CREATE TABLE "public"."hs_device_ts_hour" (
                                              "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                              "updated_time" int8,
                                              "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                              "tenant_id" uuid,
                                              "factory_id" uuid,
                                              "device_id" uuid,
                                              "num" int8,
                                              "time" int8,
                                              "hour_time" int8,
                                              "id" uuid NOT NULL,
                                              "created_time" int8,
                                              "group_id" uuid,
                                              "workshop_id" uuid,
                                              "gateway_id" uuid,
                                              "value" int8,
                                              CONSTRAINT "hs_device_ts_hour_pkey" PRIMARY KEY ("id"),
                                              CONSTRAINT "uk_device_ts_hour" UNIQUE ("device_id", "hour_time")
)
;

ALTER TABLE "public"."hs_device_ts_hour"
    OWNER TO "postgres";

CREATE INDEX "idx_device_ts_hour_device" ON "public"."hs_device_ts_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_ts_hour_factory" ON "public"."hs_device_ts_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_ts_hour"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_ts_hour"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_ts_hour"."gateway_id" IS '网关id';

COMMENT ON COLUMN "public"."hs_device_ts_hour"."value" IS '值';




CREATE TABLE "public"."hs_device_water" (
                                            "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                            "updated_time" int8,
                                            "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                            "tenant_id" uuid,
                                            "factory_id" uuid,
                                            "device_id" uuid,
                                            "day_used" varchar(255) COLLATE "pg_catalog"."default",
                                            "time" int8,
                                            "id" uuid NOT NULL,
                                            "created_time" int8,
                                            "group_id" uuid,
                                            "workshop_id" uuid,
                                            "gateway_id" uuid,
                                            CONSTRAINT "hs_device_water_pkey" PRIMARY KEY ("id"),
                                            CONSTRAINT "uk_device_water" UNIQUE ("device_id", "time")
)
;

ALTER TABLE "public"."hs_device_water"
    OWNER TO "postgres";

CREATE INDEX "idx_device_water_device" ON "public"."hs_device_water" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_water_factory" ON "public"."hs_device_water" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_water"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_device_water"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_device_water"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_device_water"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_device_water"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_device_water"."device_id" IS '设备Id';

COMMENT ON COLUMN "public"."hs_device_water"."day_used" IS '总日用水';

COMMENT ON COLUMN "public"."hs_device_water"."time" IS '时间';

COMMENT ON COLUMN "public"."hs_device_water"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_device_water"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_water"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_water"."gateway_id" IS '网关id';





CREATE TABLE "public"."hs_device_water_hour" (
                                                 "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                                 "updated_time" int8,
                                                 "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                                 "tenant_id" uuid,
                                                 "factory_id" uuid,
                                                 "device_id" uuid,
                                                 "hour_used" varchar(255) COLLATE "pg_catalog"."default",
                                                 "time" int8,
                                                 "id" uuid NOT NULL,
                                                 "created_time" int8,
                                                 "hour_time" int8,
                                                 "value" varchar(255) COLLATE "pg_catalog"."default",
                                                 "group_id" uuid,
                                                 "workshop_id" uuid,
                                                 "gateway_id" uuid,
                                                 CONSTRAINT "hs_device_water_hour_pkey" PRIMARY KEY ("id"),
                                                 CONSTRAINT "uk_device_water_hour" UNIQUE ("device_id", "hour_time")
)
;

ALTER TABLE "public"."hs_device_water_hour"
    OWNER TO "postgres";

CREATE INDEX "idx_device_water_hour_device" ON "public"."hs_device_water_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "device_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

CREATE INDEX "idx_device_water_hour_factory" ON "public"."hs_device_water_hour" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "hour_time" "pg_catalog"."int8_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_device_water_hour"."value" IS '值';

COMMENT ON COLUMN "public"."hs_device_water_hour"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_device_water_hour"."workshop_id" IS '车间id';

COMMENT ON COLUMN "public"."hs_device_water_hour"."gateway_id" IS '网关id';





CREATE TABLE "public"."hs_external_interface" (
                                                  "id" uuid NOT NULL,
                                                  "created_time" int8,
                                                  "created_user" uuid,
                                                  "tenant_id" uuid,
                                                  "updated_time" int8,
                                                  "updated_user" uuid,
                                                  "app_id" varchar(255) COLLATE "pg_catalog"."default",
                                                  "app_key" varchar(255) COLLATE "pg_catalog"."default",
                                                  "app_secret" varchar(255) COLLATE "pg_catalog"."default",
                                                  "apply_name" varchar(255) COLLATE "pg_catalog"."default",
                                                  "enable_status" bool,
                                                  "notes" varchar(255) COLLATE "pg_catalog"."default",
                                                  "project_describe" varchar(255) COLLATE "pg_catalog"."default",
                                                  "project_telephone" varchar(255) COLLATE "pg_catalog"."default",
                                                  "project_user" varchar(255) COLLATE "pg_catalog"."default",
                                                  "statistic_value" int8,
                                                  CONSTRAINT "hs_external_interface_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_external_interface"
    OWNER TO "postgres";




CREATE TABLE "public"."hs_last_expand_extension" (
                                                     "key_id" int4 NOT NULL,
                                                     "entity_id" uuid NOT NULL,
                                                     "created_time" int8,
                                                     "tenant_id" uuid,
                                                     "updated_time" int8,
                                                     "device_name" varchar(255) COLLATE "pg_catalog"."default",
                                                     "device_type" varchar(255) COLLATE "pg_catalog"."default",
                                                     "enable" bool,
                                                     "factory_id" uuid,
                                                     "factory_name" varchar(255) COLLATE "pg_catalog"."default",
                                                     "gateway_id" uuid,
                                                     "gateway_name" varchar(255) COLLATE "pg_catalog"."default",
                                                     "group_id" uuid,
                                                     "group_name" varchar(255) COLLATE "pg_catalog"."default",
                                                     "history_lower" varchar(255) COLLATE "pg_catalog"."default",
                                                     "history_upper" varchar(255) COLLATE "pg_catalog"."default",
                                                     "key" varchar(255) COLLATE "pg_catalog"."default",
                                                     "unit_name" varchar(255) COLLATE "pg_catalog"."default",
                                                     "volume_on_day" int8,
                                                     "workshop_id" uuid,
                                                     "workshop_name" varchar(255) COLLATE "pg_catalog"."default",
                                                     CONSTRAINT "hs_last_expand_extension_pkey" PRIMARY KEY ("key_id", "entity_id")
)
;

ALTER TABLE "public"."hs_last_expand_extension"
    OWNER TO "postgres";

COMMENT ON COLUMN "public"."hs_last_expand_extension"."key_id" IS 'keyId';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."entity_id" IS '设备id';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."created_time" IS '创建时间(表设计基础字段)';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."tenant_id" IS '租户id(表设计基础字段)';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."updated_time" IS '修改时间(表设计基础字段)';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."device_name" IS '设备名称';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."device_type" IS '0是设备，1是网关';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."enable" IS '是否启用（默认启用)';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."factory_name" IS '工厂名称';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."group_id" IS '分组id';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."group_name" IS '分组名称';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."history_lower" IS '历史最小值';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."history_upper" IS '历史最大值';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."key" IS '遥测的名称';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."unit_name" IS '单位名称';

COMMENT ON COLUMN "public"."hs_last_expand_extension"."volume_on_day" IS '当日遥测量（条数)';




CREATE TABLE "public"."hs_push_conf_table" (
                                               "id" uuid NOT NULL,
                                               "created_time" int8,
                                               "created_user" uuid,
                                               "tenant_id" uuid,
                                               "updated_time" int8,
                                               "updated_user" uuid,
                                               "kafka_ip" varchar(255) COLLATE "pg_catalog"."default",
                                               "kafka_names" varchar(255) COLLATE "pg_catalog"."default",
                                               "kafka_port" varchar(255) COLLATE "pg_catalog"."default",
                                               "kafka_status" bool,
                                               "kafka_topic_pre" varchar(255) COLLATE "pg_catalog"."default",
                                               "mqtt_ip" varchar(255) COLLATE "pg_catalog"."default",
                                               "mqtt_port" varchar(255) COLLATE "pg_catalog"."default",
                                               "mqtt_qos_type" varchar(255) COLLATE "pg_catalog"."default",
                                               "mqtt_status" bool,
                                               "mqtt_user_name" varchar(255) COLLATE "pg_catalog"."default",
                                               "mqtt_password" varchar(255) COLLATE "pg_catalog"."default",
                                               "notes" varchar(255) COLLATE "pg_catalog"."default",
                                               "statistic_value" int8,
                                               CONSTRAINT "hs_push_conf_table_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_push_conf_table"
    OWNER TO "postgres";





CREATE TABLE "public"."hs_role" (
                                    "id" uuid NOT NULL,
                                    "created_time" int8,
                                    "created_user" uuid,
                                    "tenant_id" uuid,
                                    "updated_time" int8,
                                    "updated_user" uuid,
                                    "role_code" varchar(255) COLLATE "pg_catalog"."default",
                                    "role_desc" varchar(255) COLLATE "pg_catalog"."default",
                                    "role_name" varchar(255) COLLATE "pg_catalog"."default",
                                    "factory_id" uuid,
                                    "system_tab" varchar(255) COLLATE "pg_catalog"."default",
                                    "type" varchar(255) COLLATE "pg_catalog"."default",
                                    "operation_type" int4 DEFAULT 0,
                                    "user_level" int4 DEFAULT 0,
                                    "virtual_code" int4,
                                    CONSTRAINT "hs_role_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_role"
    OWNER TO "postgres";





CREATE TABLE "public"."hs_weather" (
                                       "id" uuid NOT NULL,
                                       "created_time" int8,
                                       "created_user" varchar(255) COLLATE "pg_catalog"."default",
                                       "updated_time" int8,
                                       "updated_user" varchar(255) COLLATE "pg_catalog"."default",
                                       "tenant_id" uuid,
                                       "factory_id" uuid,
                                       "weather" varchar(255) COLLATE "pg_catalog"."default",
                                       "temperature" varchar(255) COLLATE "pg_catalog"."default",
                                       "wind_direction" varchar(255) COLLATE "pg_catalog"."default",
                                       "wind_power" varchar(255) COLLATE "pg_catalog"."default",
                                       "humidity" varchar(255) COLLATE "pg_catalog"."default",
                                       "report_time_str" varchar(255) COLLATE "pg_catalog"."default",
                                       "report_time" int8,
                                       CONSTRAINT "hs_weather_pkey" PRIMARY KEY ("id")
)
;

ALTER TABLE "public"."hs_weather"
    OWNER TO "postgres";

CREATE INDEX "idx_weather" ON "public"."hs_weather" USING btree (
    "tenant_id" "pg_catalog"."uuid_ops" ASC NULLS LAST,
    "factory_id" "pg_catalog"."uuid_ops" ASC NULLS LAST
    );

COMMENT ON COLUMN "public"."hs_weather"."id" IS 'Id';

COMMENT ON COLUMN "public"."hs_weather"."created_time" IS '创建时间';

COMMENT ON COLUMN "public"."hs_weather"."created_user" IS '创建人';

COMMENT ON COLUMN "public"."hs_weather"."updated_time" IS '更新时间';

COMMENT ON COLUMN "public"."hs_weather"."updated_user" IS '更新人';

COMMENT ON COLUMN "public"."hs_weather"."tenant_id" IS '租户Id';

COMMENT ON COLUMN "public"."hs_weather"."factory_id" IS '工厂id';

COMMENT ON COLUMN "public"."hs_weather"."weather" IS '天气';

COMMENT ON COLUMN "public"."hs_weather"."temperature" IS '温度';

COMMENT ON COLUMN "public"."hs_weather"."wind_direction" IS '风向';

COMMENT ON COLUMN "public"."hs_weather"."wind_power" IS '风力';

COMMENT ON COLUMN "public"."hs_weather"."humidity" IS '湿度';

COMMENT ON COLUMN "public"."hs_weather"."report_time_str" IS '报告时间';

COMMENT ON COLUMN "public"."hs_weather"."report_time" IS '报告时间';

COMMENT ON TABLE "public"."hs_weather" IS '天气';






CREATE TABLE IF NOT EXISTS public.tb_menu
(
    id uuid NOT NULL,
    code character varying(255) COLLATE pg_catalog."default" NOT NULL,
    name character varying(255) COLLATE pg_catalog."default",
    level bigint NOT NULL,
    sort bigint NOT NULL,
    url character varying(1000) COLLATE pg_catalog."default",
    parent_id uuid,
    menu_icon character varying(255) COLLATE pg_catalog."default",
    menu_images character varying(1000) COLLATE pg_catalog."default",
    region character varying(255) COLLATE pg_catalog."default",
    created_time bigint NOT NULL,
    created_user uuid,
    updated_time character varying(255) COLLATE pg_catalog."default",
    updated_user uuid,
    menu_type character varying(255) COLLATE pg_catalog."default",
    path character varying(255) COLLATE pg_catalog."default" DEFAULT NULL::character varying,
    is_button boolean DEFAULT false,
    lang_key character varying(255) COLLATE pg_catalog."default"
    )

    TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.tb_menu
    OWNER to postgres;





-- Table: public.tb_tenant_menu

-- DROP TABLE IF EXISTS public.tb_tenant_menu;

CREATE TABLE IF NOT EXISTS public.tb_tenant_menu
(
    id uuid NOT NULL,
    tenant_id uuid NOT NULL,
    sys_menu_id uuid,
    sys_menu_code character varying(255) COLLATE pg_catalog."default",
    sys_menu_name character varying(255) COLLATE pg_catalog."default",
    tenant_menu_name character varying(255) COLLATE pg_catalog."default",
    tenant_menu_code character varying(255) COLLATE pg_catalog."default" NOT NULL,
    level bigint NOT NULL,
    sort bigint NOT NULL,
    url character varying(1000) COLLATE pg_catalog."default",
    parent_id uuid,
    tenant_menu_icon character varying(255) COLLATE pg_catalog."default",
    tenant_menu_images character varying(1000) COLLATE pg_catalog."default",
    region character varying(255) COLLATE pg_catalog."default",
    created_time bigint NOT NULL,
    created_user uuid,
    updated_time character varying(255) COLLATE pg_catalog."default",
    updated_user uuid,
    menu_type character varying(255) COLLATE pg_catalog."default",
    path character varying(255) COLLATE pg_catalog."default" DEFAULT NULL::character varying,
    is_button boolean DEFAULT false,
    lang_key character varying(255) COLLATE pg_catalog."default",
    has_children boolean DEFAULT false,
    CONSTRAINT tb_tenant_menu_pkey PRIMARY KEY (id)
    )

    TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.tb_tenant_menu
    OWNER to postgres;




-- Table: public.tb_tenant_menu_role

-- DROP TABLE IF EXISTS public.tb_tenant_menu_role;

CREATE TABLE IF NOT EXISTS public.tb_tenant_menu_role
(
    id uuid NOT NULL,
    created_time bigint,
    created_user uuid,
    tenant_id uuid,
    updated_time bigint,
    updated_user uuid,
    remark character varying(255) COLLATE pg_catalog."default",
    tenant_menu_id uuid,
    tenant_sys_role_id uuid,
    flg character varying(255) COLLATE pg_catalog."default",
    CONSTRAINT tb_tenant_menu_role_pkey PRIMARY KEY (id)
    )

    TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.tb_tenant_menu_role
    OWNER to postgres;






