入库出库盘点

This commit is contained in:
qianhao.xu 2024-12-30 15:25:40 +08:00
parent 760d0505f8
commit 4125a2efca
11 changed files with 147 additions and 5 deletions

View File

@ -102,7 +102,33 @@ namespace DOAN.Admin.WebApi.Controllers
return ToResponse(response);
}
//TODO 入库
[HttpPost("entryInventory")]
public IActionResult EntryInventory([FromBody] DevicePartsInventoryDto parm)
{
var response = _DevicePartsInventoryService.EntryInventory(parm);
return SUCCESS(response);
}
//TODO 出库
[HttpPost("OutInventory")]
public IActionResult OutInventory([FromBody] DevicePartsInventoryDto parm)
{
var response = _DevicePartsInventoryService.OutInventory(parm);
return SUCCESS(response);
}
//TODO 盘点
[HttpPost("CheckInventory")]
public IActionResult CheckInventory([FromBody] DevicePartsInventoryDto parm)
{
var response = _DevicePartsInventoryService.CheckInventory(parm);
return SUCCESS(response);
}

View File

@ -38,6 +38,15 @@ namespace DOAN.Admin.WebApi.Controllers
var response = _DevicePartsStorageLocationsService.GetList(parm);
return SUCCESS(response);
}
//TODO 查询备品备件库位编号
[HttpGet("list_location_code")]
public IActionResult QueryDevicePartsStorageLocationsLocationCode(string query)
{
var response = _DevicePartsStorageLocationsService.QueryDevicePartsStorageLocationsLocationCode(query);
return SUCCESS(response);
}
/// <summary>

View File

@ -38,6 +38,16 @@ namespace DOAN.Admin.WebApi.Controllers
var response = _DeviceSparePartsService.GetList(parm);
return SUCCESS(response);
}
//TODO 查询备品备件基本信息表列表 不分页
[HttpGet("list_nopage")]
[ActionPermissionFilter(Permission = "deviceManagement:devicespareparts:list")]
public IActionResult QueryDeviceSpareParts2(string query)
{
var response = _DeviceSparePartsService.GetListNOPage(query);
return SUCCESS(response);
}
/// <summary>

View File

@ -28,7 +28,7 @@ namespace DOAN.Model.Dto
/// </summary>
public class DevicePartsInventoryDto
{
[Required(ErrorMessage = "库存ID不能为空")]
public int InventoryId { get; set; }
[Required(ErrorMessage = "备件ID不能为空")]
@ -36,7 +36,7 @@ namespace DOAN.Model.Dto
[Required(ErrorMessage = "数量不能为空")]
public int Quantity { get; set; }
[Required(ErrorMessage = "库位不能为空")]
public string Location { get; set; }
public DateTime? LastInventoryCheck { get; set; }

View File

@ -7,14 +7,17 @@ namespace DOAN.Model.MES.dev.Dto
/// </summary>
public class DeviceSparePartsQueryDto : PagerInfo
{
public string PartName { get; set; }
public string PartCode { get; set; }
}
/// <summary>
/// 备品备件基本信息表输入输出对象
/// </summary>
public class DeviceSparePartsDto
{
[Required(ErrorMessage = "备件ID不能为空")]
public int PartId { get; set; }
[Required(ErrorMessage = "备件名称不能为空")]

View File

@ -101,6 +101,68 @@ namespace DOAN.Service.MES.dev
//return response;
return Update(model, true);
}
/// <summary>
/// 入库
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public bool EntryInventory(DevicePartsInventoryDto parm)
{
//要么新增,要么修改
bool isExist = Context.Queryable<DevicePartsInventory>()
.Where(it => it.PartId == parm.PartId && it.Location == parm.Location).Any();
if (isExist)
{
return Context.Updateable<DevicePartsInventory>()
.SetColumns(it=>it.Quantity==it.Quantity+parm.Quantity)
.SetColumns(it=>it.UpdatedAt==DateTime.Now)
.Where(it=>it.PartId==parm.PartId&&it.Location==parm.Location)
.ExecuteCommand()>0;
}
else
{ DevicePartsInventory inventory = new DevicePartsInventory
{
PartId = parm.PartId,
Quantity = parm.Quantity,
Location = parm.Location,
CreatedAt = DateTime.Now,
};
return Context.Insertable(inventory).ExecuteCommand()>0;
}
}
/// <summary>
/// 出库
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public bool OutInventory(DevicePartsInventoryDto parm)
{
return Context.Updateable<DevicePartsInventory>()
.SetColumns(it=>it.Quantity==it.Quantity-parm.Quantity)
.SetColumns(it=>it.UpdatedAt==DateTime.Now)
.Where(it=>it.PartId==parm.PartId&&it.Location==parm.Location)
.ExecuteCommand()>0;
}
public bool CheckInventory(DevicePartsInventoryDto parm)
{
return Context.Updateable<DevicePartsInventory>()
.SetColumns(it=>it.Quantity==parm.Quantity)
.SetColumns(it=>it.UpdatedAt==DateTime.Now)
.SetColumns(it=>it.LastInventoryCheck==DateTime.Now)
.Where(it=>it.PartId==parm.PartId&&it.Location==parm.Location)
.ExecuteCommand()>0;
}
}
}

