INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(596,'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 60 as cron,1 as len ,\n 60*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) * 60,\nmtime = CURRENT_TIMESTAMP,\nupdated_time = (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8;\n\n\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(596,'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 60 as cron,1 as len ,\n 60*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) * 60,\nmtime = CURRENT_TIMESTAMP,\nupdated_time = (extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8;\n\n\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(597,'FNMVwfcu','-- 记录日志\nINSERT INTO \"public\".\"trep_group_sta_detail_log\" (\"created_time\", \"start_time\") VALUES ((extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8, NOW());\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(597,'FNMVwfcu','-- 记录日志\nINSERT INTO \"public\".\"trep_group_sta_detail_log\" (\"created_time\", \"start_time\") VALUES ((extract(epoch from CURRENT_TIMESTAMP) * 1000)::int8, NOW());\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(598,'73T52QSe','update trep_group_sta_detail set \ntime = time + 43200 - c.times \n from (\n SELECT a.did,max(a.mtime) as mtime \n FROM trep_group_sta_detail a\n where a.bdate = CURRENT_DATE - 1 and \n a.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n a.grpcode = \'pm\'\n GROUP BY a.did\n ORDER BY a.did \n ) a,\n (SELECT t.did,sum(time) as times from trep_group_sta_detail t \n where t.bdate = CURRENT_DATE - 1 and \n t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.grpcode = \'pm\'\n GROUP BY t.did\n ORDER BY t.did) c\nwhere trep_group_sta_detail.bdate = CURRENT_DATE - 1 and \n trep_group_sta_detail.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n trep_group_sta_detail.grpcode = \'pm\' and \n trep_group_sta_detail.did = a.did and \n trep_group_sta_detail.mtime = a.mtime and \n trep_group_sta_detail.did = c.did \n\n ',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(598,'73T52QSe','update trep_group_sta_detail set \ntime = time + 43200 - c.times \n from (\n SELECT a.did,max(a.mtime) as mtime \n FROM trep_group_sta_detail a\n where a.bdate = CURRENT_DATE - 1 and \n a.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n a.grpcode = \'pm\'\n GROUP BY a.did\n ORDER BY a.did \n ) a,\n (SELECT t.did,sum(time) as times from trep_group_sta_detail t \n where t.bdate = CURRENT_DATE - 1 and \n t.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n t.grpcode = \'pm\'\n GROUP BY t.did\n ORDER BY t.did) c\nwhere trep_group_sta_detail.bdate = CURRENT_DATE - 1 and \n trep_group_sta_detail.tid = \'22eed190-39af-11ed-8d4e-1d9073a615c6\' and \n trep_group_sta_detail.grpcode = \'pm\' and \n trep_group_sta_detail.did = a.did and \n trep_group_sta_detail.mtime = a.mtime and \n trep_group_sta_detail.did = c.did \n\n ',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(837,'p2UJlrzZ','-- 请输入sql,一个标签只能输入一条sql\nselect \'工厂名称\' as title,\'fname\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT \'能源类型\' as title,\'name\' as datakey,\'150px\' as width ,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nselect \'单位\' as title,\'units\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT to_char(date_value, \'YYYY-MM-DD\') as title, to_char(date_value, \'YYYY-MM-DD\') as dataKey ,\'110px\' as width,\'money\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from generate_month_dates(#{year}::int4, #{month}::int4) \n union all \nselect \'累计用量\' as title,\'total_energy\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(838,'p2UJlrzZ','-- 生成临时表\nselect * from generate_dynamic_table_f(#{year}::int4, #{month}::int4,#{tid});',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(839,'p2UJlrzZ','-- 查询临时表\nselect * from tmp_target_table_f',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(840,'XO3iDJu3','-- 表头\nselect \'车间名称\' as title,\'wname\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT \'能源类型\' as title,\'name\' as datakey,\'150px\' as width ,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nselect \'单位\' as title,\'units\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT to_char(date_value, \'YYYY-MM-DD\') as title, to_char(date_value, \'YYYY-MM-DD\') as dataKey ,\'110px\' as width,\'money\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from generate_month_dates(#{year}::int4, #{month}::int4) \nunion all \nselect \'累计用量\' as title,\'total_energy\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(841,'XO3iDJu3','-- 生成临时表\nselect * from generate_dynamic_table_workshop(#{year}::int4, #{month}::int4,#{tid});',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(842,'XO3iDJu3','-- 查询临时表\nselect * from tmp_target_table_workshop',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(843,'evthM2bc','-- 表头\nselect \'车间\' as title,\'wname\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nselect \'机台\' as title,\'dname\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT \'能源类型\' as title,\'name\' as datakey,\'150px\' as width ,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nselect \'单位\' as title,\'units\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT to_char(date_value, \'YYYY-MM-DD\') as title, to_char(date_value, \'YYYY-MM-DD\') as dataKey ,\'110px\' as width,\'money\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from generate_month_dates(#{year}::int4, #{month}::int4) \nunion all \nselect \'累计用量\' as title,\'total_energy\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\n\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(844,'evthM2bc','-- 生成临时表\nselect * from generate_dynamic_table_jt(#{year}::int4, #{month}::int4,#{tid},\'\');',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(845,'evthM2bc','-- 查询数据\nselect * from tmp_target_table_jt order by serial_number,dname',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(846,'8SzuiAbE','select \'序号\' as title,\'序号\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'车间名称\' as title,\'车间名称\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'设备名称\' as title,\'设备名称\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nSELECT \'能源类型\' as title,\'能源类型\' as datakey,\'150px\' as width ,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'单位\' as title,\'单位\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'累计用量\' as title,\'累计用量\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \n(SELECT cast(t.month_value as VARCHAR)||\'月\' as title,cast(t.month_value as VARCHAR) as dataKey ,\'110px\' as width,\'money\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from \n (SELECT * FROM generate_year_months(#{year_int}::int4)) t)\n ',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(848,'8SzuiAbE','select * from tmp_denergy_month\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(849,'K29naO78','select \'序号\' as title,\'序号\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'车间名称\' as title,\'车间名称\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nSELECT \'能源类型\' as title,\'能源类型\' as datakey,\'150px\' as width ,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'单位\' as title,\'单位\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'累计用量\' as title,\'累计用量\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \n(SELECT cast(t.month_value as VARCHAR)||\'月\' as title,cast(t.month_value as VARCHAR) as dataKey ,\'110px\' as width,\'money\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from \n (SELECT * FROM generate_year_months(#{year_int}::int4)) t)\n ',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(851,'K29naO78','select * from tmp_wenergy_month\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(852,'RN17YQZz','select \'序号\' as title,\'序号\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'工厂名称\' as title,\'工厂名称\' as datakey,\'100px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nSELECT \'能源类型\' as title,\'能源类型\' as datakey,\'150px\' as width ,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'单位\' as title,\'单位\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'累计用量\' as title,\'累计用量\' as datakey,\'120px\' as width,\'text\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \n(SELECT cast(t.month_value as VARCHAR)||\'月\' as title,cast(t.month_value as VARCHAR) as dataKey ,\'110px\' as width,\'money\' as dataType,\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from \n (SELECT * FROM generate_year_months(#{year_int}::int4)) t)\n ',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(854,'RN17YQZz','select * from tmp_fenergy_month',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(855,'Nx4g8GTB','SELECT fname,wname,grpname,dname,name,val_std,val_lud,\n(val_lud::NUMERIC-val_std::NUMERIC) val_ret, \nto_char(ltime, \'yyyy-mm-dd hh24:mi:ss\') ltime,\nto_char(mtime, \'yyyy-mm-dd hh24:mi:ss\') mtime\nfrom trep_energy where tid::varchar=#{tid} \nand ltime::varchar>=#{start_time}\nand mtime::varchar between #{start_time} and #{end_time}\nand (name =#{type_name} or \'\' = #{type_name}) \nand (dname like concat(\'%\',#{dname},\'%\') or \'\' = #{dname}) \nand (fname like concat(\'%\',#{fname},\'%\') or \'\' = #{fname})\nand (wname like concat(\'%\',#{wname},\'%\') or \'\' = #{wname})\nand (grpname like concat(\'%\',#{grpname},\'%\') or \'\' = #{grpname})\norder by ltime desc',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(856,'V6VnrUXa','select \'序号\' as title,\'序号\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'工厂名称\' as title,\'工厂名称\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'车间名称\' as title,\'车间名称\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nSELECT \'设备名称\' as title,\'设备名称\' as datakey,\'150px\' as width ,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'能源类型\' as title,\'能源类型\' as datakey,\'120px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'单位\' as title,\'单位\' as datakey,\'120px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT t::VARCHAR as title,t::VARCHAR as dataKey ,\'110px\' as width,\'money\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from generate_series(#{date}, #{dep}, 1) as t\nunion all\nselect \'累计用量\' as title,\'累计用量\' as datakey,\'120px\' as width,\'money\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(858,'V6VnrUXa','SELECT * from tmp_device_energy_table;',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(859,'kJ2vKiZb','select \'序号\' as title,\'序号\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'工厂名称\' as title,\'工厂名称\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'车间名称\' as title,\'车间名称\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'能源类型\' as title,\'能源类型\' as datakey,\'120px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'单位\' as title,\'单位\' as datakey,\'120px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT t::VARCHAR as title,t::VARCHAR as dataKey ,\'110px\' as width,\'money\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from generate_series(#{date}, #{dep}, 1) as t\nunion all\nselect \'累计用量\' as title,\'累计用量\' as datakey,\'120px\' as width,\'money\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(861,'kJ2vKiZb','SELECT * from tmp_wname_energy_table;',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(862,'HMDaRCo8','\nselect \'序号\' as title,\'序号\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'工厂名称\' as title,\'工厂名称\' as datakey,\'100px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nselect \'能源类型\' as title,\'能源类型\' as datakey,\'120px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all \nselect \'单位\' as title,\'单位\' as datakey,\'120px\' as width,\'text\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export\nunion all\nSELECT t::VARCHAR as title,t::VARCHAR as dataKey ,\'110px\' as width,\'money\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,1 as tag,1 as export\n from generate_series(#{date}, #{dep}, 1) as t\nunion all\nselect \'累计用量\' as title,\'累计用量\' as datakey,\'120px\' as width,\'money\' as dataType,\n\'text\' as editType,\'\' as lock,\'\' as render,0 as tag,1 as export',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(864,'HMDaRCo8','SELECT * from tmp_fname_energy_table;',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(865,'SK6hQIOj','SELECT fname,wname,grpname,gname,key,dname,val,update_time from vcode_key_detail \nwhere tid::varchar=#{tid} \nand (dname like concat(\'%\',#{dname},\'%\') or \'\' = #{dname}) \nand (fname like concat(\'%\',#{fname},\'%\') or \'\' = #{fname})\nand (wname like concat(\'%\',#{wname},\'%\') or \'\' = #{wname})\nand (grpname like concat(\'%\',#{grpname},\'%\') or \'\' = #{grpname})\norder by update_time desc\n',NULL,NULL);
INSERTINTO`api_sql`(`id`,`api_id`,`sql_text`,`transform_plugin`,`transform_plugin_params`)VALUES(866,'5yT39rTw','SELECT 所属机台, 能源类型, 单位, 所属车间, 开始值, 结束值, \n结束值::NUMERIC - 开始值::NUMERIC 用量\nfrom (\nSELECT dname 所属机台, name 能源类型, units 单位, wname 所属车间, min(val_std) 开始值, \nmax(val_lud) 结束值 FROM trep_energy \nWHERE tid::varchar = #{tid}::varchar and ltime::date >= #{start_time}::date \nand mtime::date between #{start_time}::date and #{end_time}::date \n and (dname like concat(\'%\',#{dname},\'%\') or \'\' = #{dname}) and \n (name like concat(\'%\',#{type_name},\'%\') or \'\' = #{type_name}) \n and (wname like concat(\'%\',#{wname},\'%\') or \'\' = #{wname})\n group by name,dname,wname,units\n) t1',NULL,NULL);