Просмотр исходного кода

增加查询最近的3个航次接口

ZHOUTD 3 недель назад
Родитель
Сommit
5f8f069bfc

+ 10 - 1
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/dal/mysql/voyage/VoyageMapper.java

@@ -118,6 +118,15 @@ public interface VoyageMapper extends BaseMapperX<VoyageDO> {
                 .eq(VoyageDO::getShipId, shipId)
                 .orderByAsc(VoyageDO::getStartTime));
     }
+
+    /**
+     * 查询指定游轮最近的三个航次:上一个航次、当前航次、下一个航次
+     *
+     * @param shipId 游轮 ID
+     * @return 按开航时间升序排列的航次列表
+     */
+    List<VoyageDO> selectRecentThreeVoyages(@Param("shipId") Long shipId);
+
     /**
      * 根据船Id和日期查询航次
      * @param shipId
@@ -152,4 +161,4 @@ public interface VoyageMapper extends BaseMapperX<VoyageDO> {
 
     @Select("SELECT direction FROM resource_route where id =(SELECT route_id FROM product_voyage where id = #{voyageId})")
     String getVoyageDirectionByVoyageId(Long voyageId);
-}
+}

+ 12 - 0
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/service/voyage/VoyageService.java

@@ -107,4 +107,16 @@ public interface VoyageService {
     List<Map<String, Object>> countBatchByVoyageIds(@Param("voyageId") List<Long> voyageIds);
 
     void syncVoyage(Long id);
+
+
+
+    List<VoyageDO> selectOnShelfListByShipId(Long shipId);
+
+    /**
+     * 查询指定游轮最近的三个航次:上一个航次、当前航次、下一个航次
+     *
+     * @param shipId 游轮 ID
+     * @return 按开航时间升序排列的航次列表
+     */
+    List<VoyageDO> selectRecentThreeVoyages(Long shipId);
 }

+ 10 - 0
ship-module-product/ship-module-product-biz/src/main/java/com/yc/ship/module/product/service/voyage/VoyageServiceImpl.java

@@ -749,6 +749,16 @@ public class VoyageServiceImpl implements VoyageService {
         }
     }
 
+    @Override
+    public List<VoyageDO> selectOnShelfListByShipId(Long shipId) {
+        return voyageMapper.selectOnShelfListByShipId(shipId);
+    }
+
+    @Override
+    public List<VoyageDO> selectRecentThreeVoyages(Long shipId) {
+        return voyageMapper.selectRecentThreeVoyages(shipId);
+    }
+
     private String getValidToken(Long taskId) throws Exception {
         String token = stringRedisTemplate.opsForValue().get("ship:platform:token");
         if (StringUtils.isBlank(token)) {

+ 32 - 1
ship-module-product/ship-module-product-biz/src/main/resources/mapper/voyage/VoyageMapper.xml

@@ -32,6 +32,37 @@
         </if>
         and w.shelf_status = 1 order by w.start_time asc;
     </select>
+    <select id="selectRecentThreeVoyages"
+            resultType="com.yc.ship.module.product.dal.dataobject.voyage.VoyageDO">
+        SELECT voyage.*
+        FROM (
+            (SELECT previous_voyage.*
+             FROM product_voyage previous_voyage
+             WHERE previous_voyage.ship_id = #{shipId}
+               AND previous_voyage.deleted = 0
+               AND previous_voyage.leave_time &lt; NOW()
+             ORDER BY previous_voyage.start_time DESC
+             LIMIT 1)
+            UNION ALL
+            (SELECT current_voyage.*
+             FROM product_voyage current_voyage
+             WHERE current_voyage.ship_id = #{shipId}
+               AND current_voyage.deleted = 0
+               AND current_voyage.start_time &lt;= NOW()
+               AND current_voyage.leave_time >= NOW()
+             ORDER BY current_voyage.start_time DESC
+             LIMIT 1)
+            UNION ALL
+            (SELECT next_voyage.*
+             FROM product_voyage next_voyage
+             WHERE next_voyage.ship_id = #{shipId}
+               AND next_voyage.deleted = 0
+               AND next_voyage.start_time > NOW()
+             ORDER BY next_voyage.start_time ASC
+             LIMIT 1)
+        ) voyage
+        ORDER BY voyage.start_time ASC
+    </select>
     <select id="selectVoyageListByShipIdAndDate"
             resultType="com.yc.ship.module.product.controller.app.voyage.vo.AppVoyageDayRespVO">
         select w.id voyage_id, w.name as voyage_name,
@@ -219,4 +250,4 @@
         where DATE_FORMAT(td.travel_date, '%Y-%m-%d') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL (-#{day}) DAY), '%Y-%m-%d')
           and td.deleted='0' and  td.order_status in (0,1,2,3,6,7,8,9,12,13,14,15) and rr.direction = #{direction}
     </select>
-</mapper>
+</mapper>