|
|
|
|
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 Castle.Core.Internal;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using NPOI.POIFS.FileSystem;
|
|
|
|
|
using NPOI.POIFS.Properties;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
using StackExchange.Redis;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
static List<BaseBomInfo> tmpList = new List<BaseBomInfo>();
|
|
|
|
|
|
|
|
|
|
public BaseOrderInfoServices(IBaseRepository<BaseOrderInfo> dal, IBaseOrderInfoRepository baseOrderInfoRepository, IPrintOrderInfoRepository printOrderInfoRepository,
|
|
|
|
|
IBaseBomInfoRepository baseBomInfoRepository)
|
|
|
|
|
{
|
|
|
|
|
this._dal = dal;
|
|
|
|
|
base.BaseDal = dal;
|
|
|
|
|
_baseBomInfoRepository = baseBomInfoRepository;
|
|
|
|
|
_baseOrderInfoRepository = baseOrderInfoRepository;
|
|
|
|
|
_printOrderInfoRepository = printOrderInfoRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<BaseOrderInfo>> GetOrderInfoData()
|
|
|
|
|
{
|
|
|
|
|
return await _baseOrderInfoRepository.GetOrderInfoData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取打印订单信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取打印订单信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<PrintPlanInfoView>> QueryPrintInfo()
|
|
|
|
|
{
|
|
|
|
|
List<PrintPlanInfoView> list = new List<PrintPlanInfoView>();
|
|
|
|
|
List<BaseBomInfo> baseBomList = await _baseBomInfoRepository.QueryAsync();
|
|
|
|
|
List<BaseOrderInfo> orderList = await this.GetOrderInfoData();
|
|
|
|
|
List<PrintOrderInfo> printOrderInfoList = await _printOrderInfoRepository.QueryAsync();
|
|
|
|
|
tmpList.Clear();
|
|
|
|
|
if (orderList == null) return null;
|
|
|
|
|
orderList.ForEach( bb =>
|
|
|
|
|
{
|
|
|
|
|
GetParentID(baseBomList, bb.MaterialCode);
|
|
|
|
|
if (tmpList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var bomInfo in tmpList.Where(d=>d.MaterialType.Equals("500")|| d.MaterialType.Equals("200")))
|
|
|
|
|
{
|
|
|
|
|
list.Add(new PrintPlanInfoView()
|
|
|
|
|
{
|
|
|
|
|
OrderCode = bb.OrderCode,
|
|
|
|
|
ProductCode = bb.MaterialCode,
|
|
|
|
|
ProductName = bb.MaterialName,
|
|
|
|
|
PlanAmount = bb.OrderAmount,
|
|
|
|
|
MaterialCode = bomInfo.MaterialCode,
|
|
|
|
|
MaterialName = bomInfo.MaterialName,
|
|
|
|
|
LinerAmount = bomInfo.StandardAmount,
|
|
|
|
|
BoxAmount = bomInfo.StandardAmount,
|
|
|
|
|
StandardAmount = bomInfo.StandardAmount,
|
|
|
|
|
PrintName = bb.PrintName,
|
|
|
|
|
CreateTime = bb.CreatedTime
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.ForEach(b =>
|
|
|
|
|
{
|
|
|
|
|
if (printOrderInfoList != null)
|
|
|
|
|
{
|
|
|
|
|
PrintOrderInfo info = printOrderInfoList.FirstOrDefault(d => d.OrderCode == b.OrderCode);
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
b.LinerAmount = info.LinerAmount;
|
|
|
|
|
b.BoxAmount = info.BoxAmount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
b.LinerAmount =0;
|
|
|
|
|
b.BoxAmount = 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 递归
|
|
|
|
|
public static void GetParentID(List<BaseBomInfo> treeNodes, string materialCode)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(materialCode))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var query = from c in treeNodes
|
|
|
|
|
where c.ParentId == materialCode
|
|
|
|
|
select c;
|
|
|
|
|
foreach (var item in query)
|
|
|
|
|
{
|
|
|
|
|
GetParentID(treeNodes, item.MaterialCode);
|
|
|
|
|
tmpList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|