From 6249ef6adf616e11aa7a9b601635c9f0e6ac0ba0 Mon Sep 17 00:00:00 2001
From: whycxzp <glperry@163.com>
Date: 星期一, 31 三月 2025 11:19:23 +0800
Subject: [PATCH] 更新建表

---
 src/main/java/com/whyc/service/BattStationTempHisService.java |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/whyc/service/BattStationTempHisService.java b/src/main/java/com/whyc/service/BattStationTempHisService.java
index cfc2a20..ed88be7 100644
--- a/src/main/java/com/whyc/service/BattStationTempHisService.java
+++ b/src/main/java/com/whyc/service/BattStationTempHisService.java
@@ -30,7 +30,53 @@
     private SubTablePageInfoUtil pageInfoUtil;
 
     public void createTableByMonth(Integer battGroupId,String yearMonth) {
-        jdbcSqlExecuteService.execute("CREATE TABLE IF NOT EXISTS `db_power_history`.`db_batt_station_temp_history_"+yearMonth+"` LIKE `db_power_history`.`db_batt_station_temp_history`");
+        yearMonth = battGroupId+"_"+yearMonth;
+        //鍒涘缓鑷搴忓垪
+        String createSeq = "CREATE SEQUENCE db_power_history.\"tb_batt_station_temp_history_"+yearMonth+"_id_seq\"\n" +
+                "INCREMENT 1\n" +
+                "MINVALUE 1\n" +
+                "MAXVALUE 9223372036854775807\n" +
+                "START 1\n" +
+                "CACHE 1;\n" +
+                "\n" +
+                "ALTER SEQUENCE db_power_history.\"tb_batt_station_temp_history_"+yearMonth+"_id_seq\" OWNER TO sysdba;\n" +
+                "\n" +
+                "SELECT setval('db_power_history.\"tb_batt_station_temp_history_"+yearMonth+"_id_seq\"',1,false);";
+
+        String sqlTable = "CREATE TABLE db_power_history.tb_batt_station_temp_history_"+yearMonth+"(\n" +
+                "\tid bigint NOT NULL DEFAULT nextval('db_power_history.tb_batt_station_temp_history_"+yearMonth+"_id_seq'::regclass),\n" +
+                "\tpixel_x integer NOT NULL,\n" +
+                "\tpixel_y integer NOT NULL,\n" +
+                "\tmax_temp double precision NOT NULL,\n" +
+                "\tmin_temp double precision NOT NULL,\n" +
+                "\tmin_temp_point character varying NOT NULL COLLATE pg_catalog.\"default\",\n" +
+                "\tmax_temp_point character varying NOT NULL COLLATE pg_catalog.\"default\",\n" +
+                "\tcamera_id integer NOT NULL,\n" +
+                "\trecord_time timestamp without time zone NOT NULL,\n" +
+                "\tstation_id integer,\n" +
+                "\tbatt_group_id integer,\n" +
+                "\t PRIMARY KEY (id)\n" +
+                ")\n" +
+                "\n" +
+                ";\n" +
+                "\n" +
+                "ALTER    TABLE db_power_history.tb_batt_station_temp_history_"+yearMonth+"\n" +
+                "\tOWNER TO sysdba;\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".pixel_x IS '鍍忕礌x杞�';\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".pixel_y IS '鍍忕礌y杞�';\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".max_temp IS '鏈�澶ф俯搴�';\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".min_temp IS '鏈�灏忔俯搴�';\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".min_temp_point IS '鏈�灏忔俯搴﹀潗鏍�,鏍煎紡涓簒*y,鐢ㄩ�楀彿闅斿紑';\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".max_temp_point IS '鏈�澶ф俯搴﹀潗鏍�,鏍煎紡涓簒*y,鐢ㄩ�楀彿闅斿紑';\n" +
+                "\n" +
+                "COMMENT ON COLUMN db_power_history.tb_batt_station_temp_history_"+yearMonth+".camera_id IS '鎽勫儚澶磇d';";
+        jdbcSqlExecuteService.execute(createSeq+sqlTable);
     }
 
     public boolean existTempHisTableByMonth(Integer battGroupId, String yearMonth) {

--
Gitblit v1.9.1