using Business.ResourceExamineManagement.Dto; using Bussiness.Model.MES.IC; using Bussiness.Model.Sale; using Bussiness.MongoModel.MES.IC; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Services; namespace Business.PriorityManagement { /// /// 优先级算法 /// public class PriorityAppService : ApplicationService { /// /// 计算订单优先级 /// /// 订单数据 /// 订单行数据 /// public List CalcOrderPriority(List seorders, List sentrys) { //数据处理:取主表数据 var rtn = seorders.Select(p=>new PriorityDto { id = p.Id, urgent = p.urgent.GetValueOrDefault(), level = p.custom_level.GetValueOrDefault() }).AsQueryable().ToList(); ; //子表数据处理:根据订单id分组取出客户要求交期交期最大的数据 var entrys = from t in sentrys group t by t.seorder_id into temp select new { id = temp.Key, plan_date = temp.Max(x => x.plan_date.GetValueOrDefault()) }; foreach (var item in rtn) { var entry = entrys.FirstOrDefault(p => p.id == item.id); if (entry != null) { item.plan_date = entry.plan_date; } } //根据紧急级别倒序,客户级别升序,交期升序排序 rtn = rtn.OrderByDescending(p => p.urgent).ThenBy(m => m.level).ThenBy(n => n.plan_date).ToList(); return rtn; } } }