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.
113 lines
3.6 KiB
C#
113 lines
3.6 KiB
C#
using Admin.Core.IRepository;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Model;
|
|
using Admin.Core.Model.Model_New;
|
|
using Admin.Core.Model.ViewModels;
|
|
using log4net;
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
using Microsoft.IdentityModel.Logging;
|
|
using NPOI.XSSF.UserModel;
|
|
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;
|
|
private readonly IBaseBomInfoRepository _baseBomInfoRepository;
|
|
|
|
public BaseBomInfoServices(IBaseRepository<BaseBomInfo> dal, IBaseBomInfoRepository baseBomInfoRepository)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
_baseBomInfoRepository = baseBomInfoRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取系统班组时间
|
|
/// </summary>
|
|
public async Task<List<WorkTime>> getWorkTime()
|
|
{
|
|
try
|
|
{
|
|
List<WorkTime> list = null;
|
|
var _db = this.BaseDal.Db;
|
|
list = await _db.Ado.SqlQueryAsync<WorkTime>("SELECT * FROM VIEW_CURRENT_TEAM_TIME ORDER BY START_TIME");
|
|
return list;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <param name="materialCode"></param>
|
|
/// <returns></returns>
|
|
public async Task<BaseBomInfo> GetBomInfoByMaterialCode(string materialCode)
|
|
{
|
|
BaseBomInfo bomInfo = null;
|
|
try
|
|
{
|
|
bomInfo = await _dal.FirstAsync(x => x.MaterialCode == materialCode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("根据物料编号获取BOM信息异常", ex);
|
|
}
|
|
return bomInfo;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public async Task<List<BaseBomInfo>> GetBoxChildData(string materialCode)
|
|
{
|
|
return await _baseBomInfoRepository.GetBoxChildData(materialCode);
|
|
}
|
|
}
|
|
} |