毛坯出库功能添加
This commit is contained in:
@@ -171,6 +171,29 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PDA毛坯出库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("PDABlankOutbound")]
|
||||
[AllowAnonymous]
|
||||
[Log(Title = "PDA毛坯出库", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult PDABlankOutbound([FromBody] BlankInventoryOutboundDto parm)
|
||||
{
|
||||
try
|
||||
{
|
||||
var modal = parm.Adapt<BlankInventoryOutboundDto>().ToCreate(HttpContext);
|
||||
|
||||
int successNum = _WmBlankInventoryService.PDABlankOutbound(modal);
|
||||
|
||||
return ToResponse(new ApiResult(200, "出库成功,已出库:" + successNum + "条毛坯记录!", "出库成功"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ToResponse(new ApiResult(500, ex.Message, "出库失败"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PDA毛坯标签解析
|
||||
/// </summary>
|
||||
|
||||
@@ -104,4 +104,23 @@ namespace ZR.Model.MES.wms.Dto
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 毛坯库存出库
|
||||
/// </summary>
|
||||
public class BlankInventoryOutboundDto
|
||||
{
|
||||
public List<ResultionPackageCodeDto> PackageList { get; set; } = new List<ResultionPackageCodeDto>();
|
||||
|
||||
// 1-返工件 对应数据库type=2 0-非返工件 对应数据库type=1
|
||||
public int IsBack { get; set; } = 1;
|
||||
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ namespace ZR.Service.mes.wms.IService
|
||||
/// <returns></returns>
|
||||
public int PDABlankWarehousing(BlankInventoryWarehousingDto warehousingDto);
|
||||
|
||||
/// <summary>
|
||||
/// PDA-扫码毛坯入库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int PDABlankOutbound(BlankInventoryOutboundDto outboundDto);
|
||||
|
||||
/// <summary>
|
||||
/// PDA-毛坯标签解析
|
||||
/// </summary>
|
||||
|
||||
@@ -320,7 +320,7 @@ namespace ZR.Service.mes.wms
|
||||
Type = 1,
|
||||
Status = 1,
|
||||
ActionTime = nowTime,
|
||||
Remark = $"PDA毛坯入库,批次号:{packageInfo.PatchCode}",
|
||||
Remark = $"PDA毛坯扫码入库,批次号:{packageInfo.PatchCode}",
|
||||
CreatedBy = warehousingDto.CreatedBy,
|
||||
CreatedTime = nowTime
|
||||
};
|
||||
@@ -343,6 +343,79 @@ namespace ZR.Service.mes.wms
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PDA扫码出库
|
||||
/// </summary>
|
||||
/// <param name="outboundDto"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int PDABlankOutbound(BlankInventoryOutboundDto outboundDto)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime nowTime = DateTime.Now;
|
||||
int result = 0;
|
||||
List<WmBlankInventory> updateWmBlankInventories = new();
|
||||
List<WmBlankRecord> addWmBlankRecourds = new();
|
||||
// 检查是否返工件
|
||||
int BackType = outboundDto.IsBack == 0 ? 1 : 2;
|
||||
List<ResultionPackageCodeDto> packageList = outboundDto.PackageList;
|
||||
if (packageList.Count == 0)
|
||||
{
|
||||
throw new Exception("无箱标签传入");
|
||||
}
|
||||
foreach (ResultionPackageCodeDto packageInfo in packageList)
|
||||
{
|
||||
// 库存变动
|
||||
WmBlankInventory wmBlankInventory = Context
|
||||
.Queryable<WmBlankInventory>()
|
||||
.Where(it => it.Type == BackType)
|
||||
.Where(it => it.Status == 1)
|
||||
.Where(it => it.BlankNum == packageInfo.BlankNumber)
|
||||
.First();
|
||||
if (wmBlankInventory == null)
|
||||
{
|
||||
throw new Exception("毛坯库中暂无此毛坯");
|
||||
}
|
||||
wmBlankInventory.Quantity -= packageInfo.Quantity;
|
||||
wmBlankInventory.UpdatedTime = nowTime;
|
||||
wmBlankInventory.UpdatedBy = outboundDto.CreatedBy;
|
||||
updateWmBlankInventories.Add(wmBlankInventory);
|
||||
// 记录添加
|
||||
WmBlankRecord wmBlankRecord =
|
||||
new()
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
FkBlankInventoryId = wmBlankInventory.Id,
|
||||
BlankNum = wmBlankInventory.BlankNum,
|
||||
ChangeQuantity = packageInfo.Quantity,
|
||||
// 1-入库 2-出库 3=盘点
|
||||
Type = 2,
|
||||
Status = 1,
|
||||
ActionTime = nowTime,
|
||||
Remark = $"PDA毛坯扫码出库,批次号:{packageInfo.PatchCode}",
|
||||
CreatedBy = outboundDto.CreatedBy,
|
||||
CreatedTime = nowTime
|
||||
};
|
||||
addWmBlankRecourds.Add(wmBlankRecord);
|
||||
}
|
||||
Context.Ado.BeginTran();
|
||||
result = Context.Updateable(updateWmBlankInventories).ExecuteCommand();
|
||||
if (result > 0)
|
||||
{
|
||||
//添加库存记录
|
||||
Context.Insertable(addWmBlankRecourds).ExecuteCommand();
|
||||
}
|
||||
Context.Ado.CommitTran();
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PDA 标签解析
|
||||
/// </summary>
|
||||
@@ -362,5 +435,7 @@ namespace ZR.Service.mes.wms
|
||||
throw new Exception("毛坯标签解析异常:" + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user