diff --git a/DOAN.Admin.WebApi/Controllers/MES/Material/MmInventoryController.cs b/DOAN.Admin.WebApi/Controllers/MES/Material/MmInventoryController.cs new file mode 100644 index 0000000..0ba9c24 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Material/MmInventoryController.cs @@ -0,0 +1,102 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Model.BZFM.Dto; +using DOAN.Model.BZFM; +using DOAN.Service.BZFM.IBZFMService; +using DOAN.Admin.WebApi.Filters; + +//创建时间:2025-12-24 +namespace DOAN.Admin.WebApi.Controllers.BZFM +{ + /// + /// 库存表 + /// + [Verify] + [Route("BZFM/MmInventory")] + public class MmInventoryController : BaseController + { + /// + /// 库存表接口 + /// + private readonly IMmInventoryService _MmInventoryService; + + public MmInventoryController(IMmInventoryService MmInventoryService) + { + _MmInventoryService = MmInventoryService; + } + + /// + /// 查询库存表列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "mminventory:list")] + public IActionResult QueryMmInventory([FromQuery] MmInventoryQueryDto parm) + { + var response = _MmInventoryService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询库存表详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "mminventory:query")] + public IActionResult GetMmInventory(int Id) + { + var response = _MmInventoryService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加库存表 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "mminventory:add")] + [Log(Title = "库存表", BusinessType = BusinessType.INSERT)] + public IActionResult AddMmInventory([FromBody] MmInventoryDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _MmInventoryService.AddMmInventory(modal); + + return SUCCESS(response); + } + + /// + /// 更新库存表 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "mminventory:edit")] + [Log(Title = "库存表", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateMmInventory([FromBody] MmInventoryDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _MmInventoryService.UpdateMmInventory(modal); + + return ToResponse(response); + } + + /// + /// 删除库存表 + /// + /// + [HttpPost("delete/{ids}")] + [ActionPermissionFilter(Permission = "mminventory:delete")] + [Log(Title = "库存表", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteMmInventory([FromRoute]string ids) + { + var idArr = Tools.SplitAndConvert(ids); + + return ToResponse(_MmInventoryService.Delete(idArr)); + } + + } +} \ No newline at end of file diff --git a/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs b/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs new file mode 100644 index 0000000..e6acbfe --- /dev/null +++ b/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs @@ -0,0 +1,49 @@ + +namespace DOAN.Model.BZFM.Dto +{ + /// + /// 库存表查询对象 + /// + public class MmInventoryQueryDto : PagerInfo + { + } + + /// + /// 库存表输入输出对象 + /// + public class MmInventoryDto + { + [Required(ErrorMessage = "主键ID不能为空")] + public int Id { get; set; } + + [Required(ErrorMessage = "物料编码不能为空")] + public string MaterialCode { get; set; } + + [Required(ErrorMessage = "仓库编码不能为空")] + public string WarehouseCode { get; set; } + + public string WarehouseName { get; set; } + + [Required(ErrorMessage = "库位编码不能为空")] + public string LocationCode { get; set; } + + public string LocationName { get; set; } + + public string BatchNo { get; set; } + + public decimal CurrentQty { get; set; } + + public string Unit { get; set; } + + public DateTime? ProductionDate { get; set; } + + public DateTime? ExpiryDate { get; set; } + + public DateTime? LastUpdatedTime { get; set; } + + public DateTime? CreatedTime { get; set; } + + + + } +} \ No newline at end of file diff --git a/DOAN.Model/MES/Material/MmInventory.cs b/DOAN.Model/MES/Material/MmInventory.cs new file mode 100644 index 0000000..d89b76e --- /dev/null +++ b/DOAN.Model/MES/Material/MmInventory.cs @@ -0,0 +1,88 @@ + +namespace DOAN.Model.BZFM +{ + /// + /// 库存表 + /// + [SugarTable("mm_inventory")] + public class MmInventory + { + /// + /// 主键ID + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 物料编码 + /// + [SugarColumn(ColumnName = "material_code")] + public string MaterialCode { get; set; } + + /// + /// 仓库编码 + /// + [SugarColumn(ColumnName = "warehouse_code")] + public string WarehouseCode { get; set; } + + /// + /// 仓库名称 + /// + [SugarColumn(ColumnName = "warehouse_name")] + public string WarehouseName { get; set; } + + /// + /// 库位编码 + /// + [SugarColumn(ColumnName = "location_code")] + public string LocationCode { get; set; } + + /// + /// 库位名称 + /// + [SugarColumn(ColumnName = "location_name")] + public string LocationName { get; set; } + + /// + /// 批次号 + /// + [SugarColumn(ColumnName = "batch_no")] + public string BatchNo { get; set; } + + /// + /// 当前库存量 + /// + [SugarColumn(ColumnName = "current_qty")] + public decimal CurrentQty { get; set; } + + /// + /// 计量单位 + /// + public string Unit { get; set; } + + /// + /// 生产日期 + /// + [SugarColumn(ColumnName = "production_date")] + public DateTime? ProductionDate { get; set; } + + /// + /// 有效期至 + /// + [SugarColumn(ColumnName = "expiry_date")] + public DateTime? ExpiryDate { get; set; } + + /// + /// 最后更新时间 + /// + [SugarColumn(ColumnName = "last_updated_time")] + public DateTime? LastUpdatedTime { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "created_time")] + public DateTime? CreatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Material/IService/IMmInventoryService.cs b/DOAN.Service/MES/Material/IService/IMmInventoryService.cs new file mode 100644 index 0000000..85de502 --- /dev/null +++ b/DOAN.Service/MES/Material/IService/IMmInventoryService.cs @@ -0,0 +1,21 @@ +using DOAN.Model.BZFM.Dto; +using DOAN.Model.BZFM; + +namespace DOAN.Service.BZFM.IBZFMService +{ + /// + /// 库存表service接口 + /// + public interface IMmInventoryService : IBaseService + { + PagedInfo GetList(MmInventoryQueryDto parm); + + MmInventory GetInfo(int Id); + + + MmInventory AddMmInventory(MmInventory parm); + int UpdateMmInventory(MmInventory parm); + + + } +} diff --git a/DOAN.Service/MES/Material/MmInventoryService.cs b/DOAN.Service/MES/Material/MmInventoryService.cs new file mode 100644 index 0000000..8f55bd6 --- /dev/null +++ b/DOAN.Service/MES/Material/MmInventoryService.cs @@ -0,0 +1,79 @@ +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model.BZFM.Dto; +using DOAN.Model.BZFM; +using DOAN.Repository; +using DOAN.Service.BZFM.IBZFMService; + +namespace DOAN.Service.BZFM +{ + /// + /// 库存表Service业务层处理 + /// + [AppService(ServiceType = typeof(IMmInventoryService), ServiceLifetime = LifeTime.Transient)] + public class MmInventoryService : BaseService, IMmInventoryService + { + /// + /// 查询库存表列表 + /// + /// + /// + public PagedInfo GetList(MmInventoryQueryDto parm) + { + var predicate = QueryExp(parm); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public MmInventory GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加库存表 + /// + /// + /// + public MmInventory AddMmInventory(MmInventory model) + { + return Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改库存表 + /// + /// + /// + public int UpdateMmInventory(MmInventory model) + { + return Update(model, true); + } + + /// + /// 查询导出表达式 + /// + /// + /// + private static Expressionable QueryExp(MmInventoryQueryDto parm) + { + var predicate = Expressionable.Create(); + + return predicate; + } + } +} \ No newline at end of file