yourName 1 year ago
parent
commit
b6a8379584
1 changed files with 26 additions and 41 deletions
  1. 26 41
      src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

+ 26 - 41
src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

@@ -447,6 +447,7 @@
     </select>
     </select>
 
 
     <select id="getCapacityByLike" resultType="java.util.Map">
     <select id="getCapacityByLike" resultType="java.util.Map">
+        select * from (
         select * from (
         select * from (
         select * from (
         select * from (
         SELECT DISTINCT
         SELECT DISTINCT
@@ -476,14 +477,8 @@
         END "receivingCompanyId",
         END "receivingCompanyId",
         RCA.CAPACITY_NUMBER "label",
         RCA.CAPACITY_NUMBER "label",
         RCA.CAPACITY_NUMBER "text",
         RCA.CAPACITY_NUMBER "text",
-        CASE WHEN RCA.REMARK1 is null
-        then RCA.CAPACITY_NUMBER
-        else RCA.REMARK1
-        end "remark1",
-        CASE WHEN RCA.REMARK1 is null
-        then RCA.CAPACITY_NUMBER
-        else RCA.REMARK1
-        end "capacityNumber",
+        RCA.REMARK1 "remark1",
+        RCA.CAPACITY_NUMBER "capacityNumber",
         (case
         (case
         when oto.capacity_id is null then '空闲'
         when oto.capacity_id is null then '空闲'
         when oto.deleted != '2' and oto.capacity_id is not null then '已派'
         when oto.deleted != '2' and oto.capacity_id is not null then '已派'
@@ -531,24 +526,20 @@
             <if test="capacityType == null">
             <if test="capacityType == null">
                 AND RCT.CAPACITY_TYPE_NAME != '火车'
                 AND RCT.CAPACITY_TYPE_NAME != '火车'
             </if>
             </if>
-            <if test="index!=null and index!=''">
-                AND REGEXP_LIKE(RCA.CAPACITY_NUMBER, #{index})
-            </if>
             <if test="capacityId!=null and capacityId!=''">
             <if test="capacityId!=null and capacityId!=''">
                 AND RCA .CAPACITY_ID = #{capacityId}
                 AND RCA .CAPACITY_ID = #{capacityId}
             </if>
             </if>
-
-            <if test="lastIndex!=null">
-                and RCA.CAPACITY_ID &lt; #{lastIndex}
-            </if>
             <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
             <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
                 ORDER BY "countNumber" DESC
                 ORDER BY "countNumber" DESC
             </if>
             </if>
-            <if test="!((driverId!=null and driverId!='') or (driverId2!=null and driverId2!=''))">
-                order by RCA.CAPACITY_ID desc
+
+        ) <where>
+            <if test="index!=null and index!=''">
+                AND REGEXP_LIKE("capacityNumber", #{index})
             </if>
             </if>
-            FETCH NEXT 10 ROWS ONLY
-        )
+          </where>
+            order by LENGTH("capacityNumber")
+            FETCH NEXT 10 ROWS ONLY)
         <if test="id!=null and id.size>0">
         <if test="id!=null and id.size>0">
             UNION
             UNION
             SELECT DISTINCT
             SELECT DISTINCT
@@ -578,14 +569,8 @@
             END "receivingCompanyId",
             END "receivingCompanyId",
             RCA.CAPACITY_NUMBER "label",
             RCA.CAPACITY_NUMBER "label",
             RCA.CAPACITY_NUMBER "text",
             RCA.CAPACITY_NUMBER "text",
-            CASE WHEN RCA.REMARK1 is null
-            then RCA.CAPACITY_NUMBER
-            else RCA.REMARK1
-            end "remark1",
-            CASE WHEN RCA.REMARK1 is null
-            then RCA.CAPACITY_NUMBER
-            else RCA.REMARK1
-            end "capacityNumber",
+            RCA.REMARK1 "remark1",
+            RCA.CAPACITY_NUMBER "capacityNumber",
             (case
             (case
             when oto.capacity_id is null then '空闲'
             when oto.capacity_id is null then '空闲'
             when oto.deleted != '2' and oto.capacity_id is not null then '已派'
             when oto.deleted != '2' and oto.capacity_id is not null then '已派'
@@ -622,16 +607,17 @@
             <foreach collection="id" item="item" open="(" close=")" separator="," >
             <foreach collection="id" item="item" open="(" close=")" separator="," >
                 #{item}
                 #{item}
             </foreach>
             </foreach>
+        </if>)
+        <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+            ORDER BY "countNumber" DESC
         </if>
         </if>
-    )
-    <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
-        ORDER BY "countNumber" DESC
-    </if>
     </select>
     </select>
 
 
     <select id="getCapacityByLikeSc" resultType="java.util.Map">
     <select id="getCapacityByLikeSc" resultType="java.util.Map">
         select * from (
         select * from (
         select * from (
         select * from (
+        select * from (
+        select rownum id,t.* from (
         SELECT DISTINCT
         SELECT DISTINCT
         RCA .CAPACITY_ID "capacityId",
         RCA .CAPACITY_ID "capacityId",
         RCA .CAPACITY_ID "id",
         RCA .CAPACITY_ID "id",
@@ -731,21 +717,23 @@
         <if test="capacityId!=null and capacityId!=''">
         <if test="capacityId!=null and capacityId!=''">
             AND RCA .CAPACITY_ID = #{capacityId}
             AND RCA .CAPACITY_ID = #{capacityId}
         </if>
         </if>
-
-        <if test="lastIndex!=null">
-            and RCA.CAPACITY_ID &lt; #{lastIndex}
-        </if>
         <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
         <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
             ORDER BY "countNumber" DESC
             ORDER BY "countNumber" DESC
         </if>
         </if>
         <if test="!((driverId!=null and driverId!='') or (driverId2!=null and driverId2!=''))">
         <if test="!((driverId!=null and driverId!='') or (driverId2!=null and driverId2!=''))">
-            order by RCA.CAPACITY_ID desc
+            order by length("capacityNumber"),"capacityNumber"
         </if>
         </if>
-        FETCH NEXT 10 ROWS ONLY
-        )
+        )t)t1
+        <where>
+            <if test="lastIndex!=null">
+                and t1.id > #{lastIndex}
+            </if>
+        </where>
+        FETCH NEXT 10 ROWS ONLY)
         <if test="id!=null and id.size>0">
         <if test="id!=null and id.size>0">
             UNION
             UNION
             SELECT DISTINCT
             SELECT DISTINCT
+            0 id,
             RCA .CAPACITY_ID "capacityId",
             RCA .CAPACITY_ID "capacityId",
             RCA .CAPACITY_ID "id",
             RCA .CAPACITY_ID "id",
             RCA .CAPACITY_ID "value",
             RCA .CAPACITY_ID "value",
@@ -824,9 +812,6 @@
             </foreach>
             </foreach>
         </if>
         </if>
         )
         )
-        <where>
-            <include refid="com.steerinfo.dil.mapper.CommonMapper.filterCompanyData"></include>
-        </where>
         <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
         <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
             ORDER BY "countNumber" DESC
             ORDER BY "countNumber" DESC
         </if>
         </if>