From 512231d555187fb80c8ec109b5bf3063e15d2a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Fri, 26 Jul 2024 17:34:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=9B=E5=85=89=E4=BB=93=E5=BA=93=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/wms/WmPolishInventoryController.cs | 84 +++++++++---- ZR.Model/MES/wms/Dto/WmPolishRecordDto.cs | 15 ++- .../wms/IService/IWmPolishInventoryService.cs | 7 ++ .../mes/wms/WmPolishInventoryService.cs | 114 +++++++++++++++++- ZR.Service/mes/wms/WmPolishRecordService.cs | 31 ++++- 5 files changed, 219 insertions(+), 32 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmPolishInventoryController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmPolishInventoryController.cs index 30688f13..b6492818 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WmPolishInventoryController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmPolishInventoryController.cs @@ -104,27 +104,6 @@ namespace ZR.Admin.WebApi.Controllers return ToResponse(response); } - /// - /// 抛光手动入库 - /// - /// - [HttpPost("doWmPolishWarehousing")] - [ActionPermissionFilter(Permission = "business:wmpolishinventory:add")] - [Log(Title = "抛光手动入库", BusinessType = BusinessType.INSERT)] - public IActionResult DoWmPolishWarehousing([FromBody] WmPolishInventoryDto parm) - { - try - { - var modal = parm.Adapt().ToCreate(HttpContext); - var response = _WmPolishInventoryService.DoWmPolishWarehousing(modal); - return ToResponse(new ApiResult(200, "手动入库成功", response)); - } - catch (Exception e) - { - return ToResponse(new ApiResult(500, "手动入库异常:" + e.Message, e.Message)); - } - } - /// /// 物料下拉菜单查看 /// @@ -142,5 +121,68 @@ namespace ZR.Admin.WebApi.Controllers return ToResponse(new ApiResult(500, "获取物料下拉菜单数据失败:" + e.Message, null)); } } + + /// + /// 抛光手动入库 + /// + /// + [HttpPost("doWmPolishWarehousing")] + [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")] + [Log(Title = "抛光手动入库", BusinessType = BusinessType.UPDATE)] + public IActionResult DoWmPolishWarehousing([FromBody] WmPolishInventoryDto parm) + { + try + { + var modal = parm.Adapt().ToCreate(HttpContext); + var response = _WmPolishInventoryService.DoWmPolishWarehousing(modal); + return ToResponse(new ApiResult(200, "手动入库成功", response)); + } + catch (Exception e) + { + return ToResponse(new ApiResult(500, "手动入库异常:" + e.Message, e.Message)); + } + } + + /// + /// 抛光手动出库 + /// + /// + [HttpPost("doWmPolishRetrieval")] + [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")] + [Log(Title = "抛光手动出库", BusinessType = BusinessType.UPDATE)] + public IActionResult DoWmPolishRetrieval([FromBody] WmPolishInventoryDto parm) + { + try + { + var modal = parm.Adapt().ToCreate(HttpContext); + var response = _WmPolishInventoryService.DoWmPolishRetrieval(modal); + return ToResponse(new ApiResult(200, "手动出库成功", response)); + } + catch (Exception e) + { + return ToResponse(new ApiResult(500, "手动出库异常:" + e.Message, e.Message)); + } + } + + /// + /// 抛光仓库盘点 + /// + /// + [HttpPost("doWmPolishStocktaking")] + [ActionPermissionFilter(Permission = "business:wmpolishinventory:edit")] + [Log(Title = "抛光仓库盘点", BusinessType = BusinessType.INSERT)] + public IActionResult DoWmPolishStocktaking([FromBody] WmPolishInventoryDto parm) + { + try + { + var modal = parm.Adapt().ToCreate(HttpContext); + var response = _WmPolishInventoryService.DoWmPolishStocktaking(modal); + return ToResponse(new ApiResult(200, "盘点成功", response)); + } + catch (Exception e) + { + return ToResponse(new ApiResult(500, "盘点异常:" + e.Message, e.Message)); + } + } } } diff --git a/ZR.Model/MES/wms/Dto/WmPolishRecordDto.cs b/ZR.Model/MES/wms/Dto/WmPolishRecordDto.cs index 8b507951..c4e352d9 100644 --- a/ZR.Model/MES/wms/Dto/WmPolishRecordDto.cs +++ b/ZR.Model/MES/wms/Dto/WmPolishRecordDto.cs @@ -5,8 +5,16 @@ namespace ZR.Model.MES.wms.Dto /// /// 工艺路线-抛光 库存变动表查询对象 /// - public class WmPolishRecordQueryDto : PagerInfo + public class WmPolishRecordQueryDto : PagerInfo { + public string Id { get; set; } + public string FkInventoryId { get; set; } + public string Code { get; set; } + public string BlankNum { get; set; } + public string Partnumber { get; set; } + public int? ChangeType { get; set; } + public DateTime? StartActionTime { get; set; } + public DateTime? EndActionTime { get; set; } } /// @@ -43,8 +51,5 @@ namespace ZR.Model.MES.wms.Dto public string UpdatedBy { get; set; } public DateTime? UpdatedTime { get; set; } - - - } -} \ No newline at end of file +} diff --git a/ZR.Service/mes/wms/IService/IWmPolishInventoryService.cs b/ZR.Service/mes/wms/IService/IWmPolishInventoryService.cs index 347ddc1d..b1372864 100644 --- a/ZR.Service/mes/wms/IService/IWmPolishInventoryService.cs +++ b/ZR.Service/mes/wms/IService/IWmPolishInventoryService.cs @@ -30,6 +30,13 @@ namespace ZR.Service.mes.wms.IService /// int DoWmPolishWarehousing(WmPolishInventory parm); + /// + /// 抛光零件出库 + /// + /// + /// + int DoWmPolishRetrieval(WmPolishInventory parm); + /// /// 抛光零件盘点 /// diff --git a/ZR.Service/mes/wms/WmPolishInventoryService.cs b/ZR.Service/mes/wms/WmPolishInventoryService.cs index ba3c0219..6b8db5d1 100644 --- a/ZR.Service/mes/wms/WmPolishInventoryService.cs +++ b/ZR.Service/mes/wms/WmPolishInventoryService.cs @@ -252,7 +252,7 @@ namespace ZR.Service.mes.wms .Insertable(newWmPolishInventory) .ExecuteReturnEntity(); string code = SnowFlakeSingle.Instance.NextId().ToString(); - string remark = "初次创建仓库,新增手动入库数据"; + string remark = "初次创建仓库,新增入库数据 " + parm.Remark; int successNum = AddPolishRecord( addWmPolishInventory.Id, code, @@ -280,7 +280,6 @@ namespace ZR.Service.mes.wms } // 已有则新增记录 string code = SnowFlakeSingle.Instance.NextId().ToString(); - string remark = "手动入库"; int successNum = AddPolishRecord( polishInventory.Id, code, @@ -288,13 +287,117 @@ namespace ZR.Service.mes.wms 1, parm.Quantity, parm.ActionTime, + parm.Remark, + parm.CreatedBy + ); + if (successNum == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("入库日志添加失败"); + } + } + Context.Ado.CommitTran(); + return 1; + } + catch (Exception e) + { + Context.Ado.RollbackTran(); + throw new Exception(e.Message); + } + } + + public int DoWmPolishRetrieval(WmPolishInventory parm) + { + try + { + Context.Ado.BeginTran(); + // 零件号检查 + string partnumber = parm.Partnumber; + WmMaterial material = Context + .Queryable() + .Where(it => it.Partnumber == partnumber) + .Where(it => it.Type == 1) + .Where(it => it.Status == 1) + .First(); + if (material == null) + { + Context.Ado.RollbackTran(); + throw new Exception("零件号在物料清单未查到,请到物料清单新增零件号记录"); + } + // 检查是否存在库中 + WmPolishInventory polishInventory = Context + .Queryable() + .Where(it => it.Partnumber == partnumber) + .Where(it => it.Type == parm.Type) + .Where(it => it.Status == 1) + .First(); + if (polishInventory == null) + { + // 为空则新增库 + WmPolishInventory newWmPolishInventory = + new() + { + Id = SnowFlakeSingle.Instance.NextId().ToString(), + BlankNum = "", + Partnumber = partnumber, + Type = parm.Type, + Quantity = parm.Quantity * -1, + MaxNum = 0, + MinNum = 0, + WarnNum = 0, + Status = 1, + Remark = "系统自动创建库", + CreatedBy = parm.CreatedBy, + CreatedTime = DateTime.Now.ToLocalTime(), + UpdatedBy = parm.CreatedBy, + UpdatedTime = DateTime.Now.ToLocalTime(), + }; + WmPolishInventory addWmPolishInventory = Context + .Insertable(newWmPolishInventory) + .ExecuteReturnEntity(); + string code = SnowFlakeSingle.Instance.NextId().ToString(); + string remark = "初次创建仓库,新增手动出库数据" + parm.Remark; + int successNum = AddPolishRecord( + addWmPolishInventory.Id, + code, + partnumber, + 2, + parm.Quantity, + parm.ActionTime, remark, parm.CreatedBy ); if (successNum == 0) { Context.Ado.RollbackTran(); - throw new Exception("入库日志添加失败"); + throw new Exception("出库日志添加失败"); + } + } + else + { + polishInventory.Quantity -= parm.Quantity; + int updateNum = Context.Updateable(polishInventory).ExecuteCommand(); + if (updateNum == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("修改抛光仓库零件数失败"); + } + // 已有则新增记录 + string code = SnowFlakeSingle.Instance.NextId().ToString(); + int successNum = AddPolishRecord( + polishInventory.Id, + code, + partnumber, + 2, + parm.Quantity, + parm.ActionTime, + parm.Remark, + parm.CreatedBy + ); + if (successNum == 0) + { + Context.Ado.RollbackTran(); + throw new Exception("出库日志添加失败"); } } Context.Ado.CommitTran(); @@ -326,7 +429,6 @@ namespace ZR.Service.mes.wms Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); // 已有则新增记录 string code = SnowFlakeSingle.Instance.NextId().ToString(); - string remark = "手动盘点"; int successNum = AddPolishRecord( parm.Id, code, @@ -334,7 +436,7 @@ namespace ZR.Service.mes.wms 3, parm.Quantity, parm.ActionTime, - remark, + parm.Remark, parm.CreatedBy ); if (successNum == 0) @@ -351,5 +453,7 @@ namespace ZR.Service.mes.wms throw new Exception(e.Message); } } + + } } diff --git a/ZR.Service/mes/wms/WmPolishRecordService.cs b/ZR.Service/mes/wms/WmPolishRecordService.cs index fab1970b..acd40ede 100644 --- a/ZR.Service/mes/wms/WmPolishRecordService.cs +++ b/ZR.Service/mes/wms/WmPolishRecordService.cs @@ -1,4 +1,6 @@ +using System; using Infrastructure.Attribute; +using Infrastructure.Extensions; using SqlSugar; using ZR.Model; using ZR.Model.MES.wms; @@ -21,10 +23,37 @@ namespace ZR.Service.mes.wms /// public PagedInfo GetList(WmPolishRecordQueryDto parm) { - var predicate = Expressionable.Create(); + DateTime startTime = parm.StartActionTime ?? DateTime.MinValue; + DateTime endTime = parm.EndActionTime ?? DateTime.MinValue; + var predicate = Expressionable + .Create() + .AndIF( + !string.IsNullOrEmpty(parm.Partnumber), + it => it.Partnumber.Contains(parm.Partnumber) + ) + .AndIF( + !string.IsNullOrEmpty(parm.BlankNum), + it => it.BlankNum.Contains(parm.BlankNum) + ) + .AndIF(!string.IsNullOrEmpty(parm.Code), it => it.Code.Contains(parm.Code)) + .AndIF( + !string.IsNullOrEmpty(parm.FkInventoryId), + it => it.FkInventoryId == parm.FkInventoryId + ) + .AndIF(!string.IsNullOrEmpty(parm.Id), it => it.Id == parm.Id) + .AndIF(parm.ChangeType > -1, it => it.ChangeType == parm.ChangeType) + .AndIF( + startTime > DateTime.MinValue, + it => startTime <= it.ActionTime + ) + .AndIF( + endTime > DateTime.MinValue, + it => endTime >= it.ActionTime + ); var response = Queryable() .Where(predicate.ToExpression()) + .OrderByDescending(it => it.ActionTime) .ToPage(parm); return response;