载具更换代码优化
This commit is contained in:
58
WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
Normal file
58
WarehouseMgr/Tnb.WarehouseMgr/WmsFeedingService.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user