From 1c285b38777e9f37ee8d112e994443d3640b78c1 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 25 三月 2024 13:47:07 +0800
Subject: [PATCH] 解决查询出错

---
 src/main/resources/mapper/sys/ReportMapper.xml |  433 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 422 insertions(+), 11 deletions(-)

diff --git a/src/main/resources/mapper/sys/ReportMapper.xml b/src/main/resources/mapper/sys/ReportMapper.xml
index bca5da8..5b6dfaa 100644
--- a/src/main/resources/mapper/sys/ReportMapper.xml
+++ b/src/main/resources/mapper/sys/ReportMapper.xml
@@ -5,24 +5,30 @@
         select count(*) from lf.sys_report
         <where>
             <if test="name != null">
-                name like #{name}
+                upper(name) like #{name}
+            </if>
+            <if test="code != null">
+                code = #{code}
             </if>
         </where>
     </select>
 
     <select id="selectByPage" resultType="com.lf.server.entity.sys.ReportEntity">
-        select * from lf.sys_report
+        select a.*,fn_uname(a.create_user) createName,fn_uname(a.update_user) updateName from lf.sys_report a
         <where>
             <if test="name != null">
-                name like #{name}
+                upper(name) like #{name}
+            </if>
+            <if test="code != null">
+                code = #{code}
             </if>
         </where>
-        order by id
+        order by a.id desc
         limit #{limit} offset #{offset}
     </select>
 
     <select id="selectAll" resultType="com.lf.server.entity.sys.ReportEntity">
-        select * from lf.sys_report order by id;
+        select * from lf.sys_report order by id desc;
     </select>
 
     <select id="selectById" resultType="com.lf.server.entity.sys.ReportEntity">
@@ -31,17 +37,17 @@
 
     <insert id="insert" parameterType="com.lf.server.entity.sys.ReportEntity">
         insert into lf.sys_report
-        (name,type,path,code,create_user,create_time,bak)
+        (name,type,fname,guid,code,create_user,create_time,bak)
         values
