|
|
@@ -0,0 +1,55 @@
|
|
|
+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
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 优先级算法
|
|
|
+ /// </summary>
|
|
|
+ public class PriorityAppService : ApplicationService
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 计算订单优先级
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="seorders">订单数据</param>
|
|
|
+ /// <param name="sentrys">订单行数据</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public List<PriorityDto> CalcOrderPriority(List<crm_seorder> seorders, List<crm_seorderentry> sentrys)
|
|
|
+ {
|
|
|
+ //数据处理:取主表数据
|
|
|
+ var rtn = seorders.Select(p=>new PriorityDto {
|
|
|
+ id = p.Id,
|
|
|
+ urgent = p.urgent.GetValueOrDefault(),
|
|
|
+ level = p.custom_level.GetValueOrDefault()
|
|
|
+ }).AsQueryable<PriorityDto>().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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|