仓库-拼箱功能实现

This commit is contained in:
赵正易 2024-04-18 17:02:17 +08:00
parent d83d634fc4
commit 59dd7307d8
3 changed files with 105 additions and 5 deletions

View File

@ -13,7 +13,7 @@ namespace ZR.Admin.WebApi.Controllers
/// <summary>
/// 仓库操作
/// </summary>
[Verify]
// [Verify]
[Route("/mes/wm/WmGoodsAction")]
public class WmGoodsActionController : BaseController
{
@ -38,6 +38,10 @@ namespace ZR.Admin.WebApi.Controllers
public IActionResult doConsolidationGoods([FromBody] WmGoodsConsolidationDto parm)
{
WmGoodsChangeLog response = _WmGoodsActionService.doConsolidationGoods(parm);
if(response == null)
{
return ToResponse(new ApiResult(500, "拼箱异常!", "拼箱异常!"));
}
return SUCCESS(response);
}

View File

@ -7,7 +7,9 @@ namespace ZR.Model.MES.wms.Dto
/// </summary>
public class WmGoodsConsolidationDto
{
public List<ResultionPackageCodeDto> List { get; set; }
public List<ResultionPackageCodeDto> PackageList { get; set; }
public string CreateBy { get; set; }
}
@ -16,7 +18,8 @@ namespace ZR.Model.MES.wms.Dto
/// </summary>
public class WmGoodsUnpackingDto
{
public List<ResultionPackageCodeDto> List { get; set; }
public ResultionPackageCodeDto Package { get; set; }
public string CreateBy { get; set; }
}
}

View File

@ -10,6 +10,7 @@ using ZR.Service.Business.IBusinessService;
using System.Linq;
using ZR.Service.mes.wms.IService;
using ZR.Model.MES.wms.Dto;
using System.Text.Json;
namespace ZR.Service.Business
{
@ -21,12 +22,104 @@ namespace ZR.Service.Business
{
public WmGoodsChangeLog doConsolidationGoods(WmGoodsConsolidationDto parm)
{
throw new NotImplementedException();
List<ResultionPackageCodeDto> list = parm.PackageList;
string description = "";
// 拼箱计数器
int num = 0;
int? quantityCount = 0;
List<string> ids = new();
// 箱验证
foreach (ResultionPackageCodeDto package in list)
{
num++;
WmGoodsNowProduction check1 = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient == package.PatchCode).First();
if (check1 == null)
{
return null;
}
if (num == 1)
{
description = "主箱:" + package.PatchCode + ",次箱:";
}
else
{
ids.Add(check1.Id);
description += package.PatchCode + ",";
}
quantityCount += package.Quantity;
}
ResultionPackageCodeDto mainPackage = list[0];
// 短批次
string shortPatchCode = mainPackage.PatchCode.Split('_')[0];
// 该批次最后一个拼箱记录
WmGoodsNowProduction lastConsolidationPackage = Context.Queryable<WmGoodsNowProduction>().Where(it => it.PackageCodeClient.Contains(shortPatchCode + "_4")).OrderBy(it => it.PackageCodeClient, OrderByType.Desc).First();
string newShortPatchCode = shortPatchCode;
int lastCode = 400;
if (lastConsolidationPackage == null)
{
newShortPatchCode += "_401";
}
else
{
if (int.TryParse(lastConsolidationPackage.PackageCodeClient.Split('_')[1], out lastCode))
{
if (lastCode > 400)
{
newShortPatchCode += "_" + (lastCode + 1);
}
else
{
newShortPatchCode += "_401";
}
}
}
description += "拼箱结果:" + newShortPatchCode;
var jsonObject = new
{
packageList = list
};
// 日志记录
WmGoodsChangeLog log = new WmGoodsChangeLog();
log.CreatedBy = parm.CreateBy;
log.CreatedTime = DateTime.Now.ToLocalTime();
log.Description = description;
log.JsonMsg = JsonSerializer.Serialize(jsonObject);
log.Type = 1;
Context.Insertable(log).ExecuteReturnEntity();
// 执行修改
// 1.主箱查出并修改参数
WmGoodsNowProduction nowProduction = Context.Queryable<WmGoodsNowProduction>()
.Where(it => it.PackageCodeClient == mainPackage.PatchCode).First();
if (nowProduction == null)
{
return null;
}
nowProduction.UpdatedBy = parm.CreateBy;
nowProduction.UpdatedTime = DateTime.Now.ToLocalTime();
nowProduction.PackageCodeClient = newShortPatchCode;
nowProduction.PackageCodeOriginal = "Code=" + newShortPatchCode
+ "^ItemNumber=" + nowProduction.Partnumber
+ "^Order=" + newShortPatchCode.Split('_')[0]
+ "^Qty=" + quantityCount;
nowProduction.GoodsNumLogic = quantityCount;
nowProduction.GoodsNumAction = quantityCount;
nowProduction.Remark = "拼箱";
// 修改主箱
Context.Updateable(nowProduction).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
// TODO修改打印记录
// 删除分箱
Context.Deleteable<WmGoodsNowProduction>().In(ids).ExecuteCommand();
return log;
}
public WmGoodsChangeLog doUnpackingGoods(WmGoodsUnpackingDto parm)
{
throw new NotImplementedException();
return null;
}
}
}