新增货架出入库 和打印操作
This commit is contained in:
1 parent
c27a357771
commit
6a1329d74e
17 files changed
+620
-9
No files matched your search
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection.Emit;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
namespace HHWMS.Web.Controllers;
|
||||
|
||||
[Area("receipt")]
|
||||
[ActionDescription("货架入库")]
|
||||
public class ReceiptShelfInController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
|
||||
public ReceiptShelfInController(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
return PartialView("Index");
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 扫描唯一码,并验证,返回入库单明细
|
||||
/// </summary>
|
||||
/// <param name="uniqueCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult ScanUniqueCode(string uniqueCode)
|
||||
{
|
||||
var receiptDetail = _unitWork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
|
||||
if (receiptDetail != null)
|
||||
{
|
||||
if (receiptDetail.Status == ReceiptStatusEnum.收完)
|
||||
{
|
||||
return JsonMore(null, 500, $"{uniqueCode}已全部收完,无需重新绑定!");
|
||||
}
|
||||
return JsonMore(receiptDetail);
|
||||
}
|
||||
return JsonMore(null, 500, $"{uniqueCode}不存在!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult BindingData(List<Binding> data)
|
||||
{
|
||||
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
|
||||
data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString()))
|
||||
.Include(x => x.ReceiptDetails).ToList();
|
||||
|
||||
var invList = new List<Inventory>();
|
||||
var listInvtran = new List<InventoryTransaction>();
|
||||
|
||||
// 查找明细,修改对应状态,并且 绑定物料周转箱
|
||||
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
|
||||
{
|
||||
// 更新入库单明细状态
|
||||
var header = receiptHeaderList.Find(x => x.ID.ToString().Equals(item.ReceiptCode));
|
||||
var receipt = header.ReceiptDetails.First(x => x.UniqueCode.Equals(item.UniqueCode));
|
||||
if (receipt != null)
|
||||
{
|
||||
if (receipt.Status == ReceiptStatusEnum.收完) continue;
|
||||
receipt.CompletedQty += item.BindQty;
|
||||
}
|
||||
if(receipt.CompletedQty == receipt.Qty)
|
||||
{
|
||||
receipt.Status = ReceiptStatusEnum.收完;
|
||||
if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完))
|
||||
{
|
||||
header.FirstStatus = ReceiptStatusEnum.收完;
|
||||
}
|
||||
receipt.UpdateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
// 新建库存
|
||||
invList.Add(new Inventory
|
||||
{
|
||||
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,
|
||||
Status = "0",
|
||||
TaskStatus = InventoryTaskStatus.无任务,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
CreateTime = DateTime.Now
|
||||
}); ;
|
||||
|
||||
foreach (var inv in invList)
|
||||
{
|
||||
listInvtran.Add(new InventoryTransaction
|
||||
{
|
||||
BillType = "in",
|
||||
ZoneCode = inv.ZoneCode,
|
||||
Type = inv.UniqueCode,
|
||||
MaterialCode = inv.MaterialCode,
|
||||
MaterialName = inv.MaterialName,
|
||||
MaterialSpec = inv.MaterialSpec,
|
||||
MaterialUnit = inv.MaterialUnit,
|
||||
MaterialType = inv.MaterialType,
|
||||
Batch = inv.Batch,
|
||||
Lot = inv.Lot,
|
||||
CompanyCode = inv.CompanyCode,
|
||||
LocationCode = inv.LocationCode,
|
||||
SupplierCode = inv.SupplierCode,
|
||||
Qty = inv.Qty,
|
||||
CreateTime = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
_unitWork.BatchAdd(invList.ToArray());
|
||||
_unitWork.BatchAdd(listInvtran.ToArray());
|
||||
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
|
||||
return JsonMore(null);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user