liyg 1 rok temu
rodzic
commit
f5cd452c49

+ 101 - 18
src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

@@ -311,7 +311,9 @@
         </foreach>
     </if>
     </select>
+
     <select id="getPersonnelByLike" resultType="java.util.Map">
+    select * from (
     select * from (
         select * from (
         select
@@ -324,8 +326,21 @@
         PERSONNEL_NAME "label",
         PERSONNEL_NAME "text",
         'personnelName' "prop"
-        from RMS_PERSONNEL
-        where DELETED = 0
+        <if test="capacityId!=null and capacityId!=''">
+            ,NVL(T ."countNumber",0) "countNumber"
+        </if>
+        FROM
+        RMS_PERSONNEL RP
+        <if test="capacityId!=null and capacityId!=''">
+            LEFT JOIN (
+            SELECT DRIVER_ID "driverId",
+            COUNT(DRIVER_ID) "countNumber"
+            FROM OMS_TRANS_ORDER
+            WHERE CAPACITY_ID = #{capacityId}
+            GROUP BY DRIVER_ID
+            ) T ON T."driverId" = RP .PERSONNEL_ID
+        </if>
+        WHERE DELETED = 0
         <if test="isNC!=null">
             AND SOURCE_ID IS NOT NULL
         </if>
@@ -347,6 +362,9 @@
                 AND REGEXP_LIKE("label", #{index})
             </if>
         </where>
+        <if test="capacityId!=null and capacityId!=''">
+            ORDER BY "countNumber" DESC
+        </if>
         FETCH NEXT 10 ROWS ONLY
     )
     <if test="id!=null and id.size>0">
@@ -361,29 +379,67 @@
         PERSONNEL_NAME "label",
         PERSONNEL_NAME "text",
         'personnelName' "prop"
-        from RMS_PERSONNEL
+        <if test="capacityId!=null and capacityId!=''">
+            ,NVL(T ."countNumber",0) "countNumber"
+        </if>
+        from RMS_PERSONNEL RP
+        <if test="capacityId!=null and capacityId!=''">
+            LEFT JOIN (
+            SELECT DRIVER_ID "driverId",
+            COUNT(DRIVER_ID) "countNumber"
+            FROM OMS_TRANS_ORDER
+            WHERE CAPACITY_ID = #{capacityId}
+            GROUP BY DRIVER_ID
+            ) T ON T."driverId" = RP .PERSONNEL_ID
+        </if>
         WHERE PERSONNEL_ID in
         <foreach collection="id" item="item"  open="(" close=")" separator="," >
             #{item}
         </foreach>
     </if>
+    )
+    <if test="capacityId!=null and capacityId!=''">
+        ORDER BY "countNumber" DESC
+    </if>
     </select>
+
     <select id="getCapacityByLike" resultType="java.util.Map">
         select * from (
-            SELECT DISTINCT
-            RCA .CAPACITY_ID "capacityId",
-            RCA .CAPACITY_ID "id",
-            RCA .CAPACITY_ID "value",
-            RCA .CAPACITY_NUMBER "label",
-            RCA .CAPACITY_NUMBER "text",
-            RCA.CAPACITY_NUMBER "capacityNumber",
-            'capacityNumber' "prop"
-            FROM RMS_CAPACITY RCA
-            LEFT JOIN RMS_CAPACITY_CARRIER RCC ON RCA .CAPACITY_ID = RCC .CAPACITY_ID
-            LEFT JOIN RMS_COMPANY RC ON RC .COMPANY_ID = RCC .COMPANY_ID
-            LEFT JOIN RMS_CAPACITY_TYPE RCT ON RCA.CAPACITY_TYPE_ID = RCT.CAPACITY_TYPE_ID
-            WHERE RCA .DELETED = 0
-            <if test="orgCode!=null and orgCode !='' and roleCodes.contains('chengYunShang')">
+        select * from (
+        SELECT DISTINCT
+        RCA .CAPACITY_ID "capacityId",
+        RCA .CAPACITY_ID "id",
+        RCA .CAPACITY_ID "value",
+        RCA .CAPACITY_NUMBER "label",
+        RCA .CAPACITY_NUMBER "text",
+        RCA.CAPACITY_NUMBER "capacityNumber",
+        'capacityNumber' "prop"
+        <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+            ,NVL(T ."countNumber",0) "countNumber"
+        </if>
+        FROM
+        RMS_CAPACITY RCA
+        LEFT JOIN RMS_CAPACITY_CARRIER RCC ON RCA .CAPACITY_ID = RCC .CAPACITY_ID
+        LEFT JOIN RMS_COMPANY RC ON RC .COMPANY_ID = RCC .COMPANY_ID
+        LEFT JOIN RMS_CAPACITY_TYPE RCT ON RCA.CAPACITY_TYPE_ID = RCT.CAPACITY_TYPE_ID
+        <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+            LEFT JOIN (
+                SELECT CAPACITY_ID "capacityId",
+                COUNT( CAPACITY_ID ) "countNumber"
+                FROM OMS_TRANS_ORDER
+                <where>
+                    <if test="driverId!=null and driverId!=''">
+                       AND (DRIVER_ID = #{driverId}  OR DRIVER_ID2 = #{driverId})
+                    </if>
+                    <if test="driverId2!=null and driverId2!=''">
+                       AND DRIVER_ID = #{driverId2}  OR DRIVER_ID2 = #{driverId2}
+                    </if>
+                </where>
+                GROUP BY CAPACITY_ID
+            ) T ON T."capacityId" = RCA .CAPACITY_ID
+        </if>
+        WHERE RCA .DELETED = 0
+        <if test="orgCode!=null and orgCode !='' and roleCodes.contains('chengYunShang')">
                 AND RC.SSO_CODE = #{orgCode}
             </if>
             <if test="capacityType != null and capacityType != '' ">
@@ -398,6 +454,9 @@
             <if test="capacityId!=null and capacityId!=''">
                 AND RCA .CAPACITY_ID = #{capacityId}
             </if>
+            <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+                ORDER BY "countNumber" DESC
+            </if>
             FETCH NEXT 10 ROWS ONLY
         )
         <if test="id!=null and id.size>0">
@@ -410,16 +469,40 @@
             RCA .CAPACITY_NUMBER "text",
             RCA.CAPACITY_NUMBER "capacityNumber",
             'capacityNumber' "prop"
+            <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+                ,NVL(T ."countNumber",0) "countNumber"
+            </if>
             FROM RMS_CAPACITY RCA
             LEFT JOIN RMS_CAPACITY_CARRIER RCC ON RCA .CAPACITY_ID = RCC .CAPACITY_ID
             LEFT JOIN RMS_COMPANY RC ON RC .COMPANY_ID = RCC .COMPANY_ID
             LEFT JOIN RMS_CAPACITY_TYPE RCT ON RCA.CAPACITY_TYPE_ID = RCT.CAPACITY_TYPE_ID
+            <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+                LEFT JOIN (
+                SELECT CAPACITY_ID "capacityId",
+                COUNT( CAPACITY_ID ) "countNumber"
+                FROM OMS_TRANS_ORDER
+                <where>
+                    <if test="driverId!=null and driverId!=''">
+                        AND (DRIVER_ID = #{driverId}  OR DRIVER_ID2 = #{driverId})
+                    </if>
+                    <if test="driverId2!=null and driverId2!=''">
+                        AND DRIVER_ID = #{driverId2}  OR DRIVER_ID2 = #{driverId2}
+                    </if>
+                </where>
+                GROUP BY CAPACITY_ID
+                ) T ON T."capacityId" = RCA .CAPACITY_ID
+            </if>
             WHERE RCA .CAPACITY_ID in
-            <foreach collection="id" item="item"  open="(" close=")" separator="," >
+            <foreach collection="id" item="item" open="(" close=")" separator="," >
                 #{item}
             </foreach>
         </if>
+    )
+    <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+        ORDER BY "countNumber" DESC
+    </if>
     </select>
+
     <select id="getrmsrmsjobinfosBylike" resultType="java.util.Map">
         select * from(
         select