diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsChangeLogController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsChangeLogController.cs new file mode 100644 index 00000000..6cd38041 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsChangeLogController.cs @@ -0,0 +1,111 @@ +using Microsoft.AspNetCore.Mvc; +using ZR.Model.Dto; +using ZR.Service.Business.IBusinessService; +using ZR.Admin.WebApi.Extensions; +using ZR.Admin.WebApi.Filters; +using ZR.Model.MES.wms.Dto; +using ZR.Service.mes.wms.IService; +using ZR.Model.MES.wms; + +//创建时间:2024-04-18 +namespace ZR.Admin.WebApi.Controllers +{ + /// + /// 仓库操作日志 + /// + [Verify] + [Route("business/WmGoodsChangeLog")] + public class WmGoodsChangeLogController : BaseController + { + /// + /// 仓库操作日志接口 + /// + private readonly IWmGoodsChangeLogService _WmGoodsChangeLogService; + + public WmGoodsChangeLogController(IWmGoodsChangeLogService WmGoodsChangeLogService) + { + _WmGoodsChangeLogService = WmGoodsChangeLogService; + } + + /// + /// 查询仓库操作日志列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:wmgoodschangelog:list")] + public IActionResult QueryWmGoodsChangeLog([FromQuery] WmGoodsChangeLogQueryDto parm) + { + var response = _WmGoodsChangeLogService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询仓库操作日志详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:wmgoodschangelog:query")] + public IActionResult GetWmGoodsChangeLog(int Id) + { + var response = _WmGoodsChangeLogService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加仓库操作日志 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:wmgoodschangelog:add")] + [Log(Title = "仓库操作日志", BusinessType = BusinessType.INSERT)] + public IActionResult AddWmGoodsChangeLog([FromBody] WmGoodsChangeLogDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _WmGoodsChangeLogService.AddWmGoodsChangeLog(modal); + + return SUCCESS(response); + } + + /// + /// 更新仓库操作日志 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:wmgoodschangelog:edit")] + [Log(Title = "仓库操作日志", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateWmGoodsChangeLog([FromBody] WmGoodsChangeLogDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _WmGoodsChangeLogService.UpdateWmGoodsChangeLog(modal); + + return ToResponse(response); + } + + /// + /// 删除仓库操作日志 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:wmgoodschangelog:delete")] + [Log(Title = "仓库操作日志", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteWmGoodsChangeLog(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _WmGoodsChangeLogService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/wms/Dto/WmGoodsChangeLogDto.cs b/ZR.Model/MES/wms/Dto/WmGoodsChangeLogDto.cs new file mode 100644 index 00000000..a5f6ceba --- /dev/null +++ b/ZR.Model/MES/wms/Dto/WmGoodsChangeLogDto.cs @@ -0,0 +1,43 @@ +using System.ComponentModel.DataAnnotations; + +namespace ZR.Model.MES.wms.Dto +{ + /// + /// 仓库操作日志查询对象 + /// + public class WmGoodsChangeLogQueryDto : PagerInfo + { + public int Id { get; set; } + public int Type { get; set; } + + public string Description { get; set; } + public string StartTimeStr { get; set; } + public string EndTimeStr { get; set; } + + } + + /// + /// 仓库操作日志输入输出对象 + /// + public class WmGoodsChangeLogDto + { + public int Id { get; set; } + + public int Type { get; set; } + + public string Description { get; set; } + + public string JsonMsg { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/wms/WmGoodsChangeLog.cs b/ZR.Model/MES/wms/WmGoodsChangeLog.cs new file mode 100644 index 00000000..04cf36e6 --- /dev/null +++ b/ZR.Model/MES/wms/WmGoodsChangeLog.cs @@ -0,0 +1,56 @@ + +namespace ZR.Model.MES.wms +{ + /// + /// 仓库操作日志 + /// + [SugarTable("wm_goods_change_log")] + public class WmGoodsChangeLog + { + /// + /// 主键 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 操作类型;0-默认1-拼箱2-拆箱3-移库4-待定。。。其余待定 + /// + public int Type { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + /// + /// 内容;存入json格式字符串,根据type类型不同,灵活存储不同数据,不可解析,算作空 + /// + public string JsonMsg { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "cREATED_BY")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "cREATED_TIME")] + public DateTime? CreatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "uPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "uPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/ZR.Service/mes/wms/IService/IWmGoodsChangeLogService.cs b/ZR.Service/mes/wms/IService/IWmGoodsChangeLogService.cs new file mode 100644 index 00000000..1c17d0ef --- /dev/null +++ b/ZR.Service/mes/wms/IService/IWmGoodsChangeLogService.cs @@ -0,0 +1,24 @@ +using System; +using ZR.Model; +using ZR.Model.Dto; +using ZR.Model.MES.wms; +using System.Collections.Generic; +using ZR.Model.MES.wms.Dto; + +namespace ZR.Service.mes.wms.IService +{ + /// + /// 仓库操作日志service接口 + /// + public interface IWmGoodsChangeLogService : IBaseService + { + PagedInfo GetList(WmGoodsChangeLogQueryDto parm); + + WmGoodsChangeLog GetInfo(int Id); + + WmGoodsChangeLog AddWmGoodsChangeLog(WmGoodsChangeLog parm); + + int UpdateWmGoodsChangeLog(WmGoodsChangeLog parm); + + } +} diff --git a/ZR.Service/mes/wms/WmGoodsChangeLogService.cs b/ZR.Service/mes/wms/WmGoodsChangeLogService.cs new file mode 100644 index 00000000..5ffde051 --- /dev/null +++ b/ZR.Service/mes/wms/WmGoodsChangeLogService.cs @@ -0,0 +1,93 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using ZR.Model; +using ZR.Model.Dto; +using ZR.Model.MES.wms; +using ZR.Repository; +using ZR.Service.Business.IBusinessService; +using System.Linq; +using ZR.Service.mes.wms.IService; +using ZR.Model.MES.wms.Dto; + +namespace ZR.Service.Business +{ + /// + /// 仓库操作日志Service业务层处理 + /// + [AppService(ServiceType = typeof(IWmGoodsChangeLogService), ServiceLifetime = LifeTime.Transient)] + public class WmGoodsChangeLogService : BaseService, IWmGoodsChangeLogService + { + /// + /// 查询仓库操作日志列表 + /// + /// + /// + public PagedInfo GetList(WmGoodsChangeLogQueryDto parm) + { + DateTime searchStartTime = DateTime.Now; + DateTime searchEndTime = DateTime.Now; + var predicate = Expressionable.Create() + .AndIF(parm.Type > 0, it => it.Type == parm.Type) + .AndIF(!string.IsNullOrEmpty(parm.Description), it => it.Description.Contains(parm.Description)) + // 当天0点 + .AndIF(DateTime.TryParse(parm.StartTimeStr,out searchStartTime), it => it.CreatedTime > searchStartTime) + // 当天23点59分59秒 + .AndIF(DateTime.TryParse(parm.EndTimeStr, out searchEndTime), it => it.CreatedTime < searchEndTime.AddDays(1).AddTicks(-1)) + ; + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public WmGoodsChangeLog GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加仓库操作日志 + /// + /// + /// + public WmGoodsChangeLog AddWmGoodsChangeLog(WmGoodsChangeLog model) + { + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改仓库操作日志 + /// + /// + /// + public int UpdateWmGoodsChangeLog(WmGoodsChangeLog model) + { + //var response = Update(w => w.Id == model.Id, it => new WmGoodsChangeLog() + //{ + // Type = model.Type, + // Description = model.Description, + // JsonMsg = model.JsonMsg, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file