feat(wms): 添加PDA毛坯入库功能及标签解析

- 在ResultionPackageCodeDto中添加BlankNumber字段用于存储毛坯号
- 新增IWmBlankInventoryService接口方法PDABlankWarehousing和ResolutionPackage
- 实现毛坯标签解析逻辑ResolutionPackagecode4
- 添加BlankInventoryWarehousingDto用于毛坯入库数据传输
- 在WmBlankInventoryController中新增PDA入库和标签解析API
- 实现WmBlankInventoryService中PDA入库核心逻辑
This commit is contained in:
2025-10-14 19:36:07 +08:00
parent d9c9e13d15
commit 893bffa431
6 changed files with 276 additions and 13 deletions

View File

@@ -29,5 +29,17 @@ namespace ZR.Service.mes.wms.IService
/// </summary>
/// <returns></returns>
public int GetPartNumber();
/// <summary>
/// PDA-扫码毛坯入库
/// </summary>
/// <returns></returns>
public int PDABlankWarehousing(BlankInventoryWarehousingDto warehousingDto);
/// <summary>
/// PDA-毛坯标签解析
/// </summary>
/// <returns></returns>
public ResultionPackageCodeDto ResolutionPackage(string code);
}
}

View File

@@ -1,12 +1,14 @@
using Infrastructure.Attribute;
using SqlSugar;
using System;
using System.Linq;
using Infrastructure.Attribute;
using Microsoft.AspNetCore.Authentication;
using SqlSugar;
using ZR.Model;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Repository;
using ZR.Service.mes.wms.IService;
using ZR.Service.Utils;
namespace ZR.Service.mes.wms
{
@@ -29,7 +31,15 @@ namespace ZR.Service.mes.wms
List<string> blankNums = Context
.Queryable<WmMaterial>()
.Where(it => it.Type == 2)
.Where(it => it.Status == 1).WhereIF(!string.IsNullOrEmpty(parm.Description), it => it.Description.Contains(parm.Description) || it.ProductName.Contains(parm.Description)).Select(o => o.BlankNum).ToList();
.Where(it => it.Status == 1)
.WhereIF(
!string.IsNullOrEmpty(parm.Description),
it =>
it.Description.Contains(parm.Description)
|| it.ProductName.Contains(parm.Description)
)
.Select(o => o.BlankNum)
.ToList();
var predicate = Expressionable
.Create<WmBlankInventory>()
@@ -41,18 +51,15 @@ namespace ZR.Service.mes.wms
!string.IsNullOrEmpty(parm.Description),
it => blankNums.Contains(it.BlankNum)
)
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
.AndIF(parm.Status > -1, it => it.Status == parm.Status)
.AndIF(parm.Type > 0, it => it.Type == parm.Type);
var response = Queryable()
.Where(predicate.ToExpression())
.OrderByDescending(it => it.UpdatedTime)
.ToPage<WmBlankInventory, WmBlankInventoryDto>(parm);
if (response.Result.Count > 0)
{
foreach (WmBlankInventoryDto item in response.Result)
{
WmMaterial material = Context
@@ -262,5 +269,98 @@ namespace ZR.Service.mes.wms
.Where(it => it.Status == 1)
.Sum(it => it.Quantity) ?? 0;
}
/// <summary>
/// PDA扫码入库
/// </summary>
/// <param name="labelCode"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public int PDABlankWarehousing(BlankInventoryWarehousingDto warehousingDto)
{
try
{
DateTime nowTime = DateTime.Now;
int result = 0;
List<WmBlankInventory> updateWmBlankInventories = new();
List<WmBlankRecord> addWmBlankRecourds = new();
// 检查是否返工件
int BackType = warehousingDto.IsBack == 0 ? 1 : 2;
List<ResultionPackageCodeDto> packageList = warehousingDto.PackageList;
if (packageList.Count == 0)
{
throw new Exception("无箱标签传入");
}
foreach (ResultionPackageCodeDto packageInfo in packageList)
{
// 库存变动
WmBlankInventory wmBlankInventory = Context
.Queryable<WmBlankInventory>()
.Where(it => it.Type == BackType)
.Where(it => it.Status == 1)
.Where(it => it.BlankNum == packageInfo.BlankNumber)
.First();
if (wmBlankInventory == null)
{
throw new Exception("毛坯库中暂无此毛坯");
}
wmBlankInventory.Quantity += packageInfo.Quantity;
wmBlankInventory.UpdatedTime = nowTime;
wmBlankInventory.UpdatedBy = warehousingDto.CreatedBy;
updateWmBlankInventories.Add(wmBlankInventory);
// 记录添加
WmBlankRecord wmBlankRecord =
new()
{
Id = SnowFlakeSingle.Instance.NextId().ToString(),
FkBlankInventoryId = wmBlankInventory.Id,
BlankNum = wmBlankInventory.BlankNum,
ChangeQuantity = packageInfo.Quantity,
// 1-入库 2-出库 3=盘点
Type = 1,
Status = 1,
ActionTime = nowTime,
Remark = $"PDA毛坯入库,批次号:{packageInfo.PatchCode}",
CreatedBy = warehousingDto.CreatedBy,
CreatedTime = nowTime
};
addWmBlankRecourds.Add(wmBlankRecord);
}
Context.Ado.BeginTran();
result = Context.Updateable(updateWmBlankInventories).ExecuteCommand();
if (result > 0)
{
//添加库存记录
Context.Insertable(addWmBlankRecourds).ExecuteCommand();
}
Context.Ado.CommitTran();
return result;
}
catch (Exception ex)
{
Context.Ado.RollbackTran();
throw new Exception(ex.Message);
}
}
/// <summary>
/// PDA 标签解析
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public ResultionPackageCodeDto ResolutionPackage(string code)
{
try
{
MaterialUtils materialToos = new();
ResultionPackageCodeDto packageCodeDto = materialToos.ResolutionPackage(code);
return packageCodeDto;
}
catch (Exception ex)
{
throw new Exception("毛坯标签解析异常:" + ex.Message);
}
}
}
}