|  |  | 
 |  |  | package com.zy.asrs.utils; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSON; | 
 |  |  | import com.core.common.Arith; | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.zy.core.properties.SlaveProperties; | 
 |  |  |  | 
 |  |  | import java.text.DecimalFormat; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.Arrays; | 
 |  |  | import java.util.Collections; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  | public class Utils { | 
 |  |  |  | 
 |  |  |     public static final List<Integer> FIRST_GROUP_ROW_LIST = new ArrayList<Integer>() {{ | 
 |  |  |         add(2);add(3);add(4);add(5);add(6);add(7);add(8);add(9);add(10); | 
 |  |  |         add(11);add(12);add(13);add(14);add(15);add(16);add(17); | 
 |  |  |         add(1);add(2);add(3);add(4); | 
 |  |  |     }}; | 
 |  |  |     public static final List<Integer> SECOND_GROUP_ROW_LIST = new ArrayList<Integer>() {{ | 
 |  |  |         add(18);add(19);add(20); | 
 |  |  |         add(21);add(22);add(23);add(24);add(25);add(26);add(27);add(28);add(29);add(30); | 
 |  |  |         add(5);add(6);add(7);add(8);add(9);add(10);add(11); | 
 |  |  |     }}; | 
 |  |  |  | 
 |  |  |     private static final DecimalFormat fmt = new DecimalFormat("##0.00"); | 
 |  |  | 
 |  |  |         return getGroupRow(row, pakin); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static Integer getGroupRow(Integer row, Boolean pakin) { | 
 |  |  |         if (pakin) { | 
 |  |  |             if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |                 return 17; | 
 |  |  |             } else if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |                 return 18; | 
 |  |  |             } else { | 
 |  |  |                 return 0; | 
 |  |  |     public static List<String> getGroupLocNo(String locNo){ | 
 |  |  |         int row = getRow(locNo); | 
 |  |  |         List<String> result = new ArrayList<>(); | 
 |  |  |         if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |             for (Integer groupRow : FIRST_GROUP_ROW_LIST) { | 
 |  |  |                 result.add(zerofill(String.valueOf(groupRow), 2) + locNo.substring(2)); | 
 |  |  |             } | 
 |  |  |         } else { | 
 |  |  |             if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |                 return 2; | 
 |  |  |             } else if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |                 return 30; | 
 |  |  |             } else { | 
 |  |  |                 return 0; | 
 |  |  |         } else if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |             for (Integer groupRow : SECOND_GROUP_ROW_LIST) { | 
 |  |  |                 result.add(zerofill(String.valueOf(groupRow), 2) + locNo.substring(2)); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static Integer getGroupRow(Integer row, Boolean pakin) { | 
 |  |  |         if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |             return 4; | 
 |  |  |         } else if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |             return 5; | 
 |  |  |         } else { | 
 |  |  |             return 0; | 
 |  |  |         } | 
 |  |  | //        if (pakin) { | 
 |  |  | //            if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  | //                return 2; | 
 |  |  | //            } else if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  | //                return 18; | 
 |  |  | //            } else { | 
 |  |  | //                return 0; | 
 |  |  | //            } | 
 |  |  | //        } else { | 
 |  |  | //            if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  | //                return 12; | 
 |  |  | //            } else if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  | //                return 30; | 
 |  |  | //            } else { | 
 |  |  | //                return 0; | 
 |  |  | //            } | 
 |  |  | //        } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 判断库位是否为穿梭库位 | 
 |  |  |      * @param locNo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static Boolean isShuttle(String locNo) { | 
 |  |  |         int row = Utils.getRow(locNo); | 
 |  |  |         if (row >= 2 && row <= 12) { | 
 |  |  |             return Boolean.TRUE; | 
 |  |  |         } | 
 |  |  |         return Boolean.FALSE; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // ------------------------------------------------------------------------------------------------------------------- | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |         return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static void main(String[] args) { | 
 |  |  |         SlaveProperties slaveProperties = new SlaveProperties(); | 
 |  |  |         slaveProperties.setDoubleDeep(true); | 
 |  |  |         slaveProperties.setGroupCount(2); | 
 |  |  |         System.out.println(getShallowLoc(slaveProperties, "3200101")); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取 深库位排对应的浅库位排 | 
 |  |  | 
 |  |  |         return zerofill(String.valueOf(row), 2) + zerofill(String.valueOf(bay), 3) + zerofill(String.valueOf(lev), 2); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static void main(String[] args) { | 
 |  |  |         System.out.println(JSON.toJSONString(getGroupOutsideLoc("0200101"))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // 外侧方向的货位  优先入库方向/优先出库方向 ===>> 反之 | 
 |  |  |     public static List<String> getGroupOutsideLoc(String locNo){ | 
 |  |  |         int row = getRow(locNo); | 
 |  |  |         List<String> result = new ArrayList<>(); | 
 |  |  |         if (SECOND_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |             for (Integer integer : SECOND_GROUP_ROW_LIST) { | 
 |  |  |                 if (integer < row) { | 
 |  |  |                     result.add(zerofill(String.valueOf(integer), 2) + locNo.substring(2)); | 
 |  |  |                 } else { | 
 |  |  |                     break; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } else if (FIRST_GROUP_ROW_LIST.contains(row)) { | 
 |  |  |             List<Integer> clone = Arrays.asList(new Integer[FIRST_GROUP_ROW_LIST.size()]); | 
 |  |  |             Collections.copy(clone, FIRST_GROUP_ROW_LIST); | 
 |  |  |             Collections.reverse(clone); | 
 |  |  |             for (Integer integer : clone) { | 
 |  |  |                 if (integer > row) { | 
 |  |  |                     result.add(zerofill(String.valueOf(integer), 2) + locNo.substring(2)); | 
 |  |  |                 } else { | 
 |  |  |                     break; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } else { | 
 |  |  | //            throw new RuntimeException("库位解析异常"); | 
 |  |  |         } | 
 |  |  |         if (!Cools.isEmpty(result)) { | 
 |  |  |             Collections.reverse(result); | 
 |  |  |         } | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |