From b2d25faa69ee7e9f24b6ac98d3b4dcbddada70bc Mon Sep 17 00:00:00 2001
From: yuyou_x <2336760928@qq.com>
Date: 星期四, 14 三月 2024 13:37:15 +0800
Subject: [PATCH] 修改pda托盘绑定同一物料多批次 无法具体选中批次问题。
---
Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs | 366 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 366 insertions(+), 0 deletions(-)
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
index ed93f45..13d05b0 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -6,10 +6,13 @@
using Model.ModelDto.PdaDto;
using SqlSugar;
using WMS.BLL.LogServer;
+using WMS.DAL;
using WMS.Entity.BllAsnEntity;
using WMS.Entity.BllCheckEntity;
+using WMS.Entity.BllSoEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
+using WMS.Entity.LogEntity;
using WMS.Entity.SysEntity;
using WMS.IBLL.IPdaServer;
@@ -292,6 +295,17 @@
checkDetail.RealQty = qty;
}
checkDetail.CheckResult = 1;
+ var checkInfo = Db.Queryable<BllStockCheckLog>().First(m =>
+ m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
+ checkInfo.RealQty = qty;
+ checkInfo.CheckResult = 1;
+
+ checkInfo.CheckUserId = userId;
+ checkInfo.CheckDate = time;
+
+ checkInfo.UpdateUser = userId;
+ checkInfo.UpdateTime = time;
+ Db.Updateable(checkInfo).ExecuteCommand();
Db.Updateable(checkDetail).ExecuteCommand();
Db.Updateable(list).ExecuteCommand();
}
@@ -738,6 +752,10 @@
{
throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
+ if (models.WareHouseNo != "W02")
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+ }
return models.LocatNo;
}
catch (Exception ex)
@@ -764,6 +782,10 @@
{
throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
}
+ if (models.WareHouseNo != "W02")
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+ }
var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == models.LocatNo);
if (storageLocat == null)
{
@@ -785,6 +807,350 @@
throw new Exception(ex.Message);
}
}
+ /// <summary>
+ /// 鑾峰彇宸插垎閰嶇殑鍑哄簱鍗曟嵁
+ /// </summary>
+ /// <returns></returns>
+ public List<string> GetRunSoNoticeList()
+ {
+ try
+ {
+ var allotList = Db.Queryable<BllExportNotice>().Where(m => m.IsDel == "0" && m.Status == "2").Select(m => m.SONo).Distinct().ToList();
+ return allotList;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鏍规嵁鎵樼洏鍙疯幏鍙栨墭鐩樹笂鐗╂枡淇℃伅
+ /// </summary>
+ /// <param name="palletNo"></param>
+ /// <returns></returns>
+ public List<DataStockDetail> GetSkuInfoByPalletNo(string palletNo)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(palletNo))
+ {
+ throw new Exception("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+ }
+ var skuInfoList = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
+ return skuInfoList;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鏍规嵁鍑哄簱鍗曞彿鑾峰彇鍒嗛厤鐨勬墭鐩樹俊鎭�
+ /// </summary>
+ /// <param name="soNo"></param>
+ /// <returns></returns>
+ public List<string> GetPalletNoListBySoNo(string soNo)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(soNo))
+ {
+ throw new Exception("璇烽�夋嫨鍑哄簱鍗曞彿锛�");
+ }
+ var palletNoList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo).Select(m => m.PalletNo).Distinct().ToList();
+ return palletNoList;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
+
+ /// <summary>
+ /// agv杞繍鍛煎彨灏忚溅-寮�鍙戞湭瀹屾垚寰呯‘璁�
+ /// </summary>
+ /// <param name="palletNo"></param>
+ /// <param name="areaNo"></param>
+ /// <param name="ruku"></param>
+ public void AgvTransport(string palletNo, string areaNo, string ruku, int userId)
+ {
+ if (string.IsNullOrEmpty(palletNo))
+ {
+ throw new Exception("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+ }
+ if (string.IsNullOrEmpty(areaNo) && string.IsNullOrEmpty(ruku))
+ {
+ throw new Exception("璇烽�夋嫨鐩爣鍖哄煙鎴栧叆搴撳彛锛�");
+ }
+ if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku))
+ {
+ throw new Exception("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�");
+ }
+ try
+ {
+ string EndLocat = string.Empty;//鐩爣浣嶇疆
+
+ var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+ if (log != null)
+ {
+ throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+ }
+ var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
+ if (stockDetail == null)
+ {
+ throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樻槑缁嗕俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ if (!string.IsNullOrEmpty(areaNo))
+ {
+ var storageArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.AreaNo == areaNo);
+ if (storageArea == null)
+ {
+ throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo);
+ }
+ else
+ {
+ EndLocat = ruku;
+ }
+ var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo);
+ if (stock == null)
+ {
+ throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ if (string.IsNullOrEmpty(stockDetail.LocatNo))
+ {
+ throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ if (stockDetail.WareHouseNo != "W02")
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+ }
+ var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
+ if (storageLocat == null)
+ {
+ throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ //寮�鍚簨鍔�
+ Db.BeginTran();
+
+ //娣诲姞鍑哄簱浠诲姟
+ var taskNo = new Common().GetMaxNo("TK");
+ var exTask = new LogTask
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "AGV",
+ IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+ StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+ EndLocat = EndLocat,//鐩爣浣嶇疆
+ PalletNo = palletNo,//鎵樼洏鐮�
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
+
+ CreateTime = DateTime.Now
+ };
+ Db.Insertable(exTask).ExecuteCommand();
+
+ //淇敼搴撳瓨鏄庣粏淇℃伅
+ stockDetail.Status = "4";//绉诲簱閿佸畾
+ stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺
+ Db.Updateable(stockDetail).ExecuteCommand();
+ //淇敼搴撳瓨淇℃伅
+ stock.LockQty += (decimal)stockDetail.Qty;
+ Db.Updateable(stock).ExecuteCommand();
+
+ //淇敼鍌ㄤ綅鍦板潃鐘舵��
+ storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑
+ Db.Updateable(storageLocat).ExecuteCommand();
+
+ //娣诲姞鎿嶄綔鏃ュ織璁板綍
+ var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+ //鎻愪氦浜嬪姟
+ Db.CommitTran();
+
+ #region 鍛煎彨灏忚溅浠g爜
+
+ #endregion
+ }
+ catch (Exception ex)
+ {
+ Db.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ }
+ /// <summary>
+ /// agv杞繍鍛煎彨灏忚溅鍙栬揣-寮�鍙戞湭瀹屾垚寰呯‘璁�
+ /// </summary>
+ /// <param name="soNo"></param>
+ /// <param name="palletNo"></param>
+ /// <param name="areaNo"></param>
+ /// <param name="userId"></param>
+ public void AgvTransport2(string soNo,string palletNo, string areaNo, int userId)
+ {
+ if (string.IsNullOrEmpty(soNo))
+ {
+ throw new Exception("璇烽�夋嫨鍑哄簱鍗曟嵁锛�");
+ }
+ if (string.IsNullOrEmpty(palletNo))
+ {
+ throw new Exception("璇锋壂鎻忔墭鐩樻潯鐮侊紒");
+ }
+ if (string.IsNullOrEmpty(areaNo))
+ {
+ throw new Exception("璇烽�夋嫨鐩爣鍖哄煙锛�");
+ }
+ try
+ {
+ var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
+ if (log != null)
+ {
+ throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!");
+ }
+
+ var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo);
+ if (notice == null)
+ {
+ throw new Exception("鍑哄簱鍗曟嵁淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ var allot = Db.Queryable<BllExportAllot>().First(w => w.IsDel == "0" && w.SONo == soNo && w.PalletNo == palletNo);
+ if (allot == null)
+ {
+ throw new Exception("璇ユ墭鐩樺嚭搴撳垎閰嶄俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
+ if (stockDetail == null)
+ {
+ throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == stockDetail.SkuNo && w.LotNo == stockDetail.LotNo);
+ if (stock == null)
+ {
+ throw new Exception("鎵樼洏涓婄墿鏂欏簱瀛樹俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ if (string.IsNullOrEmpty(stockDetail.LocatNo))
+ {
+ throw new Exception("鎵樼洏鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ if (stockDetail.WareHouseNo != "W02")
+ {
+ throw new Exception("璇ユ墭鐩樻湭鍦ㄥ钩搴撳唴,璇锋鏌�!");
+ }
+ var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
+ if (storageLocat == null)
+ {
+ throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!");
+ }
+ var storageArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.AreaNo == areaNo);
+ if (storageArea == null)
+ {
+ throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!");
+ }
+ string EndLocat = string.Empty;//鐩爣浣嶇疆
+ EndLocat= GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo);
+ //寮�鍚簨鍔�
+ Db.BeginTran();
+
+ //娣诲姞鍑哄簱浠诲姟
+ var taskNo = new Common().GetMaxNo("TK");
+ var exTask = new LogTask
+ {
+ TaskNo = taskNo,
+ Sender = "WMS",
+ Receiver = "AGV",
+ IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
+
+ StartLocat = stockDetail.LocatNo,//璧峰浣嶇疆
+ EndLocat = EndLocat,//鐩爣浣嶇疆
+ PalletNo = palletNo,//鎵樼洏鐮�
+ IsSend = 1,//鏄惁鍙啀娆′笅鍙�
+ IsCancel = 1,//鏄惁鍙彇娑�
+ IsFinish = 1,//鏄惁鍙畬鎴�
+ Type = "2",//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟
+ Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚
+ OrderType = "3",//0 鍏ュ簱鍗� 1 鍑哄簱鍗� 2 鐩樼偣鍗� 3 绉诲簱鍗�
+
+ CreateTime = DateTime.Now
+ };
+ Db.Insertable(exTask).ExecuteCommand();
+
+ //淇敼搴撳瓨鏄庣粏淇℃伅
+ stockDetail.Status = "4";//绉诲簱閿佸畾
+ stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺
+ Db.Updateable(stockDetail).ExecuteCommand();
+ //淇敼搴撳瓨淇℃伅
+ stock.LockQty += (decimal)stockDetail.Qty;
+ Db.Updateable(stock).ExecuteCommand();
+
+ //淇敼鍌ㄤ綅鍦板潃鐘舵��
+ storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑
+ Db.Updateable(storageLocat).ExecuteCommand();
+
+ //娣诲姞鎿嶄綔鏃ュ織璁板綍
+ var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId);
+ //鎻愪氦浜嬪姟
+ Db.CommitTran();
+
+ #region 鍛煎彨灏忚溅浠g爜
+
+ #endregion
+ }
+ catch (Exception ex)
+ {
+ Db.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鏍规嵁鍖哄煙鍒嗛厤鍌ㄤ綅
+ /// </summary>
+ /// <param name="areaNo"></param>
+ /// <param name="skuNo"></param>
+ /// <param name="lotNo"></param>
+ /// <returns></returns>
+ private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo)
+ {
+ try
+ {
+ string endLocat = string.Empty;//鐩爣鍌ㄤ綅
+ //褰撶劧鍖哄煙鎵�鏈夊偍浣嶄俊鎭�
+ var storageLocatList = Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W02" && w.AreaNo == areaNo).ToList();
+ //鍚屽尯鍩熷悓鎵规鐗╂枡鐨勫偍浣嶄俊鎭�
+ List<string> locatList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo && w.PalletNo != palletNo)
+ .OrderByDescending(o=>o.LocatNo).Select(s=>s.LocatNo).Distinct().ToList();
+ foreach (var item in locatList)
+ {
+ var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First();
+
+ var locatInfo2 = storageLocatList.Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.LocatNo != locatInfo.LocatNo && w.Row == locatInfo.Row)
+ .OrderByDescending(o => o.Column).First();
+ if (locatInfo2 != null)
+ {
+ endLocat = locatInfo2.LocatNo;
+ }
+ }
+ if (string.IsNullOrEmpty(endLocat))
+ {
+ var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
+ .OrderByDescending(m => new { m.Layer, m.Column, m.Row }).First();
+
+ if (locatInfo3 != null)
+ {
+ endLocat = locatInfo3.LocatNo;
+ }
+ }
+ return endLocat;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ }
#endregion
}
--
Gitblit v1.8.0