feat(仪表盘): 添加任务历史、库位状态和当前任务统计图表

refactor(库存交易): 使用AutoMapper简化库存交易记录创建逻辑
This commit is contained in:
zhougf committed 2025-10-01 03:22:33 +08:00
1 parent d89f6ffb3e
commit 3cba19da98
5 files changed
+563 -203

No files matched your search

@@ -1,8 +1,10 @@
using System;
using System.Linq;
using AutoMapper;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
@@ -14,11 +16,13 @@ namespace HHWMS.Web.Controllers
{
private readonly IUnitWork _unitWork;
private readonly WTMContext _context;
private readonly IMapper _mapper;
public SimpleReceiptInController(IUnitWork unitWork, WTMContext wtmContext)
public SimpleReceiptInController(IUnitWork unitWork, WTMContext wtmContext,IMapper mapper)
{
_unitWork = unitWork;
_context = wtmContext;
_mapper = mapper;
}
#region Index
@@ -96,9 +100,9 @@ namespace HHWMS.Web.Controllers
var materials = _unitWork.Find<Material>(x =>
x.MaterialCode.Contains(keyword) ||
x.MaterialType.Contains(keyword))
.Take(10)
.Take(50)
.Select(x => new {
x.MaterialCode,
x.MaterialCode,
x.MaterialName,
x.MaterialSpec,
x.MaterialUnit,
@@ -123,7 +127,7 @@ namespace HHWMS.Web.Controllers
CompanyCode = x.Code,
CompanyName = x.Name
})
.Take(10)
.Take(50)
.ToList();
return Json(new { Code = 200, Data = companies });
}
@@ -184,27 +188,10 @@ namespace HHWMS.Web.Controllers
_unitWork.Add(inventory);
// 创建入库交易记录
var transaction = new InventoryTransaction
{
ZoneCode = zone.ZoneCode,
BillType = InventoryTranType.入库,
MaterialCode = material.MaterialCode,
MaterialType = inventory.MaterialType,
MaterialName = material.MaterialName,
MaterialSpec = inventory.MaterialSpec,
MaterialUnit = material.MaterialUnit,
ContainerCode = container.Code,
CompanyCode = inventory.CompanyCode,
SourceCode = inventory.SourceCode,
SupplierCode = inventory.SupplierCode,
Batch = batch,
Qty = qty,
CreateTime = DateTime.Now,
CreateBy = "WMS",
UpdateTime = DateTime.Now,
UpdateBy = "WMS"
};
_unitWork.Add(transaction);
var invTran = _mapper.Map<InventoryTransaction>(inventory);
invTran.Type = InventoryTranType.入库;
_unitWork.Add(invTran);
return JsonMore(new { Id = inventory.ID });
}
@@ -328,24 +315,10 @@ namespace HHWMS.Web.Controllers
}
// 创建出库交易记录
var transaction = new InventoryTransaction
{
BillType = InventoryTranType.出库,
MaterialCode = inventory.MaterialCode,
MaterialName = inventory.MaterialName,
MaterialUnit = inventory.MaterialUnit,
ContainerCode = inventory.ContainerCode,
CompanyCode = inventory.CompanyCode,
SourceCode = inventory.SourceCode,
SupplierCode = inventory.SupplierCode,
Batch = inventory.Batch,
Qty = inventory.Qty,
CreateTime = DateTime.Now,
CreateBy = "WMS",
UpdateTime = DateTime.Now,
UpdateBy = "WMS"
};
_unitWork.Add(transaction);
var invTran = _mapper.Map<InventoryTransaction>(inventory);
invTran.Type = InventoryTranType.出库;
_unitWork.Add(invTran);
// 删除库存记录
_unitWork.Delete(inventory);
@@ -377,44 +350,17 @@ namespace HHWMS.Web.Controllers
}
// 创建出库交易记录(原数量)
var outTransaction = new InventoryTransaction
{
BillType = InventoryTranType.出库,
MaterialCode = inventory.MaterialCode,
MaterialName = inventory.MaterialName,
MaterialUnit = inventory.MaterialUnit,
ContainerCode = inventory.ContainerCode,
CompanyCode = inventory.CompanyCode,
SourceCode = inventory.SourceCode,
SupplierCode = inventory.SupplierCode,
Batch = inventory.Batch,
Qty = inventory.Qty,
CreateTime = DateTime.Now,
CreateBy = "WMS",
UpdateTime = DateTime.Now,
UpdateBy = "WMS"
};
_unitWork.Add(outTransaction);
var invOutTran = _mapper.Map<InventoryTransaction>(inventory);
invOutTran.Type = InventoryTranType.出库;
_unitWork.Add(invOutTran);
// 创建入库交易记录(新数量)
var inTransaction = new InventoryTransaction
{
BillType = InventoryTranType.入库,
MaterialCode = inventory.MaterialCode,
MaterialName = inventory.MaterialName,
MaterialUnit = inventory.MaterialUnit,
ContainerCode = inventory.ContainerCode,
CompanyCode = inventory.CompanyCode,
SourceCode = inventory.SourceCode,
SupplierCode = inventory.SupplierCode,
Batch = inventory.Batch,
Qty = qty,
CreateTime = DateTime.Now,
CreateBy = "WMS",
UpdateTime = DateTime.Now,
UpdateBy = "WMS"
};
_unitWork.Add(inTransaction);
var invInTran = _mapper.Map<InventoryTransaction>(inventory);
invInTran.Qty = qty;
invInTran.Type = InventoryTranType.入库;
_unitWork.Add(invInTran);
// 更新库存数量
inventory.Qty = qty;