质量大屏添加合格率,描述排序,新增一个标签解析
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using System;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace ZR.Service.Utils
|
||||
string quantity = "";
|
||||
string batchCode = "";
|
||||
// 判断解析是否成功
|
||||
if (!partnumberMatch.Success) {
|
||||
if (!partnumberMatch.Success)
|
||||
{
|
||||
throw new Exception("解析零件号失败");
|
||||
}
|
||||
if (!quantityMatch.Success)
|
||||
@@ -52,16 +53,18 @@ namespace ZR.Service.Utils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
throw new Exception("解析失败" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//解析外箱标签码
|
||||
public ResultionPackageCodeDto ResolutionPackage(string code)
|
||||
{
|
||||
// 德国大众
|
||||
if (code.Contains("MX2D") && code.Contains("MLX"))
|
||||
{
|
||||
return ResolutionPackagecode3(code);
|
||||
}
|
||||
if (code.Contains('^'))
|
||||
{
|
||||
// 初步进行解析检测,增加解析成功率
|
||||
@@ -109,12 +112,18 @@ namespace ZR.Service.Utils
|
||||
string workoderidid = splitstr[2].Substring(7);
|
||||
resultionPackageCode.WorkoderID = workoderidid;
|
||||
// 解析生产时间 工单号生产时间提取
|
||||
resultionPackageCode.ProductionTime = string.Concat("20", workoderidid.AsSpan(0, 6));
|
||||
resultionPackageCode.ProductionTime = string.Concat(
|
||||
"20",
|
||||
workoderidid.AsSpan(0, 6)
|
||||
);
|
||||
// 解析箱子中产品数量
|
||||
string product_num = splitstr[3].Substring(4);
|
||||
resultionPackageCode.Quantity = int.Parse(product_num);
|
||||
// 解析产品描述 partnumber 从物料列表抓取数据
|
||||
WmMaterial material = Context.Queryable<WmMaterial>().Where(it => it.Partnumber == partnumber).First();
|
||||
WmMaterial material = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = "物料记录未录入此零件号信息!";
|
||||
@@ -138,7 +147,12 @@ namespace ZR.Service.Utils
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 2-解析门把手
|
||||
|
||||
/// <summary>
|
||||
/// 2-解析门把手
|
||||
/// </summary>
|
||||
/// <param name="packagecode"></param>
|
||||
/// <returns></returns>
|
||||
private ResultionPackageCodeDto ResolutionPackagecode2(string packagecode)
|
||||
{
|
||||
ResultionPackageCodeDto resultionPackageCode = new ResultionPackageCodeDto();
|
||||
@@ -162,7 +176,10 @@ namespace ZR.Service.Utils
|
||||
string product_num = splitstr[4].Substring(3);
|
||||
resultionPackageCode.Quantity = int.Parse(product_num);
|
||||
// 解析产品描述 partnumber 从物料列表抓取数据
|
||||
WmMaterial material = Context.Queryable<WmMaterial>().Where(it => it.Partnumber == partnumber).First();
|
||||
WmMaterial material = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.First();
|
||||
if (material == null)
|
||||
{
|
||||
resultionPackageCode.ProductionDescribe = "物料记录未录入此零件号信息!";
|
||||
@@ -191,5 +208,100 @@ namespace ZR.Service.Utils
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3-解析德国大众标签
|
||||
/// </summary>
|
||||
/// <param name="packagecode">原始标签码</param>
|
||||
/// <returns></returns>
|
||||
private ResultionPackageCodeDto ResolutionPackagecode3(string packagecode)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 定义正则表达式模式
|
||||
string partnumberPattern = @"1P(\d+)Q"; // 产品零件号
|
||||
string quantityPattern = @"Q(\d+)S"; // 产品数量
|
||||
string batchCodePattern = @"S(\d+)13Q"; // 批次号(工单号)
|
||||
string serialNumberPattern = @"13Q(\d+)B"; // 流水号
|
||||
string productionTimePattern = @"12D(\d+)4L"; // 生产日期
|
||||
// 使用正则表达式进行匹配
|
||||
Match partnumberMatch = Regex.Match(packagecode, partnumberPattern);
|
||||
Match quantityMatch = Regex.Match(packagecode, quantityPattern);
|
||||
Match batchCodeMatch = Regex.Match(packagecode, batchCodePattern);
|
||||
Match serialNumberMatch = Regex.Match(packagecode, serialNumberPattern);
|
||||
Match productionTimeMatch = Regex.Match(packagecode, productionTimePattern);
|
||||
// 创建接收
|
||||
string partnumber = "";
|
||||
string quantityStr = "";
|
||||
string batchCode = "";
|
||||
string serialNumber = "";
|
||||
string productionTime = "";
|
||||
// 判断解析是否成功
|
||||
if (!partnumberMatch.Success)
|
||||
{
|
||||
throw new Exception("解析零件号失败");
|
||||
}
|
||||
if (!quantityMatch.Success)
|
||||
{
|
||||
throw new Exception("解析产品数量失败");
|
||||
}
|
||||
if (!batchCodeMatch.Success)
|
||||
{
|
||||
throw new Exception("解析产品批次号失败");
|
||||
}
|
||||
if (!serialNumberMatch.Success)
|
||||
{
|
||||
throw new Exception("解析产品流水号失败");
|
||||
}
|
||||
if (!productionTimeMatch.Success)
|
||||
{
|
||||
throw new Exception("解析产品生产日期失败");
|
||||
}
|
||||
partnumber = partnumberMatch.Groups[1].Value;
|
||||
quantityStr = quantityMatch.Groups[1].Value.TrimStart('0');
|
||||
batchCode = batchCodeMatch.Groups[1].Value.TrimStart('0');
|
||||
serialNumber = serialNumberMatch.Groups[1].Value.TrimStart('0');
|
||||
productionTime = productionTimeMatch.Groups[1].Value;
|
||||
string PatchCode = "BNW" + batchCode + '_' + serialNumber;
|
||||
string WorkoderID = batchCode;
|
||||
string ProductionTime = productionTime;
|
||||
bool isSuccess1 = int.TryParse(quantityStr, out int quantity);
|
||||
if (!isSuccess1)
|
||||
{
|
||||
quantity = 0;
|
||||
}
|
||||
// 产品描述
|
||||
string ProductionDescribe = "";
|
||||
WmMaterial material = Context
|
||||
.Queryable<WmMaterial>()
|
||||
.Where(it => it.Partnumber == partnumber)
|
||||
.Where(it => it.Type == 1)
|
||||
.Where(it => it.Status == 1)
|
||||
.First();
|
||||
if (material != null)
|
||||
{
|
||||
ProductionDescribe = !string.IsNullOrEmpty(material.Description)
|
||||
? material.Description
|
||||
: material.ProductName;
|
||||
}
|
||||
ResultionPackageCodeDto resultionPackageCode =
|
||||
new()
|
||||
{
|
||||
originalCode = packagecode,
|
||||
PatchCode = PatchCode,
|
||||
WorkoderID = WorkoderID,
|
||||
PartNumner = partnumber,
|
||||
ProductionTime = ProductionTime,
|
||||
Quantity = quantity,
|
||||
Team = "",
|
||||
ProductionDescribe = ProductionDescribe,
|
||||
Remark = "德国大众",
|
||||
};
|
||||
return resultionPackageCode;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception("解析失败" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user