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