From 8ef52020771c0cc7180e6d25c61c062352a4409a Mon Sep 17 00:00:00 2001 From: manful mr Date: Wed, 24 Dec 2025 19:09:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=93=E5=AD=98=E8=A1=A8?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=9A=E5=90=AB=E5=AE=9E=E4=BD=93=E3=80=81?= =?UTF-8?q?DTO=E3=80=81Service=E5=8F=8AAPI=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 本次提交实现了库存表(MmInventory)模块的全套后端代码,包括: - 新增 MmInventoryController,提供库存表的增删改查(CRUD)API,集成权限与日志注解; - 新增 MmInventory 实体类,定义库存表数据库字段映射; - 新增 MmInventoryDto、MmInventoryQueryDto 用于数据传输和分页查询,含字段校验; - 新增 IMmInventoryService 接口及其实现 MmInventoryService,支持库存表的业务操作和动态查询。 该提交为库存管理功能提供了完整的后端支撑。 --- .../MES/Material/MmInventoryController.cs | 102 ++++++++++++++++++ DOAN.Model/MES/Material/Dto/MmInventoryDto.cs | 49 +++++++++ DOAN.Model/MES/Material/MmInventory.cs | 88 +++++++++++++++ .../Material/IService/IMmInventoryService.cs | 21 ++++ .../MES/Material/MmInventoryService.cs | 79 ++++++++++++++ 5 files changed, 339 insertions(+) create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Material/MmInventoryController.cs create mode 100644 DOAN.Model/MES/Material/Dto/MmInventoryDto.cs create mode 100644 DOAN.Model/MES/Material/MmInventory.cs create mode 100644 DOAN.Service/MES/Material/IService/IMmInventoryService.cs create mode 100644 DOAN.Service/MES/Material/MmInventoryService.cs 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