|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Admin.Core.IRepository;
|
|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using Admin.Core.Model.ViewModels;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection.Emit;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.Service
|
|
|
|
|
{
|
|
|
|
|
public class BaseOrderInfoServices : BaseServices<BaseOrderInfo>, IBaseOrderInfoServices
|
|
|
|
|
{
|
|
|
|
|
private readonly IBaseRepository<BaseOrderInfo> _dal;
|
|
|
|
|
private readonly IPrintOrderInfoRepository _printOrderInfoRepository;
|
|
|
|
|
private readonly IBaseOrderInfoRepository _baseOrderInfoRepository;
|
|
|
|
|
private readonly IBaseBomInfoRepository _baseBomInfoRepository;
|
|
|
|
|
List<BaseBomInfo> bbinfolist=new List<BaseBomInfo>();
|
|
|
|
|
public BaseOrderInfoServices(IBaseRepository<BaseOrderInfo> dal,IBaseBomInfoRepository baseBomInfoRepository, IBaseOrderInfoRepository baseOrderInfoRepository, IPrintOrderInfoRepository printOrderInfoRepository)
|
|
|
|
|
{
|
|
|
|
|
this._dal = dal;
|
|
|
|
|
base.BaseDal = dal;
|
|
|
|
|
_baseBomInfoRepository = baseBomInfoRepository;
|
|
|
|
|
_baseOrderInfoRepository = baseOrderInfoRepository;
|
|
|
|
|
_printOrderInfoRepository = printOrderInfoRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印订单信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<PrintPlanInfoView>> QueryPrintInfo()
|
|
|
|
|
{
|
|
|
|
|
List<PrintPlanInfoView> list = new List<PrintPlanInfoView>();
|
|
|
|
|
List<BaseOrderInfo> orderList = await _baseOrderInfoRepository.QueryAsync();
|
|
|
|
|
List<BaseBomInfo> bomInfoList = await _baseBomInfoRepository.QueryAsync();
|
|
|
|
|
List<PrintOrderInfo> printOrderInfoList = await _printOrderInfoRepository.QueryAsync();
|
|
|
|
|
bbinfolist.Clear();
|
|
|
|
|
foreach (BaseOrderInfo order in orderList)
|
|
|
|
|
{
|
|
|
|
|
var bom = bomInfoList.FirstOrDefault(d=>d.BomCode.Equals(order.MaterialCode));
|
|
|
|
|
if (bom!=null)
|
|
|
|
|
{
|
|
|
|
|
if (bom.BomCode == bom.MaterialCode)
|
|
|
|
|
{
|
|
|
|
|
PrintPlanInfoView view = new PrintPlanInfoView();
|
|
|
|
|
view.OrderCode = order.OrderCode;
|
|
|
|
|
view.ProductCode = order.MaterialCode;
|
|
|
|
|
view.ProductName = order.MaterialName;
|
|
|
|
|
view.PlanAmount = order.OrderAmount;
|
|
|
|
|
view.MaterialCode = bom.MaterialCode;
|
|
|
|
|
view.MaterialName = bom.MaterialName;
|
|
|
|
|
view.StandardAmount = bom.StandardAmount;
|
|
|
|
|
view.CreateTime = order.CreatedTime;
|
|
|
|
|
list.Add(view);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
List<BaseBomInfo> bbList = RecursionFn(bomInfoList, bom.MaterialCode);
|
|
|
|
|
if (bbList != null)
|
|
|
|
|
{
|
|
|
|
|
bbList.ForEach(b =>
|
|
|
|
|
{
|
|
|
|
|
if (b.BomCode.IsNotEmptyOrNull())
|
|
|
|
|
{
|
|
|
|
|
PrintPlanInfoView view = new PrintPlanInfoView();
|
|
|
|
|
view.OrderCode = order.OrderCode;
|
|
|
|
|
view.ProductCode = order.MaterialCode;
|
|
|
|
|
view.ProductName = order.MaterialName;
|
|
|
|
|
view.PlanAmount = order.OrderAmount;
|
|
|
|
|
view.MaterialCode = b.MaterialCode;
|
|
|
|
|
view.MaterialName = b.MaterialName;
|
|
|
|
|
view.StandardAmount = b.StandardAmount;
|
|
|
|
|
view.CreateTime = order.CreatedTime;
|
|
|
|
|
|
|
|
|
|
list.Add(view);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list.ForEach(b =>
|
|
|
|
|
{
|
|
|
|
|
PrintOrderInfo info = printOrderInfoList.FirstOrDefault(d => d.OrderCode == b.OrderCode);
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
b.LinerAmount = info.LinerAmount;
|
|
|
|
|
b.BoxAmount = info.BoxAmount;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 递归列表
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 递归列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<BaseBomInfo> RecursionFn(List<BaseBomInfo> list, string materialCode)
|
|
|
|
|
{
|
|
|
|
|
// 得到子节点列表
|
|
|
|
|
List<BaseBomInfo> childList = GetChildList(list, materialCode);
|
|
|
|
|
childList.ForEach(c => bbinfolist.Add(c));
|
|
|
|
|
foreach (var tChild in childList)
|
|
|
|
|
{
|
|
|
|
|
if (HasChild(list, tChild.MaterialCode))
|
|
|
|
|
{
|
|
|
|
|
RecursionFn(list, tChild.MaterialCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bbinfolist;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 得到子节点列表
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 得到子节点列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
/// <param name="t"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<BaseBomInfo> GetChildList(List<BaseBomInfo> list, string materialCode)
|
|
|
|
|
{
|
|
|
|
|
List<BaseBomInfo> tlist = new List<BaseBomInfo>();
|
|
|
|
|
IEnumerator<BaseBomInfo> it = list.Where(d => d.ParentId == materialCode).GetEnumerator();
|
|
|
|
|
while (it.MoveNext())
|
|
|
|
|
{
|
|
|
|
|
BaseBomInfo n = it.Current;
|
|
|
|
|
if (n.ParentId.IsNotEmptyOrNull())
|
|
|
|
|
{
|
|
|
|
|
tlist.Add(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tlist;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 判断是否有子节点
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 判断是否有子节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
/// <param name="t"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool HasChild(List<BaseBomInfo> list, string materialCode)
|
|
|
|
|
{
|
|
|
|
|
return IsExist(list, materialCode).Count > 0 ? true : false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<BaseBomInfo> IsExist(List<BaseBomInfo> list, string materialCode)
|
|
|
|
|
{
|
|
|
|
|
List<BaseBomInfo> tlist = list.Where(d => d.ParentId == materialCode).ToList();
|
|
|
|
|
return tlist;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|