-- ----------------------------
-- Table structure for sync_tables_info
-- ----------------------------
CREATE TABLE `sync_tables_info`  (
  `client_id` int UNSIGNED NOT NULL,
  `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `sql` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `devid_field_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `outer_devid_fname` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `field_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `field_type` tinyint NOT NULL DEFAULT 1 COMMENT '1: 整数 2: 字符串 3: 日期 4: 浮点数',
  `update_time` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0),
  PRIMARY KEY (`client_id`, `table_name`) USING BTREE
);

-- ----------------------------
-- Records of sync_tables_info
-- ----------------------------

INSERT INTO `sync_tables_info` VALUES (10, 'data_eaif_h', 'SELECT t2.equipmentid , t2.sensorid, DATE_FORMAT(t1.capturetime, ''%Y-%m-%d %H:%i:%s'') as capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase` FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.capturetime>%%KEYVALUE%% ORDER BY t1.capturetime LIMIT 10000', 'eqmid', 'sensorid', 'd_time', 3, '2023-12-11 16:17:33');
INSERT INTO `sync_tables_info` VALUES (10, 'data_eia_h', 'SELECT t2.equipmentid, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.d_ct_1, t2.phase FROM `data_eia_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-11 16:17:38');
INSERT INTO `sync_tables_info` VALUES (10, 'data_epa_h', 'SELECT t2.equipmentid, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time,t1.h2ppm,t1.ch4ppm,t1.c2h6ppm,t1.c2h4ppm,t1.c2h2ppm,t1.coppm,t1.co2ppm,t1.o2ppm,t1.n2ppm,t1.totalhydrocarbon,t1.gaspress,t1.h2oppm,t2.`Phase` FROM `data_epa_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time  LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:19:56');
INSERT INTO `sync_tables_info` VALUES (10, 'data_etp_h', 'SELECT t2.equipmentid, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time,t1.t1 FROM `data_etp_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:19:33');
INSERT INTO `sync_tables_info` VALUES (10, 'data_microclimate_h', 'SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.envtmp, t1.envpres, t1.envhum, t1.rnfll, t2.phase FROM `data_microclimate_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:40:54');
INSERT INTO `sync_tables_info` VALUES (10, 'data_moa_h', 'SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.pt1, t1.lc1, t1.rc1, t1.ligcnt1, t1.lastligtm1, t2.phase FROM `data_moa_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:43:47');
INSERT INTO `sync_tables_info` VALUES (10, 'data_pd_h', 'SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.waveform, t1.plsnum, t1.apppadsch, t2.phase FROM `data_pd_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:40:29');
INSERT INTO `sync_tables_info` VALUES (10, 'data_scur_h', 'SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.current_val, t2.phase FROM `data_scur_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:44:23');
INSERT INTO `sync_tables_info` VALUES (10, 'data_sf6env_h', 'SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.gas1, t1.yq1, t1.md1, t1.pm1, t1.gascnt1, t1.hmcnt1,t1.sf6warn1, t1.o2warn1,t2.phase FROM `data_sf6env_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:42:33');
INSERT INTO `sync_tables_info` VALUES (10, 'data_sf6_h', 'SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, DATE_FORMAT(t1.d_time, ''%Y-%m-%d %H:%i:%s'') as d_time, t1.temp1, t1.md1, t1.pressure1+900, t1.pressure1, t1.pm1, t2.phase FROM `data_sf6_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid WHERE t1.eqmid=%%DEVID%% AND t1.d_time>%%KEYVALUE%% ORDER BY t1.d_time LIMIT 10000', 'eqmid', 'sensorid', 'capturetime', 3, '2023-12-13 09:42:12');


CREATE TABLE `sync_fields_info`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `client_id` int UNSIGNED NOT NULL,
  `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `field_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `field_type` tinyint UNSIGNED NOT NULL DEFAULT 0,
  `dest_field_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `fields`(`client_id`, `table_name`, `field_name`) USING BTREE
);

-- ----------------------------
-- Records of sync_fields_info
-- ----------------------------
INSERT INTO `sync_fields_info` VALUES (10, 10, 'data_eaif_h', 'maxtemp', 4, 'MaxTemp');
INSERT INTO `sync_fields_info` VALUES (11, 10, 'data_eaif_h', 'mintemp', 4, 'MinTemp');
INSERT INTO `sync_fields_info` VALUES (12, 10, 'data_eaif_h', 'avgtemp', 4, 'avgtemp');
INSERT INTO `sync_fields_info` VALUES (13, 10, 'data_eaif_h', 'phase', 2, 'Phase');
INSERT INTO `sync_fields_info` VALUES (15, 10, 'data_eia_h', 'phase', 2, 'Phase');
INSERT INTO `sync_fields_info` VALUES (19, 10, 'data_eia_h', 'd_ct_1', 4, 'TotalCoreCurrent');
INSERT INTO `sync_fields_info` VALUES (20, 10, 'data_epa_h', 'h2ppm', 0, 'H2');
INSERT INTO `sync_fields_info` VALUES (21, 10, 'data_epa_h', 'ch4ppm', 0, 'CH4');
INSERT INTO `sync_fields_info` VALUES (22, 10, 'data_epa_h', 'c2h6ppm', 0, 'C2H6');
INSERT INTO `sync_fields_info` VALUES (23, 10, 'data_epa_h', 'c2h4ppm', 0, 'C2H4');
INSERT INTO `sync_fields_info` VALUES (24, 10, 'data_epa_h', 'c2h2ppm', 0, 'C2H2');
INSERT INTO `sync_fields_info` VALUES (25, 10, 'data_epa_h', 'coppm', 0, 'CO');
INSERT INTO `sync_fields_info` VALUES (26, 10, 'data_epa_h', 'co2ppm', 0, 'CO2');
INSERT INTO `sync_fields_info` VALUES (27, 10, 'data_epa_h', 'o2ppm', 0, 'O2');
INSERT INTO `sync_fields_info` VALUES (28, 10, 'data_epa_h', 'n2ppm', 0, 'N2');
INSERT INTO `sync_fields_info` VALUES (29, 10, 'data_epa_h', 'totalhydrocarbon', 0, 'TotalHydrocarbon');
INSERT INTO `sync_fields_info` VALUES (30, 10, 'data_epa_h', 'gaspress', 0, 'GasPress');
INSERT INTO `sync_fields_info` VALUES (31, 10, 'data_epa_h', 'h2oppm', 0, 'H2O');
INSERT INTO `sync_fields_info` VALUES (32, 10, 'data_etp_h', 'MaxTmp', 0, 't1');
INSERT INTO `sync_fields_info` VALUES (33, 10, 'data_pd_h', 'waveform', 0, 'DischargeCapacity');
INSERT INTO `sync_fields_info` VALUES (34, 10, 'data_pd_h', 'apppadsch', 0, 'DischargePosition');
INSERT INTO `sync_fields_info` VALUES (35, 10, 'data_pd_h', 'plsnum', 0, 'PulseCount');
INSERT INTO `sync_fields_info` VALUES (36, 10, 'data_microclimate_h', 'envtmp', 0, 'AirTemperature');
INSERT INTO `sync_fields_info` VALUES (37, 10, 'data_microclimate_h', 'envpres', 0, 'AirPressure');
INSERT INTO `sync_fields_info` VALUES (38, 10, 'data_microclimate_h', 'envhum', 0, 'Humidity');
INSERT INTO `sync_fields_info` VALUES (39, 10, 'data_microclimate_h', 'rnfll', 0, 'Precipitation');
INSERT INTO `sync_fields_info` VALUES (40, 10, 'data_sf6_h', 'temp1', 0, 'Temperature');
INSERT INTO `sync_fields_info` VALUES (41, 10, 'data_sf6_h', 'md1', 0, 'Density');
INSERT INTO `sync_fields_info` VALUES (42, 10, 'data_sf6_h', 'pressure1', 0, 'Pressure20C');
INSERT INTO `sync_fields_info` VALUES (43, 10, 'data_sf6_h', 'pm1', 0, 'Moisture');
INSERT INTO `sync_fields_info` VALUES (44, 10, 'data_sf6env_h', 'gas1', 0, 'Gas1');
INSERT INTO `sync_fields_info` VALUES (45, 10, 'data_sf6env_h', 'yq1', 0, 'Gas1');
INSERT INTO `sync_fields_info` VALUES (46, 10, 'data_pd_h', 'waveform', 0, 'DischargeCapacity');
INSERT INTO `sync_fields_info` VALUES (47, 10, 'data_pd_h', 'apppadsch', 0, 'DischargePosition');
INSERT INTO `sync_fields_info` VALUES (48, 10, 'data_pd_h', 'plsnum', 0, 'PulseCount');
INSERT INTO `sync_fields_info` VALUES (49, 10, 'data_scur_h', 'current_val', 0, 'CoreCurrent');
INSERT INTO `sync_fields_info` VALUES (50, 10, 'rpt_temper', 'a_o_temper', 0, 'OlTmpA');
INSERT INTO `sync_fields_info` VALUES (51, 10, 'rpt_temper', 'b_o_temper', 0, 'OlTmpB');
INSERT INTO `sync_fields_info` VALUES (52, 10, 'rpt_temper', 'c_o_temper', 0, 'OlTmpC');
INSERT INTO `sync_fields_info` VALUES (53, 10, 'rpt_temper', 'a_i_temper', 0, 'IlTmpA');
INSERT INTO `sync_fields_info` VALUES (54, 10, 'rpt_temper', 'b_i_temper', 0, 'IlTmpB');
INSERT INTO `sync_fields_info` VALUES (55, 10, 'rpt_temper', 'c_i_temper', 0, 'IlTmpC');
INSERT INTO `sync_fields_info` VALUES (56, 10, 'rpt_temper', 'box_temper', 0, 'OntologyTmp');
INSERT INTO `sync_fields_info` VALUES (57, 10, 'transformer_evaluation_results', 'evaluate_date', 0, 'AcquisitionTime');
INSERT INTO `sync_fields_info` VALUES (58, 10, 'transformer_evaluation_results', 'health_index', 0, 'HealthLevel');
INSERT INTO `sync_fields_info` VALUES (59, 10, 'transformer_evaluation_results', 'aging_rate', 0, 'NaturalAgingRate');
INSERT INTO `sync_fields_info` VALUES (60, 10, 'transformer_evaluation_results', 'expect_life', 0, 'lifeExpectancy');
INSERT INTO `sync_fields_info` VALUES (61, 10, 'transformer_evaluation_results', 'future_failure_rate', 0, 'FutureFailureRate');
INSERT INTO `sync_fields_info` VALUES (62, 10, 'gis_assessment_result', 'evaluate_date', 0, 'AcquisitionTime');
INSERT INTO `sync_fields_info` VALUES (63, 10, 'gis_assessment_result', 'health_index', 0, 'HealthLevel');
INSERT INTO `sync_fields_info` VALUES (64, 10, 'gis_assessment_result', 'aging_rate', 0, 'NaturalAgingRate');
INSERT INTO `sync_fields_info` VALUES (65, 10, 'gis_assessment_result', 'expect_life', 0, 'lifeExpectancy');
INSERT INTO `sync_fields_info` VALUES (66, 10, 'gis_assessment_result', 'future_failure_rate', 0, 'FutureFailureRate');
INSERT INTO `sync_fields_info` VALUES (67, 10, 'arrester_assessment_result', 'assess_time', 0, 'AcquisitionTime');
INSERT INTO `sync_fields_info` VALUES (68, 10, 'arrester_assessment_result', 'health_level', 0, 'HealthLevel');
INSERT INTO `sync_fields_info` VALUES (69, 10, 'arrester_assessment_result', 'future_failure_rate', 0, 'FutureFailureRate');

-- ----------------------------
-- Table structure for sync_records
-- ----------------------------
CREATE TABLE `sync_records`  (
  `client_id` int UNSIGNED NOT NULL,
  `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `devid_val` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `field_val1` bigint UNSIGNED NULL DEFAULT 0,
  `field_val2` datetime(0) NULL DEFAULT '2000-01-01 01:00:00',
  `update_time` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0),
  PRIMARY KEY (`client_id`, `table_name`, `devid_val`) USING BTREE
);

