|
@@ -18,12 +18,68 @@ using System.Linq;
|
|
|
using System.Runtime.Remoting;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
-
|
|
|
+using System.Web;
|
|
|
+using System.Windows.Shell;
|
|
|
|
|
|
namespace SCADA_DAQ.Customer.Service
|
|
|
{
|
|
|
public partial class WcsService
|
|
|
{
|
|
|
+ public ApiResult<object> WmsCancelLow(List<CancelLowBo> cancelLowList)
|
|
|
+ {
|
|
|
+ var res = new ApiResult<object>();
|
|
|
+ if (cancelLowList.Count == 0)
|
|
|
+ {
|
|
|
+ res.IsSucceed = false;
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ List<AppBCItemTaskModel> appBCItemTaskModels = new List<AppBCItemTaskModel>();
|
|
|
+ cancelLowList.ForEach(item => {
|
|
|
+ appBCItemTaskModels.Add(new AppBCItemTaskModel
|
|
|
+ {
|
|
|
+ TaskNo = item.No,
|
|
|
+ ErrorMsg = "取消发货",
|
|
|
+ State = TaskStateEnum.Close,
|
|
|
+ EndDate = DateTime.Now,
|
|
|
+ }) ;
|
|
|
+ });
|
|
|
+ var taskDbRes = Env.DAL.BatchUpdateOrInsert(
|
|
|
+ appBCItemTaskModels,
|
|
|
+ t => new { t.TaskNo }, //更新条件
|
|
|
+ null,
|
|
|
+ t => new { t.ErrorMsg,t.State, t.EndDate } //更新字段
|
|
|
+ ); //批量更新
|
|
|
+ var cancelQtySumList = cancelLowList.GroupBy(t => new { t.WarehouseCode, t.ItemCode })
|
|
|
+ .Select(group => new AppBCInventoryModel { WarehouseCode = group.Key.WarehouseCode, ItemCode = group.Key.ItemCode, Qty = group.Sum(it => it.Qty) })
|
|
|
+ .ToList();
|
|
|
+ var sqlStr = "";
|
|
|
+ cancelQtySumList.ForEach(item =>
|
|
|
+ {
|
|
|
+ if (sqlStr == "")
|
|
|
+ {
|
|
|
+ sqlStr = $"(WarehouseCode_Str= '{item.WarehouseCode}' and ItemCode_Str = '{item.ItemCode}')";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sqlStr = $"{sqlStr} or (WarehouseCode_Str='{item.WarehouseCode}' and ItemCode_Str = '{item.ItemCode}')";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<AppBCInventoryModel> appBCInventoryList= Env.DAL.App_BC_Inventory.GetData<AppBCInventoryModel>(sqlStr);
|
|
|
+ var sumQtyInventoryList = cancelQtySumList.Concat(appBCInventoryList).GroupBy(t => new { t.WarehouseCode, t.ItemCode }).Select(group => new AppBCInventoryModel { WarehouseCode = group.Key.WarehouseCode, ItemCode = group.Key.ItemCode, Qty = group.Sum(it => it.Qty) })
|
|
|
+ .ToList();
|
|
|
+ var inventoryDbRes = Env.DAL.BatchUpdateOrInsert(
|
|
|
+ sumQtyInventoryList,
|
|
|
+ t => new { t.ItemCode, t.WarehouseCode }, //更新条件
|
|
|
+ null,
|
|
|
+ t => new { t.Qty } //更新字段
|
|
|
+ ); //批量更新
|
|
|
+ if (inventoryDbRes == false || taskDbRes == false)
|
|
|
+ {
|
|
|
+ res.IsSucceed = false;
|
|
|
+ res.Message = "失败";
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 更改任务状态
|
|
|
/// </summary>
|
|
@@ -260,7 +316,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
var taskNos = "接收下架任务";
|
|
|
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();
|
|
|
decimal? actualQty = 0m;
|
|
|
if (inventory != null && inventory?.Qty >= task.Qty)
|
|
|
{
|
|
@@ -272,7 +328,6 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
actualQty = inventory?.Qty;
|
|
|
inventory.Qty -= actualQty;
|
|
|
}
|
|
|
- taskNos = $"{taskNos} {task.No} ";
|
|
|
var newTask = new AppBCItemTaskModel
|
|
|
{
|
|
|
BillNo = task.BillNo,
|
|
@@ -314,20 +369,25 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
CreateTime = DateTime.Now.ToString(),
|
|
|
};
|
|
|
wmsTasks.Add(newTask);
|
|
|
- //wmsHaveSourceLocationTask.Add(newTask.SourceLocation != "" ? newTask : null);
|
|
|
- if (newTask.SourceLocation != null && newTask.ActualQty != 0m)
|
|
|
+ if (newTask.SourceLocation != null)
|
|
|
{
|
|
|
+ taskNos = $"{taskNos} {task.No} ";
|
|
|
wmsHaveSourceLocationTask.Add(newTask);
|
|
|
}
|
|
|
+ if (newTask.SourceLocation == null)
|
|
|
+ {
|
|
|
+ taskNos = $"{taskNos} {task.No}无库位 ";
|
|
|
+ }
|
|
|
});
|
|
|
wmsTasks.Sort((item1, item2) => item1.TaskNo.CompareTo(item2.TaskNo)); //排序
|
|
|
var dbRes = Env.DAL.Insert(wmsTasks);
|
|
|
Log.Info(taskNos);
|
|
|
+ //wmsHaveSourceLocationTask = wmsHaveSourceLocationTask.Where(t=>!t.WoNo.StartsWith("CS12")).ToList();
|
|
|
AddDeviceTaskList(wmsHaveSourceLocationTask);
|
|
|
- wmsUpLoad(wmsHaveSourceLocationTask);
|
|
|
+ //UpLoadWms(wmsHaveSourceLocationTask);
|
|
|
if (dbRes.IsSucceed == true)
|
|
|
{
|
|
|
- res.Message = $"下架任务已接收";
|
|
|
+ res.Message = $"{taskNos}";
|
|
|
return res;
|
|
|
}
|
|
|
res.IsSucceed = false;
|
|
@@ -339,7 +399,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
/// 回传任务信息
|
|
|
/// </summary>
|
|
|
/// <param name="task"></param>
|
|
|
- public static void wmsUpLoad(List<AppBCItemTaskModel> task)
|
|
|
+ public void UpLoadWms(List<AppBCItemTaskModel> task)
|
|
|
{
|
|
|
var message = "";
|
|
|
var itemTaskUpList = new List<AppBCItemTaskModel>(); //更新任务状态
|
|
@@ -356,6 +416,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
itemTaskUpList.Add(new AppBCItemTaskModel
|
|
|
{
|
|
|
TaskNo = task[i].TaskNo,
|
|
|
+ EndDate = DateTime.Now,
|
|
|
ErrorMsg = wmsRes.Message
|
|
|
});
|
|
|
}
|
|
@@ -366,6 +427,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
itemTaskUpList.Add(new AppBCItemTaskModel
|
|
|
{
|
|
|
TaskNo = task[i].TaskNo,
|
|
|
+ EndDate = DateTime.Now,
|
|
|
ErrorMsg = wmsRes.Result.Error
|
|
|
});
|
|
|
}
|
|
@@ -459,10 +521,10 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
{
|
|
|
Env.DAL.BatchUpdateOrInsert(
|
|
|
updateInventoryQtyList,
|
|
|
- t => new { t.ItemCode, t.SourceLocation, t.WarehouseCode }, //更新条件
|
|
|
+ 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 } //更新字段
|
|
|
- ); //批量更新
|
|
|
+ t => new { t.Qty, t.ItemCode, t.SourceLocation, t.ItemName, t.OnhandState, t.UnitCode, t.WarehouseCode }
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -470,7 +532,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
/// 自动下发堆垛机任务
|
|
|
/// </summary>
|
|
|
/// <param name="sourceLocations"></param>
|
|
|
- public static void AddDeviceTaskList(List<AppBCItemTaskModel> sourceLocations)
|
|
|
+ public void AddDeviceTaskList(List<AppBCItemTaskModel> sourceLocations)
|
|
|
{
|
|
|
var sourceLocationGroupBy = sourceLocations.GroupBy(i => i.SourceLocation).Select(j => j.FirstOrDefault()).ToList();
|
|
|
var sourceLocationList = new List<OperationBo>();
|