隐藏不必要文件,添加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
|
/ZR.Admin.WebApi/wwwroot/2025/1213
|
||||||
/.gitignore
|
/.gitignore
|
||||||
/ZR.Admin.WebApi/wwwroot/Generatecode
|
/ZR.Admin.WebApi/wwwroot/Generatecode
|
||||||
|
/.trae
|
||||||
|
|||||||
@ -6,10 +6,12 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ZR.Model.Business;
|
using ZR.Model.Business;
|
||||||
using ZR.Model.Dto;
|
using ZR.Model.Dto;
|
||||||
|
using ZR.Model.MES.qc.DTO;
|
||||||
using ZR.Model.MES.wms;
|
using ZR.Model.MES.wms;
|
||||||
using ZR.Model.MES.wms.Dto;
|
using ZR.Model.MES.wms.Dto;
|
||||||
using ZR.Service.Business.IBusinessService;
|
using ZR.Service.Business.IBusinessService;
|
||||||
using ZR.Service.Utils;
|
using ZR.Service.Utils;
|
||||||
|
using ZR.Service.mqtt;
|
||||||
|
|
||||||
namespace ZR.Service.Business
|
namespace ZR.Service.Business
|
||||||
{
|
{
|
||||||
@ -19,6 +21,13 @@ namespace ZR.Service.Business
|
|||||||
[AppService(ServiceType = typeof(IQcGp12Service), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(IQcGp12Service), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class QcGp12Service : BaseService<QcGp12ServiceWorkorder>, IQcGp12Service
|
public class QcGp12Service : BaseService<QcGp12ServiceWorkorder>, IQcGp12Service
|
||||||
{
|
{
|
||||||
|
private readonly MqttService _mqttService;
|
||||||
|
|
||||||
|
public QcGp12Service(MqttService mqttService)
|
||||||
|
{
|
||||||
|
_mqttService = mqttService;
|
||||||
|
}
|
||||||
|
|
||||||
public QcGp12LabelAnalysisDto AnalyzeLabelToDto(string label, int type)
|
public QcGp12LabelAnalysisDto AnalyzeLabelToDto(string label, int type)
|
||||||
{
|
{
|
||||||
QcGp12LabelAnalysisDto labelAnalysisDto =
|
QcGp12LabelAnalysisDto labelAnalysisDto =
|
||||||
@ -736,6 +745,19 @@ namespace ZR.Service.Business
|
|||||||
Context.Insertable(qcGp12Log).ExecuteCommand();
|
Context.Insertable(qcGp12Log).ExecuteCommand();
|
||||||
// 提交事务
|
// 提交事务
|
||||||
Context.Ado.CommitTran();
|
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(() =>
|
_ = Task.Run(() =>
|
||||||
{
|
{
|
||||||
@ -771,7 +793,7 @@ namespace ZR.Service.Business
|
|||||||
newReceiptNo = $"{receiptNoPrefix}0001";
|
newReceiptNo = $"{receiptNoPrefix}0001";
|
||||||
}
|
}
|
||||||
// 箱数
|
// 箱数
|
||||||
int _packageCount = Context.Queryable<QcGp12RecordLabelScan>().Where(it=>it.WorkOrder == qcGp12Workorder.WorkOrder).Where(it => it.LabelType == 1).Count();
|
int _packageCount = Context.Queryable<QcGp12RecordLabelScan>().Where(it => it.WorkOrder == qcGp12Workorder.WorkOrder).Where(it => it.LabelType == 1).Count();
|
||||||
// 工单号
|
// 工单号
|
||||||
MaterialUtils materialUtils = new MaterialUtils();
|
MaterialUtils materialUtils = new MaterialUtils();
|
||||||
ResultionPackageCodeDto packageCodeDto = materialUtils.ResolutionPackage(qcGp12Workorder.Label);
|
ResultionPackageCodeDto packageCodeDto = materialUtils.ResolutionPackage(qcGp12Workorder.Label);
|
||||||
@ -781,7 +803,8 @@ namespace ZR.Service.Business
|
|||||||
_workOrder = packageCodeDto.WorkoderID;
|
_workOrder = packageCodeDto.WorkoderID;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProFinishedProductReceipt newModel = new() {
|
ProFinishedProductReceipt newModel = new()
|
||||||
|
{
|
||||||
ReceiptNo = newReceiptNo,
|
ReceiptNo = newReceiptNo,
|
||||||
SiteNo = qcGp12Workorder.SiteNo,
|
SiteNo = qcGp12Workorder.SiteNo,
|
||||||
WorkOrder = _workOrder,
|
WorkOrder = _workOrder,
|
||||||
@ -1002,5 +1025,55 @@ namespace ZR.Service.Business
|
|||||||
return Guid.NewGuid().ToString("N").Substring(0, 10); // Generate a 10-character unique ID
|
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