|
@@ -22,12 +22,12 @@ namespace Business.PriorityManagement
|
|
|
/// <param name="seorders">订单数据</param>
|
|
/// <param name="seorders">订单数据</param>
|
|
|
/// <param name="sentrys">订单行数据</param>
|
|
/// <param name="sentrys">订单行数据</param>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
- public List<PriorityDto> CalcOrderPriority(List<crm_seorder> seorders, List<crm_seorderentry> sentrys)
|
|
|
|
|
|
|
+ public List<crm_seorder> CalcOrderPriority(List<crm_seorder> seorders, List<crm_seorderentry> sentrys)
|
|
|
{
|
|
{
|
|
|
//数据处理:取主表数据
|
|
//数据处理:取主表数据
|
|
|
- var rtn = seorders.Select(p=>new PriorityDto {
|
|
|
|
|
|
|
+ var dtos = seorders.Select(p=>new PriorityDto {
|
|
|
id = p.Id,
|
|
id = p.Id,
|
|
|
- urgent = p.urgent.GetValueOrDefault(),
|
|
|
|
|
|
|
+ urgent = p.urgent,
|
|
|
level = p.custom_level.GetValueOrDefault()
|
|
level = p.custom_level.GetValueOrDefault()
|
|
|
}).AsQueryable<PriorityDto>().ToList();
|
|
}).AsQueryable<PriorityDto>().ToList();
|
|
|
|
|
|
|
@@ -39,7 +39,7 @@ namespace Business.PriorityManagement
|
|
|
id = temp.Key,
|
|
id = temp.Key,
|
|
|
plan_date = temp.Max(x => x.plan_date.GetValueOrDefault())
|
|
plan_date = temp.Max(x => x.plan_date.GetValueOrDefault())
|
|
|
};
|
|
};
|
|
|
- foreach (var item in rtn)
|
|
|
|
|
|
|
+ foreach (var item in dtos)
|
|
|
{
|
|
{
|
|
|
var entry = entrys.FirstOrDefault(p => p.id == item.id);
|
|
var entry = entrys.FirstOrDefault(p => p.id == item.id);
|
|
|
if (entry != null)
|
|
if (entry != null)
|
|
@@ -48,8 +48,59 @@ namespace Business.PriorityManagement
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//根据紧急级别倒序,客户级别升序,交期升序排序
|
|
//根据紧急级别倒序,客户级别升序,交期升序排序
|
|
|
- rtn = rtn.OrderByDescending(p => p.urgent).ThenBy(m => m.level).ThenBy(n => n.plan_date).ToList();
|
|
|
|
|
- return rtn;
|
|
|
|
|
|
|
+ dtos = dtos.OrderByDescending(p => p.urgent).ThenBy(m => m.level).ThenBy(n => n.plan_date).ToList();
|
|
|
|
|
+
|
|
|
|
|
+ List<crm_seorder> rtnOrders = new List<crm_seorder>();
|
|
|
|
|
+ foreach (var item in dtos)
|
|
|
|
|
+ {
|
|
|
|
|
+ var order = seorders.First(p=>p.Id == item.id);
|
|
|
|
|
+ rtnOrders.Add(order);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rtnOrders;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 计算订单行优先级
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="seorders">订单数据</param>
|
|
|
|
|
+ /// <param name="sentrys">订单行数据</param>
|
|
|
|
|
+ /// <returns></returns>
|
|
|
|
|
+ public List<crm_seorderentry> CalcOrderEntryPriority(List<crm_seorder> seorders, List<crm_seorderentry> sentrys)
|
|
|
|
|
+ {
|
|
|
|
|
+ //数据处理:取主表数据
|
|
|
|
|
+ var dtos = seorders.Select(p => new PriorityDto
|
|
|
|
|
+ {
|
|
|
|
|
+ id = p.Id,
|
|
|
|
|
+ urgent = p.urgent,
|
|
|
|
|
+ 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 dtos)
|
|
|
|
|
+ {
|
|
|
|
|
+ var entry = entrys.FirstOrDefault(p => p.id == item.id);
|
|
|
|
|
+ if (entry != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ item.plan_date = entry.plan_date;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //根据紧急级别倒序,客户级别升序,交期升序排序
|
|
|
|
|
+ dtos = dtos.OrderByDescending(p => p.urgent).ThenBy(m => m.level).ThenBy(n => n.plan_date).ToList();
|
|
|
|
|
+
|
|
|
|
|
+ List<crm_seorderentry> rtnEntrys = new List<crm_seorderentry>();
|
|
|
|
|
+ foreach (var item in dtos)
|
|
|
|
|
+ {
|
|
|
|
|
+ var curEntrys = sentrys.Where(p => p.seorder_id == item.id).ToList();
|
|
|
|
|
+ rtnEntrys.AddRange(curEntrys);
|
|
|
|
|
+ }
|
|
|
|
|
+ return rtnEntrys;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|