| package com.zy.asrs.common.wms.service.impl; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
| import com.zy.asrs.common.wms.mapper.LocDirectionMapper; | 
| import com.zy.asrs.common.wms.entity.LocDirection; | 
| import com.zy.asrs.common.wms.service.LocDirectionService; | 
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
| import org.springframework.stereotype.Service; | 
|   | 
| import java.util.ArrayList; | 
| import java.util.Collections; | 
| import java.util.List; | 
|   | 
| @Service("locDirectionService") | 
| public class LocDirectionServiceImpl extends ServiceImpl<LocDirectionMapper, LocDirection> implements LocDirectionService { | 
|   | 
|     @Override | 
|     public List<ArrayList<Integer>> getInnerList(Long hostId) { | 
|         List<LocDirection> inner = this.list(new LambdaQueryWrapper<LocDirection>() | 
|                 .eq(LocDirection::getHostId, hostId) | 
|                 .eq(LocDirection::getType, "inner")); | 
|         return this.parseData(inner); | 
|     } | 
|   | 
|     @Override | 
|     public List<ArrayList<Integer>> getOuterList(Long hostId) { | 
|         List<LocDirection> outer = this.list(new LambdaQueryWrapper<LocDirection>() | 
|                 .eq(LocDirection::getHostId, hostId) | 
|                 .eq(LocDirection::getType, "outer")); | 
|         return this.parseData(outer); | 
|     } | 
|   | 
|     @Override | 
|     public List<ArrayList<Integer>> getNaturalList(Long hostId) { | 
|         List<LocDirection> natural = this.list(new LambdaQueryWrapper<LocDirection>() | 
|                 .eq(LocDirection::getHostId, hostId) | 
|                 .eq(LocDirection::getType, "natural")); | 
|         return this.parseData(natural); | 
|     } | 
|   | 
|     @Override | 
|     public List<ArrayList<Integer>> parseData(List<LocDirection> origin) { | 
|         ArrayList<ArrayList<Integer>> data = new ArrayList<>(); | 
|         for (LocDirection direction : origin) { | 
|             ArrayList<Integer> list = new ArrayList<>(); | 
|             String[] split = direction.getData().split(","); | 
|             for (String row : split) { | 
|                 list.add(Integer.parseInt(row)); | 
|             } | 
|             data.add(list); | 
|         } | 
|         return data; | 
|     } | 
|   | 
|     @Override | 
|     public boolean isAsc(Integer row, String direction, Long hostId) { | 
|         List<ArrayList<Integer>> list = null; | 
|         if(direction.equals("inner")){ | 
|             list = this.getInnerList(hostId); | 
|         } else if (direction.equals("outer")) { | 
|             list = this.getOuterList(hostId); | 
|         }else { | 
|             list = this.getNaturalList(hostId); | 
|         } | 
|   | 
|         ArrayList<Integer> obj = null; | 
|         for (ArrayList<Integer> arrayList : list) { | 
|             if(arrayList.contains(row)){ | 
|                 obj = arrayList; | 
|                 break; | 
|             } | 
|         } | 
|   | 
|         if (obj != null && obj.size() >= 2) { | 
|             Integer i0 = obj.get(0); | 
|             Integer i1 = obj.get(1); | 
|             return i0 - i1 < 0; | 
|         } | 
|   | 
|         return false; | 
|     } | 
|   | 
|     @Override | 
|     public List<Integer> getInnerDeepRow(Long hostId) { | 
|         ArrayList<Integer> data = new ArrayList<>(); | 
|         List<ArrayList<Integer>> innerList = getInnerList(hostId); | 
|         for (ArrayList<Integer> list : innerList) { | 
|             data.add(list.get(0)); | 
|         } | 
|         return data; | 
|     } | 
| } |