Преглед изворни кода

Merge branch 'master' of https://gitee.com/antai-wuliu/ANTAI-API

Redeem пре 1 година
родитељ
комит
2c37c99699

+ 25 - 0
src/main/java/com/steerinfo/dil/controller/UniversalController.java

@@ -296,6 +296,31 @@ public class UniversalController extends BaseRESTfulController {
         return success(universalMapper.getCapacityDriver(map));
     }
 
+
+    @ApiOperation("查询运单中所有的司机排班")
+    @PostMapping("/getCapacityDriverSelect")
+    public RESTfulResult getCapacityDriverSelect(@RequestBody Map<String,Object> map) {
+        List<Map<String,Object>> list = universalMapper.getCapacityDriverSelect(map);
+        List<Map<String,Object>> result = new ArrayList<>();
+        Set<String> set = new HashSet<>();
+        //对list去重
+        for (Map<String,Object> item : list) {
+            //只保留5条
+            if(result.size() >= 5){
+                break;
+            }
+            //去重
+            String key = item.get("capacityId") + "-" +item.get("driverId");
+            if(set.contains(key)){
+                continue;
+            }else{
+                set.add(key);
+                result.add(item);
+            }
+        }
+        return success(result);
+    }
+
     @ApiOperation("获取车辆信息")
     @PostMapping("/getCapacityInfo")
     public RESTfulResult getCapacityInfo(@RequestBody Map<String,Object> map) {

+ 2 - 0
src/main/java/com/steerinfo/dil/mapper/UniversalMapper.java

@@ -99,6 +99,8 @@ public interface UniversalMapper {
 
     Map<String,Object> getCapacityDriver(Map<String, Object> map);
 
+    List<Map<String, Object>> getCapacityDriverSelect(Map<String, Object> map);
+
     Map<String,Object> getCapacityInfo(Map<String, Object> map);
 
     Map<String,Object> getDriverInfo(Map<String, Object> map);

+ 159 - 72
src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

@@ -474,14 +474,8 @@
         THEN RC.COMPANY_ID
         else -1
         END "receivingCompanyId",
-        CASE WHEN RCA.REMARK1 is null
-        then RCA.CAPACITY_NUMBER
-        else RCA.REMARK1
-        end "label",
-        CASE WHEN RCA.REMARK1 is null
-        then RCA.CAPACITY_NUMBER
-        else RCA.REMARK1
-        end "text",
+        RCA.CAPACITY_NUMBER "label",
+        RCA.CAPACITY_NUMBER "text",
         CASE WHEN RCA.REMARK1 is null
         then RCA.CAPACITY_NUMBER
         else RCA.REMARK1
@@ -538,12 +532,7 @@
                 AND RCT.CAPACITY_TYPE_NAME != '火车'
             </if>
             <if test="index!=null and index!=''">
-                AND REGEXP_LIKE(
-                    CASE WHEN RCA.REMARK1 is null
-                    then RCA.CAPACITY_NUMBER
-                    else RCA.REMARK1
-                    end, #{index}
-                )
+                AND REGEXP_LIKE(RCA.CAPACITY_NUMBER, #{index})
             </if>
             <if test="capacityId!=null and capacityId!=''">
                 AND RCA .CAPACITY_ID = #{capacityId}
@@ -587,14 +576,8 @@
             THEN RC.COMPANY_ID
             else -1
             END "receivingCompanyId",
-            CASE WHEN RCA.REMARK1 is null
-            then RCA.CAPACITY_NUMBER
-            else RCA.REMARK1
-            end "label",
-            CASE WHEN RCA.REMARK1 is null
-            then RCA.CAPACITY_NUMBER
-            else RCA.REMARK1
-            end "text",
+            RCA.CAPACITY_NUMBER "label",
+            RCA.CAPACITY_NUMBER "text",
             CASE WHEN RCA.REMARK1 is null
             then RCA.CAPACITY_NUMBER
             else RCA.REMARK1
@@ -656,15 +639,48 @@
         RCA .CAPACITY_ID "capacityId",
         RCA .CAPACITY_ID "id",
         RCA .CAPACITY_ID "value",
-        RCA .CAPACITY_NUMBER "label",
-        RCA .CAPACITY_NUMBER "text",
-        RCA .REMARK1 "remark1",
-        RCA.CAPACITY_NUMBER "capacityNumber",
+        RCA .CAPACITY_LICENCE_NUMBER "capacityLicenceNumber",
+        RCA. CAPACITY_OPERATE_NUMBER "capacityOperateNumber",
+        RCA. CAPACITY_AXIS_NUMBER "capacityAxisNumber",
+        RCA.CAPACITY_WEIGHT_MAIN "capacityWeightMain",
+        RCA.CAPACITY_WEIGHT_TRAILER "capacityWeightTrailer",
+        CASE WHEN RC.COMPANY_TYPE = '业务单位'
+        THEN RC.COMPANY_ID
+        else -1
+        END "businessCompanyId",
+        CASE WHEN RC.COMPANY_TYPE = '承运商'
+        THEN RC.COMPANY_ID
+        else -1
+        END "carrierId",
+        CASE WHEN RC.COMPANY_TYPE = '发货单位'
+        THEN RC.COMPANY_ID
+        else -1
+        END "shippingCompanyId",
+        CASE WHEN RC.COMPANY_TYPE = '收货客户'
+        THEN RC.COMPANY_ID
+        else -1
+        END "receivingCompanyId",
+        CASE WHEN RCA.REMARK1 is null
+        then RCA.CAPACITY_NUMBER
+        else RCA.REMARK1
+        end "label",
+        CASE WHEN RCA.REMARK1 is null
+        then RCA.CAPACITY_NUMBER
+        else RCA.REMARK1
+        end "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",
         (case
         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 '空闲'
         end) "status",
+        RCT.CAPACITY_TYPE_NAME "capacityTypeName",
         'capacityNumber' "prop"
         <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
             ,NVL(T ."countNumber",0) "countNumber"
@@ -676,46 +692,59 @@
         LEFT JOIN RMS_CAPACITY_TYPE RCT ON RCA.CAPACITY_TYPE_ID = RCT.CAPACITY_TYPE_ID
         left join oms_trans_order oto
         on RCA.capacity_id = oto.capacity_id
+        and oto.deleted between 4 and 5
         <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
+            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 != '' ">
-                AND RCT.CAPACITY_TYPE_NAME = #{capacityType}
-            </if>
-            <if test="capacityType == null">
-                AND RCT.CAPACITY_TYPE_NAME != '火车'
-            </if>
-            <if test="index!=null and index!=''">
-                AND REGEXP_LIKE(
-                CASE WHEN RCA.REMARK1 is null
-                then RCA .CAPACITY_NUMBER
-                else RCA.REMARK1
-                end, #{index}
-                )
-            </if>
-            <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>
+        <if test="capacityTypeId !=null">
+            AND RCT.CAPACITY_TYPE_ID in (
+            select rct.capacity_type_id from rms_capacity_type rct
+            START WITH rct.capacity_type_id = #{capacityTypeId}
+            connect BY PRIOR rct.capacity_type_id = rct.p_capacity_type_id
+            )
+        </if>
+        <if test="capacityType != null and capacityType != '' ">
+            AND RCT.CAPACITY_TYPE_NAME = #{capacityType}
+        </if>
+        <if test="capacityType == null">
+            AND RCT.CAPACITY_TYPE_NAME != '火车'
+        </if>
+        <if test="index!=null and index!=''">
+            AND REGEXP_LIKE(
+            CASE WHEN RCA.REMARK1 is null
+            then RCA.CAPACITY_NUMBER
+            else RCA.REMARK1
+            end, #{index}
+            )
+        </if>
+        <if test="capacityId!=null and capacityId!=''">
+            AND RCA .CAPACITY_ID = #{capacityId}
+        </if>
+
+        <if test="lastIndex!=null">
+            and RCA.CAPACITY_ID &lt; #{lastIndex}
+        </if>
+        <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+            ORDER BY "countNumber" DESC
+        </if>
+        <if test="!((driverId!=null and driverId!='') or (driverId2!=null and driverId2!=''))">
+            order by RCA.CAPACITY_ID desc
+        </if>
+        FETCH NEXT 10 ROWS ONLY
         )
         <if test="id!=null and id.size>0">
             UNION
@@ -723,15 +752,48 @@
             RCA .CAPACITY_ID "capacityId",
             RCA .CAPACITY_ID "id",
             RCA .CAPACITY_ID "value",
-            RCA .REMARK1 "label",
-            RCA .REMARK1 "text",
-            RCA .REMARK1 "remark1",
-            RCA.CAPACITY_NUMBER "capacityNumber",
+            RCA .CAPACITY_LICENCE_NUMBER "capacityLicenceNumber",
+            RCA. CAPACITY_OPERATE_NUMBER "capacityOperateNumber",
+            RCA. CAPACITY_AXIS_NUMBER "capacityAxisNumber",
+            RCA.CAPACITY_WEIGHT_MAIN "capacityWeightMain",
+            RCA.CAPACITY_WEIGHT_TRAILER "capacityWeightTrailer",
+            CASE WHEN RC.COMPANY_TYPE = '业务单位'
+            THEN RC.COMPANY_ID
+            else -1
+            END "businessCompanyId",
+            CASE WHEN RC.COMPANY_TYPE = '承运商'
+            THEN RC.COMPANY_ID
+            else -1
+            END "carrierId",
+            CASE WHEN RC.COMPANY_TYPE = '发货单位'
+            THEN RC.COMPANY_ID
+            else -1
+            END "shippingCompanyId",
+            CASE WHEN RC.COMPANY_TYPE = '收货客户'
+            THEN RC.COMPANY_ID
+            else -1
+            END "receivingCompanyId",
+            CASE WHEN RCA.REMARK1 is null
+            then RCA.CAPACITY_NUMBER
+            else RCA.REMARK1
+            end "label",
+            CASE WHEN RCA.REMARK1 is null
+            then RCA.CAPACITY_NUMBER
+            else RCA.REMARK1
+            end "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",
             (case
             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 '空闲'
             end) "status",
+            RCT.CAPACITY_TYPE_NAME "capacityTypeName",
             'capacityNumber' "prop"
             <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
                 ,NVL(T ."countNumber",0) "countNumber"
@@ -742,6 +804,7 @@
             LEFT JOIN RMS_CAPACITY_TYPE RCT ON RCA.CAPACITY_TYPE_ID = RCT.CAPACITY_TYPE_ID
             left join oms_trans_order oto
             on RCA.capacity_id = oto.capacity_id
+            and oto.deleted != 2
             <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
                 LEFT JOIN (
                 SELECT CAPACITY_ID "capacityId",
@@ -763,11 +826,13 @@
                 #{item}
             </foreach>
         </if>
-    )
-    <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
-        ORDER BY "countNumber" DESC
-    </if>
-    FETCH NEXT 10 ROWS ONLY
+        )
+        <where>
+            <include refid="com.steerinfo.dil.mapper.CommonMapper.filterCompanyData"></include>
+        </where>
+        <if test="(driverId!=null and driverId!='') or (driverId2!=null and driverId2!='')">
+            ORDER BY "countNumber" DESC
+        </if>
     </select>
 
     <select id="getrmsrmsjobinfosBylike" resultType="java.util.Map">
@@ -1701,6 +1766,28 @@
         ORDER BY ISSUE_TIME DESC
             FETCH NEXT 1 ROWS ONLY
     </select>
+    <select id="getCapacityDriverSelect" resultType="java.util.Map">
+        SELECT DISTINCT
+        OTO.DRIVER_ID "driverId",
+        OTO.CAPACITY_ID "capacityId",
+        OTO.ISSUE_TIME,
+        RP.PERSONNEL_NAME "driverName",
+        RCA.CAPACITY_NUMBER "capacityNumber"
+        FROM
+        OMS_TRANS_ORDER OTO
+        LEFT JOIN RMS_PERSONNEL RP ON OTO.DRIVER_ID = RP.PERSONNEL_ID
+        LEFT JOIN RMS_CAPACITY RCA ON OTO.CAPACITY_ID = RCA.CAPACITY_ID
+        WHERE OTO.ISSUE_TIME IS NOT NULL
+        AND RP.PERSONNEL_NAME IS NOT NULL
+        AND RCA.CAPACITY_NUMBER IS NOT NULL
+        <if test="driverId!=null and driverId!=''">
+            AND OTO.DRIVER_ID = #{driverId}
+        </if>
+        <if test="capacityId!=null and capacityId!=''">
+            AND OTO.CAPACITY_ID = #{capacityId}
+        </if>
+        ORDER BY OTO.ISSUE_TIME DESC
+    </select>
     <select id="getCapacityInfo" resultType="java.util.Map">
         SELECT * FROM RMS_CAPACITY
         WHERE CAPACITY_NUMBER = #{capacityNumber}