You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.7 KiB
C#
93 lines
2.7 KiB
C#
using Aucma.Scada.Model.domain;
|
|
using HighWayIot.Log4net;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace HighWayIot.Repository.service.Impl
|
|
{
|
|
public class BaseBomInfoServiceImpl : IBaseBomInfoService
|
|
{
|
|
Repository<BaseBomInfo> _bomInfoRepository => new Repository<BaseBomInfo>("mes");
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
public List<BaseBomInfo> GetBomInfos()
|
|
{
|
|
try
|
|
{
|
|
var info = _bomInfoRepository.GetList();
|
|
return info;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("获取BOM集合异常", ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public BaseBomInfo GetChildenBomInfoByMaterialCode(string materialCode, string materialType)
|
|
{
|
|
BaseBomInfo bomInfo = null;
|
|
try
|
|
{
|
|
var info = GetChildenByParentId(materialCode);
|
|
if (info.Count > 0)
|
|
{
|
|
bomInfo = info.Where(x => x.materialType == materialType).First();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("获取BOM集合异常", ex);
|
|
}
|
|
return bomInfo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据物料编号获取BOM信息
|
|
/// </summary>
|
|
/// <param name="materialCode"></param>
|
|
/// <returns></returns>
|
|
public BaseBomInfo GetBomInfoByMaterialCode(string materialCode)
|
|
{
|
|
BaseBomInfo bomInfo = null;
|
|
try
|
|
{
|
|
bomInfo = _bomInfoRepository.GetFirst(x=>x.materialCode == materialCode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("根据物料编号获取BOM信息异常", ex);
|
|
}
|
|
return bomInfo;
|
|
}
|
|
|
|
private List<BaseBomInfo> GetChildenByParentId(string parentId, List<BaseBomInfo> result = null)
|
|
{
|
|
if (result == null)
|
|
{
|
|
result = new List<BaseBomInfo>();
|
|
}
|
|
try
|
|
{
|
|
var info = _bomInfoRepository.GetList(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;
|
|
}
|
|
}
|
|
}
|