Преглед на файлове

修复bug,sql查询小数精度问题

Memory_LG преди 11 месеца
родител
ревизия
1efc5ae09d
променени са 1 файла, в които са добавени 10 реда и са изтрити 6 реда
  1. 10 6
      src/main/resources/mapper/digitalforest/ForestViewNewMapper.xml

+ 10 - 6
src/main/resources/mapper/digitalforest/ForestViewNewMapper.xml

@@ -191,7 +191,7 @@
     <select id="selectYlwcList" parameterType="CenterdataTForestYlscsjj" resultType="map">
         SELECT
             "当年人工更新" NAME,
-            IFNULL(sum(a.rggx_area) ,0) area
+            CAST(ROUND(IFNULL(sum(a.rggx_area) ,0), 2) AS DECIMAL(10,2)) AS area
         FROM
             centerdata_t_forest_ylscsjj a
             LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
@@ -201,7 +201,7 @@
         UNION ALL
         SELECT
             "当年人工造林" NAME,
-            IFNULL(sum( a.area ),0) area
+            CAST(ROUND(IFNULL(sum( a.area ),0), 2) AS DECIMAL(10,2)) AS area
         FROM
             centerdata_t_forest_forestation_area a
             LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
@@ -212,7 +212,7 @@
         UNION ALL
         SELECT
             "上年人工更新" NAME,
-            IFNULL(a.rggx_area ,0) area
+            CAST(ROUND(IFNULL(a.rggx_area ,0), 2) AS DECIMAL(10,2)) AS area
         FROM
             centerdata_t_forest_ylscsjj a
             LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
@@ -222,7 +222,7 @@
         UNION ALL
         SELECT
             "上年人工造林" NAME,
-            IFNULL(sum( a.area ),0) area
+            CAST(ROUND(IFNULL(sum( a.area ),0), 2) AS DECIMAL(10,2)) AS area
         FROM
             centerdata_t_forest_forestation_area a
             LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
@@ -247,13 +247,17 @@
              (SELECT a.year, CAST(ROUND(IFNULL(SUM(a.rggx_area), 0), 2) AS DECIMAL(10,2)) AS rggxArea
               FROM centerdata_t_forest_ylscsjj a
                        LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-              WHERE 1 = 1 ${params.dataScope}
+              <where>
+                  ${params.dataScope}
+              </where>
               GROUP BY a.year) b on a.time = b.year
         left join
              (SELECT a.year, CAST(ROUND(IFNULL(SUM(a.area), 0), 2) AS DECIMAL(10,2)) AS area
               FROM centerdata_t_forest_forestation_area a
                        LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-              WHERE 1 = 1 ${params.dataScope}
+              <where>
+                    ${params.dataScope}
+                </where>
               GROUP BY a.year) c on a.time = c.year
         order by a.time
     </select>