管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-13 b2e4845b84b23aa3f9cc01141c74a8a27c56c17a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
st_length( st_geographyfromtext( st_astext( st_intersection( ST_MakeValid(a.geom), ST_MakeValid(b.geom) ) ) ) ) AS acrossLength;
---------------------------------------------------------------------------------------------- -1.SQL测试
select * from lf.sys_attach where tab='lf.sys_style';
select * from lf.sys_attach order by tab,tab_guid;
 
select * from bs.s_explorationpoint where upper(exppointid) like '%XK0%';
select * from bs.s_survey_information; --勘察信息表,汉江穿越
alter table bs.s_survey_information add column workname varchar(50);
update bs.s_survey_information set workname='汉江穿越' where gid=1;
select * from bs.s_surveyworksite; --勘察工点
 
select * from lf.sys_download order by id desc;
select * from lf.sys_layer where url is not null and serve_type='WMS' and data_type in ('工程项目','工程项目-地灾类','工程项目-测量类','工程项目-洞库类','工程项目-勘察类') order by id;
select * from lf.sys_layer order by id desc limit 20;
insert into lf.sys_layer (pid,cn_name,en_name,url,type,level,order_num,is_show,create_user,serve_type,data_type,elev) values
  (423, '地面层', 'fushun_site', 'tileset/o/39HBFG/tileset.json', 2, 3, 5, 0, 1, 'Tileset', '工程测量模型', 1200);
update lf.sys_layer set elev=118,cn_name='地面层' where id=427;
-- delete from lf.sys_layer where id=427;
 
-- 28.178
select * from bd.dlg_25w_boul where ST_Intersects(geom, ST_Buffer(ST_GeomFromText('POINT (101.9281 36.58675)', 4490), 10, 'endcap=round join=round')) limit 20;
 
select * from bd.dlg_25w_boul where ST_DWithin(geom, ST_GeomFromText('POINT (101.9281 36.58675)', 4490), 10) = true limit 20;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
---------------------------------------------------------------------------------------------- 00.SQL查询
select id,cn_name,en_name,url,serve_type,data_type from lf.sys_layer where url is not null and
  serve_type='WMS' and data_type in ('工程项目','工程项目-地灾类','工程项目-测量类','工程项目-洞库类','工程项目-勘察类') order by id;
 
select modular1,modular2 from lf.sys_operate where modular1 not in ('综合展示','数据质检','数据管理','数据交换','服务管理','系统对接','运维管理');
delete from lf.sys_operate where modular1 not in ('综合展示','数据质检','数据管理','数据交换','服务管理','系统对接','运维管理');
select id,cn_name,elev from lf.sys_layer where cn_name in ('火车站','地下管线','中卫站','庆阳站','地层示例');
 
select * from lf.sys_user where uid='FME';
select * from lf.sys_token where token='c36e4f94-dfde-401e-9967-2c4a449f1300';
update lf.sys_token set type=1,create_user=61,duration=5256000,create_time='2023-03-03 19:00:00',expire='2033-03-03 19:00:00'
where token='c36e4f94-dfde-401e-9967-2c4a449f1300';
 
select gid, pipename, segname, ST_AsText(ST_LineMerge(geom)) "wkt"
from bs.m_pipesegment
where pipename is not null and not ST_IsEmpty(geom)
order by pipename, segname;
---------------------------------------------------------------------------------------------- 01.创建空间扩展
create extension postgis;
create extension pgrouting;
create extension postgis_raster;
create extension postgis_topology;
create extension fuzzystrmatch;
create extension postgis_tiger_geocoder;
create extension address_standardizer;
create extension "uuid-ossp";
 
select uuid_generate_v4();                    -- uuid,36位
select split_part('12.34.56.78', '.', 1);     -- 切割
select substr('FY2021', 3, 2);                -- 提取
select substr('FY2021', 3);                   -- 提取
select substring('FY2021' FROM 3 for 2);      -- 提取
select position('23' in 'w123456');           -- 位置
select md5('');                               -- MD5
select concat('aa', 'bb');                    -- 连接
select concat_ws('_', 'a', 'b');              -- 连接
select chr(97);                               -- ACSII值转字符
select ascii('x');                            -- 字符转ACSII值
select to_hex(31);                            -- 转16进制
select length('aabbcc');                      -- 字符长度
select reverse('aabbcc');                     -- 反转
select initcap('aabbcc');                     -- 首字母大写
select replace('aabbcc', 'bc', 'xy');         -- 替换
select left('abcde', 2);                      -- 左截取
select right('abcde', 2);                     -- 右截取
---------------------------------------------------------------------------------------------- 02.查询连接数
show max_connections;
select count(1) from pg_stat_activity;
 
-- 查询表架构和表名
select oid,table_catalog,table_schema,table_name
from information_schema.tables t1, pg_class t2 
where table_schema = 'bd' and t1."table_name" = t2.relname
order by table_catalog,table_schema,table_name;
 
-- 查询字段信息
select e.table_catalog, e.table_schema, c.relname "tab", cast(obj_description(c.oid) as varchar) "desc", a.attnum "num", a.attname "col",
  d.typname "type", concat_ws('', d.typname, SUBSTRING(format_type(a.atttypid, a.atttypmod) from '(.*)')) "type2", b.description "bak"
from pg_attribute a left join pg_description b on b.objoid = a.attrelid and b.objsubid = a.attnum
  left join pg_class c on a.attrelid = c.oid
  left join pg_type d on a.atttypid = d.oid
  left join information_schema.tables e on e.table_name = c.relname
where a.attnum >= 0 and reltype > 0 and a.attname = 'updateuser' and d.typname != 'int4' --and relnamespace in (29257,20582)
order by c.relname desc, a.attnum asc;
 
select pg_constraint.conname as pk_name,pg_attribute.attname as colname,pg_type.typname as typename from pg_constraint inner join pg_class 
on pg_constraint.conrelid = pg_class.oid inner join pg_attribute on pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum = pg_constraint.conkey[1]
inner join pg_type on pg_type.oid = pg_attribute.atttypid where pg_class.relname = 'sys_user' and pg_constraint.contype='p';
---------------------------------------------------------------------------------------------- 03.查询
select depid from bd.dlg_25w_boul where depid > 0 and depid != ALL(fn_rec_array(38, 'dep'))
and ST_Intersects(geom, ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4490))
group by depid;
 
select * from lf.sys_dir where id in (select min(id) from lf.sys_dir where name in ('测量(ESV)','勘察(EGE)','地灾(EGD)','洞库(EGD)') group by name);
select * from lf.sys_dir where pid = 1;
select * from lf.sys_dir order by id;
 
select * from lf.sys_token where create_time >= '2022-09-29' and create_time <= '2022-09-30';
 
select * from lf.sys_token where to_char(create_time,'yyyy-MM-dd') = '2022-09-30';
 
select fn_rec_query(depid,'dep') depName,fn_rec_query(dirid,'dir') dirName,fn_ver(verid) verName,fn_uname(createuser) createName,fn_uname(updateuser) updateName from bd.dlg_agnp limit 5;
 
select ns,tab from lf.sys_dict a where not exists (select id from lf.sys_dict b where b.ns=a.ns and b.tab=a.tab and b.field='gid') group by ns,tab; -- 查询字典中不存在gid的表
----------------------------------------------------------------------------------------------