| | |
| | | package com.zy.asrs.utils; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/27 |
| | |
| | | } |
| | | return msgBuilder.toString(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 通过排列层拼接出库位号 |
| | | */ |
| | | public static String append(int row, int bay, int lev) { |
| | | return zerofill(String.valueOf(row), 2) + zerofill(String.valueOf(bay), 3) + zerofill(String.valueOf(lev), 2); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 列 |
| | | */ |
| | | public static int getBay(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(2, 5)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 通过库位号获取 层 |
| | | */ |
| | | public static int getLev(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(5, 7)); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | |
| | | /** |
| | | * 当检索到双深库位的浅库位时,如果深库位无货,则放入对应的深库位 |
| | | */ |
| | | public static void toDeepIfEmptyByShallow(String shallowLoc) { |
| | |
| | | } |
| | | } |
| | | |
| | | public static Integer getInnermostRow(String locNo){ |
| | | int row = getRow(locNo); |
| | | switch (row) { |
| | | case 1: |
| | | case 2: |
| | | case 3: |
| | | return 1; |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | return 7; |
| | | case 8: |
| | | case 9: |
| | | case 10: |
| | | case 11: |
| | | return 8; |
| | | case 12: |
| | | case 13: |
| | | case 14: |
| | | return 14; |
| | | case 15: |
| | | case 16: |
| | | case 17: |
| | | case 18: |
| | | return 15; |
| | | case 19: |
| | | case 20: |
| | | case 21: |
| | | return 21; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static List<String> getGroupLoc(String locNo){ |
| | | int row = getRow(locNo); |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | switch (row) { |
| | | case 1: |
| | | case 2: |
| | | case 3: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(1), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(2), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(3), 2) + locNo.substring(2)); |
| | | }}; |
| | | list.add(zerofill(String.valueOf(1), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(2), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(3), 2) + locNo.substring(2)); |
| | | Collections.reverse(list); |
| | | return list; |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(4), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(6), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(7), 2) + locNo.substring(2)); |
| | | }}; |
| | | list.add(zerofill(String.valueOf(4), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(6), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(7), 2) + locNo.substring(2)); |
| | | return list; |
| | | case 8: |
| | | case 9: |
| | | case 10: |
| | | case 11: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(8), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(9), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(11), 2) + locNo.substring(2)); |
| | | }}; |
| | | list.add(zerofill(String.valueOf(8), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(9), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(11), 2) + locNo.substring(2)); |
| | | Collections.reverse(list); |
| | | return list; |
| | | case 12: |
| | | case 13: |
| | | case 14: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(12), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(13), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(14), 2) + locNo.substring(2)); |
| | | }}; |
| | | list.add(zerofill(String.valueOf(12), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(13), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(14), 2) + locNo.substring(2)); |
| | | return list; |
| | | case 15: |
| | | case 16: |
| | | case 17: |
| | | case 18: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(15), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(16), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(18), 2) + locNo.substring(2)); |
| | | }}; |
| | | list.add(zerofill(String.valueOf(15), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(16), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(18), 2) + locNo.substring(2)); |
| | | Collections.reverse(list); |
| | | return list; |
| | | case 19: |
| | | case 20: |
| | | case 21: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(19), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(20), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(21), 2) + locNo.substring(2)); |
| | | }}; |
| | | list.add(zerofill(String.valueOf(19), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(20), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(21), 2) + locNo.substring(2)); |
| | | return list; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | |
| | | add(19); |
| | | add(20); |
| | | add(21); |
| | | }}; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取内侧巷道库位组 |
| | | */ |
| | | public static List<String> getGroupInsideRoadwayLoc(String locNo){ |
| | | int row = getRow(locNo); |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | switch (row) { |
| | | case 1: |
| | | case 2: |
| | | case 3: |
| | | list.add(zerofill(String.valueOf(1), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(2), 2) + locNo.substring(2)); |
| | | Collections.reverse(list); |
| | | return list; |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | list.add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(6), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(7), 2) + locNo.substring(2)); |
| | | return list; |
| | | case 8: |
| | | case 9: |
| | | case 10: |
| | | case 11: |
| | | list.add(zerofill(String.valueOf(8), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(9), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | Collections.reverse(list); |
| | | return list; |
| | | case 12: |
| | | case 13: |
| | | case 14: |
| | | list.add(zerofill(String.valueOf(13), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(14), 2) + locNo.substring(2)); |
| | | return list; |
| | | case 15: |
| | | case 16: |
| | | case 17: |
| | | case 18: |
| | | list.add(zerofill(String.valueOf(15), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(16), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | Collections.reverse(list); |
| | | return list; |
| | | case 19: |
| | | case 20: |
| | | case 21: |
| | | list.add(zerofill(String.valueOf(20), 2) + locNo.substring(2)); |
| | | list.add(zerofill(String.valueOf(21), 2) + locNo.substring(2)); |
| | | return list; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | } |
| | | |
| | | // 获取库位前侧全部单品区域库位组(不包含最外侧库位高频区域) |
| | | public static List<String> getGroupOuterSingleLoc(String locNo){ |
| | | int row = getRow(locNo); |
| | | switch (row) { |
| | | case 1: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(2), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 2: |
| | | case 3: |
| | | return new ArrayList<>(); |
| | | case 4: |
| | | case 5: |
| | | return new ArrayList<>(); |
| | | case 6: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 7: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(6), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 8: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(9), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 9: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 10: |
| | | case 11: |
| | | return new ArrayList<>(); |
| | | case 12: |
| | | case 13: |
| | | return new ArrayList<>(); |
| | | case 14: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(13), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 15: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(16), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 16: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 17: |
| | | case 18: |
| | | return new ArrayList<>(); |
| | | case 19: |
| | | case 20: |
| | | return new ArrayList<>(); |
| | | case 21: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(20), 2) + locNo.substring(2)); |
| | | }}; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | } |
| | | |
| | | // 获取库位前侧全部低频区域库位组 |
| | | public static List<String> getGroupOuterSingleLocLowFrequency(String locNo){ |
| | | int row = getRow(locNo); |
| | | switch (row) { |
| | | case 1: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(3), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(2), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 2: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(3), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 3: |
| | | case 4: |
| | | return new ArrayList<>(); |
| | | case 5: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(4), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 6: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(4), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 7: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(4), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(6), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 8: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(11), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(9), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 9: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(11), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 10: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(11), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 11: |
| | | case 12: |
| | | return new ArrayList<>(); |
| | | case 13: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(12), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 14: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(12), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(13), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 15: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(18), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(16), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 16: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(18), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 17: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(18), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 18: |
| | | case 19: |
| | | return new ArrayList<>(); |
| | | case 20: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(19), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 21: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(19), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(20), 2) + locNo.substring(2)); |
| | | }}; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | |
| | | } |
| | | } |
| | | |
| | | public static List<String> getGroupOutsideLoc(String locNo){ |
| | | int row = getRow(locNo); |
| | | switch (row) { |
| | | case 1: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(2), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 2: |
| | | case 3: |
| | | case 4: |
| | | case 5: |
| | | return new ArrayList<>(); |
| | | case 6: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 7: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(6), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(5), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 8: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(9), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 9: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(10), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 10: |
| | | case 11: |
| | | case 12: |
| | | case 13: |
| | | return new ArrayList<>(); |
| | | case 14: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(13), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 15: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(16), 2) + locNo.substring(2)); |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 16: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(17), 2) + locNo.substring(2)); |
| | | }}; |
| | | case 17: |
| | | case 18: |
| | | case 19: |
| | | case 20: |
| | | return new ArrayList<>(); |
| | | case 21: |
| | | return new ArrayList<String>() {{ |
| | | add(zerofill(String.valueOf(20), 2) + locNo.substring(2)); |
| | | }}; |
| | | default: |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | } |
| | | |
| | | public Map<Integer, List<Integer>> getRowSeqHasSortOfPakin(int start, int end) { |
| | | Map<Integer, List<Integer>> result = new HashMap<>(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | //检测提交的出库库位是否合法(浅库位有非空库位) |
| | | public static void checkStockOutLocNo(List<String> locNos) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | //检测是否为浅库位 |
| | | boolean sign = false; |
| | | String th = ""; |
| | | for (String locNo : locNos) { |
| | | if (sign) { |
| | | break; |
| | | } |
| | | List<String> groupInsideLoc = Utils.getGroupOuterSingleLoc(locNo); |
| | | if (!Cools.isEmpty(groupInsideLoc)) { |
| | | for (String insideLoc : groupInsideLoc) { |
| | | if (locNos.contains(insideLoc)) { |
| | | break; |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", insideLoc)); |
| | | if (locMast != null) { |
| | | if (!locMast.getLocSts().equals("O") && !locMast.getLocSts().equals("R")) { |
| | | sign = true; |
| | | th = "库位号:" + locNo + " 浅库位有非空库位" + locMast.getLocNo() + "!"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (sign){ |
| | | throw new CoolException("出库失败;" + th); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 检测当前库位内侧其他库位是否为D、F、X |
| | | * 返回true表示内侧库位不是DFX,返回false表示内侧库位是DFX |
| | | */ |
| | | public static boolean checkInsideLocIsDFX(String locNo) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | List<String> insideLoc = Utils.getGroupInsideLoc(locNo); |
| | | if (insideLoc.size() > 0) { |
| | | List<LocMast> insideLocMast = locMastService.selectByLocNos(insideLoc); |
| | | for (LocMast mast : insideLocMast) { |
| | | if (!mast.getLocSts().equals("D") |
| | | && !mast.getLocSts().equals("F") |
| | | && !mast.getLocSts().equals("X")) { |
| | | //D、F、X(不能选定这个外侧库位) |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 检测当前库位外侧其他库位是否为O |
| | | * 返回true表示外侧库位是O,返回false表示内侧库位不是O |
| | | */ |
| | | public static boolean checkOutsideLocIsDFX(String locNo) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | List<String> insideLoc = Utils.getGroupOutsideLoc(locNo); |
| | | if (insideLoc.size() > 0) { |
| | | List<LocMast> insideLocMast = locMastService.selectByLocNos(insideLoc); |
| | | for (LocMast mast : insideLocMast) { |
| | | if (!mast.getLocSts().equals("O")) { |
| | | //!O(不能选定这个外侧库位) |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 检测当前库位内侧其他库位是否为D、F、X、O |
| | | * 返回true表示内侧库位不是DFX,返回false表示内侧库位是DFX |
| | | */ |
| | | public static boolean checkInsideLocIsDFXO(String locNo) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | List<String> insideLoc = Utils.getGroupInsideLoc(locNo); |
| | | if (insideLoc.size() > 0) { |
| | | List<LocMast> insideLocMast = locMastService.selectByLocNos(insideLoc); |
| | | for (LocMast mast : insideLocMast) { |
| | | if (!mast.getLocSts().equals("D") |
| | | && !mast.getLocSts().equals("F") |
| | | && !mast.getLocSts().equals("O") |
| | | && !mast.getLocSts().equals("X")) { |
| | | //D、F、X、O(不能选定这个外侧库位) |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 检测当前库位内侧其他库位是否为D、F、X、S |
| | | * 返回true表示内侧库位不是DFX,返回false表示内侧库位是DFX |
| | | */ |
| | | public static boolean checkInsideLocIsDFXS(String locNo) { |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | List<String> insideLoc = Utils.getGroupInsideLoc(locNo); |
| | | if (insideLoc.size() > 0) { |
| | | List<LocMast> insideLocMast = locMastService.selectByLocNos(insideLoc); |
| | | for (LocMast mast : insideLocMast) { |
| | | if (!mast.getLocSts().equals("D") |
| | | && !mast.getLocSts().equals("F") |
| | | && !mast.getLocSts().equals("X") |
| | | && !mast.getLocSts().equals("S")) { |
| | | //D、F、X、S(不能选定这个外侧库位) |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 随机获取可用且有空库位的堆垛机号 |
| | | */ |
| | | public static Integer getRandomCrnNo(List<Integer> crnNos, Short locType1) { |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | Random random = new Random(); |
| | | //可用堆垛机list |
| | | ArrayList<Integer> normalCrnNos = new ArrayList<>(); |
| | | for (Integer crnNo : crnNos) { |
| | | List<LocMast> emptyLocMast = locMastService.findEmptyLocMast(locType1, crnNo); |
| | | if (basCrnpService.checkSiteError(crnNo, true) && emptyLocMast.size() > 0) { |
| | | normalCrnNos.add(crnNo); |
| | | } |
| | | } |
| | | if (normalCrnNos.size() == 0) { |
| | | throw new CoolException("没有可用堆垛机"); |
| | | } |
| | | //随机可用堆垛机号 |
| | | Integer randomCrnNo = normalCrnNos.get(random.nextInt(normalCrnNos.size())); |
| | | return randomCrnNo; |
| | | } |
| | | |
| | | //public static void main(String[] args) { |
| | | // List<String> groupLoc = Utils.getGroupLoc("1300801"); |
| | | // System.out.println(groupLoc); |
| | | //} |
| | | |
| | | public static Double getIoPri(String locNo){ |
| | | switch (Utils.getRow(locNo)){ |
| | | case 3: |
| | | case 4: |
| | | case 11: |
| | | case 12: |
| | | case 18: |
| | | case 19: |
| | | return 21.0; |
| | | case 2: |
| | | case 5: |
| | | case 10: |
| | | case 13: |
| | | case 17: |
| | | case 20: |
| | | return 19.0; |
| | | case 1: |
| | | case 6: |
| | | case 9: |
| | | case 14: |
| | | case 16: |
| | | case 21: |
| | | return 17.0; |
| | | default: |
| | | return 15.0; |
| | | } |
| | | } |
| | | |
| | | public static List<String> getLocNosSort(List<String> locNos){ |
| | | List<String> locSort = new ArrayList<>(); |
| | | for (String loc : locNos){ |
| | | if (getIoPri(loc).equals(15.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | for (String loc : locNos){ |
| | | if (getIoPri(loc).equals(17.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | for (String loc : locNos){ |
| | | if (getIoPri(loc).equals(19.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | for (String loc : locNos){ |
| | | if (getIoPri(loc).equals(21.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | return locSort; |
| | | } |
| | | |
| | | public static List<StockOutParam.LocDetl> getStockOutParamLocDetlSort(List<StockOutParam.LocDetl> locNos){ |
| | | List<StockOutParam.LocDetl> locSort = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl loc : locNos){ |
| | | if (getIoPri(loc.getLocNo()).equals(15.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | for (StockOutParam.LocDetl loc : locNos){ |
| | | if (getIoPri(loc.getLocNo()).equals(17.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | for (StockOutParam.LocDetl loc : locNos){ |
| | | if (getIoPri(loc.getLocNo()).equals(19.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | for (StockOutParam.LocDetl loc : locNos){ |
| | | if (getIoPri(loc.getLocNo()).equals(21.0)){ |
| | | locSort.add(loc); |
| | | } |
| | | } |
| | | return locSort; |
| | | } |
| | | |
| | | public static boolean getLocNoWeighting(List<String> locNos,String locNo){ |
| | | boolean sign=false; |
| | | for (String loc : locNos){ |
| | | if (getBay(loc)==getBay(locNo) && getLev(loc)==getLev(locNo) && getRowWeighting(loc)==getRowWeighting(locNo)){ |
| | | sign = true; |
| | | break; |
| | | } |
| | | } |
| | | return sign; |
| | | } |
| | | |
| | | |
| | | public static int getRowWeighting(String locNo){ |
| | | switch (Utils.getRow(locNo)){ |
| | | case 1: |
| | | case 2: |
| | | case 3: |
| | | return 123; |
| | | case 4: |
| | | case 5: |
| | | case 6: |
| | | case 7: |
| | | return 456; |
| | | case 8: |
| | | case 9: |
| | | case 10: |
| | | case 11: |
| | | return 891011; |
| | | case 12: |
| | | case 13: |
| | | case 14: |
| | | return 121314; |
| | | case 15: |
| | | case 16: |
| | | case 17: |
| | | case 18: |
| | | return 15161718; |
| | | case 19: |
| | | case 20: |
| | | case 21: |
| | | case 22: |
| | | default: |
| | | return 19202122; |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | ArrayList<String> locS = new ArrayList<String>(); |
| | | locS.add("1902501"); |
| | | locS.add("2102501"); |
| | | locS.add("1802301"); |
| | | locS.add("1800101"); |
| | | locS.add("0300102"); |
| | | locS.add("0100102"); |
| | | List<String> innermostSideLoc = getInnermostSideLoc(locS, true); |
| | | System.out.println(innermostSideLoc); |
| | | } |
| | | |
| | | public static List<String> getInnermostSideLoc(List<String> locS, boolean pakin){ |
| | | ArrayList<String> listLoc = new ArrayList<>(); |
| | | ArrayList<String> listLocRBL = new ArrayList<>(); |
| | | for (String locNo : locS){ |
| | | if (!listLocRBL.contains(Utils.getInnermostSideLocRBL(locNo, pakin))){ |
| | | listLocRBL.add(Utils.getInnermostSideLocRBL(locNo, pakin)); |
| | | listLoc.add(locNo); |
| | | }else { |
| | | for (String loc1 : listLoc){ |
| | | if (Utils.getInnermostSideLocRBL(locNo, pakin).equals(Utils.getInnermostSideLocRBL(loc1, pakin))){ |
| | | if (!pakin){ |
| | | if (Utils.getRow(loc1)>17 && Utils.getRow(locNo)>Utils.getRow(loc1) ){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | }else if ( Utils.getRow(loc1)<18 && Utils.getRow(locNo)<Utils.getRow(loc1)){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } |
| | | }else { |
| | | if ( Utils.getRow(loc1)<4 && Utils.getRow(locNo)>Utils.getRow(loc1)){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } else if (Utils.getRow(loc1)>3 && Utils.getRow(loc1)<8 && Utils.getRow(locNo)<Utils.getRow(loc1) ){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } else if (Utils.getRow(loc1)>7 && Utils.getRow(loc1)<12 && Utils.getRow(locNo)>Utils.getRow(loc1) ){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } else if (Utils.getRow(loc1)>11 && Utils.getRow(loc1)<15 && Utils.getRow(locNo)<Utils.getRow(loc1) ){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } else if (Utils.getRow(loc1)>14 && Utils.getRow(loc1)<19 && Utils.getRow(locNo)>Utils.getRow(loc1) ){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } else if ( Utils.getRow(loc1)>18 && Utils.getRow(locNo)<Utils.getRow(loc1)){ |
| | | listLoc.remove(loc1); |
| | | listLoc.add(locNo); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return listLoc; |
| | | } |
| | | |
| | | public static String getInnermostSideLocRBL(String locNo, boolean pakin){ |
| | | int row = Utils.getRow(locNo); |
| | | if (row <= 3) { |
| | | row = 3; |
| | | } else if (row <= 7) { |
| | | row = 4; |
| | | } else if (row <= 11) { |
| | | row = 11; |
| | | } else if (row <= 14) { |
| | | row = 12; |
| | | } else if (row <= 18) { |
| | | row = 18; |
| | | } else { |
| | | row = 19; |
| | | } |
| | | return ""+row+Utils.getBay(locNo)+Utils.getLev(locNo); |
| | | |
| | | //if (row <3){ |
| | | // return ""+33+Utils.getBay(locNo)+Utils.getLev(locNo); |
| | | //}else if (row>30){ |
| | | // return ""+31+Utils.getBay(locNo)+Utils.getLev(locNo); |
| | | //} |
| | | //if (row<18 && row>1){ |
| | | // row=1; |
| | | //}else if (row < 31 && row>17){ |
| | | // row=2; |
| | | //} |
| | | //if (pakin){ |
| | | // row=3-row; |
| | | //} |
| | | //return ""+row+Utils.getBay(locNo)+Utils.getLev(locNo); |
| | | |
| | | } |
| | | } |