-        (#{name},#{type},#{path},#{code},#{createUser},now(),#{bak})
+        (#{name},#{type},#{fname},#{guid},#{code},#{createUser},now(),#{bak})
     </insert>
 
     <insert id="inserts">
         insert into lf.sys_report
-        (name,type,path,code,create_user,create_time,bak)
+        (name,type,fname,guid,code,create_user,create_time,bak)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.name},#{item.type},#{item.path},#{item.code},#{item.createUser},now(),#{item.bak})
+            (#{item.name},#{item.type},#{item.fname},#{item.guid},#{item.code},#{item.createUser},now(),#{item.bak})
         </foreach>
     </insert>
 
@@ -58,7 +64,7 @@
 
     <update id="update">
         update lf.sys_report
-        set name=#{name},type=#{type},path=#{path},code=#{code},update_user=#{updateUser},update_time=now(),bak=#{bak}
+        set name=#{name},type=#{type},fname=#{fname},guid=#{guid},code=#{code},update_user=#{updateUser},update_time=now(),bak=#{bak}
         where id=#{id}
     </update>
 
@@ -66,9 +72,414 @@
         <foreach collection="list" item="item" index="index" separator=";">
             update lf.sys_report
             <set>
-                name=#{item.name},type=#{item.type},path=#{item.path},code=#{item.code},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak}
+                name=#{item.name},type=#{item.type},fname=#{item.fname},guid=#{item.guid},code=#{item.code},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak}
             </set>
             where id = #{item.id}
         </foreach>
     </update>
+
+    <!-- 鏁版嵁閲忕粺璁� -->
+    <select id="countSizes" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select fn_get_fullname(depcode, 1) "m1", cast(sum(sizes) as decimal(18, 3)) "sizes", count(*) "count"
+        from lf.sys_meta
+        group by depcode
+        order by depcode;
+    </select>
+
+    <!-- 鎸夋枃浠剁被鍨嬬粺璁� -->
+    <select id="countSizesByType" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select type "m1", cast(sum(sizes) as decimal(18, 3)) "sizes", count(*) "count"
+        from lf.sys_meta
+        group by type
+        order by type;
+    </select>
+
+    <!-- 鏈嶅姟璋冪敤閲忕粺璁� -->
+    <select id="countServices" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1", count(*) "count"
+        from lf.sys_serve_log
+        group by name
+        order by name;
+    </select>
+
+    <!-- 鐢ㄦ埛娴侀噺缁熻 -->
+    <select id="countOperates" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select modular1 "m1", modular2 "m2", count(*) "count"
+        from lf.sys_operate
+        group by modular1,modular2
+        order by modular1 desc,modular2;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃暟鎹� -->
+    <select id="countSizesByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+		  (select cast( coalesce(sum(sizes), 0) as decimal(18, 3) ) from lf.sys_meta b where b.dircode like a.code || '%') as  "sizes",
+	      (select count(*) from lf.sys_meta b where b.dircode like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by a.code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁¢捇瀛旀暟鎹� -->
+    <select id="countExplorationPoints" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select
+            name "m1", a.code "m3", 0.0 "area",
+            (select count(*) from bs.s_explorationpoint b where dirid like a.code || '%') "count",
+            (select coalesce(round(sum(sizes)::numeric, 3), 0)
+                from bs.s_explorationpoint b
+                inner join lf.sys_meta c
+                on b.parentid = c.eventid
+                where b.dirid like a.code || '%') "sizes"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鏍规嵁椤圭洰缂栫爜鏌ヨ閽诲瓟鏁版嵁鍧愭爣鐐� -->
+    <select id="selectExplorationPoints" resultType="com.lf.server.entity.ctrl.CoordinateEntity">
+        select ST_X(geom) "x", ST_Y(geom) "y"
+        from bs.s_explorationpoint b
+        <where>
+            dirid like #{code} and geom is not null
+        </where>
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃暟瀛楅珮绋嬫ā鍨嬮潰绉� -->
+    <select id="countDemAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) from lf.sys_meta b
+		   inner join lf.sys_dir c on b.dircode = c.code
+		   where c.name = '鏁板瓧楂樼▼妯″瀷' and b.type in ('dem', 'tif', 'tiff') and b.dircode like a.code || '%') "area"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁′笁缁村湴褰㈡ā鍨嬮潰绉�:mpt -->
+    <select id="countMptAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1", 0.0 "area"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″�炬枩鎽勫奖妯″瀷闈㈢Н:osgb -->
+    <select id="countOsgbAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select cast( coalesce(sum(area), 0) as decimal(20, 2) ) from lf.sys_meta b
+           where b.type = 'osgb' and b.dircode like a.code || '%') "area"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃縺鍏夌偣浜戞ā鍨嬮潰绉�:las,laz -->
+    <select id="countLasAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select cast( coalesce(sum(area), 0) as decimal(20, 2) ) from lf.sys_meta b
+           where b.type in ('las', 'laz') and b.dircode like a.code || '%') "area"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″嫎瀵熷伐鐐逛釜鏁� -->
+    <select id="countSurveyWorksiteByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.s_surveyworksite b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″嫎瀵熸姤鍛婁釜鏁� -->
+    <select id="countExplorationReportByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.s_explorationpoint b
+           inner join lf.sys_attach c on b.eventid = c.tab_guid
+           where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″穿濉屼釜鏁� -->
+    <select id="countCollapseByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_collapse b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃偿鐭虫祦涓暟 -->
+    <select id="countDebrisFlowByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_debrisflow b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″湴闈㈠闄蜂釜鏁� -->
+    <select id="countGroundCollapseByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_ground_collapse b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁¢珮闄¤竟鍧′釜鏁� -->
+    <select id="countHighSteepSlopeByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_highandsteep_slope b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃粦鍧′釜鏁� -->
+    <select id="countLandSlideByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_landslide b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁′笉绋冲畾鏂滃潯涓暟 -->
+    <select id="countUnstableSlopeByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_unstable_slope b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃按姣佷釜鏁� -->
+    <select id="countWaterDamageByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.g_water_damage b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 缁熻鏁板瓧绾垮垝鍥鹃潰绉� -->
+    <select id="countDlgAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select dir "m1", cast( coalesce(sum(area), 0) as decimal(20, 2) ) "area"
+        from lf.sys_line_buffer
+        group by code, dir
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁℃暟瀛楁灏勫奖鍍忓浘闈㈢Н -->
+    <select id="countDomAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) from lf.sys_meta b
+		   inner join lf.sys_dir c on b.dircode = c.code
+		   where c.name = '鏁板瓧姝e皠褰卞儚鍥�' and b.type in ('img', 'tif', 'tiff') and b.dircode like a.code || '%') "area"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁$绾块暱搴� -->
+    <select id="countLineLength" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+		  (select cast( coalesce(sum( ST_Length( ST_GeographyFromText( ST_AsText(geom) ) ) ) / 1000, 0) as decimal(20, 2) )
+		   from bs.m_pipeline b where b.dirid like a.code || '%') as  "len"
+        from lf.sys_dir a
+        where pid = 0
+        order by a.code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″嫎鎺㈢偣涓暟 -->
+    <select id="countExplorationPointByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bs.s_explorationpoint b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁′笁缁村湴璐ㄦā鍨嬮潰绉� -->
+    <select id="countGeoModelAreaByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select cast( coalesce(sum(b.area), 0) as decimal(20, 2) )
+           from lf.sys_meta b where b.type in ('fbx', 'ifc') and b.dircode like a.code || '%') "area"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 鎸夐」鐩粺璁″湴鐏剧偣涓暟 -->
+    <select id="countGeologicHazardByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        select name "m1",
+          (select count(*) from bd.b_geologic_hazard b where b.dirid like a.code || '%') "count"
+        from lf.sys_dir a
+        where pid = 0
+        order by code;
+    </select>
+
+    <!-- 椤圭洰鏁版嵁鍒嗙被缁熻 -->
+    <select id="countVariousDataByPrj" resultType="com.lf.server.entity.ctrl.CountEntity">
+        (select '鏁板瓧绾垮垝鍥�' "m1", 'area' "m2", 0 "count", cast( coalesce(sum(area), 0) as decimal(20, 2) ) "area", 0 "len"
+            from lf.sys_line_buffer
+            <where>
+                <if test="null != code">
+                    code like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鏁板瓧楂樼▼妯″瀷' "m1", 'area' "m2", 0 "count", cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) "area", 0 "len"
+            from lf.sys_meta b inner join lf.sys_dir c on b.dircode = c.code
+            <where>
+                c.name = '鏁板瓧楂樼▼妯″瀷' and b.type in ('dem', 'tif', 'tiff')
+                <if test="null != code">
+                    and b.dircode like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鏁板瓧姝e皠褰卞儚鍥�' "m1", 'area' "m2", 0 "count", cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) "area", 0 "len"
+            from lf.sys_meta b inner join lf.sys_dir c on b.dircode = c.code
+            <where>
+                c.name = '鏁板瓧姝e皠褰卞儚鍥�' and b.type in ('img', 'tif', 'tiff')
+                <if test="null != code">
+                    and b.dircode like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鍊炬枩鎽勫奖妯″瀷' "m1", 'area' "m2", 0 "count", cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) "area", 0 "len"
+            from lf.sys_meta b
+            <where>
+                b.type = 'osgb'
+                <if test="null != code">
+                    and b.dircode like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '婵�鍏夌偣浜戞ā鍨�' "m1", 'area' "m2", 0 "count", cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) "area", 0 "len"
+            from lf.sys_meta b
+            <where>
+                b.type in ('las', 'laz')
+                <if test="null != code">
+                    and b.dircode like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '绠$嚎闀垮害' "m1", 'len' "m2", 0 "count", 0 "area",
+                cast( coalesce(sum( ST_Length( ST_GeographyFromText( ST_AsText(geom) ) ) ) / 1000, 0) as decimal(20, 2) ) "len"
+            from bs.m_pipeline b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鍕樻帰鐐�' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.s_explorationpoint b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鍕樺療宸ョ偣' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.s_surveyworksite b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鍕樺療鎶ュ憡' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.s_explorationpoint b
+            inner join lf.sys_attach c on b.eventid = c.tab_guid
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '涓夌淮鍦拌川妯″瀷' "m1", 'area' "m2", 0 "count", cast( coalesce(sum(b.area), 0) as decimal(20, 2) ) "area", 0 "len" from lf.sys_meta b
+            <where>
+                b.type in ('fbx', 'ifc')
+                <if test="null != code">
+                    and b.dircode like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鍦扮伨鐐�' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bd.b_geologic_hazard b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '宕╁' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_collapse b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '娉ョ煶娴�' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_debrisflow b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '鍦伴潰濉岄櫡' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_ground_collapse b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '楂橀櫋杈瑰潯' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_highandsteep_slope b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '婊戝潯' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_landslide b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '涓嶇ǔ瀹氭枩鍧�' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_unstable_slope b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        )
+        union all
+        (select '姘存瘉' "m1", 'count' "m2", count(*), 0 "area", 0 "len" from bs.g_water_damage b
+            <where>
+                <if test="null != code">
+                    b.dirid like #{code}
+                </if>
+            </where>
+        );
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3