69 lines
2.2 KiB
C#
69 lines
2.2 KiB
C#
using JNPF.Common.Core.Manager;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using JNPF.Systems.Interfaces.System;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
using Tnb.ProductionMgr.Entities;
|
|
using Tnb.ProductionMgr.Interfaces;
|
|
|
|
namespace Tnb.ProductionMgr;
|
|
|
|
/// <summary>
|
|
/// 产线自动化通信接口
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 704)]
|
|
[Route("api/produce")]
|
|
public class WorklineCommService : IWorklineCommService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarRepository<PrdWorklineState> _repository;
|
|
private readonly IDataBaseManager _dataBaseManager;
|
|
private readonly IUserManager _userManager;
|
|
private readonly IDictionaryDataService _dictionaryDataService;
|
|
|
|
public WorklineCommService(
|
|
ISqlSugarRepository<PrdWorklineState> repository,
|
|
IDataBaseManager dataBaseManager,
|
|
IUserManager userManager,
|
|
IDictionaryDataService dictionaryDataService
|
|
)
|
|
{
|
|
_repository = repository;
|
|
_dataBaseManager = dataBaseManager;
|
|
_userManager = userManager;
|
|
_dictionaryDataService = dictionaryDataService;
|
|
}
|
|
|
|
|
|
|
|
#region 外包装条码打印接口
|
|
|
|
/// <summary>
|
|
/// 获取产线当前生产的箱号条码
|
|
/// </summary>
|
|
/// <param name="workline">所属产线</param>
|
|
/// <returns></returns>
|
|
[HttpGet("get-carton-qrcode")]
|
|
[AllowAnonymous]
|
|
public async Task<dynamic> GetCartonQrcode(string workline)
|
|
{
|
|
var line = await _repository.GetFirstAsync(a => a.id == workline);
|
|
var productNo = line?.product_code;
|
|
//TODO 仅测试接口用
|
|
if (string.IsNullOrEmpty(productNo))
|
|
{
|
|
productNo = "16945" + Random.Shared.Next(0, 999999999).ToString(); //"16945155732431";
|
|
}
|
|
var pd = DateTime.Now;
|
|
var exp = pd.AddYears(3);
|
|
var lotNo = pd.ToString("yyMMddHH");
|
|
string tpl = "(01){0}\n(11){1}\n(17){2}\n(10){3}";
|
|
string qrcode = string.Format(tpl, productNo, pd.ToString("yyMM00"), exp.ToString("yyMM00"), lotNo);
|
|
return new { qrcode };
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|