Commit 221f09ce authored by 吴文龙's avatar 吴文龙

脚本数据

parent a62f3aa8
/*
Navicat Premium Data Transfer
Source Server : 47.96.236.169
Source Server Type : MySQL
Source Server Version : 80028
Source Host : 47.96.236.169:33306
Source Schema : iot_dbapi
Target Server Type : MySQL
Target Server Version : 80028
File Encoding : 65001
Date: 28/11/2022 19:47:18
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for api_auth
-- ----------------------------
DROP TABLE IF EXISTS `api_auth`;
CREATE TABLE `api_auth` (
`id` int NOT NULL AUTO_INCREMENT,
`token_id` int DEFAULT NULL,
`group_id` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of api_auth
-- ----------------------------
BEGIN;
INSERT INTO `api_auth` (`id`, `token_id`, `group_id`) VALUES (7, 1, 'XlscLq30');
INSERT INTO `api_auth` (`id`, `token_id`, `group_id`) VALUES (8, 2, 'XlscLq30');
COMMIT;
-- ----------------------------
-- Table structure for api_config
-- ----------------------------
DROP TABLE IF EXISTS `api_config`;
CREATE TABLE `api_config` (
`id` varchar(255) NOT NULL,
`path` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
`params` text,
`status` int DEFAULT NULL,
`datasource_id` varchar(255) DEFAULT NULL,
`previlege` int DEFAULT NULL,
`group_id` varchar(255) DEFAULT NULL,
`cache_plugin` varchar(255) DEFAULT NULL,
`cache_plugin_params` varchar(255) DEFAULT NULL,
`create_time` varchar(20) DEFAULT NULL,
`update_time` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `path` (`path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of api_config
-- ----------------------------
BEGIN;
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('0qLjHowN', 'v1_switch_detail', '南泰君霖对外接口-班组开停机状态查询', NULL, '[{\"name\":\"date\",\"type\":\"string\",\"note\":\"营业日期\"},{\"name\":\"deviceName\",\"type\":\"string\",\"note\":\"设备名称\"},{\"name\":\"grpcode\",\"type\":\"string\",\"note\":\"班组am或pm\"},{\"name\":\"grptype\",\"type\":\"string\",\"note\":\"分区\"}]', 1, 'kSC2Qziy', 0, 'XlscLq30', NULL, NULL, '2022-11-15 13:55:43', '2022-11-15 14:05:44');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('3qxDmpBG', 'dbapi/f_set_trep_group_detail', '生产-保存班组能耗数据', NULL, '[]', 1, 'kSC2Qziy', 1, 'OPKu3Okm', NULL, NULL, '2022-09-29 14:32:10', '2022-11-15 21:31:37');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('5SeUCRJy', 'dbapi/f_rep_device_groups_detail', 'f_rep_device_groups_detail', NULL, '[{\"name\":\"did\",\"type\":\"string\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-10-10 12:27:08', '2022-11-04 00:33:28');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('7TVjkWPy', 'f_set_days_key_detail', '生产-保存每日能耗数据-停用', NULL, '[]', 0, 'kSC2Qziy', 1, 'OGvyLgXx', NULL, NULL, '2022-11-02 16:48:26', '2022-11-16 01:45:39');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('9xFhax2y', 'junlin_hous_key', 'junlin_hous_key', NULL, '[]', 1, 'kSC2Qziy', 1, 'OPKu3Okm', NULL, NULL, '2022-09-24 08:05:07', '2022-09-24 19:00:16');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('B1ANmtET', 'f_set_sta_detail', '生产-当前状态持续时长统计', NULL, '[]', 1, 'kSC2Qziy', 1, 'OGvyLgXx', NULL, NULL, '2022-10-16 00:45:27', '2022-11-16 16:19:48');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('bw6ULlLe', 'f_func_rep_test', 'f_func_rep_test', NULL, '[]', 1, 'EhgozRdv', 1, 'OGvyLgXx', NULL, NULL, '2022-09-24 23:20:40', '2022-09-24 23:47:39');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('cD4sCi7I', 'v1_group_detail', '南泰君霖对外接口-班组能耗查询', NULL, '[{\"name\":\"deviceName\",\"type\":\"string\",\"note\":\"设备名称\"},{\"name\":\"propName\",\"type\":\"string\",\"note\":\"属性名称\"},{\"name\":\"grpcode\",\"type\":\"string\",\"note\":\"班组am或pm\"},{\"name\":\"grptype\",\"type\":\"string\",\"note\":\"分组A区或B区等\"},{\"name\":\"arr\",\"type\":\"string\",\"note\":\"开始日期\"},{\"name\":\"dep\",\"type\":\"string\",\"note\":\"结束日期\"}]', 1, 'kSC2Qziy', 0, 'XlscLq30', NULL, NULL, '2022-11-15 13:25:47', '2022-11-17 10:26:06');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('CQ9VkAr9', 'dbapi/f_rep_hour_key_detail', 'f_rep_hour_key_detail', NULL, '[{\"name\":\"tid\",\"type\":\"string\",\"note\":\"租户ID\"},{\"name\":\"grpid\",\"type\":\"string\",\"note\":\"分组ID\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-09-24 09:49:48', '2022-11-04 00:37:17');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('EeBkndxU', 'f_set_hours_switch_detail', '生产-每小时保存开停机变化数据', NULL, '[]', 1, 'kSC2Qziy', 1, 'OGvyLgXx', NULL, NULL, '2022-11-12 13:35:21', '2022-11-14 13:52:41');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('EnFpExkx', 'dbapi/f_rep_days_hours_device', 'f_rep_days_hours_device', NULL, '[{\"name\":\"did\",\"type\":\"string\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-09-27 23:30:00', '2022-09-29 13:47:12');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('FNMVwfcu', 'f_set_group_switch_detail', '生产-班组保存开停机状态', NULL, '[]', 1, 'kSC2Qziy', 1, 'OGvyLgXx', NULL, NULL, '2022-11-12 13:36:00', '2022-11-14 13:52:57');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('hGLKRYiu', 'f_trep_day_detail', 'f_trep_day_detail', NULL, '[{\"name\":\"month\",\"type\":\"string\",\"note\":\"日期示例10代表10月\"},{\"name\":\"deviceName\",\"type\":\"string\",\"note\":\"设备名称\"},{\"name\":\"propName\",\"type\":\"string\",\"note\":\"属性名称\"},{\"name\":\"year\",\"type\":\"string\",\"note\":\"年份\"},{\"name\":\"grptype\",\"type\":\"string\",\"note\":\"分组A区或B区等\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-10-09 23:36:54', '2022-11-15 15:55:42');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('HYORZYyI', 'dbapi/f_rep_yesterday_key_sum', 'f_rep_yesterday_key_sum', NULL, '[{\"name\":\"tid\",\"type\":\"string\"},{\"name\":\"grpid\",\"type\":\"string\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-11-03 17:43:35', '2022-11-03 18:25:46');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('IHQJLVtr', 'dbapi/f_rep_group_key_sum', 'f_rep_group_key_sum', NULL, '[{\"name\":\"tid\",\"type\":\"string\"},{\"name\":\"grpid\",\"type\":\"string\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-11-03 17:42:58', '2022-11-04 00:12:09');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('K4QZT40A', 'f_junlin_rep_out_key', 'f_junlin_rep_out_key', NULL, '[{\"name\":\"bdate\",\"type\":\"string\",\"note\":\"日期\"}]', 1, 'kSC2Qziy', 0, 'XlscLq30', NULL, NULL, '2022-09-28 14:49:53', '2022-09-28 14:49:53');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('kU15HMrE', 'dbapi/f_rep_device_days_detail', 'f_rep_device_days_detail', NULL, '[{\"name\":\"did\",\"type\":\"string\",\"note\":\"设备ID\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-10-10 11:38:43', '2022-10-11 12:06:28');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('N8sgjOWD', 'dbapi/f_rep_hour_key_sum', 'f_rep_hour_key_sum', NULL, '[{\"name\":\"tid\",\"type\":\"string\"},{\"name\":\"grpid\",\"type\":\"string\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-09-25 22:26:44', '2022-11-03 15:23:25');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('pjYii91f', 'f_junlin_temp_cache', '生产-君霖定制处理缓存数据', NULL, '[]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-11-16 02:05:49', '2022-11-16 02:05:49');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('RSuNGzhs', 'f_set_day_switch_detail', '生产-每日保存开停机数据', NULL, '[]', 1, 'kSC2Qziy', 1, 'OGvyLgXx', NULL, NULL, '2022-11-12 13:36:36', '2022-11-14 13:53:12');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('tCoVivD8', 'dbapi/f_set_hour_key_detail', '生产-每小时保存能耗数据', NULL, '[]', 1, 'kSC2Qziy', 1, 'OGvyLgXx', NULL, NULL, '2022-09-26 13:38:15', '2022-11-15 22:41:30');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('UDzGSkeZ', 'set_tcode_base', 'set_tcode_base', NULL, '[]', 1, 'kSC2Qziy', 1, 'OPKu3Okm', NULL, NULL, '2022-09-24 09:24:20', '2022-09-24 09:24:20');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('v7p2AAqp', 'v1_device_detail', '南泰君霖对外接口-设备实时采集数据查询', NULL, '[{\"name\":\"deviceName\",\"type\":\"string\",\"note\":\"设备名称\"},{\"name\":\"key\",\"type\":\"string\",\"note\":\"属性名称\"},{\"name\":\"grptype\",\"type\":\"string\",\"note\":\"分区\"}]', 1, 'kSC2Qziy', 0, 'XlscLq30', NULL, NULL, '2022-11-15 14:25:59', '2022-11-15 14:27:35');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('VyCtYO0f', 'dbapi/f_rep_device_lastDays_detail', 'f_rep_device_lastDays_detail', NULL, '[{\"name\":\"did\",\"type\":\"string\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-11-03 18:39:46', '2022-11-03 18:44:56');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('wFz52Yb1', 'dbapi/f_rep_device_months_detail', 'f_rep_device_months_detail', NULL, '[{\"name\":\"did\",\"type\":\"string\",\"note\":\"设备ID\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-10-10 12:30:16', '2022-10-11 12:13:20');
INSERT INTO `api_config` (`id`, `path`, `name`, `note`, `params`, `status`, `datasource_id`, `previlege`, `group_id`, `cache_plugin`, `cache_plugin_params`, `create_time`, `update_time`) VALUES ('xfXpHIg0', 'f_trep_group_detail', 'f_trep_group_detail', NULL, '[{\"name\":\"date\",\"type\":\"string\",\"note\":\"日期\"},{\"name\":\"deviceName\",\"type\":\"string\",\"note\":\"设备名称\"},{\"name\":\"propName\",\"type\":\"string\",\"note\":\"属性名称\"},{\"name\":\"grpcode\",\"type\":\"string\",\"note\":\"班组am或pm\"},{\"name\":\"grptype\",\"type\":\"string\",\"note\":\"分组A区B区等\"}]', 1, 'kSC2Qziy', 1, 'XlscLq30', NULL, NULL, '2022-09-29 15:11:36', '2022-11-17 10:25:20');
COMMIT;
-- ----------------------------
-- Table structure for api_group
-- ----------------------------
DROP TABLE IF EXISTS `api_group`;
CREATE TABLE `api_group` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of api_group
-- ----------------------------
BEGIN;
INSERT INTO `api_group` (`id`, `name`) VALUES ('OGvyLgXx', '公共分组');
INSERT INTO `api_group` (`id`, `name`) VALUES ('OPKu3Okm', '南泰君霖');
INSERT INTO `api_group` (`id`, `name`) VALUES ('XlscLq30', '南泰君霖-输出');
COMMIT;
-- ----------------------------
-- Table structure for api_sql
-- ----------------------------
DROP TABLE IF EXISTS `api_sql`;
CREATE TABLE `api_sql` (
`id` int NOT NULL AUTO_INCREMENT,
`api_id` varchar(11) NOT NULL,
`sql_text` text NOT NULL,
`transform_plugin` varchar(255) DEFAULT NULL,
`transform_plugin_params` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=267 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of api_sql
-- ----------------------------
BEGIN;
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (4, 'UDzGSkeZ', 'insert into tcode_device(tid,fid,fname,wid,wname,grpid,grpname,gid,gname,did,dname,knumb,kcnt,sort,halt,htime,ctime,mtime)\nSELECT \nt.tid,t.fid,t.fname,t.wid,t.wname,t.grpid,t.grpname,t.gid,t.gname,\nt.did,t.dname,count(1) as key_cnt ,\nsum(t.volume_on_day) as keyval_cnt,\n\'1000\' as sort,\n\'F\' as halt,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP\nfrom vcode_key_detail t \nGROUP BY t.tid,t.fid,t.fname,t.wid,t.wname,t.grpid,t.grpname,t.gid,t.gname,t.did,t.dname\nORDER BY t.dname desc \nON conflict(tid,did)\ndo update set \nfid = EXCLUDED.fid,\nfname = EXCLUDED.fname,\nwid = EXCLUDED.wid,\nwname = EXCLUDED.wname,\ngrpid = EXCLUDED.grpid,\ngrpname = EXCLUDED.grpname,\ngid = EXCLUDED.gid,\ngname = EXCLUDED.gname,\ndname = EXCLUDED.dname,\nknumb = EXCLUDED.knumb,\nkcnt = EXCLUDED.kcnt,\nmtime = CURRENT_TIMESTAMP;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (48, '9xFhax2y', 'INSERT into trep_hkey_detail(tid,did,key,bdate,hours,val,ctime,mtime)\nSELECT t.tid,t.did, \n case when t.key = \'gas\' then \'蒸汽\' \n when t.key = \'正向累积数值整数部分\' then \'碱用量\'\n else t.key \n end as key ,\n current_date as bdate,\ndate_part(\'hour\', CURRENT_TIME) as hours,t.val_ex ,\nCURRENT_TIMESTAMP ,CURRENT_TIMESTAMP\nfrom \n(\n SELECT \n to_number(a.val,\'999999999.999999999\') + to_number(b.val,\'999999999.999999999\') as val_ex,\n a.* from \n (\n SELECT t.* from vcode_key_detail t \n where t.key = \'正向累积数值整数部分\'\n \n ) a,\n (\n SELECT t.* from vcode_key_detail t \n WHERE t.key = \'正向累积数值小数部分\'\n ) b\n where a.tid = b.tid and \n a.did = b.did and \n a.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\'\n union all \n SELECT to_number(t.val,\'999999999.999999999\') as val_ex,t.* from vcode_key_detail t \n where t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.key = \'gas\'\n) t\nON CONFLICT (tid,did,key,bdate,hours)\nDO UPDATE SET \nval = EXCLUDED.val,\nmtime = CURRENT_TIMESTAMP;\n \n\n\n ', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (50, 'bw6ULlLe', 'begin;\nSELECT func05(\'cur_open\');\nfetch all in cur_open;\nend; ', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (72, 'K4QZT40A', 'SELECT t.* from trep_dkey_detail t \nwhere t.bdate = #{bdate} and \n t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\'', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (77, 'EnFpExkx', 'SELECT t.key,\njsonb_agg(b) as arr\nfrom tcode_model_detail_ex t\n left JOIN \n (select concat(bdate,\' \',hours,\':00:00\')::TIMESTAMP::VARCHAR as time ,tid,key as nkey,val as value \n from trep_hkey_detail \n where ctime >= (CURRENT_TIMESTAMP - interval \'24 hour\')) b \non t.tid = b.tid and \n t.key = b.nkey \nwhere t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.code = \'all\' and \n substr(t.ex_s1,1,1) = \'1\'\nGROUP BY t.key;\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (151, 'kU15HMrE', 'SELECT case when t.key = \'蒸汽\' then \'vapor\'\n when t.key = \'碱用量\' then \'alkali\' \n else t.key end as key,t.sort,jsonb_agg(b ORDER BY b.bdate,to_number(b.hours, \'99\')) as arr\n from tcode_model_detail_ex t\n left JOIN \n (select concat(bdate,\' \',hours,\':00:00\')::TIMESTAMP::VARCHAR as time,tid,\n case when key = \'蒸汽\' then \'vapor\'\n when key = \'碱用量\' then \'alkali\' \n else key end as nkey,val as value ,bdate,hours\n from trep_hkey_detail \n where bdate = CURRENT_DATE and \n did::varchar = #{did}\n ) b \n on t.tid = b.tid and \n t.key = b.nkey \n where t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.code = \'all\' and \n t.key in (\'vapor\',\'alkali\',\'electric\',\'gas\',\'water\')\n GROUP BY t.key,t.sort\n ORDER BY t.sort', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (153, 'wFz52Yb1', 'SELECT case when t.key = \'蒸汽\' then \'vapor\'\n when t.key = \'碱用量\' then \'alkali\' \n else t.key end as key,t.sort,jsonb_agg(b ORDER BY b.bdate,to_number(b.hours, \'99\')) as arr\n from tcode_model_detail_ex t\n left JOIN \n (select concat(bdate,\' \',hours,\':00:00\')::TIMESTAMP::VARCHAR as time,tid,\n case when key = \'蒸汽\' then \'vapor\'\n when key = \'碱用量\' then \'alkali\' \n else key end as nkey,val as value ,bdate,hours\n from trep_hkey_detail \n where bdate = CURRENT_DATE and \n did::varchar = #{did}\n ) b \n on t.tid = b.tid and \n t.key = b.nkey \n where t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.code = \'all\' and \n t.key in (\'vapor\',\'alkali\',\'electric\',\'gas\',\'water\')\n GROUP BY t.key,t.sort\n ORDER BY t.sort', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (193, 'N8sgjOWD', 'SELECT b.* from (\n SELECT case when a.key = \'alkali\' then \'碱用量\'\n when a.key = \'vapor\' then \'蒸汽\'\n else a.key \n end as name ,\n a.val as value,\n case when a.key = \'alkali\' then \'1020\'\n when a.key = \'vapor\' then \'1010\'\n else a.key \n end as sort \n from (\n SELECT t.key,\n sum(to_number(val_dep, \'9999999999999999999.99\'))-sum(to_number(val_arr, \'9999999999999999999.99\')) as val\n from trep_hkey_detail t,vcode_key_detail b \n where t.tid = b.tid and \n t.did = b.did and \n t.key = b.key and \n (t.tid::VARCHAR = #{tid}) AND\n (\'\'=#{grpid} or b.grpid::VARCHAR= #{grpid}) and \n t.key in (\'vapor\',\'alkali\') and \n t.bdate = CURRENT_DATE \n group by t.key \n ) a \n) b \norder by b.sort\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (194, 'N8sgjOWD', 'SELECT \'蒸汽\' as name,sum(value) as value from (\n SELECT \n concat(a.bdate,\' \',a.hours,\':00:00\')::timestamp as time,\n (a.cval - b.cval) as value,\n a.key,a.hours,a.did\nfrom \n(SELECT to_number(t.val,\'999999999.99\') as cval,t.*,\n b.dname,b.id\n from trep_hkey_detail t,tcode_device b \n where t.tid = b.id and \n t.tid::character varying= #{tid} and \n (\'\' = \'\' or b.gid::character varying = \'\') and \n t.did = b.did and \n t.bdate = CURRENT_DATE - 1\n) a,\n(SELECT to_number(t.val,\'999999999.99\') as cval,t.*,\n b.dname,b.id\n from trep_hkey_detail t,tcode_device b \n where t.tid = b.id and \n t.tid::character varying= #{tid} and \n (\'\' = \'\' or b.gid::character varying = \'\') and \n t.did = b.did and \n t.bdate = CURRENT_DATE - 1\n) b \nwhere a.tid = b.id and \n a.did = b.did and \n a.key = b.key and \n a.key = \'蒸汽\' and \n a.bdate = b.bdate and \n to_number(a.hours,\'999999999\') - 1 = to_number(b.hours, \'999999999\')\n) t \nunion all \nSELECT \'碱用量\' as name,sum(value) as value from (\n SELECT \n concat(a.bdate,\' \',a.hours,\':00:00\')::timestamp as time,\n (a.cval - b.cval) as value,\n a.key,a.hours,a.did\nfrom \n(SELECT to_number(t.val,\'999999999.99\') as cval,t.*,\n b.dname,b.id\n from trep_hkey_detail t,tcode_device b \n where t.tid = b.id and \n t.tid::character varying= #{tid} and \n (\'\' = \'\' or b.gid::character varying = \'\') and \n t.did = b.did and \n t.bdate = CURRENT_DATE - 1\n) a,\n(SELECT to_number(t.val,\'999999999.99\') as cval,t.*,\n b.dname,b.id\n from trep_hkey_detail t,tcode_device b \n where t.tid = b.id and \n t.tid::character varying= #{tid} and \n (\'\' = \'\' or b.gid::character varying = \'\') and \n t.did = b.did and \n t.bdate = CURRENT_DATE -1 \n) b \nwhere a.tid = b.id and \n a.did = b.did and \n a.key = b.key and \n a.key = \'碱用量\' and \n a.bdate = b.bdate and \n to_number(a.hours,\'999999999\') - 1 = to_number(b.hours, \'999999999\')\n) t \n\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (202, 'HYORZYyI', 'SELECT name, sum(value) as value \nfrom \n( \n SELECT to_number(t.val_dep,\'9999999999999999999.99\') - to_number(t.val_arr, \'9999999999999999999.99\') as value,\n b.name,t.key,c.descript,d.dname,d.grpname,\n t.bdate,to_char(t.ctime,\'yyyy-mm-dd hh24:mi:ss\') as ctime,to_char(t.mtime,\'yyyy-mm-dd hh24:mi:ss\') as mtime \n from trep_group_detail t,tcode_model_detail_ex b,tcode_group c ,vcode_key_detail d \n where t.tid = b.tid and \n t.tid = c.tid and \n t.tid = d.tid and \n t.did = d.did and \n t.key = d.key and \n t.grpcode = c.code and \n t.bdate = CURRENT_DATE-1 and \n t.key in (\'vapor\',\'alkali\') and \n (t.tid::VARCHAR = #{tid}) AND\n (\'\'=#{grpid} or d.grpid::VARCHAR= #{grpid}) and \n b.code = \'all\' and \n d.grpname != \'\' and \n t.key = b.key and \n substr(b.ex_s1,3,1) = \'1\'\n) a\ngroup by a.name \nORDER BY a.name desc \n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (203, 'HYORZYyI', 'SELECT b.* from (\n SELECT case when a.key = \'alkali\' then \'碱用量\'\n when a.key = \'vapor\' then \'蒸汽\'\n else a.key \n end as name ,\n a.val as value,\n case when a.key = \'alkali\' then \'1020\'\n when a.key = \'vapor\' then \'1010\'\n else a.key \n end as sort \n from (\n SELECT t.key,\n sum(to_number(val_dep, \'9999999999999999999.99\'))-sum(to_number(val_arr, \'9999999999999999999.99\')) as val\n from trep_hkey_detail t,vcode_key_detail b \n where t.tid = b.tid and \n t.did = b.did and \n t.key = b.key and \n (t.tid::VARCHAR = #{tid}) AND\n (\'\'=#{grpid} or b.grpid::VARCHAR= #{grpid}) and \n t.key in (\'vapor\',\'alkali\') and \n t.bdate = CURRENT_DATE \n group by t.key \n ) a \n) b \norder by b.sort\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (205, 'VyCtYO0f', 'SELECT case when t.key = \'蒸汽\' then \'vapor\'\n when t.key = \'碱用量\' then \'alkali\' \n else t.key end as key,t.sort,jsonb_agg(b ORDER BY b.bdate,to_number(b.hours, \'99\')) as arr\n from tcode_model_detail_ex t\n left JOIN \n (select concat(bdate,\' \',hours,\':00:00\')::TIMESTAMP::VARCHAR as time,tid,\n case when key = \'蒸汽\' then \'vapor\'\n when key = \'碱用量\' then \'alkali\' \n else key end as nkey,val as value ,bdate,hours\n from trep_hkey_detail \n where bdate = CURRENT_DATE -1 and \n did::varchar = #{did}\n ) b \n on t.tid = b.tid and \n t.key = b.nkey \n where t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.code = \'all\' and \n t.key in (\'vapor\',\'alkali\',\'electric\',\'gas\',\'water\')\n GROUP BY t.key,t.sort\n ORDER BY t.sort', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (210, 'IHQJLVtr', 'SELECT name, sum(value) as value \nfrom \n( \n SELECT to_number(t.val_dep,\'9999999999999999999.99\') - to_number(t.val_arr, \'9999999999999999999.99\') as value,\n b.name,t.key,c.descript,d.dname,d.grpname,\n t.bdate,to_char(t.ctime,\'yyyy-mm-dd hh24:mi:ss\') as ctime,to_char(t.mtime,\'yyyy-mm-dd hh24:mi:ss\') as mtime \n from trep_group_detail t,tcode_model_detail_ex b,(\n SELECT a.* from\n (\n SELECT CONCAT((CURRENT_DATE)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group t\n where t.dep >= t.arr\n union\n SELECT CONCAT((CURRENT_DATE)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE+1)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group t\n where t.dep < t.arr\n union\n SELECT CONCAT((CURRENT_DATE-1)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group t\n where t.dep < t.arr\n ) a\n where CURRENT_TIMESTAMP > a.tarr and\n CURRENT_TIMESTAMP <= a.tdep\n limit 1\n ) c ,vcode_key_detail d \n where t.tid = b.tid and \n t.tid = c.tid and \n t.tid = d.tid and \n t.did = d.did and \n t.key = d.key and \n t.grpcode = c.code and \n (t.ctime BETWEEN c.tarr and c.tdep) and \n t.key in (\'vapor\',\'alkali\') and \n (t.tid::VARCHAR = #{tid}) AND\n (\'\'=#{grpid} or d.grpid::VARCHAR= #{grpid}) and \n b.code = \'all\' and \n d.grpname != \'\' and \n t.key = b.key and \n substr(b.ex_s1,3,1) = \'1\'\n) a\ngroup by a.name \nORDER BY a.name desc \n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (211, 'IHQJLVtr', 'SELECT b.* from (\n SELECT case when a.key = \'alkali\' then \'碱用量\'\n when a.key = \'vapor\' then \'蒸汽\'\n else a.key \n end as name ,\n a.val as value,\n case when a.key = \'alkali\' then \'1020\'\n when a.key = \'vapor\' then \'1010\'\n else a.key \n end as sort \n from (\n SELECT t.key,\n sum(to_number(val_dep, \'9999999999999999999.99\'))-sum(to_number(val_arr, \'9999999999999999999.99\')) as val\n from trep_hkey_detail t,vcode_key_detail b \n where t.tid = b.tid and \n t.did = b.did and \n t.key = b.key and \n (t.tid::VARCHAR = #{tid}) AND\n (\'\'=#{grpid} or b.grpid::VARCHAR= #{grpid}) and \n t.key in (\'vapor\',\'alkali\') and \n t.bdate = CURRENT_DATE \n group by t.key \n ) a \n) b \norder by b.sort\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (215, '5SeUCRJy', 'SELECT case when t.key = \'蒸汽\' then \'vapor\'\n when t.key = \'碱用量\' then \'alkali\' \n else t.key end as key,t.sort,jsonb_agg(b ORDER BY b.bdate,to_number(b.hours, \'99\')) as arr\n from tcode_model_detail_ex t\n left JOIN \n (select concat(bdate,\' \',hours,\':00:00\')::TIMESTAMP::VARCHAR as time,tid,\n case when key = \'蒸汽\' then \'vapor\'\n when key = \'碱用量\' then \'alkali\' \n else key end as nkey,val as value ,bdate,hours\n from trep_hkey_detail \n where DATE_PART(\'Day\',CURRENT_DATE::timestamp - ctime::timestamp) < 1 and \n DATE_PART(\'hour\',ctime) <= 24 and \n did::varchar = #{did}\n ) b \n on t.tid = b.tid and \n t.key = b.nkey \n where t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.code = \'all\' and \n t.key in (\'vapor\',\'alkali\',\'electric\',\'gas\',\'water\')\n GROUP BY t.key,t.sort\n ORDER BY t.sort', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (216, 'CQ9VkAr9', 'SELECT a.time,a.key,sum(value) as value \nfrom (\nSELECT \n concat(t.bdate,\' \',t.hours,\':00:00\')::timestamp as time,\n t.key,\n (to_number(t.val_dep, \'9999999999999999.99\'))-(to_number(t.val_arr, \'9999999999999999.99\')) as value\nfrom trep_hkey_detail t,vcode_key_detail b \nwhere \n (\'\' = #{tid} or t.tid::VARCHAR = #{tid}) and\n (\'\' = #{grpid} or b.grpid::varchar = #{grpid}) and \n t.key in (\'vapor\') and \n t.tid = b.tid and \n t.did = b.did and \n t.key = b.key and \n DATE_PART(\'Day\',CURRENT_DATE::timestamp - t.ctime::timestamp) < 1 and \n DATE_PART(\'hour\',t.ctime) <= 24 \n order by t.bdate,right(concat(\'00\',t.hours),2)\n) a\nGROUP BY a.time,a.key \nORDER BY a.time,a.key', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (217, 'CQ9VkAr9', 'SELECT a.time,a.key,sum(value) as value \nfrom (\nSELECT \n concat(t.bdate,\' \',t.hours,\':00:00\')::timestamp as time,\n t.key,\n (to_number(t.val_dep, \'9999999999999999.99\'))-(to_number(t.val_arr, \'9999999999999999.99\')) as value\nfrom trep_hkey_detail t,vcode_key_detail b \nwhere \n (\'\' = #{tid} or t.tid::VARCHAR = #{tid}) and\n (\'\' = #{grpid} or b.grpid::varchar = #{grpid}) and \n t.key in (\'alkali\') and \n t.tid = b.tid and \n t.did = b.did and \n t.key = b.key and \n t.ctime > CURRENT_DATE - 1\n order by t.bdate,right(concat(\'00\',t.hours),2)\n) a\nGROUP BY a.time,a.key \nORDER BY a.time,a.key;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (225, 'EeBkndxU', 'insert into trep_hours_sta_detail as thsd (tid,did,key,bdate,hours,cron,len,val,time,ctime,mtime,created_time,updated_time)\nSELECT a.tid,a.did,a.key,CURRENT_DATE,\n date_part(\'hour\', CURRENT_TIME) as hours,\n 20 as cron,1 as len ,\n a.val,20*1,\n CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,\n (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8,\n (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8\nfrom \n(\n SELECT t.tid,t.did,t.key,\n case when round(date_part(\'epoch\', now()::timestamp - t.update_time::timestamp)::NUMERIC / 60) >= 5 then \'9\' \n else t.val \n end as val\n from vcode_key_detail t ,tcode_model_detail b \n where t.tid = b.tenant_id and \n t.key = b.key and \n b.code = \'default\' and \n b.change = true\n) a\nON CONFLICT (tid,did,key,bdate,hours,val)\nDO UPDATE SET \nlen = thsd.len + EXCLUDED.len,\ntime = (thsd.len + EXCLUDED.len) * 20,\nmtime = CURRENT_TIMESTAMP,\nupdated_time = (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8;\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (226, 'FNMVwfcu', '\ninsert into trep_group_sta_detail as trep \n (tid,did,bdate,grpcode,key,val,cron,len,time,ctime,mtime,created_time,updated_time)\nSELECT a.tid,a.did,a.tarr::date as bdate,a.code,a.key,\n a.val,\n 20 as cron,1 as len ,\n 20*1 as time,\n CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,\n (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8,\n (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8 \nfrom \n(\n SELECT t.tid,t.did,t.key,\n case when round(date_part(\'epoch\', now()::timestamp - t.update_time::timestamp)::NUMERIC / 60) >= 5 then \'9\' \n else t.val \n end as val,c.code,c.descript,c.tarr,c.tdep\n from vcode_key_detail t ,tcode_model_detail b,(\n SELECT a.* from\n (\n SELECT CONCAT((CURRENT_DATE)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE+tdays)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group t\n UNION\n SELECT CONCAT((CURRENT_DATE-tdays)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group t\n where t.tdays > 0\n \n ) a \n where (CURRENT_TIMESTAMP BETWEEN a.tarr and a.tdep) \n ) c\n where t.tid = b.tenant_id and \n t.tid = c.tid and \n t.key = b.key and \n b.code = \'default\' and \n b.change = true\n) a\nON CONFLICT (tid,did,bdate,grpcode,key,val)\nDO UPDATE SET \nlen = trep.len + EXCLUDED.len,\ntime = (trep.len + EXCLUDED.len) * 20,\nmtime = CURRENT_TIMESTAMP,\nupdated_time = (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8;\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (227, 'RSuNGzhs', 'insert into trep_day_sta_detail as trep \n (tid,did,bdate,key,val,cron,len,time,ctime,mtime,created_time,updated_time)\nSELECT a.tid,a.did,a.tarr::date as bdate,a.key,\n a.val,\n 20 as cron,1 as len ,\n 20*1 as time,\n CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,\n (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8,\n (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8 \nfrom \n(\n SELECT t.tid,t.did,t.key,\n case when round(date_part(\'epoch\', now()::timestamp - t.update_time::timestamp)::NUMERIC / 60) >= 5 then \'9\' \n else t.val \n end as val,c.tarr,c.tdep\n from vcode_key_detail t ,tcode_model_detail b,(\n SELECT a.* from\n (\n SELECT CONCAT((CURRENT_DATE)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE+tdays)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group_days t\n UNION\n SELECT CONCAT((CURRENT_DATE-tdays)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group_days t\n where t.tdays > 0\n \n ) a \n where (CURRENT_TIMESTAMP BETWEEN a.tarr and a.tdep) \n ) c\n where t.tid = b.tenant_id and \n t.tid = c.tid and \n t.key = b.key and \n b.code = \'default\' and \n b.change = true\n) a\nON CONFLICT (tid,did,bdate,key,val)\nDO UPDATE SET \nlen = trep.len + EXCLUDED.len,\ntime = (trep.len + EXCLUDED.len) * 20,\nmtime = CURRENT_TIMESTAMP,\nupdated_time = (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8;\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (235, '0qLjHowN', 'SELECT t.*,\n d.fid,d.fname,d.wid,d.wname,d.grpid,d.grpname,d.gid,d.gname,d.dname,d.volume_on_day \n from trep_group_sta_detail t,tcode_group c ,vcode_key_detail d \n where t.tid = d.tid and \n t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.tid = c.tid and \n t.tid = d.tid and \n t.key = d.key and \n t.grpcode = c.code and \n t.bdate::varchar = #{date}::varchar and \n (d.dname like concat(#{deviceName},\'%\') or \'\' = #{deviceName}) and \n (c.code = #{grpcode} or \'\' = #{grpcode}) and \n (d.grpname like concat(#{grptype},\'%\') or \'\' = #{grptype}) and \n d.grpname != \'\' ;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (237, 'v7p2AAqp', 'SELECT t.* \nfrom vcode_key_detail t \nwhere t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n (t.dname like concat(#{deviceName},\'%\') or \'\' = #{deviceName}) and \n (t.key = #{key} or \'\' = #{key}) and \n (t.grpname like concat(#{grptype},\'%\') or \'\' = #{grptype}) and \n t.grpname != \'\' ;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (240, 'hGLKRYiu', 'SELECT to_number(t.val_dep,\'9999999999999999999.9999\') - to_number(t.val_arr, \'9999999999999999999.9999\') as value,\n b.name,d.dname,d.key,d.grpname,\n t.bdate,to_char(t.ctime,\'yyyy-mm-dd hh24:mi:ss\') as ctime,to_char(t.mtime,\'yyyy-mm-dd hh24:mi:ss\') as mtime \n from trep_dkey_detail t,tcode_model_detail_ex b,vcode_key_detail d\n where t.tid = b.tid and \n t.tid = d.tid and \n t.did = d.did and \n t.key = d.key and \n (t.bdate BETWEEN concat(to_char(date_trunc(\'month\', concat(#{year},\'-\',#{month},\'-01\')::DATE - interval \'1\' month),\'yyyy-mm\'),\'-26\')::DATE and \n concat(#{year},\'-\',#{month},\'-25\')::DATE) and \n (d.dname like concat(#{deviceName},\'%\') or \'\' = #{deviceName}) and \n (b.name like concat(#{propName},\'%\') or \'\' = #{propName}) and \n (d.grpname like concat(#{grptype},\'%\') or \'\' = #{grptype}) and \n b.code = \'all\' and \n t.key = b.key and \n d.grpname != \'\' and \n substr(b.ex_s1,3,1) = \'1\'\n ORDER BY bdate desc,grpname,dname,key asc ;\n ', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (246, '3qxDmpBG', 'SELECT trep_group_detail_function();', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (247, '3qxDmpBG', 'INSERT into trep_dkey_detail(tid,did,key,bdate,ctime,mtime,val,val_dep,val_arr)\nselect a.tid,a.did,a.key,a.bdate,\nmin(a.ctime),max(a.mtime),\n(to_number(min(val_arr), \'999999999999999.99\') + sum(a.value))::varchar as val,\n(to_number(min(val_arr), \'999999999999999.99\') + sum(a.value))::varchar as val_dep,\nmin(val_arr) as val_arr\nfrom \n(\nSELECT t.*,to_number(t.val_dep, \'999999999999999.9999\') - to_number(t.val_arr, \'999999999999999.9999\') as value \nfrom trep_group_detail t\nwhere t.bdate = CURRENT_DATE\n) a\ngroup by a.tid,a.did,a.key,a.bdate\nON CONFLICT (tid,did,key,bdate)\nDO UPDATE SET \nval = EXCLUDED.val,\nval_dep = EXCLUDED.val_dep,\nmtime = CURRENT_TIMESTAMP;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (248, 'tCoVivD8', 'INSERT into trep_hkey_detail(tid,did,key,bdate,hours,val,ctime,mtime,val_arr,val_dep)\nSELECT t.tid,t.did, t.key,current_date as bdate,\ndate_part(\'hour\', CURRENT_TIME) as hours,t.val ,\nCURRENT_TIMESTAMP ,CURRENT_TIMESTAMP,\nt.val,t.val\n from vcode_key_detail t,tcode_model_detail b\nwhere t.tid = b.tenant_id and \n t.key = b.key and \n b.code = \'default\' and \n b.halt = \'F\' and \n b.hour = true \n ON CONFLICT (tid,did,key,bdate,hours)\nDO UPDATE SET \nval = EXCLUDED.val,\nval_dep = EXCLUDED.val_dep,\nmtime = CURRENT_TIMESTAMP;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (249, 'tCoVivD8', 'update trep_hkey_detail \n set peak = case when c.switch = 1 then \n (to_number(val_dep,\'9999999999999999999.99\') - to_number(val_arr, \'9999999999999999999.99\'))::varchar else \n \'0.00\' end ,\n valley = case when c.switch = 0 then \n (to_number(val_dep,\'9999999999999999999.99\') - to_number(val_arr, \'9999999999999999999.99\'))::varchar else \n \'0.00\' end \n from \n (SELECT case when CURRENT_TIME >= \'08:00\'::time then 1\n else 0 end \n as switch) c\nwhere bdate = CURRENT_DATE and \n hours = date_part(\'hour\', CURRENT_TIME)::varchar and \n key = \'electric\';', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (250, '7TVjkWPy', 'INSERT into trep_dkey_detail(tid,did,key,bdate,val_arr,val_dep,val,ctime,mtime) \nSELECT t.tid,t.did,t.key,c.tarr::date as bdate,\n t.val,t.val,t.val,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP\n from vcode_key_detail t ,tcode_model_detail b,\n (\n SELECT a.* from\n (\n SELECT CONCAT((CURRENT_DATE)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE+tdays)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group_days t\n UNION\n SELECT CONCAT((CURRENT_DATE-tdays)::TEXT,\' \',t.arr)::TIMESTAMP as tarr,\n CONCAT((CURRENT_DATE)::TEXT,\' \',t.dep)::TIMESTAMP as tdep,\n t.* from tcode_group_days t\n where t.tdays > 0\n \n ) a \n where (CURRENT_TIMESTAMP BETWEEN a.tarr and a.tdep) \n ) c\n where \n t.tid = b.tenant_id and \n t.tid = c.tid and \n t.key = b.key and \n b.code = \'default\' and \n b.day = true\nON CONFLICT (tid,did,key,bdate)\nDO UPDATE SET \nval_dep = EXCLUDED.val_dep,\nmtime = CURRENT_TIMESTAMP;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (251, '7TVjkWPy', 'update trep_dkey_detail \n set peak = (to_number(val_dep,\'9999999999999999999.99\') - to_number(val_arr, \'9999999999999999999.99\'))::varchar,\n valley = \'0.00\'\nwhere bdate = CURRENT_DATE and \n key = \'electric\';', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (252, 'pjYii91f', 'SELECT tmp_cache_group_detail_function();', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (262, 'B1ANmtET', 'insert into trep_sta_detail(tid,did,key,val_arr,val_dep)\nSELECT a.tid,a.did,a.key,a.val as val_arr,a.val as val_dep\nfrom \n(\n SELECT t.tid,t.did,t.key,\n min(case when round(date_part(\'epoch\', now()::timestamp - \n (select max(update_time)\n from vcode_key_detail x \n where x.tid = t.tid and \n x.did = t.did and \n x.key = t.key \n )::timestamp\n )::NUMERIC / 60) >= 5 then \'9\' \n else t.val \n end ) as val\n from vcode_key_detail t ,tcode_model_detail b \n where t.tid = b.tenant_id and \n t.key = b.key and \n b.code = \'default\' and \n b.change = true \n GROUP BY t.tid,t.did,t.key\n) a\nON CONFLICT (tid,did,key)\nDO UPDATE SET \nval_dep = EXCLUDED.val_dep,\nmtime = CURRENT_TIMESTAMP;\n\n', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (263, 'B1ANmtET', 'INSERT into trep_hsta_detail(tid,did,key,val,arr,dep)\nSELECT t.tid,t.did,t.key,t.val_arr,t.ctime,t.mtime\n from trep_sta_detail t \n where t.val_arr != t.val_dep ;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (264, 'B1ANmtET', 'UPDATE trep_sta_detail \n set val_arr = val_dep,ctime = CURRENT_TIMESTAMP \n where val_arr != val_dep;', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (265, 'xfXpHIg0', 'SELECT to_number(t.val_dep,\'9999999999999999999.9999\') - to_number(t.val_arr, \'9999999999999999999.9999\') as value,\n b.name,c.descript,d.dname,d.grpname,\n t.bdate,to_char(t.ctime,\'yyyy-mm-dd hh24:mi:ss\') as ctime,to_char(t.mtime,\'yyyy-mm-dd hh24:mi:ss\') as mtime \n from trep_group_detail t,tcode_model_detail_ex b,tcode_group c ,vcode_key_detail d \n where t.tid = b.tid and \n t.tid = c.tid and \n t.tid = d.tid and \n t.did = d.did and \n t.key = d.key and \n t.grpcode = c.code and \n t.bdate::varchar = #{date}::varchar and \n (d.dname like concat(\'%\',#{deviceName},\'%\') or \'\' = #{deviceName}) and \n (b.name like concat(#{propName},\'%\') or \'\' = #{propName}) and \n (c.code = #{grpcode} or \'\' = #{grpcode}) and \n (d.grpname like concat(#{grptype},\'%\') or \'\' = #{grptype}) and \n b.code = \'all\' and \n d.grpname != \'\' and \n t.key = b.key and \n substr(b.ex_s1,3,1) = \'1\'', NULL, NULL);
INSERT INTO `api_sql` (`id`, `api_id`, `sql_text`, `transform_plugin`, `transform_plugin_params`) VALUES (266, 'cD4sCi7I', 'SELECT to_number(t.val_dep,\'9999999999999999999.9999\') - to_number(t.val_arr, \'9999999999999999999.9999\') as value,\n b.name,c.descript,d.dname,d.grpname,\n t.bdate,to_char(t.ctime,\'yyyy-mm-dd hh24:mi:ss\') as ctime,to_char(t.mtime,\'yyyy-mm-dd hh24:mi:ss\') as mtime \n from trep_group_detail t,tcode_model_detail_ex b,tcode_group c ,vcode_key_detail d \n where t.tid = b.tid and \n t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.tid = c.tid and \n t.tid = d.tid and \n t.did = d.did and \n t.key = d.key and \n t.grpcode = c.code and \n (t.bdate BETWEEN #{arr}::date and #{dep}::date ) and \n (d.dname like concat(\'%\',#{deviceName},\'%\') or \'\' = #{deviceName}) and \n (b.name like concat(#{propName},\'%\') or \'\' = #{propName}) and \n (c.code = #{grpcode} or \'\' = #{grpcode}) and \n (d.grpname like concat(#{grptype},\'%\') or \'\' = #{grptype}) and \n b.code = \'all\' and \n d.grpname != \'\' and \n t.key = b.key and \n substr(b.ex_s1,3,1) = \'1\'\n order by t.did,t.key,t.bdate,t.grpcode;\n\n \n ', NULL, NULL);
COMMIT;
-- ----------------------------
-- Table structure for datasource
-- ----------------------------
DROP TABLE IF EXISTS `datasource`;
CREATE TABLE `datasource` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
`type` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`driver` varchar(100) DEFAULT NULL,
`table_sql` varchar(255) DEFAULT NULL,
`create_time` varchar(20) DEFAULT NULL,
`update_time` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of datasource
-- ----------------------------
BEGIN;
INSERT INTO `datasource` (`id`, `name`, `note`, `type`, `url`, `username`, `password`, `driver`, `table_sql`, `create_time`, `update_time`) VALUES ('EhgozRdv', 'V3-测试环境', '', 'postgresql', 'jdbc:postgresql://121.199.175.235:30433/hsiotdb', 'postgres', 'ZeDk5+VSpaKseaGVpkfEcA==', 'org.postgresql.Driver', 'SELECT table_name FROM information_schema.tables WHERE table_schema = \'public\' ORDER BY table_name', '2022-09-24 23:19:12', '2022-09-24 23:19:12');
INSERT INTO `datasource` (`id`, `name`, `note`, `type`, `url`, `username`, `password`, `driver`, `table_sql`, `create_time`, `update_time`) VALUES ('kSC2Qziy', '物联平台V3生产', '', 'postgresql', 'jdbc:postgresql://47.99.83.75:30433/hsiotdb', 'postgres', 'ZeDk5+VSpaKseaGVpkfEcA==', 'org.postgresql.Driver', 'SELECT table_name FROM information_schema.tables WHERE table_schema = \'public\' ORDER BY table_name', '2022-09-23 12:30:22', '2022-09-23 13:13:59');
COMMIT;
-- ----------------------------
-- Table structure for firewall
-- ----------------------------
DROP TABLE IF EXISTS `firewall`;
CREATE TABLE `firewall` (
`status` varchar(255) DEFAULT NULL,
`mode` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of firewall
-- ----------------------------
BEGIN;
INSERT INTO `firewall` (`status`, `mode`) VALUES ('off', 'black');
COMMIT;
-- ----------------------------
-- Table structure for ip_rules
-- ----------------------------
DROP TABLE IF EXISTS `ip_rules`;
CREATE TABLE `ip_rules` (
`type` varchar(255) DEFAULT NULL,
`ip` varchar(10240) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of ip_rules
-- ----------------------------
BEGIN;
INSERT INTO `ip_rules` (`type`, `ip`) VALUES ('white', NULL);
INSERT INTO `ip_rules` (`type`, `ip`) VALUES ('black', NULL);
COMMIT;
-- ----------------------------
-- Table structure for token
-- ----------------------------
DROP TABLE IF EXISTS `token`;
CREATE TABLE `token` (
`id` int NOT NULL AUTO_INCREMENT,
`token` varchar(255) DEFAULT NULL,
`note` varchar(255) DEFAULT NULL,
`expire` bigint DEFAULT NULL,
`create_time` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of token
-- ----------------------------
BEGIN;
INSERT INTO `token` (`id`, `token`, `note`, `expire`, `create_time`) VALUES (1, '6f3ec539d2ad4d08384e9c1f080e2eda', '', NULL, 1663984118254);
INSERT INTO `token` (`id`, `token`, `note`, `expire`, `create_time`) VALUES (2, 'a4359cffacda5d0f24d11af4e6952312', '南泰君霖', NULL, 1668485985478);
COMMIT;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int NOT NULL AUTO_INCREMENT,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb3;
-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` (`id`, `username`, `password`) VALUES (1, 'admin', 'admin');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment