需求:将excel中的所有数据导入到PG数据库的对应数据表中,需要对数据进行校验等操作
maven依赖:
<properties>
<hutool.version>5.5.1</hutool.version>
<poi.version>3.17</poi.version>
</properties>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!-- hutool相关依赖 -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
PG数据表的设计:
CREATE TABLE "public"."shopping_detail" (
"id" int8 NOT NULL,
"order_id" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
"good_name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
"address" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"receiver" varchar(50) COLLATE "pg_catalog"."default",
"phone" varchar(30) COLLATE "pg_catalog"."default",
"num" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
"create_by" varchar(30) COLLATE "pg_catalog"."default",
"create_time" timestamptz(6),
"update_by" varchar(30) COLLATE "pg_catalog"."default",
"update_time" timestamptz(6),
"remark" varchar(500) COLLATE "pg_catalog"."default",
CONSTRAINT "cgm_drug_info_pkey" PRIMARY KEY ("id")
)
;
ALTER TABLE "public"."shopping_detail"
OWNER TO "postgres";
COMMENT ON COLUMN "public"."shopping_detail"."id" IS '主键ID';
COMMENT ON COLUMN "public"."shopping_detail"."order_id" IS '订单号';
COMMENT ON COLUMN "public"."shopping_detail"."good_name" IS '商品名称';
COMMENT ON COLUMN "public"."shopping_detail"."address" IS '收货地址';
COMMENT ON COLUMN "public"."shopping_detail"."receiver" IS '收件人';
COMMENT ON COLUMN "public"."shopping_detail"."phone" IS '手机号';
COMMENT ON COLUMN "public"."shopping_detail"."num" IS '数量';
COMMENT ON COLUMN "public"."shopping_detail"."create_by" IS '创建人(账号name)';
COMMENT ON COLUMN "public".