仓库-批量出库功能实现

This commit is contained in:
2024-04-23 18:42:44 +08:00
parent 50226106f5
commit b3fc2394e7
4 changed files with 114 additions and 1 deletions

View File

@@ -104,7 +104,25 @@ namespace ZR.Admin.WebApi.Controllers
return ToResponse(response);
}
/// <summary>
/// 按批次出库
/// </summary>
/// <returns></returns>
[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));
}
}
}

View File

@@ -93,5 +93,19 @@ namespace ZR.Model.MES.wms.Dto
}
/// <summary>
/// 批次出库
/// </summary>
public class WmBatchGoodsOutProductionDto
{
public List<string> Ids { get; set; }
public string FkOutOrderId { get; set; } = "无出库单";
public string PackageCodeClient { get; set; } = string.Empty;
public string Partnumber { get; set; }
/// <summary>
/// 1-传ids全部出库 2-按批次号全部出库
/// </summary>
public int Type { get; set; }
}
}

View File

@@ -20,5 +20,6 @@ namespace ZR.Service.mes.wms.IService
int UpdateWmGoodsOutProduction(WmGoodsOutRecord parm);
string DoPatchOutProduction(WmBatchGoodsOutProductionDto parm);
}
}

View File

@@ -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<WmGoodsNowProduction>()
.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<WmGoodsNowProduction>().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<WmGoodsNowProduction> nowProductionList = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient.Contains(shortPackageCode)).ToList();
for (int i = 0; i < nowProductionList.Count; i++)
{
WmGoodsNowProduction nowProduction = Context.Queryable<WmGoodsNowProduction>()
.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<WmGoodsNowProduction>().Where(it => it.Id == nowProduction.Id).ExecuteCommand();
}
}
return "ok";
}
}
}