소스 검색

SQL调整

ZhangShuling 3 주 전
부모
커밋
51d1c6d50e
1개의 변경된 파일26개의 추가작업 그리고 27개의 파일을 삭제
  1. 26 27
      ship-module-resource/ship-module-resource-biz/src/main/resources/mapper/resourceroom/ResourceRoomMapper.xml

+ 26 - 27
ship-module-resource/ship-module-resource-biz/src/main/resources/mapper/resourceroom/ResourceRoomMapper.xml

@@ -22,24 +22,6 @@
     </select>
 
 
-    <select id="selectFreeRoomList" resultType="com.yc.ship.module.resource.dal.dataobject.room.ResourceRoomDO">
-        select t1.id            as id,
-        t1.room_num      as roomNum,
-        t1.room_model_id as roomModelId,
-        t1.floors as floors,
-        group_concat(t3.gender separator ',') as genders,
-        count(t3.id) as count
-        from resource_room t1
-        left join (select tv.* from trade_visitor tv
-        join trade_order to1 on tv.order_id = to1.id where to1.voyage_id = #{voyageId}) t3
-        on if(t3.final_room_id is null,t3.init_room_id,t3.final_room_id)= t1.id
-        where t1.ship_id = (select ship_id from product_voyage where id=#{voyageId})
-        <if test="roomId!=null" >and t1.id=#{roomId}</if>
-        group by t1.id, t1.room_num, t1.room_model_id, t1.floors having count(t3.id)&lt;2
-        ORDER BY t1.room_num
-    </select>
-
-
     <select id="selectAllByShipIdAndFloors"
             resultType="com.yc.ship.module.resource.controller.admin.room.vo.ResourceRoomRespVO">
         select t1.id            as id,
@@ -64,20 +46,37 @@
                             from trade_visitor tv
                                      join trade_order to1 on tv.order_id = to1.id
                             where to1.voyage_id = #{voyageId}) t3
-                           on (t1.id = t3.final_room_id or t1.id = t3.init_room_id)
-            on if(t3.final_room_id is null,t3.init_room_id,t3.final_room_id)= t1.id
+                           on if(t3.final_room_id is null,t3.init_room_id,t3.final_room_id)= t1.id
                  left join buss_room_status t5 on t1.id = t5.room_id and t5.voyage_id= #{voyageId}
         where t1.ship_id = #{shipId}
           and t1.deleted = 0
           and t1.floors = #{floors}
         group by t1.id, t1.room_num, t1.ship_id, t1.room_model_id, t2.name, t1.floors ,CASE
-            WHEN t5.status IS NULL THEN
-            CASE
-            WHEN t3.name IS NOT NULL THEN 3
-            ELSE 0
-        END
-        ELSE t5.status
-        END
+                                                                                           WHEN t5.status IS NULL THEN
+                                                                                               CASE
+                                                                                                   WHEN t3.name IS NOT NULL THEN 3
+                                                                                                   ELSE 0
+                                                                                                   END
+                                                                                           ELSE t5.status
+            END
         order by t1.room_num
     </select>
+
+    <select id="selectFreeRoomList" resultType="com.yc.ship.module.resource.dal.dataobject.room.ResourceRoomDO">
+        select t1.id            as id,
+        t1.room_num      as roomNum,
+        t1.room_model_id as roomModelId,
+        t1.floors as floors,
+        group_concat(t3.gender separator ',') as genders,
+        count(t3.id) as count
+        from resource_room t1
+        left join (select tv.* from trade_visitor tv
+        join trade_order to1 on tv.order_id = to1.id where to1.voyage_id = #{voyageId}) t3
+        on if(t3.final_room_id is null,t3.init_room_id,t3.final_room_id)= t1.id
+        where t1.ship_id = (select ship_id from product_voyage where id=#{voyageId})
+        <if test="roomId!=null" >and t1.id=#{roomId}</if>
+
+        group by t1.id, t1.room_num, t1.room_model_id, t1.floors having count(t3.id)&lt;2
+        ORDER BY t1.room_num
+    </select>
 </mapper>