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.
AUCMA_SCADA/Admin.Core.Service/Service_New/BaseOrderInfoServices.cs

135 lines
4.7 KiB
C#

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