库存回传MES

This commit is contained in:
zgf 2023-11-22 16:39:13 +08:00
parent b864a80e29
commit 4334683c6f
5 changed files with 139 additions and 71 deletions

View File

@ -37,40 +37,54 @@ namespace HHWMS.Web
[HttpPost]
public IActionResult RequestIn(WcsRequest request)
{
var inv = _unitwork.Find<Inventory>(x => x.ID > 0).FirstOrDefault();
var bizData = new InStore
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)
{
INWMS = new INWMS
var num = group.Sum(x => (x.Length - x.Width));
sizeEmptyNum.Add(new
{
INITEMS = new INITEMS
{
INITEM = new List<INITEMItem>()
{
new INITEMItem()
{
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: $"传入参数不正确!");
size = group.Key,
num = Convert.ToInt32(num)
});
}
var vm = Wtm.CreateVM<LocationVM>();
var result = vm.GetLocation(request);
return Ok();
//var inv = _unitwork.Find<Inventory>(x => x.ID > 0).FirstOrDefault();
//var bizData = new InStore
//{
// INWMS = new INWMS
// {
// INITEMS = new INITEMS
// {
// INITEM = new List<INITEMItem>()
// {
// new INITEMItem()
// {
// 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))
{
return ApiResultError(msg: $"巷道{request.RoadWay}内无空仓位!");
}
return ApiResult(new { Location = result.Data.LocationCode });
//if (string.IsNullOrEmpty(result.Data.LocationCode))
//{
// return ApiResultError(msg: $"巷道{request.RoadWay}内无空仓位!");
//}
//return ApiResult(new { Location = result.Data.LocationCode });
}
/// <summary>

View File

@ -6,6 +6,7 @@ using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web.Models;
using System.Collections.Generic;
using System;
using System.Linq;
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)
{

View File

@ -97,6 +97,46 @@ namespace HHWMS.Web.Controllers
[HttpPost]
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 =>
data.Select(x => x.ReceiptCode).ToList().Contains(x.Code))
.Include(x => x.ReceiptDetails).ToList();

View File

@ -173,12 +173,19 @@ public class ReceiptSLInController : BaseController
{
ZoneCode = ZoneCodeEnum.散料库,
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,
Lot = item.Size.ToString(),
LocationCode = item.BoxCode,
ContainerCode = station.ContainerCode,
Status = "0",
TaskStatus = InventoryTaskStatus.任务中
TaskStatus = InventoryTaskStatus.任务中,
Flag = item.Size,
};
_unitWork.Add(inventory);
}

View File

@ -39,48 +39,50 @@ namespace HHWMS.Web
}
}
};
foreach (var inv in Invs)
if (Invs.Count > 0)
{
//var inv = _unitwork.FindById<Inventory>(int.Parse(id));
var qr = _unitwork.FindSingle<MaterialQr>(x => x.UniqueCode.Equals(inv.UniqueCode))?.QRCode;
bizData.INWMS.INITEMS.INITEM.Add(
new INITEMItem()
foreach (var inv in Invs)
{
ERPSN = qr,
WMSSN = inv?.UniqueCode,
QTY = ((int?)inv?.Qty).ToString(),
TYPE = "2"
});
}
var str = JsonConvert.SerializeObject(bizData);
var request = new ServiceReference1.bizOperationV1Request
{
fromUnit = "8357S",
toUnit = "8357TEST",
fromSys = "WMSTEST",
toSys = "MES",
bizOperation = "InStore",
bizData = str
};
var client = new ServiceReference1.portTypeClient();
var result = client.bizOperationV1Async(request).Result;
if (result.Status == "Y")
{
_unitwork.BatchUpdate<Inventory>(x => Invs.Select(y => y.ID).Contains(x.ID), x => new Inventory
//var inv = _unitwork.FindById<Inventory>(int.Parse(id));
var qr = _unitwork.FindSingle<MaterialQr>(x => x.UniqueCode.Equals(inv.UniqueCode))?.QRCode;
bizData.INWMS.INITEMS.INITEM.Add(
new INITEMItem()
{
ERPSN = qr,
WMSSN = inv?.UniqueCode,
QTY = ((int?)inv?.Qty).ToString(),
TYPE = "2"
});
}
var str = JsonConvert.SerializeObject(bizData);
var request = new ServiceReference1.bizOperationV1Request
{
Status = "1",
UpdateBy = "invjob",
UpdateTime = DateTime.Now
});
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "success");
//return FFResult().Message("库存回传成功").RefreshGrid();
fromUnit = "8357S",
toUnit = "8357S",
fromSys = "WMSTEST",
toSys = "MES",
bizOperation = "InStore",
bizData = str
};
var client = new ServiceReference1.portTypeClient();
var result = client.bizOperationV1Async(request).Result;
if (result.Status == "Y")
{
_unitwork.BatchUpdate<Inventory>(x => Invs.Select(y => y.ID).Contains(x.ID), x => new Inventory
{
Status = "1",
UpdateBy = "invjob",
UpdateTime = DateTime.Now
});
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "success");
//return FFResult().Message("库存回传成功").RefreshGrid();
}
else
{
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error");
//return FFResult().Message($"{result.Message}").RefreshGrid();
}
}
else
{
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error");
//return FFResult().Message($"{result.Message}").RefreshGrid();
}
#region 更新时间
var job = _unitwork.FindSingle<SysJob>(x => x.JobName == context.JobDetail.Key.Name);