53 lines
2.2 KiB
C#
53 lines
2.2 KiB
C#
using System.Linq.Expressions;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
using Tnb.BasicData.Entities;
|
|
using Tnb.WarehouseMgr.Entities;
|
|
using Tnb.WarehouseMgr.Entities.Consts;
|
|
using Tnb.WarehouseMgr.Entities.Dto;
|
|
using Tnb.WarehouseMgr.Interfaces;
|
|
|
|
|
|
namespace Tnb.WarehouseMgr
|
|
{
|
|
/// <summary>
|
|
/// 投料记录
|
|
/// </summary>
|
|
public class WmsFeedingService : BaseWareHouseService, IWmsFeedingService
|
|
{
|
|
private readonly ISqlSugarClient _db;
|
|
private static Dictionary<string, object> dicMaterial = new();
|
|
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);
|
|
}
|
|
WmsCarryH carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == carryId);
|
|
List<string> carryMIds = new();
|
|
if (carry.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID)
|
|
{
|
|
List<WmsCarryD> carryDs = await _db.Queryable<WmsCarryD>().Where(it => it.carry_id == carryId).ToListAsync();
|
|
carryMIds = carryDs.Select(x => x.membercarry_id).ToList();
|
|
}
|
|
Expression<Func<WmsCarryCode, bool>> whereExp = carryMIds?.Count > 0 ? a => carryMIds.Contains(a.carry_id) : a => a.carry_id == carryId;
|
|
List<CarryCodeDetailOutput> items = await _db.Queryable<WmsCarryCode>().Where(whereExp)
|
|
.Select<CarryCodeDetailOutput>()
|
|
.Mapper(it => it.material_name = (it.material_id != null && dicMaterial.ContainsKey(it.material_id)) ? dicMaterial[it.material_id].ToString() : "")
|
|
.ToListAsync();
|
|
|
|
return items ?? Enumerable.Empty<CarryCodeDetailOutput>();
|
|
}
|
|
}
|
|
}
|