From b3fc2394e7794a5b3b5903b3b97688e53686d643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=AD=A3=E6=98=93?= Date: Tue, 23 Apr 2024 18:42:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=BA=93-=E6=89=B9=E9=87=8F=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/wms/WmGoodsOutProductionController.cs | 20 ++++- .../MES/wms/Dto/WmGoodsOutProductionDto.cs | 14 ++++ .../IService/IWmGoodsOutProductionService.cs | 1 + .../mes/wms/WmGoodsOutProductionService.cs | 80 +++++++++++++++++++ 4 files changed, 114 insertions(+), 1 deletion(-) diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs index de44a27b..27967ae5 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WmGoodsOutProductionController.cs @@ -104,7 +104,25 @@ namespace ZR.Admin.WebApi.Controllers return ToResponse(response); } - + /// + /// 按批次出库 + /// + /// + [HttpPost("doPatchOutProduction")] + [Log(Title = "按批次出库", BusinessType = BusinessType.INSERT)] + public IActionResult DoPatchOutProduction([FromBody] WmBatchGoodsOutProductionDto parm) + { + string response = _WmGoodsOutProductionService.DoPatchOutProduction(parm); + if(response == "ok") + { + return ToResponse(new ApiResult(200, response, response)); + } + else + { + return ToResponse(new ApiResult(500, response, response)); + } + + } } diff --git a/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs b/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs index 0af3eaa2..4465dc11 100644 --- a/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs +++ b/ZR.Model/MES/wms/Dto/WmGoodsOutProductionDto.cs @@ -93,5 +93,19 @@ namespace ZR.Model.MES.wms.Dto + } + /// + /// 批次出库 + /// + public class WmBatchGoodsOutProductionDto + { + public List Ids { get; set; } + public string FkOutOrderId { get; set; } = "无出库单"; + public string PackageCodeClient { get; set; } = string.Empty; + public string Partnumber { get; set; } + /// + /// 1-传ids全部出库 2-按批次号全部出库 + /// + public int Type { get; set; } } } \ No newline at end of file diff --git a/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs b/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs index eb907056..a9f9f168 100644 --- a/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs +++ b/ZR.Service/mes/wms/IService/IWmGoodsOutProductionService.cs @@ -20,5 +20,6 @@ namespace ZR.Service.mes.wms.IService int UpdateWmGoodsOutProduction(WmGoodsOutRecord parm); + string DoPatchOutProduction(WmBatchGoodsOutProductionDto parm); } } diff --git a/ZR.Service/mes/wms/WmGoodsOutProductionService.cs b/ZR.Service/mes/wms/WmGoodsOutProductionService.cs index 01791947..569b07e5 100644 --- a/ZR.Service/mes/wms/WmGoodsOutProductionService.cs +++ b/ZR.Service/mes/wms/WmGoodsOutProductionService.cs @@ -11,6 +11,7 @@ using ZR.Service.mes.wms.IService; using ZR.Model.MES.wms; using ZR.Model.MES.wms.Dto; using static System.Runtime.InteropServices.JavaScript.JSType; +using System.Collections.Generic; namespace ZR.Service.mes.wms { @@ -120,5 +121,84 @@ namespace ZR.Service.mes.wms return Update(model, true); } + public string DoPatchOutProduction(WmBatchGoodsOutProductionDto parm) + { + int type = parm.Type; + var time = DateTime.Now.ToLocalTime(); + if (type == 1) + { + var list = parm.Ids; + for (int i = 0; i < list.Count; i++) + { + WmGoodsNowProduction nowProduction = Context.Queryable() + .Where(it => it.Id == list[i]).First(); + if(nowProduction == null) + { + continue; + } + WmGoodsOutRecord outRecord = new() + { + Id = SnowFlakeSingle.Instance.NextId().ToString(), + FkNowProductionId = nowProduction.Id, + FkOutOrderId = parm.FkOutOrderId, + PackageCode = nowProduction.PackageCode, + PackageCodeClient = nowProduction.PackageCodeClient, + PackageCodeOriginal = nowProduction.PackageCodeOriginal, + LocationCode = nowProduction.LocationCode, + Partnumber = nowProduction.Partnumber, + GoodsNumAction = nowProduction.GoodsNumAction, + GoodsNumLogic = nowProduction.GoodsNumAction, + EntryWarehouseTime = nowProduction.EntryWarehouseTime, + OutTime = time, + Remark = "批量出库", + CreatedBy = "batch", + CreatedTime = time, + }; + Context.Insertable(outRecord).ExecuteCommand(); + Context.Deleteable().Where(it => it.Id == nowProduction.Id).ExecuteCommand(); + } + } + else if(type == 2) + { + if (parm.PackageCodeClient == "" || parm.PackageCodeClient == null) + { + return "无批次号参数"; + } + // 短批次号 + string shortPackageCode = parm.PackageCodeClient.Split('_')[0]; + List nowProductionList = Context.Queryable() + .Where(it => it.PackageCodeClient.Contains(shortPackageCode)).ToList(); + for (int i = 0; i < nowProductionList.Count; i++) + { + WmGoodsNowProduction nowProduction = Context.Queryable() + .Where(it => it.Id == nowProductionList[i].Id).First(); + if (nowProduction == null) + { + continue; + } + WmGoodsOutRecord outRecord = new() + { + Id = SnowFlakeSingle.Instance.NextId().ToString(), + FkNowProductionId = nowProduction.Id, + FkOutOrderId = parm.FkOutOrderId, + PackageCode = nowProduction.PackageCode, + PackageCodeClient = nowProduction.PackageCodeClient, + PackageCodeOriginal = nowProduction.PackageCodeOriginal, + LocationCode = nowProduction.LocationCode, + Partnumber = nowProduction.Partnumber, + GoodsNumAction = nowProduction.GoodsNumAction, + GoodsNumLogic = nowProduction.GoodsNumAction, + EntryWarehouseTime = nowProduction.EntryWarehouseTime, + OutTime = time, + Remark = "批量出库", + CreatedBy = "batch", + CreatedTime = time, + }; + Context.Insertable(outRecord).ExecuteCommand(); + Context.Deleteable().Where(it => it.Id == nowProduction.Id).ExecuteCommand(); + } + } + return "ok"; + } } } \ No newline at end of file