91 lines
3.2 KiB
C#
Raw Normal View History

2025-10-31 09:56:25 +08:00
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Seyounth.Auto.Hs.Runtime.Plc;
using Seyounth.Auto.Hs.Runtime.Printer;
using Syc.Basic.Web.WMS.Dto;
using Syc.Basic.Web.WMS.Entitys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace Syc.Basic.Web.WMS.Service
{
[AllowAnonymous]
public class AutoService : ApiService
{
private readonly IPrinterService printerService;
private readonly IRepository<AutoLabel> autoReposutory;
private readonly ILogger<AutoService> logger;
private readonly IPlcService plcService;
public AutoService(IPrinterService PrinterService,IRepository<AutoLabel> AutoReposutory,ILogger<AutoService> logger,IPlcService plcService)
{
printerService = PrinterService;
autoReposutory = AutoReposutory;
this.logger = logger;
this.plcService = plcService;
}
/// <summary>
/// 打印唯一标签
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
[HttpPost]
public async Task AutoLabel(int num)
{
var date = DateOnly.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
var autolabel = await autoReposutory.FirstOrDefaultAsync(x => x.Date == date&&x.Type==(int)AutoLabelType.);
var d = date.ToString("yyMMdd");
if (autolabel == null)
{
autolabel = await autoReposutory.InsertAsync(new AutoLabel()
{
Date = date,
Sort = 1,
Mark = "T" + d,
Type = (int)AutoLabelType.
},true);
}
//for (var i = 1; i <= num; i++)
//{
// autolabel.Sort += 1;
// logger.LogInformation(autolabel.Mark + autolabel.Sort.ToString().PadLeft(4, '0'));
// string content = "^XA" +
// "\r\n^MMP" +
// "\r\n^LL0" +
// "\r\n^JUS" +
// "\r\n#!A1" +
// "\r\n#N13" +
// "\r\n#PC1017/0" +
// "\r\n#IMR44/46" +
// "\r\n#PR6//" +
// "\r\n#PO0" +
// "\r\n#ERNC/1//0.00" +
// "\r\n#R0/0" +
// "\r\n#T11.51 #J29.54 #FD/0/L #SB13/ONKP2.0/8.80/2 #VW/L/\"" + autolabel.Mark + autolabel.Sort.ToString().PadLeft(4, '0') + "\"#G" +
// "\r\n#Q1#G" +
// "\r\n#!P1" +
// "\r\n^XZ";
// await printerService.PrintAsync(1, content);
//}
await autoReposutory.UpdateAsync(autolabel);
}
}
}