From f5df33d51a8555d709a4e8369fa98ce70759ddfc Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期一, 17 十一月 2025 13:39:17 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs | 471 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 446 insertions(+), 25 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs"
index 06a4835..159cba4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs"
@@ -1,6 +1,7 @@
锘縰sing Dm.filter;
using MailKit.Search;
using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -10,10 +11,12 @@
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
+using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Basic;
using WIDESEA_DTO.Outbound;
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
@@ -39,9 +42,26 @@
private readonly IOutboundOrderService _outboundOrderService;
private readonly ISplitPackageService _splitPackageService;
private readonly IRepository<Dt_Task> _taskRepository;
+ private readonly IESSApiService _eSSApiService;
- public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, IRepository<Dt_Task> taskRepository) : base(BaseDal)
+ private readonly ILogger<OutboundPickingService> _logger;
+
+ private Dictionary<string, string> stations = new Dictionary<string, string>
+ {
+ {"2-1","2-9" },
+ {"3-1","3-9" },
+
+ };
+
+ private Dictionary<string, string> movestations = new Dictionary<string, string>
+ {
+ {"2-1","2-5" },
+ {"3-1","3-5" },
+
+ };
+
+ public OutboundPickingService(IRepository<Dt_PickingRecord> BaseDal, IUnitOfWorkManage unitOfWorkManage, IStockInfoService stockInfoService, IStockService stockService, IOutStockLockInfoService outStockLockInfoService, IStockInfoDetailService stockInfoDetailService, ILocationInfoService locationInfoService, IOutboundOrderDetailService outboundOrderDetailService, ISplitPackageService splitPackageService, IOutboundOrderService outboundOrderService, IRepository<Dt_Task> taskRepository, IESSApiService eSSApiService, ILogger<OutboundPickingService> logger) : base(BaseDal)
{
_unitOfWorkManage = unitOfWorkManage;
_stockInfoService = stockInfoService;
@@ -53,6 +73,8 @@
_splitPackageService = splitPackageService;
_outboundOrderService = outboundOrderService;
_taskRepository = taskRepository;
+ _eSSApiService = eSSApiService;
+ _logger = logger;
}
@@ -224,9 +246,29 @@
.FirstAsync();
if (lockInfo == null)
- throw new Exception($"鏉$爜{barcode}涓嶅睘浜庢墭鐩榹palletCode}鎴栦笉瀛樺湪寰呭垎鎷h褰�");
+ {
+ var splitBarcode = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
+ .Where(it => it.NewBarcode == barcode && it.Status == 1)
+ .FirstAsync();
+ if (splitBarcode != null)
+ {
+ // 閫氳繃鎷嗗寘鏉$爜璁板綍鎵惧埌瀵瑰簲鐨勫嚭搴撻攣瀹氳褰�
+ lockInfo = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.ParentLockId == splitBarcode.OutStockLockInfoId)
+ .FirstAsync();
+ if (lockInfo == null)
+ throw new Exception($"鏈壘鍒版媶鍖呮潯鐮亄barcode}瀵瑰簲鐨勫嚭搴撻攣瀹氳褰�");
+ }
+ else
+ {
+ throw new Exception($"鏉$爜{barcode}涓嶅睘浜庢墭鐩榹palletCode}鎴栦笉瀛樺湪寰呭垎鎷h褰�");
+ }
+
+ }
+ if (lockInfo.PalletCode != palletCode)
+ throw new Exception($"鏉$爜{barcode}涓嶅睘浜庢墭鐩榹palletCode}");
var stockDetail = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
.Where(x => x.Barcode == barcode && x.StockId == lockInfo.StockId)
@@ -247,13 +289,22 @@
lockInfo.Status = (int)OutLockStockStatusEnum.鎷i�夊畬鎴�;
await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
+ var splitBarcodeRecord = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
+ .Where(it => it.NewBarcode == barcode)
+ .FirstAsync();
+
+ if (splitBarcodeRecord != null)
+ {
+ splitBarcodeRecord.Status = 2;
+ await _splitPackageService.Db.Updateable(splitBarcodeRecord).ExecuteCommandAsync();
+ }
await _outboundOrderDetailService.Db.Updateable<Dt_OutboundOrderDetail>()
.SetColumns(it => it.PickedQty == it.PickedQty + actualQty)
.Where(it => it.Id == lockInfo.OrderDetailId)
.ExecuteCommandAsync();
-
+
await CheckAndUpdateOrderStatus(orderNo);
//鏌ヨ浠诲姟琛�
@@ -313,6 +364,395 @@
.ExecuteCommandAsync();
}
}
+
+
+ /// <summary>
+ /// 鍥炲簱鎿嶄綔
+ /// </summary>
+ //public async Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason)
+ //{
+ // try
+ // {
+ // // 1. 鑾峰彇鎵�鏈夋湭鍒嗘嫞鐨勫嚭搴撻攣瀹氳褰曪紝鍖呮嫭鎷嗗寘浜х敓鐨勮褰�
+ // var remainingLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ // .Where(it => it.OrderNo == orderNo && it.Status == 1)
+ // .ToListAsync();
+
+ // if (!remainingLocks.Any())
+ // {
+ // return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖搴撶殑鍓╀綑璐х墿");
+ // }
+ // var tasks = new List<Dt_Task>();
+ // // 鎸夋墭鐩樺垎缁�
+ // var palletGroups = remainingLocks.GroupBy(x => x.PalletCode);
+ // //鏌ヨ浠诲姟琛�
+ // var task = _taskRepository.QueryData(x => x.TaskNum == remainingLocks.First().TaskNum).FirstOrDefault();
+ // foreach (var group in palletGroups)
+ // {
+ // if (group.Key == palletCode)
+ // {
+ // var totalReturnQty = group.Sum(x => x.AssignQuantity - x.PickedQty);
+
+ // if (totalReturnQty <= 0) continue;
+
+ // // 鍒嗛厤鏂拌揣浣�
+ // var newLocation = _locationInfoService.AssignLocation();
+
+ // // 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵��
+ // var lockIds = group.Where(x => x.PalletCode == palletCode).Select(x => x.Id).ToList();
+ // await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>()
+ // .SetColumns(it => new Dt_OutStockLockInfo { Status = OutLockStockStatusEnum.鍥炲簱涓�.ObjToInt() })
+ // .Where(it => lockIds.Contains(it.Id))
+ // .ExecuteCommandAsync();
+
+ // // 鏇存柊鎷嗗寘鏉$爜璁板綍鐘舵��
+ // var splitBarcodes = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
+ // .Where(it => lockIds.Contains(it.OutStockLockInfoId))
+ // .ToListAsync();
+
+ // foreach (var splitBarcode in splitBarcodes)
+ // {
+ // splitBarcode.Status = 3;
+ // await _splitPackageService.Db.Updateable(splitBarcode).ExecuteCommandAsync();
+ // }
+
+ // foreach (var lockInfo in group)
+ // {
+ // if (lockInfo.PalletCode == palletCode)
+ // {
+ // decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
+
+ // // 妫�鏌ュ簱瀛樿褰曟槸鍚﹀瓨鍦�
+ // var existingStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ // .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
+ // .FirstAsync();
+
+ // if (existingStock != null)
+ // {
+ // // 搴撳瓨璁板綍瀛樺湪锛屾仮澶嶉攣瀹氭暟閲�
+ // await _stockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
+ // .SetColumns(it => new Dt_StockInfoDetail
+ // {
+ // OutboundQuantity = it.OutboundQuantity - returnQty
+ // })
+ // .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
+ // .ExecuteCommandAsync();
+ // }
+ // else
+ // {
+ // // 搴撳瓨璁板綍涓嶅瓨鍦紙鍙兘鏄媶鍖呬骇鐢熺殑鏂版潯鐮侊級锛屽垱寤烘柊鐨勫簱瀛樿褰�
+ // var newStockDetail = new Dt_StockInfoDetail
+ // {
+ // StockId = lockInfo.StockId,
+ // MaterielCode = lockInfo.MaterielCode,
+ // OrderNo = lockInfo.OrderNo,
+ // BatchNo = lockInfo.BatchNo,
+ // StockQuantity = returnQty, // 瀹為檯搴撳瓨鏁伴噺
+ // OutboundQuantity = 0, // 鍥炲簱鍚庝笉鍐嶉攣瀹�
+ // Barcode = lockInfo.CurrentBarcode,
+ // InboundOrderRowNo = "0",
+ // Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+
+ // };
+ // await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
+ // }
+ // }
+ // }
+
+
+ // Dt_Task newtask = new()
+ // {
+ // CurrentAddress = stations[task.TargetAddress],
+ // Grade = 0,
+ // PalletCode = palletCode,
+ // NextAddress = "",
+ // OrderNo= task.OrderNo,
+ // Roadway = newLocation.RoadwayNo,
+ // SourceAddress = stations[task.TargetAddress],
+ // TargetAddress = newLocation.LocationCode,
+ // TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ // TaskType = TaskTypeEnum.InPick.ObjToInt(),
+ // // TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ // PalletType = task.PalletType,
+ // WarehouseId = task.WarehouseId,
+ // };
+ // tasks.Add(newtask);
+
+ // }
+ // }
+ // try
+ // {
+ // await _taskRepository.Db.Insertable(tasks).ExecuteCommandAsync();
+ // //鍒犻櫎 鍑哄簱鐨� task
+
+
+ // //缁� ess 娴佸姩淇″彿 鍜屽垱寤轰换鍔�
+
+
+ // }
+ // catch (Exception ex)
+ // {
+
+ // }
+
+
+
+
+ // return WebResponseContent.Instance.OK();
+ // }
+ // catch (Exception ex)
+ // {
+ // return WebResponseContent.Instance.Error($"鍥炲簱鎿嶄綔澶辫触: {ex.Message}");
+ // }
+ //}
+
+ public async Task<WebResponseContent> ReturnRemaining(string orderNo, string palletCode, string reason)
+ {
+ try
+ {
+ // 1. 鑾峰彇鎵�鏈夋湭鍒嗘嫞鐨勫嚭搴撻攣瀹氳褰曪紝鍖呮嫭鎷嗗寘浜х敓鐨勮褰�
+ var remainingLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.OrderNo == orderNo && it.Status == 1)
+ .ToListAsync();
+
+ var stockinfo = _stockInfoService.Db.Queryable<Dt_StockInfo>().First(x => x.PalletCode == palletCode);
+
+ // 2. 妫�鏌ユ墭鐩樹笂鏄惁鏈夊叾浠栭潪鍑哄簱璐х墿锛堝簱瀛樿揣鐗╋級
+ var palletStockGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(it => it.StockId == stockinfo.Id && it.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt())
+ .Where(it => it.OutboundQuantity == 0 || it.OutboundQuantity < it.StockQuantity) // 鏈畬鍏ㄥ嚭搴撶殑
+ .ToListAsync();
+
+ // 3. 濡傛灉娌℃湁闇�瑕佸洖搴撶殑璐х墿锛堟棦鏃犳湭鍒嗘嫞鍑哄簱璐х墿锛屼篃鏃犲叾浠栧簱瀛樿揣鐗╋級
+ if (!remainingLocks.Any() && !palletStockGoods.Any())
+ {
+ return WebResponseContent.Instance.Error("娌℃湁闇�瑕佸洖搴撶殑鍓╀綑璐х墿");
+ }
+
+ var tasks = new List<Dt_Task>();
+
+ // 鏌ヨ浠诲姟琛�
+ var task = remainingLocks.Any()
+ ? _taskRepository.QueryData(x => x.TaskNum == remainingLocks.First().TaskNum).FirstOrDefault()
+ : _taskRepository.QueryData(x => x.PalletCode == palletCode).FirstOrDefault();
+
+ if (task == null)
+ {
+ return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟淇℃伅");
+ }
+ var firstlocation = _locationInfoService.Db.Queryable<Dt_LocationInfo>().First(x => x.LocationCode == task.SourceAddress);
+ decimal totalReturnQty = 0;
+ var hasRemainingLocks = remainingLocks.Any(x => x.PalletCode == palletCode);
+
+ // 鎯呭喌1锛氬鐞嗘湭鍒嗘嫞鐨勫嚭搴撻攣瀹氳褰�
+ if (hasRemainingLocks)
+ {
+ var palletLocks = remainingLocks.Where(x => x.PalletCode == palletCode).ToList();
+ totalReturnQty = palletLocks.Sum(x => x.AssignQuantity - x.PickedQty);
+
+ if (totalReturnQty > 0)
+ {
+ // 鍒嗛厤鏂拌揣浣�
+ var newLocation = _locationInfoService.AssignLocation(firstlocation.LocationType);
+
+ // 鏇存柊鍑哄簱閿佸畾璁板綍鐘舵��
+ var lockIds = palletLocks.Select(x => x.Id).ToList();
+ await _outStockLockInfoService.Db.Updateable<Dt_OutStockLockInfo>()
+ .SetColumns(it => new Dt_OutStockLockInfo { Status = OutLockStockStatusEnum.鍥炲簱涓�.ObjToInt() })
+ .Where(it => lockIds.Contains(it.Id))
+ .ExecuteCommandAsync();
+
+ // 鏇存柊鎷嗗寘鏉$爜璁板綍鐘舵��
+ var splitBarcodes = await _splitPackageService.Db.Queryable<Dt_SplitPackageRecord>()
+ .Where(it => lockIds.Contains(it.OutStockLockInfoId))
+ .ToListAsync();
+
+ foreach (var splitBarcode in splitBarcodes)
+ {
+ splitBarcode.Status = 3;
+ await _splitPackageService.Db.Updateable(splitBarcode).ExecuteCommandAsync();
+ }
+
+ // 澶勭悊搴撳瓨璁板綍
+ foreach (var lockInfo in palletLocks)
+ {
+ decimal returnQty = lockInfo.AssignQuantity - lockInfo.PickedQty;
+
+ // 妫�鏌ュ簱瀛樿褰曟槸鍚﹀瓨鍦�
+ var existingStock = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
+ .FirstAsync();
+
+ if (existingStock != null)
+ {
+ // 搴撳瓨璁板綍瀛樺湪锛屾仮澶嶉攣瀹氭暟閲�
+ await _stockInfoDetailService.Db.Updateable<Dt_StockInfoDetail>()
+ .SetColumns(it => new Dt_StockInfoDetail
+ {
+ OutboundQuantity = it.OutboundQuantity - returnQty
+ })
+ .Where(it => it.Barcode == lockInfo.CurrentBarcode && it.StockId == lockInfo.StockId)
+ .ExecuteCommandAsync();
+ }
+ else
+ {
+ // 搴撳瓨璁板綍涓嶅瓨鍦紙鍙兘鏄媶鍖呬骇鐢熺殑鏂版潯鐮侊級锛屽垱寤烘柊鐨勫簱瀛樿褰�
+ var newStockDetail = new Dt_StockInfoDetail
+ {
+ StockId = lockInfo.StockId,
+ MaterielCode = lockInfo.MaterielCode,
+ OrderNo = lockInfo.OrderNo,
+ BatchNo = lockInfo.BatchNo,
+ StockQuantity = returnQty,
+ OutboundQuantity = 0,
+ Barcode = lockInfo.CurrentBarcode,
+ InboundOrderRowNo = "0",
+ Status = StockStatusEmun.鍏ュ簱纭.ObjToInt(),
+
+ };
+ await _stockInfoDetailService.Db.Insertable(newStockDetail).ExecuteCommandAsync();
+ }
+ }
+
+ // 鍒涘缓鍥炲簱浠诲姟
+ CreateReturnTask(tasks, task, palletCode, newLocation);
+ }
+ }
+
+ // 鎯呭喌2锛氬嚭搴撹揣鐗╁凡鍒嗘嫞瀹岋紝浣嗘墭鐩樹笂杩樻湁鍏朵粬搴撳瓨璐х墿闇�瑕佸洖搴�
+ if (!hasRemainingLocks && palletStockGoods.Any())
+ {
+ // 鍒嗛厤鏂拌揣浣�
+ var newLocation = _locationInfoService.AssignLocation(firstlocation.LocationType);
+
+ // 鍒涘缓鍥炲簱浠诲姟
+ CreateReturnTask(tasks, task, palletCode, newLocation);
+
+ totalReturnQty = palletStockGoods.Sum(x => x.StockQuantity - x.OutboundQuantity);
+ }
+
+ // 淇濆瓨浠诲姟
+ if (tasks.Any())
+ {
+ try
+ {
+ await _taskRepository.Db.Insertable(tasks).ExecuteCommandAsync();
+
+ // 缁� ESS 娴佸姩淇″彿鍜屽垱寤轰换鍔�
+ try
+ {
+ var result = await _eSSApiService.MoveContainerAsync(new WIDESEA_DTO.Basic.MoveContainerRequest
+ {
+ slotCode = movestations[task.TargetAddress],
+ containerCode = palletCode
+ });
+ if (result)
+ {
+ TaskModel esstask = new TaskModel()
+ {
+ taskType = "putaway",
+ taskGroupCode = "",
+ groupPriority = 0,
+ tasks = new List<TasksType>
+ {
+ new()
+ {
+ taskCode = tasks.First().TaskNum.ToString(),
+ taskPriority = 0,
+ taskDescribe = new TaskDescribeType {
+ containerCode = palletCode,
+ containerType = "CT_KUBOT_STANDARD",
+ fromLocationCode = stations.GetValueOrDefault(task.TargetAddress) ?? "",
+ toStationCode = "",
+ toLocationCode = tasks.First().TargetAddress,
+ deadline = 0, storageTag = ""
+ }
+ }
+ }
+ };
+
+
+ var resulttask = await _eSSApiService.CreateTaskAsync(esstask);
+
+ _logger.LogInformation("ReturnRemaining 鍒涘缓浠诲姟杩斿洖: " + resulttask);
+ }
+ }
+ catch (Exception ex)
+ {
+ _logger.LogInformation("ReturnRemaining 鍒涘缓浠诲姟杩斿洖 catch err: " + ex.Message);
+
+ }
+
+
+ return WebResponseContent.Instance.OK($"鍥炲簱鎿嶄綔鎴愬姛锛屽叡鍥炲簱鏁伴噺锛歿totalReturnQty}");
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鍒涘缓鍥炲簱浠诲姟澶辫触: {ex.Message}");
+ }
+ }
+
+ return WebResponseContent.Instance.Error("鏈垱寤轰换浣曞洖搴撲换鍔�");
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鍥炲簱鎿嶄綔澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鍒涘缓鍥炲簱浠诲姟
+ /// </summary>
+ private void CreateReturnTask(List<Dt_Task> tasks, Dt_Task originalTask, string palletCode, Dt_LocationInfo newLocation)
+ {
+ Dt_Task newTask = new()
+ {
+ CurrentAddress = stations[originalTask.TargetAddress],
+ Grade = 0,
+ PalletCode = palletCode,
+ NextAddress = "",
+ OrderNo = originalTask.OrderNo,
+ Roadway = newLocation.RoadwayNo,
+ SourceAddress = stations[originalTask.TargetAddress],
+ TargetAddress = newLocation.LocationCode,
+ TaskStatus = TaskStatusEnum.New.ObjToInt(),
+ TaskType = TaskTypeEnum.InPick.ObjToInt(),
+ PalletType = originalTask.PalletType,
+ WarehouseId = originalTask.WarehouseId,
+
+ };
+ tasks.Add(newTask);
+ }
+
+ /// <summary>
+ /// 妫�鏌ユ墭鐩樻槸鍚﹂渶瑕佸洖搴撶殑杈呭姪鏂规硶
+ /// </summary>
+ public async Task<bool> CheckPalletNeedReturn(string orderNo, string palletCode)
+ {
+ // 1. 妫�鏌ユ槸鍚︽湁鏈垎鎷g殑鍑哄簱璁板綍
+ var hasUnpickedLocks = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.OrderNo == orderNo && it.PalletCode == palletCode && it.Status == 1)
+ .AnyAsync();
+
+ if (hasUnpickedLocks)
+ return true;
+
+ // 2. 妫�鏌ュ嚭搴撴槸鍚﹀凡瀹屾垚浣嗘墭鐩樿繕鏈夊簱瀛樿揣鐗�
+ var outboundFinished = !await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(it => it.PalletCode == palletCode && it.Status == 1)
+ .AnyAsync();
+
+ var stockinfo = _stockInfoService.Db.Queryable<Dt_StockInfo>().First(x => x.PalletCode == palletCode);
+
+
+ var hasRemainingGoods = await _stockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
+ .Where(it => it.StockId == stockinfo.Id && it.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt())
+ .Where(it => it.OutboundQuantity == 0 || it.OutboundQuantity < it.StockQuantity)
+ .AnyAsync();
+
+ return outboundFinished && hasRemainingGoods;
+ }
+
// 鍙栨秷鎷i�夊姛鑳�
public async Task<WebResponseContent> CancelPicking(string orderNo, string palletCode, string barcode)
{
@@ -394,36 +834,17 @@
var list = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.Where(x => x.OrderNo == orderNo &&
x.PalletCode == palletCode &&
- x.Status == 2)
+ x.Status == 6)
.ToListAsync();
return list;
}
-
- public async Task<object> GetPickingSummary(string orderNo, string palletCode)
- {
- var summary = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
- .Where(x => x.OrderNo == orderNo &&
- x.PalletCode == palletCode && x.Status == 1)
- .GroupBy(x => new { x.PalletCode, x.MaterielCode })
- .Select(x => new
- {
- PalletCode = x.PalletCode,
- MaterielCode = x.MaterielCode,
- UnpickedCount = SqlFunc.AggregateCount(x.Id),
- UnpickedQuantity = SqlFunc.AggregateSum(x.AssignQuantity) - SqlFunc.AggregateSum(x.PickedQty)
- })
- .FirstAsync();
-
- return summary;
- }
-
// 鑾峰彇鎷i�夋眹鎬�
public async Task<object> GetPickingSummary(ConfirmPickingDto dto)
{
var picked = await _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
.WhereIF(!string.IsNullOrEmpty(dto.OrderNo), x => x.OrderNo == dto.OrderNo)
.WhereIF(!string.IsNullOrEmpty(dto.PalletCode), x => x.PalletCode == dto.PalletCode)
- .Where(x => x.Status == 2)
+ .Where(x => x.Status == 6)
.GroupBy(x => new { x.PalletCode, x.MaterielCode })
.Select(x => new SummaryPickingDto
{
@@ -673,7 +1094,7 @@
{
orderDetail.OverOutQuantity = item.TotalQuantity;
orderDetail.LockQuantity = 0;
- orderDetail.OrderDetailStatus = (int)OrderDetailStatusEnum.Over;
+ orderDetail.OrderDetailStatus = (int)OrderDetailStatusEnum.Over;
await _outboundOrderDetailService.Db.Updateable(orderDetail).ExecuteCommandAsync();
}
}
--
Gitblit v1.9.3