|
|
|
|
using Admin.Core.IRepository;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.Service
|
|
|
|
|
{
|
|
|
|
|
public class BaseBomInfoServices : BaseServices<BaseBomInfo>, IBaseBomInfoServices
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseBomInfoServices));
|
|
|
|
|
private readonly IBaseRepository<BaseBomInfo> _dal;
|
|
|
|
|
public BaseBomInfoServices(IBaseRepository<BaseBomInfo> dal)
|
|
|
|
|
{
|
|
|
|
|
this._dal = dal;
|
|
|
|
|
base.BaseDal = dal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<BaseBomInfo> GetChildenBomInfoByMaterialCode(string materialCode, string materialType)
|
|
|
|
|
{
|
|
|
|
|
BaseBomInfo bomInfo = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var info =await GetChildenByParentId(materialCode);
|
|
|
|
|
if (info.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
bomInfo = info.FirstOrDefault(x => x.MaterialType == materialType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("获取BOM集合异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return bomInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<List<BaseBomInfo>> GetChildenByParentId(string parentId, List<BaseBomInfo> result = null)
|
|
|
|
|
{
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
result = new List<BaseBomInfo>();
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var info =await _dal.QueryAsync(x => x.ParentId == parentId);
|
|
|
|
|
|
|
|
|
|
if (info.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in info)
|
|
|
|
|
{
|
|
|
|
|
result.Add(item);
|
|
|
|
|
var childInfos = GetChildenByParentId(item.MaterialCode, result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("获取BOM集合异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|