后道工单添加打印信息查看,补打标签,打印零头标签功能,配置文件更新
This commit is contained in:
@@ -98,5 +98,19 @@ namespace ZR.Service.Business.IBusinessService
|
||||
/// <param name="workorderDetail">工单信息</param>
|
||||
/// <returns></returns>
|
||||
public QcBackEndServiceWorkorder GenerateVirtualLabel(QcBackEndWorkorderDetailDto workorderDetail);
|
||||
|
||||
/// <summary>
|
||||
/// 后道特殊箱标签打印
|
||||
/// </summary>
|
||||
/// <param name="workorderDetail">工单信息</param>
|
||||
/// <returns></returns>
|
||||
public string PrintSpecialPacakgeLabel(QcBackEndWorkorderDetailDto workorderDetail, int specialPrintType,int packageNum);
|
||||
|
||||
/// <summary>
|
||||
/// 工单标签信息查询
|
||||
/// </summary>
|
||||
/// <param name="workorderDetail">工单信息</param>
|
||||
/// <returns></returns>
|
||||
public QcBackEndWorkorderPrintLabelDetailDto SearchWorkOrderLabelDetail(string workOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using ZR.Model.Business;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Service.Business.IBusinessService;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ZR.Service.Business
|
||||
{
|
||||
@@ -675,7 +676,7 @@ namespace ZR.Service.Business
|
||||
.Queryable<QcBackEndServiceWorkorder>()
|
||||
.Where(it => it.WorkOrder == data.WorkOrder)
|
||||
.First();
|
||||
if(workorderInfo == null)
|
||||
if (workorderInfo == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
return "工单号不存在!";
|
||||
@@ -877,7 +878,7 @@ namespace ZR.Service.Business
|
||||
.Queryable<QcBackEndServiceWorkorder>()
|
||||
.Where(it => it.WorkOrder == workorder)
|
||||
.First();
|
||||
if (workorder == null)
|
||||
if (workorderInfo == null)
|
||||
{
|
||||
throw new Exception($"异常:工单不存在{workorder}");
|
||||
}
|
||||
@@ -943,10 +944,12 @@ namespace ZR.Service.Business
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentNullException">当输入参数为null时抛出</exception>
|
||||
/// <exception cref="ArgumentException">当标签内容无效时抛出</exception>
|
||||
/// <param name="specialPrintType">特殊标签 0-正常 1-补打 2-零头箱</param>
|
||||
public async Task SendPrintPackageLabelAsync(
|
||||
QcBackEndRecordLabelScan newLabelScran,
|
||||
string path,
|
||||
int maxPackage
|
||||
int maxPackage,
|
||||
int specialPrintType = 0
|
||||
)
|
||||
{
|
||||
// 参数验证
|
||||
@@ -966,7 +969,8 @@ namespace ZR.Service.Business
|
||||
QcBackEndPrintMqttEventDto mqttEventDto = CreateNewQcBackEndPrintMqttEventDto(
|
||||
newLabelScran,
|
||||
path,
|
||||
maxPackage
|
||||
maxPackage,
|
||||
specialPrintType
|
||||
);
|
||||
|
||||
var payload = JsonSerializer.Serialize(mqttEventDto);
|
||||
@@ -982,7 +986,7 @@ namespace ZR.Service.Business
|
||||
_logger.LogInformation($"发送后道外箱标签打印成功:{topic}");
|
||||
|
||||
// 添加打印记录
|
||||
await AddBackendLabelPrintRecordAsync(mqttEventDto, maxPackage);
|
||||
await AddBackendLabelPrintRecordAsync(mqttEventDto, newLabelScran.WorkOrder, maxPackage, specialPrintType);
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
@@ -998,10 +1002,13 @@ namespace ZR.Service.Business
|
||||
|
||||
/// <summary>
|
||||
/// 异步添加后道箱标签打印记录
|
||||
/// <param name="specialPrintType">特殊标签 0-正常 1-补打 2-零头箱</param>
|
||||
/// </summary>
|
||||
private async Task AddBackendLabelPrintRecordAsync(
|
||||
QcBackEndPrintMqttEventDto labelScan,
|
||||
int maxPackage
|
||||
string workOrder,
|
||||
int maxPackage,
|
||||
int specialPrintType = 0
|
||||
)
|
||||
{
|
||||
try
|
||||
@@ -1040,7 +1047,7 @@ namespace ZR.Service.Business
|
||||
Id = SnowFlakeSingle.instance.NextId().ToString(),
|
||||
MachineCode = labelScan.SiteNo ?? "未知站点",
|
||||
LabelCode = labelCode,
|
||||
WorkOrder = labelScan.WorkOrder ?? "未知工单",
|
||||
WorkOrder = workOrder ?? "未知工单",
|
||||
PartNumber = labelScan.PartNumber ?? "未知零件号",
|
||||
Description = description,
|
||||
Team = labelScan.Team ?? "未知班组",
|
||||
@@ -1049,7 +1056,7 @@ namespace ZR.Service.Business
|
||||
PartNum = maxPackage,
|
||||
LabelType = 1,
|
||||
BoxMaxNum = maxPackage,
|
||||
IsFull = 1,
|
||||
IsFull = specialPrintType == 2 ? 0 : 1,
|
||||
IsLcl = 0,
|
||||
CreateBy = "后道标签打印系统",
|
||||
CreateTime = DateTime.Now
|
||||
@@ -1070,11 +1077,13 @@ namespace ZR.Service.Business
|
||||
/// </summary>
|
||||
/// <param name="newLabelScran"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="specialPrintType">特殊标签 0-正常 1-补打 2-零头箱</param>
|
||||
/// <returns></returns>
|
||||
public QcBackEndPrintMqttEventDto CreateNewQcBackEndPrintMqttEventDto(
|
||||
QcBackEndRecordLabelScan newLabelScran,
|
||||
string path,
|
||||
int maxPackage
|
||||
int maxPackage,
|
||||
int specialPrintType = 0
|
||||
)
|
||||
{
|
||||
// 解析产品批次号,如果没有,则生成最新批次号
|
||||
@@ -1117,8 +1126,12 @@ namespace ZR.Service.Business
|
||||
}
|
||||
// 生成工单号
|
||||
string workOrder = $"{batchCode}_{packageSort}";
|
||||
// 是否满箱 0-不满 1-满箱
|
||||
int isFull = specialPrintType == 2 ? 0 : 1;
|
||||
// 是否补打 0-非补打 1-补打
|
||||
int isAgain = specialPrintType == 1 ? 1 : 0;
|
||||
string newLabelCode =
|
||||
$"Code=PGW{workOrder}^ItemNumber={newLabelScran.PartNumber}^Order=W{workOrder}^Qty={maxPackage}^LabelType=1^LabelBy=HD^Team={newLabelScran.Team}";
|
||||
$"Code=PGW{workOrder}^ItemNumber={newLabelScran.PartNumber}^Order=W{workOrder}^Qty={maxPackage}^LabelType=1^LabelBy=HD^Team={newLabelScran.Team}^IsFull={isFull}^IsAgain={isAgain}";
|
||||
string newPackageCode = $"BOX:PGW{workOrder}{newLabelScran.Team}1";
|
||||
QcBackEndPrintMqttEventDto mqttEventDto =
|
||||
new()
|
||||
@@ -1399,5 +1412,146 @@ namespace ZR.Service.Business
|
||||
{
|
||||
return Guid.NewGuid().ToString("N").Substring(0, 10); // Generate a 10-character unique ID
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印特殊包装标签
|
||||
/// </summary>
|
||||
/// <param name="workorderDetail">工单信息</param>
|
||||
/// <param name="specialPrintType">特殊打印类别 1-补打标签 2-打印零头箱</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public string PrintSpecialPacakgeLabel(
|
||||
QcBackEndWorkorderDetailDto workorderDetail,
|
||||
int specialPrintType = 1,
|
||||
int packageNum = 0
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
Context.Ado.BeginTran();
|
||||
DateTime nowTime = DateTime.Now;
|
||||
// 工单判断
|
||||
QcBackEndServiceWorkorder workorderInfo = Context
|
||||
.Queryable<QcBackEndServiceWorkorder>()
|
||||
.Where(it => it.WorkOrder == workorderDetail.WorkOrder)
|
||||
.First();
|
||||
if (workorderInfo == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
return $"异常:工单不存在,工单号:[{workorderDetail.WorkOrder}]";
|
||||
}
|
||||
// 打印配置确认
|
||||
QcBackendBaseOutpackage packageLabelConfig = Context
|
||||
.Queryable<QcBackendBaseOutpackage>()
|
||||
.Where(it => workorderInfo.Description.Contains(it.CheckStr))
|
||||
.First();
|
||||
if (packageLabelConfig == null)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
return $"异常:零件满箱配置不存在,工单号[{workorderDetail.WorkOrder}]";
|
||||
}
|
||||
string remark = specialPrintType == 1 ? "补打标签" : "零头箱";
|
||||
// 上一个内标签流水号检查
|
||||
int oldInnerLabelSort = 0;
|
||||
QcBackEndRecordLabelScan labelScan = Context
|
||||
.Queryable<QcBackEndRecordLabelScan>()
|
||||
.Where(it => it.WorkOrder == workorderDetail.WorkOrder)
|
||||
.Where(it => it.LabelType == 2)
|
||||
.OrderByDescending(it => it.LabelSort)
|
||||
.First();
|
||||
if (labelScan != null)
|
||||
{
|
||||
oldInnerLabelSort = labelScan.LabelSort ?? 0;
|
||||
}
|
||||
// 新内标签流水号
|
||||
int newSort = oldInnerLabelSort + 1;
|
||||
// 新标签生成
|
||||
QcBackEndRecordLabelScan newLabelScran =
|
||||
new()
|
||||
{
|
||||
Id = SnowFlakeSingle.Instance.NextId().ToString(),
|
||||
WorkOrder = workorderInfo.WorkOrder,
|
||||
PartNumber = workorderInfo.PartNumber,
|
||||
Team = workorderInfo.Team,
|
||||
SiteNo = workorderInfo.SiteNo,
|
||||
ComNo = workorderInfo.ComNo,
|
||||
Label = workorderInfo.Label,
|
||||
LabelType = 1,
|
||||
LabelSort = newSort,
|
||||
ScanTime = $"{nowTime:yyyy-MM-dd HH:mm:ss}",
|
||||
Type = "1",
|
||||
Status = "1",
|
||||
Remark = remark,
|
||||
CreatedBy = "特殊标签",
|
||||
CreatedTime = nowTime,
|
||||
};
|
||||
int _pacakgeNum = packageLabelConfig.PackageNum.Value;
|
||||
// 1.补打标签
|
||||
if (specialPrintType == 1)
|
||||
{
|
||||
SendPrintPackageLabelAsync(
|
||||
newLabelScran,
|
||||
packageLabelConfig.FileUrl,
|
||||
_pacakgeNum,
|
||||
specialPrintType
|
||||
)
|
||||
.Wait();
|
||||
}
|
||||
// 2.打印零头箱
|
||||
if (specialPrintType == 2)
|
||||
{
|
||||
_pacakgeNum = packageNum;
|
||||
SendPrintPackageLabelAsync(
|
||||
newLabelScran,
|
||||
packageLabelConfig.FileUrl,
|
||||
_pacakgeNum,
|
||||
specialPrintType
|
||||
)
|
||||
.Wait();
|
||||
//Context.Insertable(newLabelScran).ExecuteCommand();
|
||||
}
|
||||
Context.Ado.CommitTran();
|
||||
return "ok";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Context.Ado.RollbackTran();
|
||||
return $"系统异常{ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
public QcBackEndWorkorderPrintLabelDetailDto SearchWorkOrderLabelDetail(string workOrder)
|
||||
{
|
||||
QcBackEndWorkorderPrintLabelDetailDto result = new();
|
||||
result.ScannedPartCount = Context
|
||||
.Queryable<QcBackEndRecordLabelScan>()
|
||||
.Where(it => it.WorkOrder == workOrder)
|
||||
.Where(it => it.LabelType == 2)
|
||||
.Count();
|
||||
result.ScannedBoxLabelCount = Context
|
||||
.Queryable<QcBackEndRecordLabelScan>()
|
||||
.Where(it => it.WorkOrder == workOrder)
|
||||
.Where(it => it.LabelType == 1)
|
||||
.Where(it => it.LabelSort > 0)
|
||||
.Count();
|
||||
result.RePrintCount = Context
|
||||
.Queryable<QcBackendRecordLabelPrint>()
|
||||
.Where(it => it.WorkOrder == workOrder)
|
||||
.Where(it => it.LabelType == 1)
|
||||
.Where(it => it.LabelCode.Contains("IsAgain=1"))
|
||||
.Count();
|
||||
result.RemainderBoxPrintCount = Context
|
||||
.Queryable<QcBackendRecordLabelPrint>()
|
||||
.Where(it => it.WorkOrder == workOrder)
|
||||
.Where(it => it.LabelType == 1)
|
||||
.Where(it => it.IsFull == 0)
|
||||
.Count();
|
||||
result.CurrentBoxLabelSequence = Context
|
||||
.Queryable<QcBackendRecordLabelPrint>()
|
||||
.Where(it => it.WorkOrder == workOrder)
|
||||
.Where(it => it.LabelType == 1)
|
||||
.Max(it => it.SerialNumber);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user