142 lines
5.2 KiB
C#
142 lines
5.2 KiB
C#
using AutoMapper;
|
|
using HHWMS.Web.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using WalkingTec.Mvvm.Core;
|
|
|
|
namespace HHWMS.Web
|
|
{
|
|
/// <summary>
|
|
/// WCS接口
|
|
/// 调用方向 WCS --> WMS
|
|
/// </summary>
|
|
[Public]
|
|
[ActionDescription("HHWMS.WCSApi")]
|
|
[ApiController]
|
|
[Route("api/[controller]/[action]"), ApiExplorerSettings(GroupName = "User")]
|
|
public class IWCSController : ApiController
|
|
{
|
|
private readonly IUnitWork _unitwork;
|
|
private readonly IMapper _mapper;
|
|
|
|
public IWCSController(IUnitWork unitwork, IMapper mapper)
|
|
{
|
|
_unitwork = unitwork;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 请求入库
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public IActionResult RequestIn(WcsRequest request)
|
|
{
|
|
// 参数判断
|
|
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 });
|
|
}
|
|
|
|
/// <summary>
|
|
/// 状态返回
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public IActionResult ReturnStatus(WcsRequest request)
|
|
{
|
|
/*// 参数判断
|
|
if (request.State == null || request.PalletNo == null)
|
|
{
|
|
return ApiResultError(msg: $"传入参数不正确!");
|
|
}
|
|
var task = _unitwork.FindSingle<TaskHeader>(x => x.ContainerCode.Equals(request.PalletNo));
|
|
if (task == null)
|
|
{
|
|
return ApiResultError(msg: $"未找到容器号{request.PalletNo}的任务!");
|
|
}
|
|
switch (task.TaskType)
|
|
{
|
|
case TaskTypeEnum.In:
|
|
//1.更新库位状态(目的仓位有货)
|
|
_unitwork.BatchUpdate<Location>(x => x.Code.Equals(task.ToLocation), x => new Location
|
|
{
|
|
Status = LocationStatus.有货
|
|
});
|
|
//2.更新容器(旭东不需要)
|
|
//3.根据任务明细,创建库存和库存交易
|
|
var details = _unitwork.Find<TaskDetail>(x => x.TaskHeaderId.Equals(task.ID));
|
|
foreach (var detail in details)
|
|
{
|
|
//创建库存
|
|
var inventory = new Inventory
|
|
{
|
|
MaterialCode = detail.MaterialCode,
|
|
MaterialName = detail.MaterialName,
|
|
MaterialSpec = detail.MaterialSpec,
|
|
MaterialUnit = detail.MaterialUnit,
|
|
Batch = detail.Batch,
|
|
Lot = detail.Lot,
|
|
ContainerCode = task.ContainerCode,
|
|
LocationCode = task.ToLocation,
|
|
Qty = detail.Qty,
|
|
TaskStatus = InventoryTaskStatus.无任务
|
|
};
|
|
_unitwork.Add(inventory);
|
|
//创建库存交易
|
|
var invTran = new InventoryTransaction
|
|
{
|
|
Type = InventoryTranType.入库,
|
|
MaterialCode = detail.MaterialCode,
|
|
MaterialName = detail.MaterialName,
|
|
MaterialSpec = detail.MaterialSpec,
|
|
MaterialUnit = detail.MaterialUnit,
|
|
Batch = detail.Batch,
|
|
Lot = detail.Lot,
|
|
ContainerCode = task.ContainerCode,
|
|
LocationCode = task.ToLocation,
|
|
Qty = detail.Qty,
|
|
};
|
|
_unitwork.Add(invTran);
|
|
}
|
|
//4.调用MES接口,告诉MES物料入库
|
|
break;
|
|
|
|
case TaskTypeEnum.Out:
|
|
//1.更新库位状态(起始仓位为空)
|
|
//2.更新容器(旭东不需要)
|
|
//3.删除对应的库存信息,创建库存交易
|
|
//4.调用MES接口,告诉MES物料出库
|
|
break;
|
|
|
|
case TaskTypeEnum.Move:
|
|
//1.更新库位状态(起始仓位为空,目的仓位有货)
|
|
//2.更新容器(旭东不需要)
|
|
//3.更新库存信息的库位
|
|
break;
|
|
}
|
|
*/
|
|
return ApiResult();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试
|
|
/// </summary>
|
|
/// <param name="response"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public IActionResult Test(TaskResponse response)
|
|
{
|
|
return ApiResult();
|
|
}
|
|
}
|
|
}
|