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 Dm.filter.log; using Microsoft.Extensions.Hosting; using NPOI.POIFS.FileSystem; using NPOI.POIFS.Properties; using NPOI.SS.Formula.Functions; using NPOI.Util; using StackExchange.Profiling.Internal; 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, IBaseOrderInfoServices { private readonly IBaseRepository _dal; private readonly IPrintOrderInfoRepository _printOrderInfoRepository; private readonly IBaseOrderInfoRepository _baseOrderInfoRepository; private readonly IBaseBomInfoRepository _baseBomInfoRepository; private readonly IPrintBarCodeServices _printBarCodeServices; static List tmpList = new List(); public BaseOrderInfoServices(IBaseRepository dal, IBaseOrderInfoRepository baseOrderInfoRepository, IPrintOrderInfoRepository printOrderInfoRepository, IBaseBomInfoRepository baseBomInfoRepository, IPrintBarCodeServices printBarCodeServices) { this._dal = dal; base.BaseDal = dal; _baseBomInfoRepository = baseBomInfoRepository; _baseOrderInfoRepository = baseOrderInfoRepository; _printOrderInfoRepository = printOrderInfoRepository; _printBarCodeServices = printBarCodeServices; } public async Task> GetOrderInfoData() { return await _baseOrderInfoRepository.GetOrderInfoData(); } /// /// 查询物料MES码 /// /// public async Task> GetAllOrderInfoData() { return await _baseOrderInfoRepository.GetAllOrderInfoData(); } #region 获取打印订单信息 /// /// 获取打印订单信息 /// /// public async Task> QueryPrintInfo() { List list = new List(); List baseBomList = await _baseBomInfoRepository.QueryAsync(); List orderList = await this.GetAllOrderInfoData(); if (orderList == null) return null; orderList.ForEach(bb => { PrintPlanInfoView view = new PrintPlanInfoView(); view.ProductLineName = bb.ProductLineName; view.OrderCode = bb.OrderCode; view.ProductCode = bb.MaterialCode; view.ProductName = bb.MaterialName; view.PlanAmount = bb.OrderAmount; view.CompleteAmount = bb.CompleteAmount; view.LinerAmount = bb.LinerAmount; view.BoxAmount = bb.BoxAmount; view.PrintName = bb.PrintName; view.BeginDate = bb.BeginDate; list.Add(view); }); //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 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 /// /// 更新打印名称 /// /// public Task UpdatePrintName(BaseOrderInfo printName) { return _baseOrderInfoRepository.UpdatePrintName(printName); } } }