| | |
| | | import com.vincent.rsf.server.manager.entity.DeviceBind; |
| | | import com.vincent.rsf.server.manager.entity.Loc; |
| | | import com.vincent.rsf.server.manager.service.DeviceBindService; |
| | | import com.vincent.rsf.server.manager.service.LocService; |
| | | |
| | | |
| | | import java.util.List; |
| | |
| | | * 获取 浅库位对应的深库位号 |
| | | */ |
| | | public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) { |
| | | int row = getRow(shallowLoc); |
| | | int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount()); |
| | | int targetRow; |
| | | if (remainder == 2) { |
| | | targetRow = row - 1; |
| | | } else if (remainder == 3) { |
| | | targetRow = row + 1; |
| | | } else { |
| | | throw new CoolException(shallowLoc + "不是浅库位,系统繁忙"); |
| | | LocService locService = SpringUtils.getBean(LocService.class); |
| | | Loc shaLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); |
| | | int row = shaLoc.getRow()-1; |
| | | boolean contains = slaveProperties.getDoubleLocs().contains(row); |
| | | Loc deepLoc = null; |
| | | if (contains) { |
| | | deepLoc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getAreaId, shaLoc.getAreaId()) |
| | | .eq(Loc::getRow, row) |
| | | .eq(Loc::getCol, shaLoc.getCol()) |
| | | .eq(Loc::getLev, shaLoc.getLev()) |
| | | ); |
| | | }else { |
| | | deepLoc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getAreaId, shaLoc.getAreaId()) |
| | | .eq(Loc::getRow, shaLoc.getRow()+1) |
| | | .eq(Loc::getCol, shaLoc.getCol()) |
| | | .eq(Loc::getLev, shaLoc.getLev()) |
| | | ); |
| | | } |
| | | return zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2); |
| | | return deepLoc.getCode(); |
| | | } |
| | | |
| | | /** |
| | | * 获取 深库位对应的浅库位号 |
| | | */ |
| | | public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) { |
| | | int row = getRow(deepLoc); |
| | | int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount()); |
| | | int shallowRow = remainder == 1 ? (row + 1) : (row - 1); |
| | | return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2); |
| | | LocService locService = SpringUtils.getBean(LocService.class); |
| | | Loc depLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, deepLoc)); |
| | | int row = depLoc.getRow()-1; |
| | | boolean contains = slaveProperties.getDoubleLocs().contains(row); |
| | | Loc shallowLoc = null; |
| | | if (!contains) { |
| | | shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getAreaId, depLoc.getAreaId()) |
| | | .eq(Loc::getRow, row) |
| | | .eq(Loc::getCol, depLoc.getCol()) |
| | | .eq(Loc::getLev, depLoc.getLev()) |
| | | ); |
| | | }else { |
| | | shallowLoc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getAreaId, depLoc.getAreaId()) |
| | | .eq(Loc::getRow, depLoc.getRow()+1) |
| | | .eq(Loc::getCol, depLoc.getCol()) |
| | | .eq(Loc::getLev, depLoc.getLev()) |
| | | ); |
| | | } |
| | | return shallowLoc.getCode(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static int getRow(String locNo) { |
| | | if (!Cools.isEmpty(locNo)) { |
| | | return Integer.parseInt(locNo.substring(0, 2)); |
| | | LocService locService = SpringUtils.getBean(LocService.class); |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, locNo)); |
| | | if (null == loc) { |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |
| | | return loc.getRow(); |
| | | } |
| | | throw new RuntimeException("库位解析异常"); |
| | | } |