管道基础大数据平台系统开发-【后端】-Server
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lf.server.mapper.show.OneMapMapper">
 
    <resultMap type="com.lf.server.entity.show.OneMapEntity" id="OneMapResult">
        <result property="value"       column="value"    />
        <result property="key"     column="key"     />
    </resultMap>
 
 
    <!--  项目类别 select * from bs.bs_project;  -->
    <select id="projectCategoryCount" resultType="java.util.Map">
        select projtype,count(*) from bs.bs_project group by projtype;
    </select>
 
 
    <!--  项目位置分布 select a.*,st_astext(geom) from bs.bs_project a  -->
    <select id="projectLocationCount" resultType="java.util.Map">
        select a.*,st_astext(geom) AS wkt from bs.bs_project a;
    </select>
 
    <!--  项目类别 国家维度-数量  -->
    <select id="countryDimensionCount" resultType="java.util.Map">
        select country,count(*) from bs.bs_project group by country;
    </select>
 
    <!--  项目类别 省维度-数量  -->
    <select id="provinceDimensionCount" resultType="java.util.Map">
        select province,count(*) from bs.bs_project where country like '%中国%' group by province ;
    </select>
 
    <!--  数据统计 数据存储  -->
    <select id="dataStorageCount" resultType="java.util.Map">
        select name "名称", (select count(*) from lf.sys_meta b where b.dircode like a.code || '%') "文件数",
               (select sum(sizes) from lf.sys_meta b where b.dircode like a.code || '%') "数量(MB)"
        from lf.sys_dir a where id > 1 and pid = 0;
    </select>
 
    <!--  数据统计 文件格式维度-文件个数 select type,count(*),count(sizes) from lf.sys_meta group by type;  -->
    <select id="fileFormatCount" resultType="java.util.Map">
        select type,count(type) AS number,count(sizes) AS capacity from lf.sys_meta group by type;
    </select>
 
    <!--  数据统计 数据申请 select * from lf.sys_apply a inner join lf.sys_user b on a.userid = b.id;  -->
    <select id="dataApplyCount" resultType="java.util.Map">
        SELECT
            count(c.name) AS number,
            c.name
        FROM
            lf.sys_apply a
                INNER JOIN lf.sys_user b ON a.userid = b.id
                INNER JOIN lf.sys_dep c ON b.depid = c.id
        GROUP BY
            c.name;
    </select>
 
    <!--  数据统计 访问统计  -->
    <select id="dataVisitCount" resultType="java.util.Map">
        select modular1,count(*) from lf.sys_operate group by modular1 order by modular1;
    </select>
 
    <!--  数据统计 下载量统计 type类型:1-Shp文件,2-专题图,3-源数据,4-业务数据,5-管道分析,6-统计报告 -->
    <!--  数据统计 select type,count(*) from lf.sys_download group by type; -->
    <select id="countDownloads" resultType="java.util.Map">
        SELECT type,
               count(*),
               case type
                   WHEN '1' THEN 'Shp文件'
                   WHEN '2' THEN '专题图'
                   WHEN '3' THEN '源数据'
                   WHEN '4' THEN '业务数据'
                   WHEN '5' THEN '管道分析'
                   WHEN '6' THEN '统计报告'
                   ELSE '0'
                   END as typename
        FROM
            lf.sys_download GROUP BY type;
    </select>
 
    <!--  统计项目显示  -->
    <select id="countProjectDisplay" resultType="java.util.Map">
        select PROJNAME,* from bs.bs_project WHERE PROJNAME IS NOT NULL;
    </select>
 
    <!--  工程巡视  -->
    <select id="countProjectTour" resultType="java.util.Map">
        SELECT st_astext(geom) AS wkt,* FROM bs.m_pipeline
        <where>
            <if test="pipename != null  and pipename != ''"> and pipename = #{pipename}</if>
        </where>
    </select>
 
    <!--  工程巡视列表  -->
    <select id="selectProjectTour" resultType="java.util.Map">
        SELECT DISTINCT pipename  FROM bs.m_pipeline;
    </select>
 
 
    <!--  统计项目类型 1  -->
    <select id="selectProjectType1"  resultMap="OneMapResult">
        select (select string_agg(code, ',') from lf.sys_dir where name = a.name) "key", name "value" from lf.sys_dir a
        where name in ('测量(ESV)', '勘察(EGE)', '地灾(EGD)', '洞库(EGD)') group by name order by name;
    </select>
 
    <!--  统计项目类型 2  -->
    <select id="selectProjectTypeOne"   resultType="com.lf.server.entity.show.OneMapEntity">
        select * from lf.sys_meta ${endSql}
    </select>
 
    <!--  统计项目类型 2  -->
    <select id="selectProjectType2"   resultType="com.lf.server.entity.show.OneMapEntity">
        select modular1,count(*) from lf.sys_operate group by modular1 order by modular1;
    </select>
 
 
    <!--  查询表信息  -->
    <select id="queryTableInfo" resultType="java.util.Map">
        SELECT a.attnum,
               a.attname,
               concat_ws('',t.typname,SUBSTRING(format_type(a.atttypid,a.atttypmod)
                                                FROM '\(.*\)')) AS type,d.description,typnotnull
        FROM pg_class c,pg_attribute a,pg_type t,pg_description d
        WHERE c.relname= '${tableName}'
          AND a.attnum>0
          AND a.attrelid=c.oid
          AND a.atttypid=t.oid
          AND d.objoid=a.attrelid
          AND d.objsubid=a.attnum;
    </select>
 
 
 
 
 
 
</mapper>