库存回传MES

This commit is contained in:
zgf committed 2023-11-22 16:39:13 +08:00
1 parent b864a80e29
commit 4334683c6f
5 files changed
+103 -35

No files matched your search

+44 -30
View File
@@ -37,40 +37,54 @@ namespace HHWMS.Web
[HttpPost] [HttpPost]
public IActionResult RequestIn(WcsRequest request) public IActionResult RequestIn(WcsRequest request)
{ {
var inv = _unitwork.Find<Inventory>(x => x.ID > 0).FirstOrDefault(); var emptyLoc = _unitwork.Find<Location>(x => x.Type == LocationTypeEnum.盘料库位)
var bizData = new InStore .ToList()
.GroupBy(x => Convert.ToInt32(x.Length));
var sizeEmptyNum = new List<dynamic>();
foreach (var group in emptyLoc)
{ {
INWMS = new INWMS var num = group.Sum(x => (x.Length - x.Width));
sizeEmptyNum.Add(new
{ {
INITEMS = new INITEMS size = group.Key,
{ num = Convert.ToInt32(num)
INITEM = new List<INITEMItem>() });
{
new INITEMItem()
{
ERPSN = inv.MaterialCode,
WMSSN = inv.UniqueCode,
QTY = ((int?)inv.Qty).ToString(),
TYPE = "2"
} }
} return Ok();
} //var inv = _unitwork.Find<Inventory>(x => x.ID > 0).FirstOrDefault();
} //var bizData = new InStore
}; //{
var str = JsonConvert.SerializeObject(bizData); // INWMS = new INWMS
// 参数判断 // {
if (request.RoadWay == null || request.Size == null) // INITEMS = new INITEMS
{ // {
return ApiResultError(msg: $"传入参数不正确!"); // INITEM = new List<INITEMItem>()
} // {
var vm = Wtm.CreateVM<LocationVM>(); // new INITEMItem()
var result = vm.GetLocation(request); // {
// ERPSN = inv.MaterialCode,
// WMSSN = inv.UniqueCode,
// QTY = ((int?)inv.Qty).ToString(),
// TYPE = "2"
// }
// }
// }
// }
//};
//var str = JsonConvert.SerializeObject(bizData);
//// 参数判断
//if (request.RoadWay == null || request.Size == null)
//{
// return ApiResultError(msg: $"传入参数不正确!");
//}
//var vm = Wtm.CreateVM<LocationVM>();
//var result = vm.GetLocation(request);
if (string.IsNullOrEmpty(result.Data.LocationCode)) //if (string.IsNullOrEmpty(result.Data.LocationCode))
{ //{
return ApiResultError(msg: $"巷道{request.RoadWay}内无空仓位!"); // return ApiResultError(msg: $"巷道{request.RoadWay}内无空仓位!");
} //}
return ApiResult(new { Location = result.Data.LocationCode }); //return ApiResult(new { Location = result.Data.LocationCode });
} }
/// <summary> /// <summary>
@@ -6,6 +6,7 @@ using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web.Models; using HHWMS.Web.Models;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
using System.Linq;
namespace HHWMS.Web.Controllers namespace HHWMS.Web.Controllers
{ {
@@ -161,7 +162,11 @@ namespace HHWMS.Web.Controllers
}); });
} }
} }
var uniqueGroup = detailList.GroupBy(x => x.UniqueCode);
if (uniqueGroup.Any(x => x.Count() > 1))
{
return FFResult().Alert("新增明细中,存在重复的唯一码!");
}
// 补充物料明细 // 补充物料明细
foreach(var item in detailList) foreach(var item in detailList)
{ {
@@ -97,6 +97,46 @@ namespace HHWMS.Web.Controllers
[HttpPost] [HttpPost]
public ActionResult BindingData(List<Binding> data) public ActionResult BindingData(List<Binding> data)
{ {
// 判断库内是否有充足库位执行入库 todo
/*var emptyLoc = _unitWork.Find<Location>(x => x.Type == LocationTypeEnum.盘料库位)
.ToList()
.GroupBy(x => Convert.ToInt32(x.Length));
var sizeEmptyNum = new List<dynamic>();
foreach (var group in emptyLoc)
{
var num = group.Sum(x => (x.Length - x.Width));
sizeEmptyNum.Add(new
{
size = group.Key,
num = Convert.ToInt32(num)
});
}
var sizeList = data.GroupBy(x => x.Size).ToList();
foreach(var item in sizeList)
{
var size = 23;
switch (item.Key)
{
case 8:
size = 23;
break;
case 10:
size = 19;
break;
case 16:
size = 16;
break;
case 24:
size = 13;
break;
default:
break;
}
var num = sizeEmptyNum.First(x => x.size == item.Key).num
if(item.Count() > num)
return JsonMore(null, 500, $"尺寸{item.Key}的盘料盒无法满足入库需求,剩余数量{num}");
}*/
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x => var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
data.Select(x => x.ReceiptCode).ToList().Contains(x.Code)) data.Select(x => x.ReceiptCode).ToList().Contains(x.Code))
.Include(x => x.ReceiptDetails).ToList(); .Include(x => x.ReceiptDetails).ToList();
@@ -173,12 +173,19 @@ public class ReceiptSLInController : BaseController
{ {
ZoneCode = ZoneCodeEnum.散料库, ZoneCode = ZoneCodeEnum.散料库,
UniqueCode = item.UniqueCode, UniqueCode = item.UniqueCode,
MaterialCode = receipt.MaterialCode,
MaterialType = receipt.MaterialType,
MaterialName = receipt.MaterialName,
MaterialSpec = receipt.MaterialSpec,
Batch = receipt.Batch,
MaterialUnit = receipt.MaterialUnit,
SupplierCode = receipt.SupplierCode,
Qty = item.BindQty, Qty = item.BindQty,
Lot = item.Size.ToString(),
LocationCode = item.BoxCode, LocationCode = item.BoxCode,
ContainerCode = station.ContainerCode, ContainerCode = station.ContainerCode,
Status = "0", Status = "0",
TaskStatus = InventoryTaskStatus.任务中 TaskStatus = InventoryTaskStatus.任务中,
Flag = item.Size,
}; };
_unitWork.Add(inventory); _unitWork.Add(inventory);
} }
@@ -39,6 +39,8 @@ namespace HHWMS.Web
} }
} }
}; };
if (Invs.Count > 0)
{
foreach (var inv in Invs) foreach (var inv in Invs)
{ {
//var inv = _unitwork.FindById<Inventory>(int.Parse(id)); //var inv = _unitwork.FindById<Inventory>(int.Parse(id));
@@ -56,7 +58,7 @@ namespace HHWMS.Web
var request = new ServiceReference1.bizOperationV1Request var request = new ServiceReference1.bizOperationV1Request
{ {
fromUnit = "8357S", fromUnit = "8357S",
toUnit = "8357TEST", toUnit = "8357S",
fromSys = "WMSTEST", fromSys = "WMSTEST",
toSys = "MES", toSys = "MES",
bizOperation = "InStore", bizOperation = "InStore",
@@ -80,7 +82,7 @@ namespace HHWMS.Web
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error"); Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error");
//return FFResult().Message($"{result.Message}").RefreshGrid(); //return FFResult().Message($"{result.Message}").RefreshGrid();
} }
}
#region 更新时间 #region 更新时间
var job = _unitwork.FindSingle<SysJob>(x => x.JobName == context.JobDetail.Key.Name); var job = _unitwork.FindSingle<SysJob>(x => x.JobName == context.JobDetail.Key.Name);