CREATE TABLE "public"."hs_device_order_statistical" (
                                                        "id" uuid NOT NULL,
                                                        "device_id" uuid NOT NULL,
                                                        "order_no" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
                                                        "code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
                                                        "statistic_val" numeric(10,4),
                                                        "current_val" varchar(255) COLLATE "pg_catalog"."default",
                                                        "first_val" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
                                                        "order_status" varchar(255) COLLATE "pg_catalog"."default" DEFAULT 'underway'::character varying,
                                                        "device_name" varchar(255) COLLATE "pg_catalog"."default",
                                                        "order_array" varchar(1000) COLLATE "pg_catalog"."default",
                                                        "tenant_id" uuid,
                                                        "start_time" timestamp(6),
                                                        "end_time" timestamp(6),
                                                        "created_time" int8,
                                                        "updated_time" int8 NOT NULL,
                                                        CONSTRAINT "hs_device_order_statistical_pkey" PRIMARY KEY ("id"),
                                                        CONSTRAINT "hs_device_order_statistical_device_id_order_no_code_key" UNIQUE ("device_id", "order_no", "code")
)
;

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

COMMENT ON COLUMN "public"."hs_device_order_statistical"."device_id" IS '设备标识';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."order_no" IS '订单号';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."code" IS 'water-水;electric-电;vapor-蒸汽;output-产量';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."statistic_val" IS '统计值';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."current_val" IS '采集值';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."first_val" IS '订单开始时首次采集值';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."order_status" IS '订单状态（underway-进行中；close-结束）';

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

COMMENT ON COLUMN "public"."hs_device_order_statistical"."order_array" IS '订单明细';

COMMENT ON COLUMN "public"."hs_device_order_statistical"."tenant_id" IS '租户标识';

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

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

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

COMMENT ON COLUMN "public"."hs_device_order_statistical"."updated_time" IS '修改时间戳';

COMMENT ON TABLE "public"."hs_device_order_statistical" IS '统计设备订单的能耗产量(kafka)';



CREATE TABLE "public"."hs_order_statistical" (
                                                 "id" uuid NOT NULL,
                                                 "order_no" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
                                                 "order_status" varchar(255) COLLATE "pg_catalog"."default" DEFAULT 'underway'::character varying,
                                                 "code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
                                                 "statistic_val" numeric(10,4) NOT NULL DEFAULT 0,
                                                 "start_time" timestamp(6),
                                                 "end_time" timestamp(6),
                                                 "created_time" int8,
                                                 "updated_time" int8 NOT NULL,
                                                 "tenant_id" uuid NOT NULL,
                                                 "order_array" varchar(1000) COLLATE "pg_catalog"."default",
                                                 CONSTRAINT "hs_order_statistical_pkey" PRIMARY KEY ("id"),
                                                 CONSTRAINT "hs_order_statistical_order_no_code_key" UNIQUE ("order_no", "code")
)
;

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

COMMENT ON COLUMN "public"."hs_order_statistical"."order_status" IS '订单状态（underway-进行中；close-结束）';

COMMENT ON COLUMN "public"."hs_order_statistical"."code" IS 'water-水;electric-电;vapor-蒸汽;output-产量';

COMMENT ON COLUMN "public"."hs_order_statistical"."statistic_val" IS '统计值';

COMMENT ON COLUMN "public"."hs_order_statistical"."tenant_id" IS '租户标识';

COMMENT ON COLUMN "public"."hs_order_statistical"."order_array" IS '订单明细';

COMMENT ON TABLE "public"."hs_order_statistical" IS '统计订单的能耗产量(kafka)';


ALTER TABLE hs_customer_extension ADD COLUMN "sort" int4 DEFAULT 1000;
ALTER TABLE tcode_group ADD COLUMN "id" uuid NOT NULL;
ALTER TABLE tcode_group ADD CONSTRAINT "tcode_group_pkey" PRIMARY KEY ("id");
