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.
115 lines
3.3 KiB
C#
115 lines
3.3 KiB
C#
using Aucma.Scada.Model.domain;
|
|
using HighWayIot.Log4net;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HighWayIot.Repository.service.Impl
|
|
{
|
|
public class BaseBomInfoServiceImpl : IBaseBomInfoService
|
|
{
|
|
Repository<BaseBomInfo> _bomInfoRepository => new Repository<BaseBomInfo>("mes");
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取系统班组时间
|
|
/// </summary>
|
|
public async Task<List<WorkTime>> getWorkTime()
|
|
{
|
|
try
|
|
{
|
|
List<WorkTime> list = null;
|
|
var _db = _bomInfoRepository.Context;
|
|
list = await _db.SqlQueryable<WorkTime>("SELECT * FROM VIEW_CURRENT_TEAM_TIME ORDER BY START_TIME").ToListAsync();
|
|
return list;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|