隐藏不必要文件,添加GP12触摸屏打印抛光,打磨标签功能
This commit is contained in:
parent
a98affad82
commit
28cd87467d
1
.gitignore
vendored
1
.gitignore
vendored
@ -264,3 +264,4 @@ __pycache__/
|
||||
/ZR.Admin.WebApi/wwwroot/2025/1213
|
||||
/.gitignore
|
||||
/ZR.Admin.WebApi/wwwroot/Generatecode
|
||||
/.trae
|
||||
|
||||
@ -6,10 +6,12 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.Business;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.MES.qc.DTO;
|
||||
using ZR.Model.MES.wms;
|
||||
using ZR.Model.MES.wms.Dto;
|
||||
using ZR.Service.Business.IBusinessService;
|
||||
using ZR.Service.Utils;
|
||||
using ZR.Service.mqtt;
|
||||
|
||||
namespace ZR.Service.Business
|
||||
{
|
||||
@ -19,6 +21,13 @@ namespace ZR.Service.Business
|
||||
[AppService(ServiceType = typeof(IQcGp12Service), ServiceLifetime = LifeTime.Transient)]
|
||||
public class QcGp12Service : BaseService<QcGp12ServiceWorkorder>, IQcGp12Service
|
||||
{
|
||||
private readonly MqttService _mqttService;
|
||||
|
||||
public QcGp12Service(MqttService mqttService)
|
||||
{
|
||||
_mqttService = mqttService;
|
||||
}
|
||||
|
||||
public QcGp12LabelAnalysisDto AnalyzeLabelToDto(string label, int type)
|
||||
{
|
||||
QcGp12LabelAnalysisDto labelAnalysisDto =
|
||||
@ -736,6 +745,19 @@ namespace ZR.Service.Business
|
||||
Context.Insertable(qcGp12Log).ExecuteCommand();
|
||||
// 提交事务
|
||||
Context.Ado.CommitTran();
|
||||
|
||||
// 发送mqtt消息通知打印抛光/打磨标签
|
||||
// 发送抛光标签打印消息
|
||||
if (qcGp12Workorder.PolishNumber > 0)
|
||||
{
|
||||
SendLabelPrintMqttMessage(qcGp12Workorder, 1, qcGp12Workorder.PolishNumber.Value);
|
||||
}
|
||||
// 发送打磨标签打印消息
|
||||
if (qcGp12Workorder.DamoNumber > 0)
|
||||
{
|
||||
SendLabelPrintMqttMessage(qcGp12Workorder, 2, qcGp12Workorder.DamoNumber.Value);
|
||||
}
|
||||
|
||||
// 插入成品入库单
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
@ -781,7 +803,8 @@ namespace ZR.Service.Business
|
||||
_workOrder = packageCodeDto.WorkoderID;
|
||||
}
|
||||
|
||||
ProFinishedProductReceipt newModel = new() {
|
||||
ProFinishedProductReceipt newModel = new()
|
||||
{
|
||||
ReceiptNo = newReceiptNo,
|
||||
SiteNo = qcGp12Workorder.SiteNo,
|
||||
WorkOrder = _workOrder,
|
||||
@ -1002,5 +1025,55 @@ namespace ZR.Service.Business
|
||||
return Guid.NewGuid().ToString("N").Substring(0, 10); // Generate a 10-character unique ID
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送标签打印MQTT消息
|
||||
/// </summary>
|
||||
/// <param name="workorder">工单信息</param>
|
||||
/// <param name="labelType">标签类型:1-抛光,2-打磨</param>
|
||||
/// <param name="quantity">数量</param>
|
||||
private void SendLabelPrintMqttMessage(QcGp12ServiceWorkorder workorder, int labelType, int quantity)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (quantity <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string labelCode = labelType == 1 ? "Type=DeNoPG" : "Type=DeNoDM";
|
||||
string path = labelType == 1 ? "D:\\RIZO\\label\\抛光送货单.btw" : "D:\\RIZO\\label\\打磨送货单.btw";
|
||||
string name = labelType == 1 ? "包装抛光送货单标签打印" : "包装打磨送货单标签打印";
|
||||
|
||||
var printDto = new PrintDeliveryNoteDto
|
||||
{
|
||||
Path = path,
|
||||
SiteNo = workorder.SiteNo,
|
||||
Name = name,
|
||||
PartNumber = workorder.PartNumber,
|
||||
Description = workorder.Description,
|
||||
Color = workorder.Color,
|
||||
Specification = workorder.Specification,
|
||||
WorkOrder = workorder.WorkOrder,
|
||||
PackageCode = workorder.WorkOrder,
|
||||
Team = workorder.Team,
|
||||
Sort = 1,
|
||||
ProductionTime = workorder.WorkOrder,
|
||||
BatchCode = workorder.WorkOrder,
|
||||
PackageNum = quantity,
|
||||
LabelCode = $"{labelCode}^ItemNumber={workorder.PartNumber}^Order={workorder.WorkOrder}^Qty={quantity}",
|
||||
LabelType = 1,
|
||||
CreatedTime = DateTime.Now.ToString()
|
||||
};
|
||||
|
||||
string message = JsonSerializer.Serialize(printDto);
|
||||
_mqttService.PublishAsync("Print/Label", message, MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录异常但不影响主流程
|
||||
Console.WriteLine($"发送标签打印MQTT消息失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user