Commit f505cdf3 zshaohui

odn出货,新功能修改

1 个父辈 5c03f747
......@@ -74,23 +74,24 @@ public class OdnCheckOutNewController {
@ApiOperation("获取odn要出库的箱子")
@RequestMapping("/getOdnCheckOutBox")
@AnonymousAccess
public ResultBean getOdnCheckOutBox(@RequestBody Map<String, String> paramMap) {
public ResultBean getOdnCheckOutBox(@RequestBody Map<String, String> paramMap) {
log.info("收到odn出库信息为:" + JSON.toJSONString(paramMap));
//判断有没有正在执行的任务
if (StringUtils.isNotEmpty(liteOrderCache.hasExecutingOrder())) {
//throw new ValidateException("","有正在执行的工单,不允许恢复");
return ResultBean.newErrorResult(-1, "", "有正在执行的工单" + liteOrderCache.hasExecutingOrder() + ",请确认");
}
//判断odn单号是否为空
String odn = paramMap.get("odn");
if (StringUtils.isEmpty(odn)) {
return ResultBean.newErrorResult(-1, "", "odn单号不能为空");
}
List<String> palletIdList = new ArrayList<>();
//解析手动输入的栈板id
List<String> inputPalletIdList = new ArrayList<>();
String palletIdListStr = paramMap.get("palletList");
if (StringUtils.isNotEmpty(palletIdListStr)) {
palletIdList = JSONObject.parseArray(palletIdListStr, String.class);
inputPalletIdList = JSONObject.parseArray(palletIdListStr, String.class);
inputPalletIdList = inputPalletIdList.stream().distinct().collect(Collectors.toList());
}
//判断odn是否存在
......@@ -102,67 +103,84 @@ public class OdnCheckOutNewController {
liteOrder = odnInfoToLiteOrder(odn);
}
//获取hold库位
List<String> holdPosIdList = liteOrderCache.getHoldPosIdList(liteOrder);
//List<String> holdPosIdList = new ArrayList<>();
//判断输入的栈板号是否符合条件
List<StoragePos> storagePosList = new ArrayList<>();
if (palletIdList != null && !palletIdList.isEmpty()) {
storagePosList = findPosByPalletId(palletIdList, liteOrder,holdPosIdList);
//获取人员手动输入栈板id,对应的库位
List<StoragePos> inPutStoragePosList = new ArrayList<>();
if (inputPalletIdList != null && !inputPalletIdList.isEmpty()) {
inPutStoragePosList = findPosByPalletId(inputPalletIdList, liteOrder, holdPosIdList);
}
//开始循环处理数据
List<String> excludePosIdList = new ArrayList<>();
for (LiteOrderItem orderItem : liteOrder.getOrderItems()) {
int targetNum = orderItem.getNeedNum() - orderItem.getTotalOutNum();
if (targetNum <= 0){
if (targetNum <= 0) {
continue;
}
Collection<String> excludeOutPosIds = liteOrderCache.excludeOutPosIds();
if (excludePosIdList != null && !excludePosIdList.isEmpty()) {
excludeOutPosIds.addAll(excludePosIdList);
}
if (holdPosIdList != null && !holdPosIdList.isEmpty()){
excludeOutPosIds.addAll(holdPosIdList);
}
List<StoragePos> needOutPosList = new ArrayList<>();
String pn = orderItem.getPn();
String warehouseCode = orderItem.getWarehouseCode();
//获取符合条件的pn
List<StoragePos> dbStoragePosList = storagePosManager.findOdnCalculatePos(pn, warehouseCode, excludeOutPosIds);
if (dbStoragePosList == null) {
dbStoragePosList = new ArrayList<>();
}
if (storagePosList != null && !storagePosList.isEmpty()) {
dbStoragePosList.addAll(storagePosList);
}
//去重
if (dbStoragePosList == null || dbStoragePosList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "料号:" + pn + "库别:" + warehouseCode + "库存中未找到料箱");
}
Map<String, StoragePos> collect = dbStoragePosList.stream().collect(Collectors.toMap(StoragePos::getId, storagePos -> storagePos, (existing, replacement) -> existing));
dbStoragePosList = new ArrayList<>(collect.values());
List<StoragePos> combinationsPosList = CalculateUtil.findCombinationsByPos(dbStoragePosList, targetNum);
if (combinationsPosList == null || combinationsPosList.isEmpty()){
return ResultBean.newErrorResult(-1,"","料号:" + pn +"库别:"+warehouseCode+"库存中未找到对应的组合数据");
if (inPutStoragePosList != null && !inPutStoragePosList.isEmpty()) {
for (StoragePos pos : inPutStoragePosList) {
Barcode barcode = pos.getBarcode();
if (barcode.getPartNumber().equals(pn) && warehouseCode.equals(barcode.getWarehouseCode())) {
needOutPosList.add(pos);
}
}
}
//加载orderItem中
for (StoragePos pos : combinationsPosList) {
excludePosIdList.add(pos.getId());
if (needOutPosList != null && !needOutPosList.isEmpty()) {
List<Barcode> barcodeList = needOutPosList.stream().map(StoragePos::getBarcode).collect(Collectors.toList());
int count = barcodeList.stream().collect(Collectors.summingInt(Barcode::getQty));
if (count > targetNum) {
throw new ValidateException("", "手动输入的料箱号数量为:" + count + "大于实际需要的数量:" + targetNum + "料号为:" + pn + "库别为:" + warehouseCode);
}
targetNum = (targetNum - count);
}
if (targetNum > 0) {
Collection<String> excludeOutPosIds = liteOrderCache.excludeOutPosIds();
if (excludePosIdList != null && !excludePosIdList.isEmpty()) {
excludeOutPosIds.addAll(excludePosIdList);
}
if (needOutPosList != null && !needOutPosList.isEmpty()) {
for (StoragePos pos : needOutPosList) {
excludeOutPosIds.add(pos.getId());
}
}
if (holdPosIdList != null && !holdPosIdList.isEmpty()) {
excludeOutPosIds.addAll(holdPosIdList);
}
//获取符合条件的pn
List<StoragePos> dbStoragePosList = storagePosManager.findOdnCalculatePos(pn, warehouseCode, excludeOutPosIds);
if (dbStoragePosList == null) {
dbStoragePosList = new ArrayList<>();
}
if (dbStoragePosList == null || dbStoragePosList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "料号:" + pn + "库别:" + warehouseCode + "库存中未找到料箱");
}
List<StoragePos> combinationsPosList = CalculateUtil.findCombinationsByPos(dbStoragePosList, targetNum);
if (combinationsPosList == null || combinationsPosList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "料号:" + pn + "库别:" + warehouseCode + "库存中未找到对应的组合数据");
}
for (StoragePos pos : combinationsPosList) {
excludePosIdList.add(pos.getId());
needOutPosList.add(pos);
}
}
List<Barcode> needOutBarcodeList = new ArrayList<>();
for (StoragePos pos : combinationsPosList) {
for (StoragePos pos : needOutPosList) {
String posName = pos.getPosName();
Barcode barcode = pos.getBarcode();
barcode.setPosName(posName);
needOutBarcodeList.add(barcode);
log.info(barcode.getBarcode()+"------"+barcode.getPalletId());
}
orderItem.setNeedOutBarcodeList(needOutBarcodeList);
}
return ResultBean.newOkResult(liteOrder);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!