Pārlūkot izejas kodu

【CHG】优化智能查询对锚查询。

fenghao 4 gadi atpakaļ
vecāks
revīzija
7cc602d37e

+ 10 - 2
railway-admin/src/main/java/com/railway/web/controller/business/baseinfo/BusFjxgmdController.java

@@ -8,6 +8,8 @@ import com.railway.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import java.util.ArrayList;
+
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -68,8 +70,14 @@ public class BusFjxgmdController extends BaseController {
     @GetMapping("/getListByZz")
     public TableDataInfo getListByZz(BusFjxgmd busFjxgmd) {
         startPage();
-        // List<BusFjxgmd> list = busFjxgmdService.getListByZz(busFjxgmd);
-        List<BusFjxgmd> list = new ArrayList<>();
+        List<BusFjxgmd> list = new ArrayList<BusFjxgmd>();
+        if (busFjxgmd != null && StringUtils.isNoneBlank(busFjxgmd.getXingbie())
+                && StringUtils.isNoneBlank(busFjxgmd.getLineId())) {
+            list = busFjxgmdService.getListByZz(busFjxgmd);
+        }
+        else {
+            list = busFjxgmdService.getList(busFjxgmd);
+        }
         return getDataTable(list);
     }
 

+ 59 - 56
railway-business/src/main/resources/mapper/baseinfo/BusFjxgmdMapper.xml

@@ -161,16 +161,16 @@
 
   <select id="getList" resultMap="BaseResultMap">
     SELECT
-    v.dept_name,
-    v.line_name,
-    v.station_name,
-    v.dept_id,
-    v.line_id,
-    dict1.dict_label as xingbie_text,
-    dict2.dict_label as fjlx_text,
+      v.dept_name,
+      v.line_name,
+      v.station_name,
+      v.dept_id,
+      v.line_id,
+      dict1.dict_label as xingbie_text,
+      dict2.dict_label as fjlx_text,
     <include refid="Base_Column_List"/>
     FROM
-    base_fjxgmd t
+        base_fjxgmd t
     LEFT JOIN v_station v ON t.station_id = v.station_id
     LEFT JOIN sys_dict_data dict1 ON (t.xingbie = dict1.dict_value AND dict1.dict_type = 'xingbie')
     LEFT JOIN sys_dict_data dict2 ON (t.fjlx = dict2.dict_value AND dict2.dict_type = 'fjlx')
@@ -199,6 +199,9 @@
       <if test="qsgh!=null and qsgh!=''">
         and t.qsgh=#{qsgh}
       </if>
+      <if test="pillarArea!=null and pillarArea!=''">
+        and t.qsglb BETWEEN (t.qsglb + 0.0) - (#{pillarArea} + 0.0) AND (t.qsglb + 0.0) + (#{pillarArea} + 0.0)
+      </if>
       <if test="delFlag!=null and delFlag!=''">
         and t.del_flag=#{delFlag}
       </if>
@@ -220,56 +223,56 @@
   <select id="getListByZz" resultMap="BaseResultMap">
     SELECT D.* FROM
     (
-    SELECT a.id,
-    a.qsgh,
-    a.qsglb,
-    v.dept_id,
-    v.station_name,
-    a.station_id,
-    a.xingbie,
-    a.fjlx,
-    v.dept_name,
-    v.line_name,
-    dict1.dict_label AS xingbie_text,
-    dict2.dict_label AS fjlx_text,
-    ${query.pillarArea} AS pillar_area
-    FROM base_fjxgmd a
-    LEFT JOIN v_station v ON a.station_id = v.station_id
-    LEFT JOIN sys_dict_data dict1 ON (a.xingbie = dict1.dict_value AND dict1.dict_type = 'xingbie')
-    LEFT JOIN sys_dict_data dict2 ON (a.fjlx = dict2.dict_value AND dict2.dict_type = 'fjlx')
-    WHERE a.del_flag = '0'
+      SELECT a.id,
+        a.qsgh,
+        a.qsglb,
+        v.dept_id,
+        v.station_name,
+        a.station_id,
+        a.xingbie,
+        a.fjlx,
+        v.dept_name,
+        v.line_name,
+        dict1.dict_label AS xingbie_text,
+        dict2.dict_label AS fjlx_text,
+        ${query.pillarArea} AS pillar_area
+      FROM base_fjxgmd a
+      LEFT JOIN v_station v ON a.station_id = v.station_id
+      LEFT JOIN sys_dict_data dict1 ON (a.xingbie = dict1.dict_value AND dict1.dict_type = 'xingbie')
+      LEFT JOIN sys_dict_data dict2 ON (a.fjlx = dict2.dict_value AND dict2.dict_type = 'fjlx')
+      WHERE a.del_flag = '0'
     ) D ,
     (
-    SELECT zzdzxx.pillar_code
-    FROM base_pillar zzdzxx,
-    (
-    SELECT zz.id,
-    zz.pillar_code,
-    zz.marker
-    FROM base_pillar zz
-    LEFT JOIN v_station v ON zz.station_id = v.station_id
-    WHERE 1 = 1
-    <if test="query.qsgh != null and query.qsgh != ''">
-      AND zz.pillar_code = #{query.qsgh}
-    </if>
-    <if test="query.qsglb != null and query.qsglb != ''">
-      AND zz.marker = #{query.qsglb}
-    </if>
-    <if test="query.deptId != null and query.deptId != ''">
-      AND v.dept_id = #{query.deptId}
-    </if>
-    <if test="query.lineId != null and query.lineId != ''">
-      AND v.line_id = #{query.lineId}
-    </if>
-    <if test="query.stationId != null and query.stationId != ''">
-      AND v.station_id = #{query.stationId}
-    </if>
-    <if test="query.xingbie != null and query.xingbie != ''">
-      AND zz.xingbie = #{query.xingbie}
-    </if>
-    ) B
-    WHERE (zzdzxx.marker + 0.0) BETWEEN (B.marker + 0.0) - (#{query.pillarArea} + 0.0) AND (B.marker + 0.0) +
-    (#{query.pillarArea} + 0.0)
+      SELECT zzdzxx.pillar_code
+      FROM base_pillar zzdzxx,
+      (
+        SELECT zz.id,
+          zz.pillar_code,
+          zz.marker
+        FROM base_pillar zz
+        LEFT JOIN v_station v ON zz.station_id = v.station_id
+        WHERE 1 = 1
+        <if test="query.qsgh != null and query.qsgh != ''">
+          AND zz.pillar_code = #{query.qsgh}
+        </if>
+        <if test="query.qsglb != null and query.qsglb != ''">
+          AND zz.marker = #{query.qsglb}
+        </if>
+        <if test="query.deptId != null and query.deptId != ''">
+          AND v.dept_id = #{query.deptId}
+        </if>
+        <if test="query.lineId != null and query.lineId != ''">
+          AND v.line_id = #{query.lineId}
+        </if>
+        <if test="query.stationId != null and query.stationId != ''">
+          AND v.station_id = #{query.stationId}
+        </if>
+        <if test="query.xingbie != null and query.xingbie != ''">
+          AND zz.xingbie = #{query.xingbie}
+        </if>
+      ) B
+      WHERE (zzdzxx.marker + 0.0) BETWEEN (B.marker + 0.0) - (#{query.pillarArea} + 0.0) AND (B.marker + 0.0) +
+      (#{query.pillarArea} + 0.0)
     ) H
     WHERE D.qsgh = H.pillar_code
     ORDER BY (D.qsgh + 0)