|
@@ -257,7 +257,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
var wmsTasks = new List<AppBCItemTaskModel>();
|
|
var wmsTasks = new List<AppBCItemTaskModel>();
|
|
var wmsHaveSourceLocationTask = new List<AppBCItemTaskModel>();
|
|
var wmsHaveSourceLocationTask = new List<AppBCItemTaskModel>();
|
|
var inventoryList = Env.DAL.App_BC_Inventory.GetData<AppBCInventoryModel>();
|
|
var inventoryList = Env.DAL.App_BC_Inventory.GetData<AppBCInventoryModel>();
|
|
- var taskNos = "";
|
|
|
|
|
|
+ var taskNos = "接收下架任务";
|
|
taskList.ForEach(task =>
|
|
taskList.ForEach(task =>
|
|
{
|
|
{
|
|
var inventory = inventoryList.Where(i => i.ItemCode == task.ItemCode && i.WarehouseCode == task.WarehouseCode && i.Qty > 0).FirstOrDefault();
|
|
var inventory = inventoryList.Where(i => i.ItemCode == task.ItemCode && i.WarehouseCode == task.WarehouseCode && i.Qty > 0).FirstOrDefault();
|
|
@@ -317,8 +317,8 @@ namespace SCADA_DAQ.Customer.Service
|
|
});
|
|
});
|
|
wmsTasks.Sort((item1, item2) => item1.TaskNo.CompareTo(item2.TaskNo)); //排序
|
|
wmsTasks.Sort((item1, item2) => item1.TaskNo.CompareTo(item2.TaskNo)); //排序
|
|
var dbRes = Env.DAL.Insert(wmsTasks);
|
|
var dbRes = Env.DAL.Insert(wmsTasks);
|
|
- wmsUpLoad(wmsHaveSourceLocationTask);
|
|
|
|
Log.Info(taskNos);
|
|
Log.Info(taskNos);
|
|
|
|
+ wmsUpLoad(wmsHaveSourceLocationTask);
|
|
if (dbRes.IsSucceed == true)
|
|
if (dbRes.IsSucceed == true)
|
|
{
|
|
{
|
|
res.Message = $"下架任务已接收";
|
|
res.Message = $"下架任务已接收";
|
|
@@ -337,6 +337,126 @@ namespace SCADA_DAQ.Customer.Service
|
|
{
|
|
{
|
|
var sourceLocations = task.ToLookup(i=>i.SourceLocation).Select(j=>j.Key).ToList();
|
|
var sourceLocations = task.ToLookup(i=>i.SourceLocation).Select(j=>j.Key).ToList();
|
|
AddDeviceTaskList(sourceLocations);
|
|
AddDeviceTaskList(sourceLocations);
|
|
|
|
+ var message = "";
|
|
|
|
+ var itemTaskUpList = new List<AppBCItemTaskModel>(); //更新任务状态
|
|
|
|
+ var successItemTaskQty = new List<AppBCItemTaskModel>(); //更新物料库存
|
|
|
|
+ if (task != null && task.Count != 0)
|
|
|
|
+ {
|
|
|
|
+ for (int i = 0; i < task.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ var wmsRes = CustomerEnv.AutoFinishWmsLowTask(new List<AppBCItemTaskModel> { task[i] });
|
|
|
|
+ if (wmsRes.Success == false)
|
|
|
|
+ {
|
|
|
|
+ message = $@"{wmsRes.Message}";
|
|
|
|
+ itemTaskUpList.Add(new AppBCItemTaskModel
|
|
|
|
+ {
|
|
|
|
+ TaskNo = task[i].TaskNo,
|
|
|
|
+ ErrorMsg = wmsRes.Message
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (wmsRes.Success == true && wmsRes.Result.IsSuccess == false)
|
|
|
|
+ {
|
|
|
|
+ message = $@"{message} {wmsRes.Result.Error}";
|
|
|
|
+ itemTaskUpList.Add(new AppBCItemTaskModel
|
|
|
|
+ {
|
|
|
|
+ TaskNo = task[i].TaskNo,
|
|
|
|
+ ErrorMsg = wmsRes.Result.Error
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (wmsRes.Success == true && wmsRes.Result.IsSuccess == true)
|
|
|
|
+ {
|
|
|
|
+ message = $@"{message} {task[i].TaskNo}上传成功";
|
|
|
|
+ itemTaskUpList.Add(new AppBCItemTaskModel
|
|
|
|
+ {
|
|
|
|
+ TaskNo = task[i].TaskNo,
|
|
|
|
+ State = TaskStateEnum.Finish,
|
|
|
|
+ EndDate = DateTime.Now,
|
|
|
|
+ Remark = "1"
|
|
|
|
+ });
|
|
|
|
+ successItemTaskQty.Add(task[i]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var updateInventoryQtyList = new List<AppBCInventoryModel>();
|
|
|
|
+ var updateSumItemQtyList = new List<AppBCInventoryModel>();
|
|
|
|
+ #region /完成任务更新库存数量逻辑
|
|
|
|
+ var successItemTaskQtyList = successItemTaskQty.ToLookup(t => new { t.ItemCode, t.SourceLocation, t.WarehouseCode }).ToList();
|
|
|
|
+ string inventoryFilter = null;
|
|
|
|
+ foreach (var itemTaskQtyValues in successItemTaskQtyList)
|
|
|
|
+ {
|
|
|
|
+ foreach (var itemTaskQtyValue in itemTaskQtyValues)
|
|
|
|
+ {
|
|
|
|
+ if (!updateSumItemQtyList.Any(i => i.ItemCode == itemTaskQtyValue.ItemCode && i.SourceLocation == itemTaskQtyValue.SourceLocation && i.WarehouseCode == itemTaskQtyValue.WarehouseCode))
|
|
|
|
+ {
|
|
|
|
+ updateSumItemQtyList.Add(new AppBCInventoryModel()
|
|
|
|
+ {
|
|
|
|
+ ItemCode = itemTaskQtyValue.ItemCode,
|
|
|
|
+ SourceLocation = itemTaskQtyValue.SourceLocation,
|
|
|
|
+ ItemName = itemTaskQtyValue.ItemName,
|
|
|
|
+ OnhandState = 10,
|
|
|
|
+ UnitCode = itemTaskQtyValue.UnitCode,
|
|
|
|
+ Qty = itemTaskQtyValue.ActualQty,
|
|
|
|
+ WarehouseCode = itemTaskQtyValue.WarehouseCode
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ var inventory = updateSumItemQtyList.Where(qty => qty.ItemCode == itemTaskQtyValue.ItemCode && qty.SourceLocation == itemTaskQtyValue.SourceLocation && qty.WarehouseCode == itemTaskQtyValue.WarehouseCode).ToList()[0];
|
|
|
|
+ inventory.Qty += itemTaskQtyValue.ActualQty;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //以上foreach为了将相同物料,库区,库位的数量相加
|
|
|
|
+ for (int j = 0; j < updateSumItemQtyList.Count; j++)
|
|
|
|
+ {
|
|
|
|
+ if (inventoryFilter == null)
|
|
|
|
+ {
|
|
|
|
+ inventoryFilter = $" (ItemCode_Str = '{updateSumItemQtyList[j].ItemCode}' and SourceLocation_Str = '{updateSumItemQtyList[j].SourceLocation}' and WarehouseCode_Str = '{updateSumItemQtyList[j].WarehouseCode}') ";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ inventoryFilter += $"or (ItemCode_Str = '{updateSumItemQtyList[j].ItemCode}' and SourceLocation_Str = '{updateSumItemQtyList[j].SourceLocation}' and WarehouseCode_Str = '{updateSumItemQtyList[j].WarehouseCode}') ";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //以上for为了从数据库拿出即将要更新物料库存的所在托盘的当前库存数量
|
|
|
|
+ var inventoryList = Env.DAL.App_BC_Inventory.GetData<AppBCInventoryModel>(inventoryFilter);
|
|
|
|
+ for (int i = 0; i < updateSumItemQtyList.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ if (inventoryList.Any(j => j.ItemCode == updateSumItemQtyList[i].ItemCode && j.SourceLocation == updateSumItemQtyList[i].SourceLocation && j.WarehouseCode == updateSumItemQtyList[i].WarehouseCode))
|
|
|
|
+ {
|
|
|
|
+ var inventory = inventoryList.Where(qty => qty.ItemCode == updateSumItemQtyList[i].ItemCode && qty.SourceLocation == updateSumItemQtyList[i].SourceLocation && qty.WarehouseCode == updateSumItemQtyList[i].WarehouseCode).ToList()[0];
|
|
|
|
+ updateInventoryQtyList.Add(new AppBCInventoryModel()
|
|
|
|
+ {
|
|
|
|
+ ItemCode = inventory.ItemCode,
|
|
|
|
+ SourceLocation = inventory.SourceLocation,
|
|
|
|
+ ItemName = inventory.ItemName,
|
|
|
|
+ OnhandState = 10,
|
|
|
|
+ UnitCode = updateSumItemQtyList[i].UnitCode,
|
|
|
|
+ Qty = inventory.Qty - updateSumItemQtyList[i].Qty,
|
|
|
|
+ WarehouseCode = inventory.WarehouseCode
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //以上for将拿出来的现库存数量减去下架任务得出的数量进行更新库存数量
|
|
|
|
+ #endregion
|
|
|
|
+ if (itemTaskUpList.Count != 0)
|
|
|
|
+ {
|
|
|
|
+ Env.DAL.BatchUpdateOrInsert(
|
|
|
|
+ itemTaskUpList,
|
|
|
|
+ t => new { t.TaskNo },
|
|
|
|
+ null,
|
|
|
|
+ t => new { t.State, t.EndDate, t.Remark, t.ErrorMsg }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ if (updateInventoryQtyList != null && updateInventoryQtyList.Count != 0)
|
|
|
|
+ {
|
|
|
|
+ Env.DAL.BatchUpdateOrInsert(
|
|
|
|
+ updateInventoryQtyList,
|
|
|
|
+ t => new { t.ItemCode, t.SourceLocation, t.WarehouseCode }, //更新条件
|
|
|
|
+ null,
|
|
|
|
+ t => new { t.Qty, t.ItemCode, t.SourceLocation, t.ItemName, t.OnhandState, t.UnitCode, t.WarehouseCode } //更新字段
|
|
|
|
+ ); //批量更新
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|