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 { /// /// 投料记录 /// public class WmsFeedingService : BaseWareHouseService, IWmsFeedingService { private readonly ISqlSugarClient _db; private static Dictionary dicMaterial = new Dictionary(); public WmsFeedingService(ISqlSugarRepository repository) { _db = repository.AsSugarClient(); } /// /// 根据载具Id获取载具条码记录 /// /// /// [HttpGet] public async Task GetCarryCodeList([FromRoute] string carryId) { if (dicMaterial.Count < 1) { dicMaterial = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.name); } var items = await _db.Queryable().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 ?? Enumerable.Empty(); } } }