|
|
@@ -22,12 +22,14 @@ using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
|
using MongoDB.Driver;
|
|
|
using MongoDB.Driver.Linq;
|
|
|
using Newtonsoft.Json;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel.Design;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
+using System.Reflection;
|
|
|
using System.Threading.Tasks;
|
|
|
using Volo.Abp.Application.Services;
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
@@ -4667,17 +4669,57 @@ namespace Business.Replenishment
|
|
|
|
|
|
public List<WorkOrdMaster> RefreshPriority(List<string> workOrdMasters, string domain)
|
|
|
{
|
|
|
- var prioritylist = _PriorityCode.Select(p => p.IsActive && p.Domain == domain).ToList();
|
|
|
+ //优先级越高越往后排
|
|
|
+ var custList = _custMaster.Select(c => c.IsActive && c.Domain == domain).ToList();
|
|
|
+ var prioritylist = _PriorityCode.Select(p => p.IsActive && p.Domain == domain).OrderByDescending(p=>p.Priority).ToList();
|
|
|
var works = _workOrdMaster.Select(a => workOrdMasters.Contains(a.WorkOrd) && a.Domain == domain && a.IsActive);
|
|
|
- prioritylist.ForEach(p => {
|
|
|
- var propertyName = p.Value;
|
|
|
- var sortedPeople = works.OrderBy(p => GetPropertyValue(p, propertyName)).ToList();
|
|
|
- if (!p.OrderBy)
|
|
|
+ var workords = works.Select(w => w.WorkOrd).ToList();
|
|
|
+ var meslist = _mysql_mes_morder.GetListAsync(m => workords.Contains(m.morder_no) && !m.IsDeleted).Result;
|
|
|
+ var messenList = _mysql_mes_moentry.GetListAsync(m => workords.Contains(m.moentry_mono) && !m.IsDeleted).Result;
|
|
|
+ var crmoList = _mysql_crm_seorder.GetListAsync(m=>messenList.Select(s => s.fbill_no).ToList().Contains(m.bill_no) && !m.IsDeleted).Result;
|
|
|
+
|
|
|
+ //排序字段
|
|
|
+ string[] sortColumns = new string[prioritylist.Count];
|
|
|
+ bool[] sortDirections = new bool[prioritylist.Count];
|
|
|
+ for (int i = 0; i < prioritylist.Count; i++)
|
|
|
+ {
|
|
|
+ sortColumns[i] = prioritylist[i].Value;
|
|
|
+ sortDirections[i] = prioritylist[i].OrderBy;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新客户优先级
|
|
|
+ for (int i = 0; i < works.Count; i++)
|
|
|
+ {
|
|
|
+ var sum = 0;
|
|
|
+ var curmessen = messenList.Where(m => m.moentry_mono == works[i].WorkOrd).First();
|
|
|
+ if (curmessen != null)
|
|
|
+ {
|
|
|
+ var curcrmo = crmoList.Where(c => c.bill_no == curmessen.fbill_no).First();
|
|
|
+ if (curcrmo != null)
|
|
|
+ {
|
|
|
+ var curcust = custList.Where(c => c.Cust == curcrmo.custom_no).First();
|
|
|
+ if (curcust != null)
|
|
|
+ {
|
|
|
+ works[i].Class = decimal.Parse(curcust.Class == "" ? "0" : curcust.Class);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //相加
|
|
|
+ foreach (var fieldName in sortColumns)
|
|
|
{
|
|
|
- sortedPeople = works.OrderByDescending(p => GetPropertyValue(p, propertyName)).ToList();
|
|
|
+ PropertyInfo propertyInfo = works[i].GetType().GetProperty(fieldName);
|
|
|
+ if (propertyInfo != null)
|
|
|
+ {
|
|
|
+ int value = (int)propertyInfo.GetValue(works[i]);
|
|
|
+ sum += value;
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ works[i].Priority = sum;
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ works.Sort(new DynamicOrderComparer<WorkOrdMaster>(sortColumns, sortDirections));
|
|
|
+ //更新优先级
|
|
|
List<WorkOrdMaster> orderedList = new List<WorkOrdMaster>();
|
|
|
decimal Priority = 1.0m;
|
|
|
for (int i = 0; i < works.Count; i++)
|