60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using JNPF.DependencyInjection;
|
|
using JNPF.DynamicApiController;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities.Dto;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
/// <summary>
|
|
/// 投料记录
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
|
[Route("api/[area]/[controller]/[action]")]
|
|
|
|
public class WmsFeedingService : IWmsFeedingService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly ISqlSugarClient _db;
|
|
private static Dictionary<string, object> dicMaterial = new Dictionary<string, object>();
|
|
public WmsFeedingService(ISqlSugarRepository<WmsFeedingrecordH> repository)
|
|
{
|
|
_db = repository.AsSugarClient();
|
|
}
|
|
/// <summary>
|
|
/// 根据载具Id获取载具条码记录
|
|
/// </summary>
|
|
/// <param name="carryId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<dynamic> GetCarryCodeList([FromRoute] string carryId)
|
|
{
|
|
if (dicMaterial.Count < 1)
|
|
{
|
|
dicMaterial = await _db.Queryable<BasMaterial>().ToDictionaryAsync(x => x.id, x => x.name);
|
|
}
|
|
var items = await _db.Queryable<WmsCarryCode>().Where(a => a.carry_id == carryId)
|
|
.Select(a => new CarryCodeDetailOutput
|
|
{
|
|
barcode = a.barcode,
|
|
code_batch = a.code_batch,
|
|
codeqty = a.codeqty,
|
|
material_code = a.material_code,
|
|
material_id = a.material_id,
|
|
unit_id = a.unit_id,
|
|
})
|
|
.Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString()! : "")
|
|
.ToListAsync();
|
|
return items;
|
|
}
|
|
}
|
|
}
|