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 { /// /// 投料记录 /// [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 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(it => it.carry_id == carryId) .Select(it => new CarryCodeDetailOutput { barcode = it.barcode, code_batch = it.code_batch, codeqty = it.codeqty, material_code = it.material_code, material_id = it.material_id, }) .Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString() : "") .ToListAsync(); return items; } } }