管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-05-29 55828b0389182ac0e0e20636bf2714f32271883c
data/db_cx.sql
@@ -1,30 +1,58 @@
set autocommit off;
st_length( st_geographyfromtext( st_astext( st_intersection( ST_MakeValid(a.geom), ST_MakeValid(b.geom) ) ) ) ) AS acrossLength;
---------------------------------------------------------------------------------------------- -1.SQL测试
select case a.userid when 2 then guid else null end "guid", a.* from lf.sys_apply a order by id desc
select * from bs.s_explorationpoint where upper(exppointid) like '%XK0%';
select * from lf.sys_layer where url is not null and serve_type='WMS' and data_type in ('工程项目','工程项目-地灾类','工程项目-测量类','工程项目-洞库类','工程项目-勘察类') order by id;
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);
select concat(gb, '_', name) from bd.dlg_agnp limit 10;
select ST_AsText(geom) "geom", a.*, fn_get_fullname(a.depid, 1) depName, fn_get_fullname(a.dirid, 2) dirName, fn_uname(create_user) createName, fn_uname(update_user) updateName from lf.sys_publish a
select fn_get_fullname(depcode, 1) "m1", cast(sum(sizes) as decimal(18, 3)) "sizes" from lf.sys_meta group by depcode order by depcode;
-- 删除冗余数据,修复tab_guid值
select id,name,path,tab,tab_guid from lf.sys_attach where tab != 'bd.b_borehole' order by id desc limit 200; 
select * from lf.sys_fme_log order by id desc limit 15; -- 255 >
select * from lf.sys_meta order by id desc limit 15; -- 1723 >
select * from lf.sys_attach where tab != 'bd.b_borehole' order by id desc limit 50; -- 358042
select * from lf.sys_meta where tab is not null order by id desc
select * from bs.m_pipeline where parentid in ('fdac47da-8879-478d-b67c-9624e8b79d6c')
select * from lf.sys_attach where tab='bs.m_pipeline' and tab_guid in (select eventid from bs.m_pipeline where parentid in ('fdac47da-8879-478d-b67c-9624e8b79d6c'))
select * from bs.s_explorationpoint where exppointid like 'EA12%'
select id,name,code from lf.sys_dir where pid=0 order by code
select * from bs.m_marker where gid=854
select * from lf.sys_meta where name='勘探点地层表.xlsx' or type='fbx'
--delete from bs.s_explorationpointstratum where parentid in (select eventid from lf.sys_meta where name='勘探点地层表.xlsx');
--delete from lf.sys_meta where name='勘探点地层表.xlsx';
select * from lf.sys_meta where type = 'tif' or type = 'tiff' or lower(name) in ('平面图索引文件.xlsx', '穿跨越地形图.dwg', '中线成果表.xlsx', '离散点.xlsx', '控制点.xlsx', '地面线.xlsx');
-- delete from lf.sys_apply where id > 47; delete from lf.sys_flow where applyid > 47;
select * from lf.sys_layer where is_project=1 order by id desc;
select * from lf.sys_layer order by id desc;
select a.*,st_astext(geom) from lf.sys_publish a order by id desc;
select * from lf.sys_meta_pub order by id desc;
select * from lf.sys_download order by id desc limit 20; --downid
select * from lf.sys_apply order by id desc;
select * from lf.sys_flow order by id desc;
select * from lf.sys_meta order by id desc limit 100;
select * from lf.sys_fme_log order by id desc;
select * from lf.sys_pub_down order by id desc;
select id, pid, name, code from lf.sys_dir order by code;
select * from public.coal2000 order by gid limit 20;
select * from lf.sys_dir where pid = 0 order by id;
select * from lf.sys_dict order by id desc;
select * from lf.sys_meta where type in ('3dml');
select * from lf.sys_ars;
select * from lf.sys_report;
-- ALL -> 560, type=2 -> 442, WMS -> 340, url=null -> 77, type=2 & url -> 25, .json -> 17
select serve_type from lf.sys_layer group by serve_type;
update lf.sys_layer set serve_type = null where type = 2;
update lf.sys_layer set serve_type = 'WMS' where type = 2 and position('LF:' in url) > 0;
update lf.sys_layer set serve_type = '3DML' where type = 2 and serve_type is null and position('b3dm' in url) > 0;
update lf.sys_layer set serve_type = 'Tileset' where type = 2 and serve_type is null and position('.json' in url) > 0;
update lf.sys_layer set serve_type = 'TMS' where type = 2 and serve_type is null and position('.png' in url) > 0;
update lf.sys_layer set serve_type = 'Mpt' where type = 2 and serve_type is null and position('.mpt' in url) > 0;
update lf.sys_layer set serve_type = 'DEM' where type = 2 and serve_type is null and position('terrain/' in url) > 0;
select id, pid, cn_name, en_name, url, serve_type, data_type, elev, pubid, is_project, bak
from lf.sys_layer
where type = 2 and serve_type is not null
order by id;
-- update lf.sys_publish a set url = replace(url, '192.168.20.205:80', '{host}') where position('192.' in url) > 0;
select * from bs.s_explorationpoint where createtime < '2023-05-26 10:00:00';
--delete from bs.s_explorationpoint where dirid in ('00','04');
select * from bs.s_surveyworksite where createtime < '2023-05-26 10:00:00';
--delete from bs.s_surveyworksite where createtime < '2023-05-26 10:00:00';
@@ -40,7 +68,99 @@
----------------------------------------------------------------------------------------------
-- update lf.sys_publish a set geom = ST_GeomFromText('POINT Z (31.231025 113.223529 12)') where id = 1;
select id from lf.sys_layer where cn_name = '三维地质模型' and pid = (select id from lf.sys_layer where cn_name = '勘察' order by pid limit 1);
select id from lf.sys_layer where cn_name = '单体模型' and pid = (select id from lf.sys_layer where cn_name = '测绘' order by pid limit 1);
select id from lf.sys_layer where cn_name = '数字正射影像图' and pid = (select id from lf.sys_layer where cn_name = '测绘' order by pid limit 1);
select id from lf.sys_layer where cn_name = '三维地形模型' and pid = (select id from lf.sys_layer where cn_name = '测绘' order by pid limit 1);
select id from lf.sys_layer where cn_name = '三维地质模型' and pid = (select id from lf.sys_layer where cn_name = '地灾' order by pid limit 1);
select id from lf.sys_layer where cn_name = '洞库模型' and pid = (select id from lf.sys_layer where cn_name = '洞库' order by pid limit 1);
select id from lf.sys_layer where cn_name = '其他' and pid = (select id from lf.sys_layer where cn_name = '工程数据' order by pid limit 1);
insert into lf.sys_layer (pid, cn_name, en_name, url, type, level, order_num, is_show, create_user, data_type, serve_type, pubid, elev) values
(@pid, @cnName, @enName, @url, 2, (select coalesce(level, 0) + 1 from lf.sys_layer where id = @pid), (select coalesce(max(order_num), 0) + 1 from lf.sys_layer where pid = @pid), 0, @user, @name, @serve, @pubid, @elev)
select fn_get_fullname(a.depcode, 1) depName, fn_get_fullname(a.dircode, 2) dirName, a.* from lf.sys_meta a order by id desc limit 10;
---------------------------------------------------------------------------------------------- SY1.煤层54表
-- drop table public.coal54;
create table if not exists public.coal54 (
    gid serial primary key,
   top numeric(12, 3),
   bottom numeric(12, 3),
    clong numeric(12, 3),
   width numeric(12, 3),
   height numeric(12, 3),
   ctype varchar(8),
   density numeric(12, 3),
   gangue numeric(12, 5),
   volume numeric(12, 3),
    geom geometry(point, 2435)
);
create index idx_coal54_geom on public.coal54 using gist (geom);
comment on table public.coal54 is '煤层54表';
comment on column public.coal54.gid is '主键ID';
comment on column public.coal54.top is '上顶高度';
comment on column public.coal54.bottom is '下底高度';
comment on column public.coal54.clong is '长度';
comment on column public.coal54.width is '宽度';
comment on column public.coal54.height is '高度';
comment on column public.coal54.ctype is '类别';
comment on column public.coal54.density is '视密度';
comment on column public.coal54.gangue is '含矸率';
comment on column public.coal54.volume is '体积';
comment on column public.coal54.geom is '空间';
select count(*) from public.coal54; -- 12701714
select a.*, ST_AsText(geom) from public.coal54 a order by gid desc limit 100;
---------------------------------------------------------------------------------------------- SY2.煤层2000表
-- create sequence public.coal2000_gid_seq increment  by 1 minvalue 1 maxvalue 2147483647 start 1 cache 1;
-- alter sequence public.coal2000_gid_seq restart with 12701715; vacuum analyze public.coal2000;
-- drop table public.coal2000;
create table if not exists public.coal2000 (
    gid serial primary key,
   top numeric(12, 3),
   bottom numeric(12, 3),
    clong numeric(12, 3),
   width numeric(12, 3),
   height numeric(12, 3),
   ctype varchar(8),
   density numeric(12, 3),
   gangue numeric(12, 5),
   volume numeric(12, 3),
   coal_prod numeric(15, 3),
   gangue_prod numeric(15, 5),
   soil_prod numeric(15, 5),
    geom geometry(point, 4490)
);
-- drop index if exists public.idx_coal2000_geom;
create index idx_coal2000_geom on public.coal2000 using gist (geom);
create index idx_coal2000_top on public.coal2000 (top);
create index idx_coal2000_bottom on public.coal2000 (bottom);
comment on table public.coal2000 is '煤层2000表';
comment on column public.coal2000.gid is '主键ID';
comment on column public.coal2000.top is '上顶高度';
comment on column public.coal2000.bottom is '下底高度';
comment on column public.coal2000.clong is '长度';
comment on column public.coal2000.width is '宽度';
comment on column public.coal2000.height is '高度';
comment on column public.coal2000.ctype is '类别';
comment on column public.coal2000.density is '视密度';
comment on column public.coal2000.gangue is '含矸率';
comment on column public.coal2000.volume is '体积';
comment on column public.coal2000.coal_prod is '煤量';
comment on column public.coal2000.gangue_prod is '矸石量';
comment on column public.coal2000.soil_prod is '土量';
comment on column public.coal2000.geom is '空间';
-- drop index if exists public.idx_coal2000_ctype;
create index idx_coal2000_ctype on public.coal2000 (ctype);
--煤量 = 体积 * 视密度,矸石量 = 体积 * 含矸率,土量 = 总体积 - 煤量- 矸石量
select count(*) from public.coal2000; -- 12701714
select * from public.coal2000 order by gid desc limit 100;
select ctype, sum(volume) "volume", sum(coal_prod) "coal_prod", sum(gangue_prod) "gangue_prod", 0 "soil_prod" from public.coal2000
where (top between 640 and 690 or bottom between 640 and 690) and ST_Intersects(geom, ST_PolygonFromText('POLYGON ((113.5807 45.4897,113.5898 45.4893,113.5857 45.4837,113.5807 45.4897))', 4490)) group by ctype order by ctype;
-- select ST_GeometryFromText('POLYGON ((113.5807 45.4897,113.5898 45.4893,113.5857 45.4837,113.5807 45.4897))', 4490)
---------------------------------------------------------------------------------------------- -1.更新钻孔
select count(*) from bd.b_borehole; -- 357824
select count(*) from lf.sys_attach; -- 357880 = 56 + 357824