View File

@ -34,6 +34,14 @@ namespace DOAN.Service.MES.dev
return response;
}
public string[] QueryDevicePartsStorageLocationsLocationCode(string query)
{
return Queryable()
.Where(x => x.LocationCode.Contains(query))
.Select(x => x.LocationCode)
.ToArray();
}
/// <summary>
/// 获取详情

View File

@ -10,6 +10,7 @@ using DOAN.Repository;
using System.Linq;
using DOAN.Service.MES.dev.IService;
using Mapster;
namespace DOAN.Service.MES.dev
{
@ -26,7 +27,10 @@ namespace DOAN.Service.MES.dev
/// <returns></returns>
public PagedInfo<DeviceSparePartsDto> GetList(DeviceSparePartsQueryDto parm)
{
var predicate = Expressionable.Create<DeviceSpareParts>();
var predicate = Expressionable.Create<DeviceSpareParts>()
.AndIF(!string.IsNullOrEmpty(parm.PartName), it => it.PartName.Contains(parm.PartName))
.AndIF(!string.IsNullOrEmpty(parm.PartCode), it => it.PartCode.Contains(parm.PartCode))
;
var response = Queryable()
.Where(predicate.ToExpression())
@ -35,6 +39,15 @@ namespace DOAN.Service.MES.dev
return response;
}
public List<DeviceSparePartsDto> GetListNOPage(string query)
{
var response = Queryable()
.Where(x => x.PartName.Contains(query)||x.PartCode.Contains(query))
.ToList().Adapt<List<DeviceSpareParts>,List<DeviceSparePartsDto>>();
return response;
}
/// <summary>
/// 获取详情

View File

@ -20,5 +20,11 @@ namespace DOAN.Service.MES.dev.IService
int UpdateDevicePartsInventory(DevicePartsInventory parm);
bool EntryInventory(DevicePartsInventoryDto parm);
bool OutInventory(DevicePartsInventoryDto parm);
bool CheckInventory(DevicePartsInventoryDto parm);
}
}

View File

@ -14,6 +14,9 @@ namespace DOAN.Service.MES.dev.IService
{
PagedInfo<DevicePartsStorageLocationsDto> GetList(DevicePartsStorageLocationsQueryDto parm);
string[] QueryDevicePartsStorageLocationsLocationCode(string query);
DevicePartsStorageLocations GetInfo(int LocationId);
DevicePartsStorageLocations AddDevicePartsStorageLocations(DevicePartsStorageLocations parm);

View File

@ -14,6 +14,8 @@ namespace DOAN.Service.MES.dev.IService
{
PagedInfo<DeviceSparePartsDto> GetList(DeviceSparePartsQueryDto parm);
List<DeviceSparePartsDto> GetListNOPage(string query);
DeviceSpareParts GetInfo(int PartId);
DeviceSpareParts AddDeviceSpareParts(DeviceSpareParts parm);