| //package com.zy.asrs.wms.common.interceptor; | 
| // | 
| //import com.baomidou.mybatisplus.core.toolkit.PluginUtils; | 
| //import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor; | 
| //import org.apache.ibatis.executor.Executor; | 
| //import org.apache.ibatis.mapping.BoundSql; | 
| //import org.apache.ibatis.mapping.MappedStatement; | 
| //import org.apache.ibatis.session.ResultHandler; | 
| //import org.apache.ibatis.session.RowBounds; | 
| // | 
| //import java.sql.SQLException; | 
| // | 
| // | 
| //public class StockSortInterceptor implements InnerInterceptor { | 
| // | 
| //    @Override | 
| //    public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { | 
| //        // 获取原始SQL语句 | 
| //        String originalSql = boundSql.getSql(); | 
| //        // 判断方法是否为特定的查询方法 | 
| //        if (isSpecificQueryMethod(ms)) { | 
| //            // 添加排序逻辑 | 
| //            String sql = addSort(originalSql); | 
| //            // 修改完成的sql 再设置回去 | 
| //            PluginUtils.MPBoundSql mpBoundSql = PluginUtils.mpBoundSql(boundSql); | 
| //            mpBoundSql.sql(sql); | 
| //        } | 
| //    } | 
| // | 
| //    private boolean isSpecificQueryMethod(MappedStatement ms) { | 
| //        // 检查MappedStatement的ID以判断是否为特定的查询方法 | 
| //        String statementId = ms.getId(); | 
| //        return statementId.equals("com.zy.asrs.wms.asrs.mapper.LocDetlMapper.getStock"); | 
| //    } | 
| // | 
| //    private String addSort(String originalSql) { | 
| //        // 根据需要添加排序逻辑 | 
| //        return originalSql + " ORDER BY" + isQueue(); | 
| //    } | 
| // | 
| //    private String isQueue() { | 
| //        //先进先出:在查询库存记录时,排序字段按照man_loc_detl表的createTime升序排序 | 
| //        return " create_time ASC"; | 
| //    } | 
| // | 
| //    private String isFree() { | 
| //        //设备空闲情况:优先查询空闲的设备,在有空闲的设备时,从空闲的设备对应的货架上查询 | 
| //        //TODO | 
| //        return " create_time ASC"; | 
| //    } | 
| // | 
| //    private String isBarcodeDesc() { | 
| //        //托盘最大值降序:就是按照托盘号降序 | 
| //        return " barcode DESC"; | 
| //    } | 
| // | 
| //    private String isBarcodeAsc() { | 
| //        //托盘最大值升序:就是按照托盘号升序 | 
| //        return " barcode ASC"; | 
| //    } | 
| // | 
| //    private String isEven() { | 
| //        // 楼层均匀分布: | 
| //        //TODO | 
| //        return " barcode ASC"; | 
| //    } | 
| // | 
| //} |