diff --git a/ZR.Admin.WebApi/Controllers/mes/pro/WmPackingrecordController.cs b/ZR.Admin.WebApi/Controllers/mes/pro/WmPackingrecordController.cs new file mode 100644 index 00000000..5d68fe54 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/mes/pro/WmPackingrecordController.cs @@ -0,0 +1,109 @@ +using Microsoft.AspNetCore.Mvc; +using ZR.Admin.WebApi.Extensions; +using ZR.Admin.WebApi.Filters; +using ZR.Service.mes.pro.IService; +using ZR.Model.MES.pro.DTO; +using ZR.Model.mes.pro; + +//创建时间:2024-05-20 +namespace ZR.Admin.WebApi.Controllers +{ + /// + /// 包装记录 + /// + [Verify] + [Route("mes/pro/WmPackingrecord")] + public class WmPackingrecordController : BaseController + { + /// + /// 包装记录接口 + /// + private readonly IWmPackingrecordService _WmPackingrecordService; + + public WmPackingrecordController(IWmPackingrecordService WmPackingrecordService) + { + _WmPackingrecordService = WmPackingrecordService; + } + + /// + /// 查询包装记录列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:list")] + public IActionResult QueryWmPackingrecord([FromQuery] WmPackingrecordQueryDto parm) + { + var response = _WmPackingrecordService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询包装记录详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:query")] + public IActionResult GetWmPackingrecord(long Id) + { + var response = _WmPackingrecordService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加包装记录 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:add")] + [Log(Title = "包装记录", BusinessType = BusinessType.INSERT)] + public IActionResult AddWmPackingrecord([FromBody] WmPackingrecordDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _WmPackingrecordService.AddWmPackingrecord(modal); + + return SUCCESS(response); + } + + /// + /// 更新包装记录 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:edit")] + [Log(Title = "包装记录", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateWmPackingrecord([FromBody] WmPackingrecordDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _WmPackingrecordService.UpdateWmPackingrecord(modal); + + return ToResponse(response); + } + + /// + /// 删除包装记录 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "productmanagement:wmpackingrecord:delete")] + [Log(Title = "包装记录", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteWmPackingrecord(string ids) + { + long[] idsArr = Tools.SpitLongArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _WmPackingrecordService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-包装记录-0520091356.zip b/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-包装记录-0520091356.zip new file mode 100644 index 00000000..a1f8b64c Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/Generatecode/ZrAdmin.NET-包装记录-0520091356.zip differ diff --git a/ZR.Model/MES/pro/DTO/WmPackingrecordDto.cs b/ZR.Model/MES/pro/DTO/WmPackingrecordDto.cs new file mode 100644 index 00000000..53557fca --- /dev/null +++ b/ZR.Model/MES/pro/DTO/WmPackingrecordDto.cs @@ -0,0 +1,53 @@ +using System.ComponentModel.DataAnnotations; + +namespace ZR.Model.MES.pro.DTO +{ + /// + /// 包装记录查询对象 + /// + public class WmPackingrecordQueryDto : PagerInfo + { + public string PartNum { get; set; } + + public string Machine { get; set; } + public string WorkOrderNum { get; set; } + public DateTime? start_time { get; set; } + public DateTime? end_time { get; set; } + + } + + /// + /// 包装记录输入输出对象 + /// + public class WmPackingrecordDto + { + public long Id { get; set; } + + + public string PartNum { get; set; } + + public string Machine { get; set; } + + public string ProductCode { get; set; } + + public string PackingCode { get; set; } + + public string ScannerContent { get; set; } + + public string WorkOrderNum { get; set; } + + public string Standby3 { get; set; } + + public string Standby4 { get; set; } + + public string Standby5 { get; set; } + + [Required(ErrorMessage = "指示是否满箱不能为空")] + public bool BFilled { get; set; } + + public DateTime? CreateTime { get; set; } + + + + } +} \ No newline at end of file diff --git a/ZR.Model/MES/pro/WmPackingrecord.cs b/ZR.Model/MES/pro/WmPackingrecord.cs new file mode 100644 index 00000000..edc5e81e --- /dev/null +++ b/ZR.Model/MES/pro/WmPackingrecord.cs @@ -0,0 +1,72 @@ + +namespace ZR.Model.mes.pro +{ + /// + /// 包装记录 + /// + [SugarTable("wm_packingrecord")] + public class WmPackingrecord + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public long Id { get; set; } + + /// + /// 零件号 + /// + public string PartNum { get; set; } + + /// + /// 设备名称(ID) + /// + public string Machine { get; set; } + + /// + /// 产品条码 + /// + public string ProductCode { get; set; } + + /// + /// 箱条码 + /// + public string PackingCode { get; set; } + + /// + /// 扫码记录 + /// + public string ScannerContent { get; set; } + + /// + /// 工单号 + /// + public string WorkOrderNum { get; set; } + + /// + /// 备用3 + /// + public string Standby3 { get; set; } + + /// + /// 备用4 + /// + public string Standby4 { get; set; } + + /// + /// 备用5 + /// + public string Standby5 { get; set; } + + /// + /// 指示是否满箱 + /// + public bool BFilled { get; set; } + + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + + } +} \ No newline at end of file diff --git a/ZR.Repository/BaseRepository.cs b/ZR.Repository/BaseRepository.cs index 552939c8..3bd2ac49 100644 --- a/ZR.Repository/BaseRepository.cs +++ b/ZR.Repository/BaseRepository.cs @@ -34,6 +34,19 @@ namespace ZR.Repository itenant = DbScoped.SugarScope;//设置租户接口 } + public long UUID + { + + get + { + return UUID; + } + set + { + UUID = SnowFlakeSingle.Instance.NextId(); + } + } + #region add /// @@ -65,7 +78,7 @@ namespace ZR.Repository //{ // return Context.Updateable(entity); //} - + /// /// 实体根据主键更新 /// diff --git a/ZR.Service/mes/pro/IService/IWmPackingrecordService.cs b/ZR.Service/mes/pro/IService/IWmPackingrecordService.cs new file mode 100644 index 00000000..5c350f6b --- /dev/null +++ b/ZR.Service/mes/pro/IService/IWmPackingrecordService.cs @@ -0,0 +1,23 @@ +using System; +using ZR.Model; +using System.Collections.Generic; +using ZR.Model.mes.pro; +using ZR.Model.MES.pro.DTO; + +namespace ZR.Service.mes.pro.IService +{ + /// + /// 包装记录service接口 + /// + public interface IWmPackingrecordService : IBaseService + { + PagedInfo GetList(WmPackingrecordQueryDto parm); + + WmPackingrecord GetInfo(long Id); + + WmPackingrecord AddWmPackingrecord(WmPackingrecord parm); + + int UpdateWmPackingrecord(WmPackingrecord parm); + + } +} diff --git a/ZR.Service/mes/pro/WmPackingrecordService.cs b/ZR.Service/mes/pro/WmPackingrecordService.cs new file mode 100644 index 00000000..ca963a97 --- /dev/null +++ b/ZR.Service/mes/pro/WmPackingrecordService.cs @@ -0,0 +1,95 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using ZR.Model; + +using ZR.Repository; +using ZR.Service.Business.IBusinessService; +using System.Linq; +using ZR.Model.mes.pro; +using ZR.Model.MES.pro.DTO; + +namespace ZR.Service.mes.pro.IService +{ + /// + /// 包装记录Service业务层处理 + /// + [AppService(ServiceType = typeof(IWmPackingrecordService), ServiceLifetime = LifeTime.Transient)] + public class WmPackingrecordService : BaseService, IWmPackingrecordService + { + /// + /// 查询包装记录列表 + /// + /// + /// + public PagedInfo GetList(WmPackingrecordQueryDto parm) + { + var predicate = Expressionable.Create(); + predicate.AndIF(!string.IsNullOrEmpty(parm.PartNum), it => it.PartNum == parm.PartNum) + .AndIF(!string.IsNullOrEmpty(parm.Machine), it => it.Machine == parm.Machine) + .AndIF(!string.IsNullOrEmpty(parm.WorkOrderNum), it => it.WorkOrderNum == parm.WorkOrderNum) + .AndIF(parm.start_time > new DateTime(2021, 1, 1), it => it.CreateTime >= parm.start_time) + .AndIF(parm.end_time > new DateTime(2021, 1, 1), it => it.CreateTime <= parm.end_time); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public WmPackingrecord GetInfo(long Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加包装记录 + /// + /// + /// + public WmPackingrecord AddWmPackingrecord(WmPackingrecord model) + { + model.Id = SnowFlakeSingle.Instance.NextId(); + model.CreateTime = DateTime.Now; + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改包装记录 + /// + /// + /// + public int UpdateWmPackingrecord(WmPackingrecord model) + { + //var response = Update(w => w.Id == model.Id, it => new WmPackingrecord() + //{ + // PartNum = model.PartNum, + // Machine = model.Machine, + // ProductCode = model.ProductCode, + // PackingCode = model.PackingCode, + // ScannerContent = model.ScannerContent, + // WorkOrderNum = model.WorkOrderNum, + // Standby3 = model.Standby3, + // Standby4 = model.Standby4, + // Standby5 = model.Standby5, + // BFilled = model.BFilled, + // CreateTime = model.CreateTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file