From 19e95f4acc328bbf62a0427fe658d00268019e66 Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期一, 07 四月 2025 10:14:34 +0800
Subject: [PATCH] 修改IIS配置
---
Wms/WMS.BLL/Logic/AllotSku.cs | 397 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 395 insertions(+), 2 deletions(-)
diff --git a/Wms/WMS.BLL/Logic/AllotSku.cs b/Wms/WMS.BLL/Logic/AllotSku.cs
index 6cfeb23..da7ef8b 100644
--- a/Wms/WMS.BLL/Logic/AllotSku.cs
+++ b/Wms/WMS.BLL/Logic/AllotSku.cs
@@ -233,12 +233,404 @@
/// <summary>
+ /// 鍘熻緟鏂欏彇鏍峰嚭搴撳垎閰嶅簱瀛�
+ /// </summary>
+ /// <param name="palletList">鎵樼洏鏄庣粏</param>
+ /// <param name="boxInfoList">绠辩爜鏄庣粏</param>
+ /// <param name="needQty">闇�姹傛暟</param>
+ /// <param name="stockQtyDic">鎵樺嚭搴撶墿鍝佹暟</param>
+ /// <param name="useBoxQtyDic">鎵樺嚭搴撶墿鍝佹暟</param>
+ /// <param name="type">鍙栨牱绫诲瀷1锛氳鍒欏彇鏍� 2锛氶殢鏈哄彇鏍�</param>
+ /// <param name="boxNum">闇�鍒嗛厤鐨勭鏁伴噺 闅忔満鍙栨牱鐢�</param>
+ /// <param name="pickNum"></param>
+ /// <returns></returns>
+ public decimal AllotPalletsQuYang(List<DataStockDetail> palletList, List<DataBoxInfo> boxInfoList, decimal needQty, Dictionary<int, decimal> stockQtyDic, Dictionary<int, decimal> useBoxQtyDic, string type, int boxNum, decimal pickNum)
+ {
+ try
+ {
+ decimal? qty = 0;
+ var listOrder = boxInfoList.Where(m => m.IsDel == "0").OrderBy(m => m.BoxNo).ThenBy(m => m.Qty).ToList();//鏍规嵁绠辩爜銆佹暟閲忔帓搴� 鏁寸鐨�
+ var boxList = listOrder.GroupBy(m => m.BoxNo).Select(m => m.Key).ToList();//鍒嗙粍鍚庣殑绠辩爜闆嗗悎
+ var boxCount = boxList.Count();//绠辨暟閲�
+ #region 鏃у垎閰嶅師鍒�
+
+ //var outInfoCount = 0;
+ //var boxStrList = new List<string>();//闅忔満浣跨敤绠�
+ //Dictionary<string, decimal> useInfoQtyDic = new Dictionary<string, decimal>();//浣跨敤绠�
+
+ //if (type == "1")//瑙勫垯鍙栨牱锛圢<3;3<N<300;300<N锛�
+ //{
+ // if (boxCount<=3)//绠卞瓙灏忎簬3
+ // {
+ // foreach (var item in boxList)//寰幆绠卞瓙
+ // {
+ // boxStrList.Add(item);
+ // }
+ // }
+ // else if (boxCount > 3)//绠卞瓙灏忎簬3
+ // {
+ // var a = Math.Sqrt(boxCount)+1;//寮�骞虫柟 //瑙勫垯 绠辨暟 鈭歂+1
+ // if (boxCount > 300)
+ // {
+ // a = Math.Sqrt(boxCount) / 2 + 1;//瑙勫垯 绠辨暟 鈭歂/2+1
+ // }
+ // var b = Math.Floor(a); //鍙栨牱鐨勭鏁�
+
+ // var lit = new List<int>();
+ // do
+ // {
+ // byte[] buffer = Guid.NewGuid().ToByteArray();
+ // int iSeed = BitConverter.ToInt32(buffer, 0);
+ // Random random = new Random(iSeed);
+ // var j = random.Next(0, boxCount);
+ // if (lit.Contains(j))
+ // {
+ // continue;
+ // }
+
+ // var boxCode = boxList[j];//绠辩爜
+ // boxStrList.Add(boxCode);
+ // lit.Add(j);
+
+ // } while (lit.Count < b);
+
+ // }
+ //}
+ //else if(type == "2") //闅忔満鍙栨牱(涓�鎵规鍑轰竴绠�)
+ //{
+ // if (boxCount < boxNum)
+ // {
+ // throw new Exception("褰撳墠搴撳瓨鏁寸鏁板皯浜庤緭鍏ョ殑鍙栨牱鏁�");
+ // }
+ // var lit = new List<int>();
+ // do
+ // {
+ // byte[] buffer = Guid.NewGuid().ToByteArray();
+ // int iSeed = BitConverter.ToInt32(buffer, 0);
+ // Random random = new Random(iSeed);
+ // var j = random.Next(0, boxCount);
+ // if (lit.Contains(j))
+ // {
+ // continue;
+ // }
+
+ // var boxCode = boxList[j];//绠辩爜
+ // boxStrList.Add(boxCode);
+ // lit.Add(j);
+
+ // } while (lit.Count < boxNum);
+ //}
+ //else
+ //{
+ // throw new Exception("璇烽�夋嫨鍙栨牱瑙勫垯");
+ //}
+ //foreach (var item in boxStrList)//寰幆绠卞瓙
+ //{
+ // var box = listOrder.Where(m => m.BoxCode == item).ToList();
+ // var infoCount = box.Count;//绠卞唴鏀暟閲�
+ // if (infoCount <= 3) //鏀暟閲�<=3
+ // {
+ // outInfoCount += infoCount;
+ // SaveDic(useInfoQtyDic, item, infoCount);
+ // }
+ // else if (infoCount > 3)//绠卞唴鏁伴噺 > 3 涓� <=300
+ // {
+ // //瑙勫垯 鍙栨牱鏀暟 鈭歂+1
+ // var c = Math.Sqrt(infoCount) + 1;//寮�骞虫柟
+
+ // if (infoCount > 300) //绠卞唴鏁伴噺 > 300
+ // {
+ // //瑙勫垯 绠辨暟 鈭歂/2+1
+ // c = Math.Sqrt(infoCount) / 2 + 1;
+ // }
+ // var d = Math.Floor(c); //鍙栨牱鐨勬敮鏁伴噺
+
+ // outInfoCount += (int)d;
+ // SaveDic(useInfoQtyDic, item, (decimal)d);
+ // }
+ //}
+
+ //var pingJunNum = needQty / outInfoCount;//骞冲潎姣忔敮鍙栫殑鏁伴噺
+ //foreach (var item in useInfoQtyDic)
+ //{
+ // var box = listOrder.Where(m => m.BoxCode == item.Key).ToList();
+ // var infoCount = box.Count;//绠卞唴鏀暟閲�
+ // if (infoCount <= 3) //鏀暟閲�<=3
+ // {
+ // foreach (var item2 in box)
+ // {
+ // if (pingJunNum >= item2.Qty)
+ // {
+ // throw new Exception("骞冲潎闇�鍙栨牱鏁伴噺澶т簬绛変簬绠辨敮鍐呮暟閲�");
+ // }
+ // qty += pingJunNum;
+ // var tray = palletList.First(m => m.Id == item2.TrayId);
+
+ // SaveDic(stockQtyDic, tray.Id, pingJunNum);
+
+ // SaveDic(useBoxQtyDic, item2.Id, pingJunNum);
+ // }
+ // }
+ // else if (infoCount > 3)//绠卞唴鏁伴噺 > 3 涓� <=300
+ // {
+ // var e = item.Value; //鍙栨牱鐨勬敮鏁伴噺
+
+ // var lit2 = new List<int>();
+
+ // do
+ // {
+ // byte[] buffer = Guid.NewGuid().ToByteArray();
+ // int iSeed = BitConverter.ToInt32(buffer, 0);
+ // Random random = new Random(iSeed);
+ // var j = random.Next(0, infoCount);//闅忔満绠卞唴鏀爜
+
+ // if (lit2.Contains(j))
+ // {
+ // continue;
+ // }
+
+ // var info = box[j];
+ // if (pingJunNum >= info.Qty)
+ // {
+ // throw new Exception("骞冲潎闇�鍙栨牱鏁伴噺澶т簬绛変簬绠辨敮鍐呮暟閲�");
+ // }
+
+ // qty += pingJunNum;
+ // var tray = palletList.First(m => m.Id == info.TrayId);
+
+ // SaveDic(stockQtyDic, tray.Id, pingJunNum);
+ // SaveDic(useBoxQtyDic, info.Id, pingJunNum);
+ // lit2.Add(j);
+
+
+ // } while (lit2.Count < e);
+ // }
+ //}
+
+ #endregion
+
+ var outInfoCount = 0;
+ var boxStrList = new List<string>();//闅忔満浣跨敤绠�
+ Dictionary<string, int> useInfoQtyDic = new Dictionary<string, int>();//浣跨敤绠� 鍙婃瘡绠卞嚭澶氬皯鏀�
+
+
+ if (type == "1")//瑙勫垯鍙栨牱锛圢<3;3<N<300;300<N锛�
+ {
+ if (boxCount <= 3)//绠卞瓙灏忎簬3
+ {
+ foreach (var item in boxList)//寰幆绠卞瓙
+ {
+ boxStrList.Add(item);
+ }
+ }
+ else if (boxCount > 3)//绠卞瓙灏忎簬3
+ {
+ var a = Math.Sqrt(boxCount) + 1;//寮�骞虫柟 //瑙勫垯 绠辨暟 鈭歂+1
+ if (boxCount > 300)
+ {
+ a = Math.Sqrt(boxCount) / 2 + 1;//瑙勫垯 绠辨暟 鈭歂/2+1
+ }
+ var b = Math.Floor(a); //鍙栨牱鐨勭鏁�
+
+ var lit = new List<int>();
+ do
+ {
+ byte[] buffer = Guid.NewGuid().ToByteArray();
+ int iSeed = BitConverter.ToInt32(buffer, 0);
+ Random random = new Random(iSeed);
+ var j = random.Next(0, boxCount);
+ if (lit.Contains(j))
+ {
+ continue;
+ }
+
+ var boxCode = boxList[j];//绠辩爜
+ boxStrList.Add(boxCode);
+ lit.Add(j);
+
+ } while (lit.Count < b);
+
+ }
+ var zhi = listOrder.Count();
+ if (zhi <= 3) //鏀暟閲�<=3
+ {
+ outInfoCount += zhi;
+ }
+ else if (zhi > 3)//绠卞唴鏁伴噺 > 3 涓� <=300
+ {
+ //瑙勫垯 鍙栨牱鏀暟 鈭歂+1
+ var c = Math.Sqrt(zhi) + 1;//寮�骞虫柟
+
+ if (zhi > 300) //绠卞唴鏁伴噺 > 300
+ {
+ //瑙勫垯 绠辨暟 鈭歂/2+1
+ c = Math.Sqrt(zhi) / 2 + 1;
+ }
+ var d = Math.Floor(c); //鍙栨牱鐨勬敮鏁伴噺
+
+ outInfoCount += (int)d;
+ }
+ }
+ else if (type == "2") //闅忔満鍙栨牱(涓�鎵规鍑轰竴绠�)
+ {
+ if (boxCount < boxNum)
+ {
+ throw new Exception("褰撳墠搴撳瓨鏁寸鏁板皯浜庤緭鍏ョ殑鍙栨牱鏁�");
+ }
+ var lit = new List<int>();
+ do
+ {
+ byte[] buffer = Guid.NewGuid().ToByteArray();
+ int iSeed = BitConverter.ToInt32(buffer, 0);
+ Random random = new Random(iSeed);
+ var j = random.Next(0, boxCount);
+ if (lit.Contains(j))
+ {
+ continue;
+ }
+
+ var boxCode = boxList[j];//绠辩爜
+ boxStrList.Add(boxCode);
+ lit.Add(j);
+
+ } while (lit.Count < boxNum);
+
+ var zhi = listOrder.Count(m => boxStrList.Contains(m.BoxNo));
+ if (zhi <= 3) //鏀暟閲�<=3
+ {
+ outInfoCount += zhi;
+ }
+ else if (zhi > 3)//绠卞唴鏁伴噺 > 3 涓� <=300
+ {
+ //瑙勫垯 鍙栨牱鏀暟 鈭歂+1
+ var c = Math.Sqrt(zhi) + 1;//寮�骞虫柟
+
+ if (zhi > 300) //绠卞唴鏁伴噺 > 300
+ {
+ //瑙勫垯 绠辨暟 鈭歂/2+1
+ c = Math.Sqrt(zhi) / 2 + 1;
+ }
+ var d = Math.Floor(c); //鍙栨牱鐨勬敮鏁伴噺
+
+ outInfoCount += (int)d;
+ }
+ }
+ else
+ {
+ throw new Exception("璇烽�夋嫨鍙栨牱瑙勫垯");
+ }
+
+ var zhiCount = outInfoCount;
+ var xiangCount = boxStrList.Count; //闅忔満鍑虹殑绠辨暟閲�
+ for (int i = 1; i <= boxStrList.Count; i++)
+ {
+ decimal t = zhiCount / xiangCount;
+ var t2 = zhiCount % xiangCount;
+ var t3 = 5 / 2;
+ var t4 = 5 % 2;
+ if (t2 > 0)
+ {
+ t += 1;
+ }
+ var q = (int)t;//绠卞唴鍑哄灏戞敮
+ var infoCount = listOrder.Count(m => m.BoxNo == boxStrList[i - 1]);
+ if (q > infoCount)
+ {
+ throw new Exception("绠卞唴鏀暟灏忎簬瑕佸垎閰嶇殑鏀暟");
+ }
+ zhiCount -= q;
+ xiangCount -= 1;
+ SaveDic2(useInfoQtyDic, boxStrList[i - 1], q);
+ }
+
+
+ var pingJunNum = needQty / outInfoCount;// / pickNum;骞冲潎姣忔敮鍙栫殑鏁伴噺
+
+ foreach (var item in useInfoQtyDic)
+ {
+ var box = listOrder.Where(m => m.BoxNo == item.Key).ToList();
+ var infoCount = box.Count;//绠卞唴鏀暟閲�
+ if (infoCount == item.Value) //鏀暟閲�<=3
+ {
+ foreach (var item2 in box)
+ {
+ if (pingJunNum > item2.Qty)
+ {
+ throw new Exception("骞冲潎闇�鍙栨牱鏁伴噺澶т簬绛変簬绠辨敮鍐呮暟閲�");
+ }
+ qty += pingJunNum;
+ var tray = palletList.First(m => m.Id == item2.Id);
+
+ SaveDic(stockQtyDic, tray.Id, pingJunNum);
+
+ SaveDic(useBoxQtyDic, item2.Id, pingJunNum);
+ }
+ }
+ else
+ {
+ var e = item.Value; //鍙栨牱鐨勬敮鏁伴噺
+
+ var lit2 = new List<int>();
+
+ do
+ {
+ byte[] buffer = Guid.NewGuid().ToByteArray();
+ int iSeed = BitConverter.ToInt32(buffer, 0);
+ Random random = new Random(iSeed);
+ var j = random.Next(0, infoCount);//闅忔満绠卞唴鏀爜
+
+ if (lit2.Contains(j))
+ {
+ continue;
+ }
+
+ var info = box[j];
+ if (pingJunNum > info.Qty)
+ {
+ throw new Exception("骞冲潎闇�鍙栨牱鏁伴噺澶т簬绛変簬绠辨敮鍐呮暟閲�");
+ }
+
+ qty += pingJunNum;
+ var tray = palletList.First(m => m.Id == info.Id);
+
+ SaveDic(stockQtyDic, tray.Id, pingJunNum);
+ SaveDic(useBoxQtyDic, info.Id, pingJunNum);
+ lit2.Add(j);
+
+
+ } while (lit2.Count < e);
+ }
+ }
+
+
+ return (decimal)qty;
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+
+ /// <summary>
/// 淇濆瓨瀛楀吀
/// </summary>
/// <param name="dic"></param>
/// <param name="key"></param>
/// <param name="v"></param>
private void SaveDic(Dictionary<int, decimal> dic, int key, decimal v)
+ {
+ if (dic.ContainsKey(key))
+ {
+ dic[key] += v;
+ }
+ else
+ {
+ dic.Add(key, v);
+ }
+ }
+
+ private void SaveDic2(Dictionary<string, int> dic, string key, int v)
{
if (dic.ContainsKey(key))
{
@@ -365,7 +757,7 @@
item.Dept = int.Parse(dept);
}
//骞冲簱
- var locate1 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W02");
+ var locate1 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W02").ToList();
var data2 = new List<StockDetailDto>();
foreach (var liku in detail2.OrderBy(m => m.Dept).ToList())
{
@@ -387,7 +779,8 @@
}
//绔嬪簱
- var locate2 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W01");
+ var locate2 = Db.Queryable<SysStorageLocat>().Where(m => m.IsDel == "0" && m.WareHouseNo == "W01").ToList();
+
var data3 = new List<StockDetailDto>();
foreach (var liku in detail3.OrderBy(m => m.Dept).ToList())
{
--
Gitblit v1.8.0