feat(库位信息): 根据层数获取库位信息
This commit is contained in:
parent
88030f5ae6
commit
57ab5d0df1
|
|
@ -30,6 +30,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* WMS库位控制类
|
||||
|
|
@ -56,6 +57,7 @@ public class LocationController extends BaseController {
|
|||
private final HttpServletRequest servletRequest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询库位
|
||||
*
|
||||
|
|
@ -70,8 +72,7 @@ public class LocationController extends BaseController {
|
|||
try {
|
||||
// 查询出所有符合条件的库位
|
||||
Location location1 = new Location();
|
||||
//location1.setLocationId("A11-15-2");
|
||||
//location1.setWareArea("A");
|
||||
location1.setLayer(location.getLayer());
|
||||
location1.setAreaId(2);
|
||||
List<Location> locations = locationService.selLocations(location1);
|
||||
if (locations.isEmpty()) {
|
||||
|
|
@ -81,37 +82,35 @@ public class LocationController extends BaseController {
|
|||
rsp.setMessage("查询库位发生错误:库位不存在");
|
||||
return JSON.toJSONString(rsp);
|
||||
}
|
||||
List<RowLocation> rowLocations = new LinkedList<>();
|
||||
// 查找到最大的排
|
||||
locations.sort(Comparator.comparing(Location::getQueue).reversed());
|
||||
int maxRow = locations.get(0).getQueue();
|
||||
// 按排查找库位
|
||||
for (int i = 0; i < maxRow; i++) {
|
||||
int finalI = i;
|
||||
List<RowLocation> rowLocations = new ArrayList<>();
|
||||
// 查找所有排
|
||||
List<Integer> queueList = locations.stream().map(l -> l.getQueue()).distinct().sorted().toList();
|
||||
|
||||
|
||||
for (Integer queue : queueList) {
|
||||
// 当前排信息
|
||||
List<Location> currentRowLocations = new ArrayList<>(locations.stream()
|
||||
.filter(l -> l.getQueue().equals(finalI + 1))
|
||||
.filter(l -> l.getQueue().equals(queue))
|
||||
.toList());
|
||||
// 先查找每一层的库位
|
||||
// 当前排的层数
|
||||
List<Integer> lineList = currentRowLocations.stream().map(l -> l.getLine()).distinct().sorted().toList();
|
||||
// 先查找每一列的库位
|
||||
List<LayerLocation> layerLocations = new LinkedList<>();
|
||||
// 找到这一排最大的层
|
||||
currentRowLocations.sort(Comparator.comparing(Location::getLayer).reversed());
|
||||
int maxLayer = currentRowLocations.get(0).getLayer();
|
||||
// 按照每一列查找库位
|
||||
for (int j = 0; j < maxLayer; j++) {
|
||||
int finalJ = j;
|
||||
for (Integer line : lineList ) {
|
||||
List<Location> currentLayerLocations = currentRowLocations.stream()
|
||||
.filter(l -> l.getLayer().equals(finalJ + 1))
|
||||
.filter(l -> l.getLine().equals(line))
|
||||
.toList();
|
||||
LayerLocation tempLayerLocation = new LayerLocation();
|
||||
tempLayerLocation.setLayer(finalJ + 1);
|
||||
tempLayerLocation.setLayer(line);
|
||||
tempLayerLocation.setCurrentColLocations(currentLayerLocations);
|
||||
layerLocations.add(tempLayerLocation);
|
||||
}
|
||||
RowLocation tempRowLocation = new RowLocation();
|
||||
tempRowLocation.setRow(finalI + 1);
|
||||
tempRowLocation.setRow(queue);
|
||||
tempRowLocation.setCurrentLayerLocations(layerLocations);
|
||||
rowLocations.add(tempRowLocation);
|
||||
}
|
||||
|
||||
logger.info("查询库位数据成功,库区:{}", location.getAreaId());
|
||||
// 设置最终数据
|
||||
rsp.setReturnData(rowLocations);
|
||||
|
|
@ -128,6 +127,78 @@ public class LocationController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 查询库位
|
||||
// *
|
||||
// * @param location 查询参数
|
||||
// * @return 结果
|
||||
// */
|
||||
// @PostMapping("/getLocations")
|
||||
// @ResponseBody
|
||||
// public String getLocations(@RequestBody Location location) {
|
||||
// // 创建响应信息
|
||||
// ResponseEntity rsp = new ResponseEntity();
|
||||
// try {
|
||||
// // 查询出所有符合条件的库位
|
||||
// Location location1 = new Location();
|
||||
// //location1.setLocationId("A11-15-2");
|
||||
// //location1.setWareArea("A");
|
||||
// location1.setAreaId(2);
|
||||
// List<Location> locations = locationService.selLocations(location1);
|
||||
// if (locations.isEmpty()) {
|
||||
// logger.error("查询库位发生错误:库位不存在");
|
||||
// // 返回错误
|
||||
// rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
// rsp.setMessage("查询库位发生错误:库位不存在");
|
||||
// return JSON.toJSONString(rsp);
|
||||
// }
|
||||
// List<RowLocation> rowLocations = new LinkedList<>();
|
||||
// // 查找到最大的排
|
||||
// locations.sort(Comparator.comparing(Location::getQueue).reversed());
|
||||
// int maxRow = locations.get(0).getQueue();
|
||||
// // 按排查找库位
|
||||
// for (int i = 0; i < maxRow; i++) {
|
||||
// int finalI = i;
|
||||
// List<Location> currentRowLocations = new ArrayList<>(locations.stream()
|
||||
// .filter(l -> l.getQueue().equals(finalI + 1))
|
||||
// .toList());
|
||||
// // 先查找每一层的库位
|
||||
// List<LayerLocation> layerLocations = new LinkedList<>();
|
||||
// // 找到这一排最大的层
|
||||
// currentRowLocations.sort(Comparator.comparing(Location::getLayer).reversed());
|
||||
// int maxLayer = currentRowLocations.get(0).getLayer();
|
||||
// // 按照每一列查找库位
|
||||
// for (int j = 0; j < maxLayer; j++) {
|
||||
// int finalJ = j;
|
||||
// List<Location> currentLayerLocations = currentRowLocations.stream()
|
||||
// .filter(l -> l.getLayer().equals(finalJ + 1))
|
||||
// .toList();
|
||||
// LayerLocation tempLayerLocation = new LayerLocation();
|
||||
// tempLayerLocation.setLayer(finalJ + 1);
|
||||
// tempLayerLocation.setCurrentColLocations(currentLayerLocations);
|
||||
// layerLocations.add(tempLayerLocation);
|
||||
// }
|
||||
// RowLocation tempRowLocation = new RowLocation();
|
||||
// tempRowLocation.setRow(finalI + 1);
|
||||
// tempRowLocation.setCurrentLayerLocations(layerLocations);
|
||||
// rowLocations.add(tempRowLocation);
|
||||
// }
|
||||
// logger.info("查询库位数据成功,库区:{}", location.getAreaId());
|
||||
// // 设置最终数据
|
||||
// rsp.setReturnData(rowLocations);
|
||||
// // 返回成功
|
||||
// rsp.setCode(ResponseCode.OK.getCode());
|
||||
// rsp.setMessage("查询库位成功");
|
||||
// return JSON.toJSONString(rsp);
|
||||
// } catch (Exception e) {
|
||||
// logger.info("查询库位发生错误:{}", e.getMessage());
|
||||
// // 返回其他异常
|
||||
// rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
// rsp.setMessage(e.getMessage());
|
||||
// return JSON.toJSONString(rsp);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 更新库位状态
|
||||
*
|
||||
|
|
@ -171,7 +242,7 @@ public class LocationController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 更新库位状态
|
||||
* 查询空闲可用库位
|
||||
*
|
||||
* @param location 库位
|
||||
* @return 结果
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user