Files
tnb.server/ProductionMgr/Tnb.ProductionMgr/PrdOutPackingService.cs
2023-11-09 10:58:15 +08:00

46 lines
1.5 KiB
C#

using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.VisualDev;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
using Tnb.ProductionMgr.Interfaces;
namespace Tnb.ProductionMgr
{
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
public class PrdOutPackingService : IPrdOutPackingService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<PrdOutPacking> _repository;
public PrdOutPackingService(ISqlSugarRepository<PrdOutPacking> repository)
{
_repository = repository;
}
/// <summary>
/// 托盘二维码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> TrayQrcode(TrayQrcodeInput input)
{
PrdOutPacking prdOutPacking = await _repository.GetFirstAsync(x=>x.code==input.qrcode && x.station_id==input.station_id && x.status=="0");
if (prdOutPacking != null) throw Oops.Bah("已存在该托盘");
prdOutPacking = new PrdOutPacking()
{
code = input.qrcode,
station_id = input.station_id,
create_time = DateTime.Now,
status = "0",
};
return await _repository.InsertAsync(prdOutPacking);
}
}
}