feat(wms): 添加PDA毛坯入库功能及标签解析
- 在ResultionPackageCodeDto中添加BlankNumber字段用于存储毛坯号 - 新增IWmBlankInventoryService接口方法PDABlankWarehousing和ResolutionPackage - 实现毛坯标签解析逻辑ResolutionPackagecode4 - 添加BlankInventoryWarehousingDto用于毛坯入库数据传输 - 在WmBlankInventoryController中新增PDA入库和标签解析API - 实现WmBlankInventoryService中PDA入库核心逻辑
This commit is contained in:
@@ -64,6 +64,18 @@ namespace ZR.Service.Utils
|
||||
{
|
||||
return ResolutionPackagecode3(code);
|
||||
}
|
||||
// 毛坯标签
|
||||
if (code.Contains('/'))
|
||||
{
|
||||
// 初步进行解析检测,增加解析成功率
|
||||
string[] splitstr = code.Split('/');
|
||||
if (splitstr.Length < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ResolutionPackagecode4(code);
|
||||
}
|
||||
// 成品标签
|
||||
if (code.Contains('^'))
|
||||
{
|
||||
// 初步进行解析检测,增加解析成功率
|
||||
@@ -302,5 +314,70 @@ namespace ZR.Service.Utils
|
||||
throw new Exception("解析失败" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 4-解析毛坯标签码
|
||||
/// </summary>
|
||||
/// <param name="packagecode"></param>
|
||||
/// <returns></returns>
|
||||
private ResultionPackageCodeDto ResolutionPackagecode4(string packagecode)
|
||||
{
|
||||
ResultionPackageCodeDto resultionPackageCode = new ResultionPackageCodeDto();
|
||||
try
|
||||
{
|
||||
resultionPackageCode.originalCode = packagecode;
|
||||
// 解析外箱标签码
|
||||
string[] splitstr = packagecode.Split('/');
|
||||
// 解析批次号
|
||||
resultionPackageCode.PatchCode = splitstr[1];
|
||||
// 解析零件号
|
||||
string partnumber = splitstr[0];
|
||||
// 零件号
|
||||
resultionPackageCode.PartNumner = partnumber;
|
||||
// 毛坯号
|
||||
string _blankNumber = splitstr[5];
|
||||
// 去掉毛坯号中带横杠的后缀(如-M2)
|
||||
if (!string.IsNullOrEmpty(_blankNumber) && _blankNumber.Contains('-'))
|
||||
{
|
||||
_blankNumber = _blankNumber.Split('-')[0];
|
||||
}
|
||||
|
||||
resultionPackageCode.BlankNumber = _blankNumber;
|
||||
// 解析工单号 工单号会带个W,需要去掉
|
||||
string workoderidid = "";
|
||||
resultionPackageCode.WorkoderID = "";
|
||||
// 解析生产时间 工单号生产时间提取
|
||||
resultionPackageCode.ProductionTime = splitstr[1];
|
||||
// 解析箱子中产品数量
|
||||
string product_num = splitstr[4];
|
||||
resultionPackageCode.Quantity = int.Parse(product_num);
|
||||
// 解析产品描述 partnumber 从物料列表抓取数据
|
||||
WmMaterial material = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = "物料记录未录入此零件号信息!";
|
||||
return resultionPackageCode;
|
||||
}
|
||||
string des1 = material.Description;
|
||||
string des2 = material.ProductName;
|
||||
if (!string.IsNullOrEmpty(des1))
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = des1;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(des2))
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = des2;
|
||||
}
|
||||
return resultionPackageCode;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error($"外箱标签码,解析失败 {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user