feat(wms): 添加PDA毛坯入库功能及标签解析
- 在ResultionPackageCodeDto中添加BlankNumber字段用于存储毛坯号 - 新增IWmBlankInventoryService接口方法PDABlankWarehousing和ResolutionPackage - 实现毛坯标签解析逻辑ResolutionPackagecode4 - 添加BlankInventoryWarehousingDto用于毛坯入库数据传输 - 在WmBlankInventoryController中新增PDA入库和标签解析API - 实现WmBlankInventoryService中PDA入库核心逻辑
This commit is contained in:
@@ -148,6 +148,53 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PDA毛坯入库
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("PDABlankWarehousing")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Log(Title = "PDA毛坯入库", BusinessType = BusinessType.UPDATE)]
|
||||||
|
public IActionResult PDABlankWarehousing([FromBody] BlankInventoryWarehousingDto parm)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var modal = parm.Adapt<BlankInventoryWarehousingDto>().ToCreate(HttpContext);
|
||||||
|
|
||||||
|
int successNum = _WmBlankInventoryService.PDABlankWarehousing(modal);
|
||||||
|
|
||||||
|
return ToResponse(new ApiResult(200, "入库成功,已入库:" + successNum + "条毛坯记录!", "入库成功"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ToResponse(new ApiResult(500, ex.Message, "入库失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PDA毛坯标签解析
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("PDABlankResolutionPackage")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
[Log(Title = "PDA毛坯入库", BusinessType = BusinessType.UPDATE)]
|
||||||
|
public IActionResult PDABlankResolutionPackage(string code)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(code)) {
|
||||||
|
return ToResponse(new ApiResult(500, "传入标签为空", "传入标签为空"));
|
||||||
|
}
|
||||||
|
var response = _WmBlankInventoryService.ResolutionPackage(code);
|
||||||
|
|
||||||
|
return SUCCESS(response);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ToResponse(new ApiResult(500, ex.Message, "入库失败"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,10 @@
|
|||||||
/// 零件号
|
/// 零件号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PartNumner { get; set; }
|
public string PartNumner { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 毛坯号
|
||||||
|
/// </summary>
|
||||||
|
public string BlankNumber { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工单号
|
/// 工单号
|
||||||
|
|||||||
@@ -25,23 +25,27 @@ namespace ZR.Model.MES.wms.Dto
|
|||||||
public string BlankNum { get; set; }
|
public string BlankNum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单位
|
/// 单位
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 颜色
|
/// 颜色
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Color { get; set; }
|
public string Color { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 规格
|
/// 规格
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Specification { get; set; }
|
public string Specification { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述
|
/// 描述
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 版本号
|
/// 版本号
|
||||||
///</summary>
|
///</summary>
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
|
|
||||||
@@ -81,4 +85,23 @@ namespace ZR.Model.MES.wms.Dto
|
|||||||
|
|
||||||
public DateTime? UpdatedTime { get; set; }
|
public DateTime? UpdatedTime { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// 毛坯库存入库
|
||||||
|
/// </summary>
|
||||||
|
public class BlankInventoryWarehousingDto
|
||||||
|
{
|
||||||
|
public List<ResultionPackageCodeDto> PackageList { get; set; } = new List<ResultionPackageCodeDto>();
|
||||||
|
|
||||||
|
// 1-返工件 对应数据库type=2 0-非返工件 对应数据库type=1
|
||||||
|
public int IsBack { get; set; } = 1;
|
||||||
|
|
||||||
|
public string CreatedBy { get; set; }
|
||||||
|
|
||||||
|
public DateTime? CreatedTime { get; set; }
|
||||||
|
|
||||||
|
public string UpdatedBy { get; set; }
|
||||||
|
|
||||||
|
public DateTime? UpdatedTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,6 +64,18 @@ namespace ZR.Service.Utils
|
|||||||
{
|
{
|
||||||
return ResolutionPackagecode3(code);
|
return ResolutionPackagecode3(code);
|
||||||
}
|
}
|
||||||
|
// 毛坯标签
|
||||||
|
if (code.Contains('/'))
|
||||||
|
{
|
||||||
|
// 初步进行解析检测,增加解析成功率
|
||||||
|
string[] splitstr = code.Split('/');
|
||||||
|
if (splitstr.Length < 1)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ResolutionPackagecode4(code);
|
||||||
|
}
|
||||||
|
// 成品标签
|
||||||
if (code.Contains('^'))
|
if (code.Contains('^'))
|
||||||
{
|
{
|
||||||
// 初步进行解析检测,增加解析成功率
|
// 初步进行解析检测,增加解析成功率
|
||||||
@@ -302,5 +314,70 @@ namespace ZR.Service.Utils
|
|||||||
throw new Exception("解析失败" + e.Message);
|
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>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int GetPartNumber();
|
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;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using SqlSugar;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.MES.wms;
|
using ZR.Model.MES.wms;
|
||||||
using ZR.Model.MES.wms.Dto;
|
using ZR.Model.MES.wms.Dto;
|
||||||
using ZR.Repository;
|
using ZR.Repository;
|
||||||
using ZR.Service.mes.wms.IService;
|
using ZR.Service.mes.wms.IService;
|
||||||
|
using ZR.Service.Utils;
|
||||||
|
|
||||||
namespace ZR.Service.mes.wms
|
namespace ZR.Service.mes.wms
|
||||||
{
|
{
|
||||||
@@ -29,7 +31,15 @@ namespace ZR.Service.mes.wms
|
|||||||
List<string> blankNums = Context
|
List<string> blankNums = Context
|
||||||
.Queryable<WmMaterial>()
|
.Queryable<WmMaterial>()
|
||||||
.Where(it => it.Type == 2)
|
.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
|
var predicate = Expressionable
|
||||||
.Create<WmBlankInventory>()
|
.Create<WmBlankInventory>()
|
||||||
@@ -41,18 +51,15 @@ namespace ZR.Service.mes.wms
|
|||||||
!string.IsNullOrEmpty(parm.Description),
|
!string.IsNullOrEmpty(parm.Description),
|
||||||
it => blankNums.Contains(it.BlankNum)
|
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);
|
.AndIF(parm.Type > 0, it => it.Type == parm.Type);
|
||||||
|
|
||||||
var response = Queryable()
|
var response = Queryable()
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
|
|
||||||
.OrderByDescending(it => it.UpdatedTime)
|
.OrderByDescending(it => it.UpdatedTime)
|
||||||
.ToPage<WmBlankInventory, WmBlankInventoryDto>(parm);
|
.ToPage<WmBlankInventory, WmBlankInventoryDto>(parm);
|
||||||
if (response.Result.Count > 0)
|
if (response.Result.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
foreach (WmBlankInventoryDto item in response.Result)
|
foreach (WmBlankInventoryDto item in response.Result)
|
||||||
{
|
{
|
||||||
WmMaterial material = Context
|
WmMaterial material = Context
|
||||||
@@ -262,5 +269,98 @@ namespace ZR.Service.mes.wms
|
|||||||
.Where(it => it.Status == 1)
|
.Where(it => it.Status == 1)
|
||||||
.Sum(it => it.Quantity) ?? 0;
|
.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