From 219a08427376efdd304e9b11e481ccd8276018bb Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期六, 18 十月 2025 11:14:29 +0800
Subject: [PATCH] 巷道形式存取放物料
---
Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs | 686 ++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 460 insertions(+), 226 deletions(-)
diff --git a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
index 1c4763c..29fb576 100644
--- a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
@@ -159,13 +159,14 @@
/// <param name="palletStatus"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
- public List<string> GetSkuByStatus(string palletStatus)
+ public List<DataStockDetail> GetSkuByStatus(string palletStatus)
{
try
{
//鑾峰彇鍌ㄤ綅涓婄殑搴撳瓨鐗╂枡
- var detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LocatNo) && m.PalletStatus == palletStatus).Select(m=>m.SkuNo).Distinct().ToList();
- return detail;
+ var detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LocatNo) && m.PalletStatus == palletStatus).ToList();
+ List<DataStockDetail> result = detail.GroupBy(x => x.SkuNo).Select(xx => xx.First()).ToList();
+ return result;
}
catch (Exception e)
{
@@ -191,12 +192,14 @@
}
}
- public List<string> GetSku()
+ public List<SysMaterials> GetSku()
{
try
{
//鑾峰彇鍌ㄤ綅涓婄殑搴撳瓨鐗╂枡
- var detail = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0" ).Select(m => m.SkuNo).Distinct().ToList();
+ //var detail = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0" ).Select(m => m.SkuNo).Distinct().ToList();
+
+ var detail = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0").ToList();
return detail;
}
catch (Exception e)
@@ -217,7 +220,7 @@
/// <param name="lotNo">鎵规</param>
/// <param name="userId">鎿嶄綔浜�</param>
/// <exception cref="Exception"></exception>
- public void jiaoLiaoHopper(string areaNo,string endLocate,string plnStatus,string standard,string skuNo,string lotNo,string url,int userId)
+ public void jiaoLiaoHopper(string areaNo,string endLocate,string plnStatus,string standard,string skuNo,string lotNo,string url, string bindUrl, int userId)
{
try
{
@@ -264,12 +267,20 @@
throw new Exception("娌℃湁鏌ヨ鍒颁粨搴撲俊鎭�");
}
//鏌ユ壘鐘舵�佹槸鏈垎閰嶄笖鍌ㄤ綅涓嶄负绌虹殑搴撳瓨淇℃伅
- var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.Status == "0" && m.WareHouseNo == house.WareHouseNo && !string.IsNullOrWhiteSpace(m.LocatNo)).ToList();
+ var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.Status == "0" && m.WareHouseNo == house.WareHouseNo && !string.IsNullOrWhiteSpace(m.LocatNo) && m.IsDel=="0").ToList();
//鍑�妗�
- if (plnStatus == "0")
+ if (plnStatus == "0") //4L鍙噣妗朵笉鍒嗘ゼ灞�
{
- stockDetail = stockDetail.Where(m => m.PalletStatus == "0" && m.Standard == standard).OrderBy(m => m.LocatNo).ToList();
+ if (house.WareHouseNo == "M01")
+ {
+ stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList();
+ }
+ else
+ {
+ stockDetail = stockDetail.Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList();
+ }
+
}
//婊℃《
else if (plnStatus == "2")
@@ -292,22 +303,24 @@
bool resultYi = false;
#region#鏌ユ壘鍚堥�傜殑 妗跺彿 鍌ㄤ綅
//鐩爣浠撳簱鎵�鏈夊偍浣�
- var locatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.WareHouseNo == house.WareHouseNo).ToList();
- //鐩爣浠撳簱鎵�鏈変笉闇�瑕佺Щ搴撶殑鍌ㄤ綅
+ var locatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Flag=="0" && w.WareHouseNo == house.WareHouseNo).OrderBy(w=>w.Column).ToList();
+ //鐩爣浠撳簱鎵�鏈夋渶澶栦晶鐨勫偍浣�
var locatListWai = locatList.Where(w => string.IsNullOrEmpty(w.AisleOne)).Select(s => s.LocatNo);
//鍏堟壘涓嶉渶瑕佺Щ搴撶殑妗�
- var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo)).OrderBy(o => o.UpdateTime).FirstOrDefault();
+ var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo) && w.Status == "0").OrderByDescending(w => w.UpdateTime).FirstOrDefault();
if (palletModel == null)
{
//鎵鹃渶瑕佺Щ搴撶殑妗�
- palletModel= stockDetail.Where(w => !locatListWai.Contains(w.LocatNo)).OrderBy(o => o.UpdateTime).FirstOrDefault();
+ palletModel= stockDetail.Where(w => !locatListWai.Contains(w.LocatNo)).OrderByDescending(w => w.UpdateTime).FirstOrDefault();
if (palletModel == null)
{
throw new Exception("鏈壘鍒板搴旀《淇℃伅");
}
- resultYi = YikuTask(palletModel.PalletNo, taskNo, url);
+ resultYi = YikuTask(palletModel.PalletNo, taskNo, url,bindUrl);
}
+ palletModel.Status = "2";
+ Db.Updateable(palletModel).ExecuteCommand();
#endregion
//璧峰鍌ㄤ綅鍦板潃淇℃伅
var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
@@ -328,9 +341,9 @@
Receiver = "RCS",
IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
- StartLocat = "",//璧峰浣嶇疆
+ StartLocat = startLoction.LocatNo,//璧峰浣嶇疆
EndLocat = endLocate,//鐩爣浣嶇疆
- PalletNo = "",//鎵樼洏鐮�
+ PalletNo = palletModel.PalletNo,//鎵樼洏鐮�
IsSend = 1,//鏄惁鍙啀娆′笅鍙�
IsCancel = 1,//鏄惁鍙彇娑�
IsFinish = 1,//鏄惁鍙畬鎴�
@@ -358,29 +371,37 @@
string agvMsg = string.Empty;
//缁欎笅杞︿笅鍙戜换鍔�
logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
- var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
- if (agvResult)//鎴愬姛
+ //涓嬪彂杞藉叿绫诲瀷
+ var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, palletModel.LocatNo, bindUrl, out string agvBindMsg);
+ if (bind)
{
- //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
- logTaskEntry.IsSuccess = 1;
- logTaskEntry.IsSend = 0;
- //logTaskEntry.IsCancel = 0;
- logTaskEntry.BackDate = DateTime.Now;
- logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Updateable(logTaskEntry).ExecuteCommand();
- startLoction.Status = "3";//鍑哄簱涓�
- Db.Updateable(startLoction).ExecuteCommand();
+ startLoction.Status = "3";//鍑哄簱涓�
+ Db.Updateable(startLoction).ExecuteCommand();
- endLocateInfo.Status = "2";//鍏ュ簱涓�
- Db.Updateable(endLocateInfo).ExecuteCommand();
+ endLocateInfo.Status = "2";//鍏ュ簱涓�
+ Db.Updateable(endLocateInfo).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ throw new Exception("妗跺彿锛�"+ task.Pallno + ",璋冨害灏忚溅澶辫触");
+ }
}
- else//澶辫触
+ else
{
- logTaskEntry.IsSuccess = 0;
- logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ throw new Exception("妗跺彿锛�" + task.Pallno + ",缁戝畾璐т綅澶辫触");
}
+
}
//鎻愪氦浜嬪姟
Db.CommitTran();
@@ -405,7 +426,7 @@
/// <param name="lotNo">鎵规</param>
/// <param name="userId">鎿嶄綔浜�</param>
/// <exception cref="Exception"></exception>
- public void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight, string skuNo, string lotNo, string url,int userId)
+ public void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight, string skuNo, string lotNo, string url,string bindUrl,int userId)
{
try
{
@@ -414,6 +435,11 @@
if (string.IsNullOrWhiteSpace(areaNo) || string.IsNullOrWhiteSpace(StartLocate) || string.IsNullOrWhiteSpace(plnStatus))
{
throw new Exception("鍖哄煙/璧峰浣�/妗剁被鍨嬩笉鑳戒负绌�");
+ }
+
+ if (weight < 0)
+ {
+ throw new Exception("閲嶉噺搴斾笉灏忎簬0");
}
//if (plnStatus == "0" && string.IsNullOrWhiteSpace(standard))
@@ -430,11 +456,12 @@
Db.BeginTran();
//妗朵俊鎭�
- var pln = Db.Queryable<SysPallets>().First(w => w.IsDel == "0" && w.PalletNo == plnNo);
+ var pln = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == StartLocate && w.AreaNo == areaNo);
if (pln == null)
{
throw new Exception("鏈煡璇㈠埌妗朵俊鎭�");
}
+ plnNo = pln.PalletNo;
//璧峰鍌ㄤ綅淇℃伅
var startLoction = Db.Queryable<SysStorageLocat>().First(m => m.IsDel == "0" && m.AreaNo == areaNo && m.LocatNo == StartLocate);
@@ -449,10 +476,6 @@
throw new Exception("娌℃湁鏌ヨ鍒扮墿鏂欎俊鎭�");
}
skuName = sku.SkuName;
- }
- else if (plnStatus == "3")
- {
-
}
//鐩爣妤煎眰
var layer = startLoction.Layer;
@@ -490,24 +513,26 @@
CompleteTime = DateTime.Now,
PalletStatus = plnStatus,
- Status = "0",
+ Status = "2",
InspectMark = "0",
BitPalletMark = "0",
InspectStatus = "1",
};
- Db.Insertable(stockDetailNew).ExecuteCommand();
+ Db.Updateable(stockDetailNew).ExecuteCommand();
}
else
{
stockDetail.PalletStatus = plnStatus;
stockDetail.SkuNo = skuNo;
+ stockDetail.SkuName = skuName;
stockDetail.LotNo = lotNo;
stockDetail.Qty = weight;
+ stockDetail.Status = "2";
Db.Updateable(stockDetail).ExecuteCommand();
}
//鍒嗛厤鍌ㄤ綅
- var endLocatInfo = GetLocatModel(house.WareHouseNo, plnStatus, skuNo, pln.Standard);//鐩爣鍌ㄤ綅
+ var endLocatInfo = GetLocatModel(house.WareHouseNo, plnStatus, startLoction.WareHouseNo, skuNo, pln.Standard,lotNo);//鐩爣鍌ㄤ綅
//娌℃湁鍙敤绌哄偍浣�
if (endLocatInfo == null)
{
@@ -550,29 +575,38 @@
string agvMsg = string.Empty;
//缁欎笅杞︿笅鍙戜换鍔�
logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
- var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
- if (agvResult)//鎴愬姛
+ //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+ var bind = RcsHelper.BindPalletAndSite(plnNo, StartLocate, bindUrl, out string agvBindMsg);
+ if (bind)
{
- //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
- logTaskEntry.IsSuccess = 1;
- logTaskEntry.IsSend = 0;
- //logTaskEntry.IsCancel = 0;
- logTaskEntry.BackDate = DateTime.Now;
- logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Updateable(logTaskEntry).ExecuteCommand();
- startLoction.Status = "3";//鍑哄簱涓�
- Db.Updateable(startLoction).ExecuteCommand();
+ startLoction.Status = "3";//鍑哄簱涓�
+ Db.Updateable(startLoction).ExecuteCommand();
- endLocatInfo.Status = "2";//鍏ュ簱涓�
- Db.Updateable(endLocatInfo).ExecuteCommand();
+ endLocatInfo.Status = "2";//鍏ュ簱涓�
+ Db.Updateable(endLocatInfo).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ throw new Exception("妗跺彿锛�" + task.Pallno + ",璋冨害灏忚溅澶辫触");
+ }
+
}
- else//澶辫触
+ else
{
- logTaskEntry.IsSuccess = 0;
- logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ throw new Exception("妗跺彿锛�" + task.Pallno + ",缁戝畾璐т綅澶辫触");
}
+
//鎻愪氦浜嬪姟
Db.CommitTran();
@@ -593,7 +627,7 @@
/// <param name="comeFrom"></param>
/// <param name="userId"></param>
/// <exception cref="Exception"></exception>
- public void RCSFinishTask(string taskNo, string status, string comeFrom, int userId = 0)
+ public void RCSFinishTask(string taskNo, string locateNo, string status, string comeFrom, int userId = 0)
{
try
{
@@ -609,10 +643,10 @@
{
throw new Exception($"浠诲姟鍙蜂负:{taskNo}鐨勪换鍔′笉瀛樺湪!");
}
- if (taskInfo.Status != "1" && comeFrom != "WMS")
- {
- throw new Exception($"浠诲姟鍙蜂负:{taskNo}鐨勪换鍔$姸鎬佸紓甯�");
- }
+ //if (taskInfo.Status != "0" && comeFrom != "WMS")
+ //{
+ // throw new Exception($"浠诲姟鍙蜂负:{taskNo}鐨勪换鍔$姸鎬佸紓甯�");
+ //}
#endregion
//寮�鍚簨鍔�
Db.BeginTran();
@@ -633,7 +667,7 @@
return;
}
//搴撳瓨鏄庣粏
- var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo);
+ var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo && w.IsDel=="0");
if (stockDetail == null)
{
throw new Exception($"妗跺簱瀛樹俊鎭笉瀛樺湪");
@@ -655,6 +689,7 @@
throw new Exception($"鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�");
}
endLocatInfo.Status = "1";//鏈夌墿鍝�
+ endLocatInfo.UpdateTime = DateTime.Now;//鏇存柊鏃堕棿
//淇敼鐩爣鍌ㄤ綅鐘舵��
Db.Updateable(endLocatInfo).ExecuteCommand();
@@ -677,7 +712,7 @@
}
else if (endAreaInfo.Type == "1")//婊℃《鍖�
{
- stockDetail.PalletStatus = "1";
+ stockDetail.PalletStatus = "2";
stockDetail.Status = "0";//寰呭垎閰�
}
else if (endAreaInfo.Type == "2")//鑴忔《鍖�
@@ -727,7 +762,7 @@
/// <param name="deviceStation">鍙枡鐐逛綅锛氣�漣nput鈥�-鍏ュ彛锛堝彨鑴忔《锛夛紝鈥漮utput鈥�-鍑哄彛锛堝噣妗剁敵璇峰偍浣嶏級</param>
/// <param name="status"></param>
/// <exception cref="Exception"></exception>
- public void RCSCleanRequest(string deviceID,string deviceStation,string status,string url)
+ public void RCSCleanRequest(string deviceID,string deviceStation,string status,string url,string bindUrl)
{
try
{
@@ -738,6 +773,38 @@
if (status != "1")
{
throw new Exception("闈炲彨鏂欑姸鎬�");
+ }
+ switch (deviceStation)
+ {
+ case "input"://鍙剰妗�
+ switch (deviceID)
+ {
+ case "2001":
+ deviceID = "1001";
+ break;
+ case "2002":
+ deviceID = "1003";
+ break;
+ default:
+ throw new Exception("鍙剰妗剁偣浣嶅紓甯�");
+ }
+ break;
+ case "output"://鍙溅鎷夊噣妗�
+ switch (deviceID)
+ {
+ case "2001":
+ deviceID = "1002";
+ break;
+ case "2002":
+ deviceID = "1004";
+ break;
+ default:
+ throw new Exception("鍙噣妗剁偣浣嶅紓甯�");
+ }
+ break;
+ default:
+ throw new Exception("鍙枡绫诲瀷寮傚父");
+
}
//閫氳繃璁惧鍙锋煡鎵惧埌鎵�灞炶澶囷紙鍖哄煙锛�
var deviceInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode == deviceID);
@@ -750,6 +817,7 @@
var startLoction = new SysStorageLocat();//璧峰鍌ㄤ綅淇℃伅
var endLoction = new SysStorageLocat();//鐩爣鍌ㄤ綅淇℃伅
var palletModel = new DataStockDetail();//鍒嗛厤妗朵俊鎭�
+ string type = "";//鍙枡绫诲瀷
//寮�鍚簨鍔�
Db.BeginTran();
@@ -758,64 +826,125 @@
switch (deviceStation)
{
case "input"://鍙剰妗�
- //鍙《璁惧鎵�鍦ㄥ偍浣嶄俊鎭紙鐩爣鍌ㄤ綅锛�
- endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
+ if (deviceID == "1001" || deviceID == "1003")
+ {
+ type = "3";
+ //鍙《璁惧鎵�鍦ㄥ偍浣嶄俊鎭紙鐩爣鍌ㄤ綅锛�
+ endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
- // 鎵�鏈夊緟鍒嗛厤鐨勮剰妗�
- var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0" && w.PalletStatus == "3");
-
- //浼樺厛鏌ユ壘鑴忔《缂撳瓨杞﹂棿
- palletModel = stockDetail.Where(w => w.AreaNo == "C43").OrderByDescending(o => o.UpdateTime).First();
- if (palletModel == null)//鑴忔《缂撳瓨杞﹂棿娌℃湁鑴忔《锛屽啀浠庝笁妤间腑闂寸珯鑴忔《鍖烘煡鎵�
- {
- palletModel = stockDetail.Where(w =>w.WareHouseNo=="M16" && w.AreaNo == "C26").OrderByDescending(o => o.UpdateTime).First();
+ // 鎵�鏈夊緟鍒嗛厤鐨勮剰妗�
+ var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0" && w.PalletStatus == "3").OrderByDescending(w => w.UpdateTime).ToList();
+
+ //鍒ゆ柇褰撳墠娓呮礂鏈鸿澶囦笂鏈夊嚑涓剰妗讹紝status锛�2 姝e湪娓呮礂鐨勮剰妗讹紙鐘舵�佽Е鍙戝彉鏇翠负AGV鍙2涓剰妗舵椂瑙﹀彂锛�
+ int ztQty = Db.Queryable<DataStockDetail>().Count(w => w.IsDel == "0" && w.Status == "2" && w.LocatNo == deviceID);
+ if (ztQty == 2)
+ {
+ throw new Exception((deviceID == "1001"?"1":"2") + "鍙锋竻娲楁満鑴忔《宸叉弧锛岄噸澶嶅彨鏂欙紒");
+ }
+
+ //鍏堟煡鐪嬪彨鏂欒澶囦綅鏄惁鏈夎剰妗�
+ if (endLoction.Status == "1")
+ {
+ //鏈夎剰妗剁殑璇濓紝灏嗘洿鏀规妗剁姸鎬�(浠h〃姝ゆ《姝e湪娓呮礂涓�)
+ var qxStock = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == endLoction.LocatNo).First();
+ qxStock.Status = "2";
+ qxStock.UpdateTime = DateTime.Now;//娓呮礂鏃堕棿
+ Db.Updateable(qxStock).ExecuteCommand();
+ //鏇存敼璁惧鍌ㄤ綅鐘舵�佷负绌哄偍浣�
+ endLoction.Status = "0";
+ Db.Updateable(endLoction).ExecuteCommand();
+ }
+ //浼樺厛鏌ユ壘鑴忔《缂撳瓨杞﹂棿
+ palletModel = stockDetail.Where(w => w.AreaNo == "C54").FirstOrDefault();
+ if (palletModel == null)//鑴忔《缂撳瓨杞﹂棿娌℃湁鑴忔《锛屽啀浠庝笁妤间腑闂寸珯鑴忔《鍖烘煡鎵�
+ {
+ palletModel = stockDetail.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C26").FirstOrDefault();
+ }
+ if (palletModel == null)//涓夋ゼ涓棿绔欒剰妗跺尯娌℃湁鑴忔《锛屽啀浠庡洓妤间腑闂寸珯鑴忔《鍖烘煡鎵�
+ {
+ palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").FirstOrDefault();
+ }
+ if (palletModel == null)
+ {
+ throw new Exception("鏃犺剰妗跺彲鍒嗛厤");
+ }
+ //璧峰鍌ㄤ綅鍦板潃淇℃伅
+ startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
+ if (startLoction == null)
+ {
+ throw new Exception($"璧峰鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦紝妗跺彿锛歿palletModel.LocatNo}");
+ }
+ //璧峰妗朵俊鎭�
+ var startDataDetil = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.Status == "0" && w.PalletStatus == "3");
+ if (startDataDetil == null)
+ {
+ throw new Exception($"娓呮礂鏈烘墍鍙殑妗剁姸鎬侀敊璇紝妗跺彿锛歿palletModel.LocatNo}");
+ }
+ startDataDetil.Status = "4";
+ Db.Updateable(startDataDetil).ExecuteCommand();
}
- if (palletModel == null)//涓夋ゼ涓棿绔欒剰妗跺尯娌℃湁鑴忔《锛屽啀浠庡洓妤间腑闂寸珯鑴忔《鍖烘煡鎵�
+ else
{
- palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").OrderByDescending(o => o.UpdateTime).First();
- }
- if (palletModel == null)
- {
- throw new Exception("鏃犺剰妗跺彲鍒嗛厤");
- }
- //璧峰鍌ㄤ綅鍦板潃淇℃伅
- startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo);
- if (startLoction == null)
- {
- throw new Exception($"璧峰鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦紝妗跺彿锛歿palletModel.LocatNo}");
+ throw new Exception("璧峰鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�");
}
break;
case "output"://鍑�妗剁敵璇峰偍浣�
- //鍙《璁惧鎵�鍦ㄥ偍浣嶄俊鎭紙璧峰鍌ㄤ綅锛�
- startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
- //妗朵俊鎭�
- palletModel = Db.Queryable<DataStockDetail>().Where(w => w.WareHouseNo==houseNo && w.AreaNo==deviceInfo.AreaNo && w.LocatNo==startLoction.LocatNo).First();
- if (palletModel == null)
+ if (deviceID == "1002" || deviceID == "1004")
{
- throw new Exception("鏈煡璇㈠埌鍑�妗朵俊鎭�");
+ type = "4";
+ //鍙《璁惧鎵�鍦ㄥ偍浣嶄俊鎭紙璧峰鍌ㄤ綅锛�
+ startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo);
+ //鑾峰彇娓呮礂鏈轰笂绗竴娆″彨鐨勮剰妗�
+ string locate = deviceID == "1002"?"1001":"1003";
+ palletModel = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == locate && (w.Status == "2" || w.Status == "0")).OrderBy(o => o.CreateTime).First();
+ if (palletModel == null)
+ {
+ throw new Exception("鏈壘鍒板簱瀛樹腑姝e湪娓呮礂鐨勮剰妗�");
+ }
+ if (!string.IsNullOrEmpty(palletModel.LocatNo))
+ {
+ palletModel.LocatNo = startLoction.LocatNo;
+ palletModel.PalletStatus = "0";
+ palletModel.Status = "4";
+ Db.Updateable(palletModel).ExecuteCommand();
+ }
+ //鍒嗛厤鍌ㄤ綅
+ //鏌ユ壘鎵�鏈夊噣妗跺偍浣�
+ var jtLocate = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0")
+ .OrderBy(w => w.Row).OrderByDescending(w => w.Column).ToList();
+ if (jtLocate.Count == 0)
+ {
+ throw new Exception("娌℃湁绌轰綑鐨勫噣妗跺偍浣�");
+ }
+ //浼樺厛鍒嗛厤鍥涙ゼ涓棿绔欏噣妗跺尯
+ endLoction = jtLocate.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C01")
+ .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
+ if (endLoction == null)//鍥涙ゼ涓棿绔欏噣妗跺尯娌℃湁绌哄偍浣嶏紝鍐嶄粠涓夋ゼ涓棿绔欏噣妗跺尯鏌ユ壘
+ {
+ endLoction = jtLocate.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C24")
+ .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
+ }
+ if (endLoction == null)//涓夋ゼ涓棿绔欏噣妗跺尯娌℃湁绌哄偍浣嶏紝鍐嶄粠涓夋ゼ娓呮礂闂寸紦瀛樺尯鏌ユ壘 PS锛氬皬杞︾幇鍦ㄨ繕涓嶆敮鎸佹竻娲楁満鐩存帴閫佸線4妤煎噣妗跺尯
+ {
+ endLoction = jtLocate.Where(w => w.WareHouseNo == "M44" && w.AreaNo == "C55")
+ .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
+ }
+ if (endLoction == null)
+ {
+ throw new Exception("鏈煡璇㈠埌鍚堥�傚偍浣�");
+ }
+ //string startlono = startLoction.LocatNo == "1001" ? "1002" : "1004";//娓呮礂瀹屾垚鐐逛綅
+ //startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == startlono);
+ //if (startLoction == null)
+ //{
+ // throw new Exception("鏈壘鍒版竻娲楄捣濮嬬偣浣�");
+ //}
}
- //鍒嗛厤鍌ㄤ綅
- //浼樺厛鍒嗛厤鍥涙ゼ涓棿绔欏噣妗跺尯
- endLoction= Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
- && w.WareHouseNo == "M01" && w.AreaNo == "C01")
- .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
- if (endLoction == null)//鍥涙ゼ涓棿绔欏噣妗跺尯娌℃湁绌哄偍浣嶏紝鍐嶄粠涓夋ゼ涓棿绔欏噣妗跺尯鏌ユ壘
+ else
{
- endLoction = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
- && w.WareHouseNo == "M16" && w.AreaNo == "C24")
- .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
- }
- if (endLoction == null)//涓夋ゼ涓棿绔欏噣妗跺尯娌℃湁绌哄偍浣嶏紝鍐嶄粠涓夋ゼ娓呮礂闂寸紦瀛樺尯鏌ユ壘
- {
- endLoction = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
- && w.WareHouseNo == "M44" && w.AreaNo == "C55")
- .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
- }
- if (endLoction == null)
- {
- throw new Exception("鏈煡璇㈠埌鍚堥�傚偍浣�");
+ throw new Exception("璧峰鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�");
}
break;
@@ -823,6 +952,7 @@
throw new Exception("鍙枡鐐逛綅寮傚父");
}
+
var taskNo = new Common().GetMaxNo("TK");
//娣诲姞浠诲姟
var logTaskEntry = new LogTask
@@ -832,9 +962,9 @@
Receiver = "RCS",
IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛
- StartLocat = "",//璧峰浣嶇疆
+ StartLocat = startLoction.LocatNo,//璧峰浣嶇疆
EndLocat = endLoction.LocatNo,//鐩爣浣嶇疆
- PalletNo = "",//鎵樼洏鐮�
+ PalletNo = palletModel.PalletNo,//鎵樼洏鐮�
IsSend = 1,//鏄惁鍙啀娆′笅鍙�
IsCancel = 1,//鏄惁鍙彇娑�
IsFinish = 1,//鏄惁鍙畬鎴�
@@ -853,35 +983,43 @@
Startport = palletModel.LocatNo,//璧峰浣嶇疆
Endport = endLoction.LocatNo,//鐩爣浣嶇疆
Pallno = palletModel.PalletNo,//妗跺彿
- Crtype = "1",//鍙《
+ Crtype = type,//鍙《
};
string agvMsg = string.Empty;
//缁欎笅杞︿笅鍙戜换鍔�
logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
- var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
- if (agvResult)//鎴愬姛
+ //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+ var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, palletModel.LocatNo, bindUrl, out string agvBindMsg);
+ if (bind)
{
- //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
- logTaskEntry.IsSuccess = 1;
- logTaskEntry.IsSend = 0;
- //logTaskEntry.IsCancel = 0;
- logTaskEntry.BackDate = DateTime.Now;
- logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Updateable(logTaskEntry).ExecuteCommand();
- startLoction.Status = "3";//鍑哄簱涓�
- Db.Updateable(startLoction).ExecuteCommand();
+ startLoction.Status = "3";//鍑哄簱涓�
+ Db.Updateable(startLoction).ExecuteCommand();
- endLoction.Status = "2";//鍏ュ簱涓�
- Db.Updateable(endLoction).ExecuteCommand();
+ endLoction.Status = "2";//鍏ュ簱涓�
+ Db.Updateable(endLoction).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ throw new Exception("妗跺彿锛�" + task.Pallno + ",璋冨害灏忚溅澶辫触");
+ }
}
- else//澶辫触
+ else
{
- logTaskEntry.IsSuccess = 0;
- logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ throw new Exception("妗跺彿锛�" + task.Pallno + ",缁戝畾璐т綅澶辫触");
}
+
//鎻愪氦浜嬪姟
Db.CommitTran();
}
@@ -893,10 +1031,11 @@
}
}
- private bool YikuTask(string palletNo, string taskNo, string url)
+ private bool YikuTask(string palletNo, string taskNo, string url,string bindUrl)
{
try
{
+ bool t = false;
//鍒嗛厤妗剁殑搴撳瓨淇℃伅
var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
if (palletInfo == null)
@@ -919,6 +1058,8 @@
//鍒ゆ柇璇ュ偍浣嶆槸鍚︽槸鍐呬晶鍌ㄤ綅
if (!string.IsNullOrEmpty(locatInfo.AisleOne))
{
+ ////鑾峰彇褰撳墠搴撲綅鐨勫渚у偍浣嶄俊鎭�
+ //var waiLocatInfo = Db.Queryable<SysStorageLocat>().First(w=>w.IsDel == "0" && w.Row == locatInfo.Row && w.Column == locatInfo.Column - 1);
//鍒ゆ柇澶栦晶鍌ㄤ綅鏄惁鏈夋《
var palletInfoYi = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == locatInfo.AisleOne);
if (palletInfoYi != null)
@@ -985,36 +1126,55 @@
string agvMsg = string.Empty;
//缁欎笅杞︿笅鍙戜换鍔�
logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
- var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
- if (agvResult)//鎴愬姛
+ //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+ var bind = RcsHelper.BindPalletAndSite(palletInfoYi.LocatNo, palletInfoYi.PalletNo, bindUrl, out string agvBindMsg);
+ if (bind)
{
- //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
- logTaskEntry.IsSuccess = 1;
- logTaskEntry.IsSend = 0;
- //logTaskEntry.IsCancel = 0;
- logTaskEntry.BackDate = DateTime.Now;
- logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Updateable(logTaskEntry).ExecuteCommand();
- //淇敼绉诲嚭鍌ㄤ綅鐘舵��
- locatInfo.Status = "5";//绉诲嚭涓�
- Db.Updateable(locatInfo).ExecuteCommand();
+ //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+ locatInfo.Status = "5";//绉诲嚭涓�
+ Db.Updateable(locatInfo).ExecuteCommand();
- //淇敼绉诲叆鍌ㄤ綅鐘舵��
- transferLocat.Status = "4";//绉诲叆涓�
- Db.Updateable(transferLocat).ExecuteCommand();
+ //淇敼绉诲叆鍌ㄤ綅鐘舵��
+ transferLocat.Status = "4";//绉诲叆涓�
+ Db.Updateable(transferLocat).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskEntry.IsSuccess = 0;
+ logTaskEntry.Information = agvMsg;
+ Db.Updateable(logTaskEntry).ExecuteCommand();
+
+ throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
+ }
}
- else//澶辫触
+ else
{
logTaskEntry.IsSuccess = 0;
- logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ logTaskEntry.Information = agvBindMsg;
+ Db.Updateable(logTaskEntry).ExecuteCommand();
throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
}
+ t = true;
+
+ }
+ else
+ {
+ return t;
}
}
- return true;
+ return t;
}
catch (Exception e)
{
@@ -1027,7 +1187,7 @@
/// <param name="taskNo"></param>
/// <param name="url"></param>
/// <exception cref="Exception"></exception>
- public void OutBinAgv(string taskNo,string url)
+ public void OutBinAgv(string taskNo,string url, string bindUrl)
{
try
{
@@ -1035,7 +1195,7 @@
Db.BeginTran();
//鏌ユ壘浠诲姟淇℃伅
- var logTaskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1" && w.TaskNo == taskNo);
+ var logTaskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "0" && w.TaskNo == taskNo);
if (logTaskInfo == null)
{
throw new Exception("鏈煡璇㈠埌璇ヤ换鍔�");
@@ -1080,34 +1240,49 @@
string agvMsg = string.Empty;
//缁欎笅杞︿笅鍙戜换鍔�
logTaskInfoZ.SendDate = DateTime.Now;//鍙戦�佹椂闂�
- var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
- if (agvResult)//鎴愬姛
+ //涓嬪彂杞藉叿涓庤揣浠粦瀹�
+ var bind = RcsHelper.BindPalletAndSite(logTaskInfoZ.PalletNo, logTaskInfoZ.StartLocat, bindUrl, out string agvBindMsg);
+ if (bind)
{
- //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
- logTaskInfoZ.IsSuccess = 1;
- logTaskInfoZ.IsSend = 0;
- //logTaskEntry.IsCancel = 0;
- logTaskInfoZ.BackDate = DateTime.Now;
- logTaskInfoZ.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskInfoZ).ExecuteCommand();
+ var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70");
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskInfoZ.IsSuccess = 1;
+ logTaskInfoZ.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskInfoZ.BackDate = DateTime.Now;
+ logTaskInfoZ.Status = "1";//姝e湪鎵ц
+ Db.Updateable(logTaskInfoZ).ExecuteCommand();
- //淇敼绉诲嚭鍌ㄤ綅鐘舵��
- startLocatInfoZ.Status = "5";//绉诲嚭涓�
- Db.Updateable(startLocatInfoZ).ExecuteCommand();
+ //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+ startLocatInfoZ.Status = "5";//绉诲嚭涓�
+ Db.Updateable(startLocatInfoZ).ExecuteCommand();
- //淇敼绉诲叆鍌ㄤ綅鐘舵��
- endLocatInfoZ.Status = "4";//绉诲叆涓�
- Db.Updateable(endLocatInfoZ).ExecuteCommand();
+ //淇敼绉诲叆鍌ㄤ綅鐘舵��
+ endLocatInfoZ.Status = "4";//绉诲叆涓�
+ Db.Updateable(endLocatInfoZ).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskInfoZ.IsSuccess = 0;
+ logTaskInfoZ.Information = agvMsg;
+ Db.Updateable(logTaskInfoZ).ExecuteCommand();
+
+ throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
+ }
}
- else//澶辫触
+ else
{
logTaskInfoZ.IsSuccess = 0;
- logTaskInfoZ.Information = agvMsg;
- Db.Insertable(logTaskInfoZ).ExecuteCommand();
+ logTaskInfoZ.Information = agvBindMsg;
+ Db.Updateable(logTaskInfoZ).ExecuteCommand();
throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿logTaskInfoZ.PalletNo}");
}
+
}
+ Db.CommitTran();
}
catch (Exception e)
{
@@ -1122,7 +1297,7 @@
/// </summary>
/// <param name="url"></param>
/// <exception cref="Exception"></exception>
- public void TransferBackTimer(string url)
+ public void TransferBackTimer(string url,string bindUrl)
{
try
{
@@ -1155,7 +1330,7 @@
continue;
}
//鍒嗛厤鍌ㄤ綅
- var endLocatInfo = GetLocatModel(itemHouseNo,detailInfo.PalletStatus,detailInfo.SkuNo,detailInfo.Standard);//鐩爣鍌ㄤ綅
+ var endLocatInfo = GetLocatModel(itemHouseNo,detailInfo.PalletStatus,"",detailInfo.SkuNo,detailInfo.Standard,detailInfo.LotNo);//鐩爣鍌ㄤ綅
//娌℃湁鍙敤绌哄偍浣�
if (endLocatInfo == null)
{
@@ -1195,35 +1370,49 @@
Crtype = "2"//鍙《
};
string agvMsg = string.Empty;
- //缁欎笅杞︿笅鍙戜换鍔�
+ //缁欎笅杞︿笅鍙戜换鍔� s
logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂�
- var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
- if (agvResult)//鎴愬姛
+ //涓嬪彂杞藉叿涓庤揣浣嶇粦瀹�
+ var bind = RcsHelper.BindPalletAndSite(detailInfo.PalletNo, detailInfo.LocatNo, bindUrl, out string agvBindMsg);
+ if (bind)
{
- //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
- logTaskEntry.IsSuccess = 1;
- logTaskEntry.IsSend = 0;
- //logTaskEntry.IsCancel = 0;
- logTaskEntry.BackDate = DateTime.Now;
- logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg);
+ if (agvResult)//鎴愬姛
+ {
+ //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬�
+ logTaskEntry.IsSuccess = 1;
+ logTaskEntry.IsSend = 0;
+ //logTaskEntry.IsCancel = 0;
+ logTaskEntry.BackDate = DateTime.Now;
+ logTaskEntry.Status = "1";//姝e湪鎵ц
+ Db.Updateable(logTaskEntry).ExecuteCommand();
- //淇敼绉诲嚭鍌ㄤ綅鐘舵��
- locatModel.Status = "5";//绉诲嚭涓�
- Db.Updateable(locatModel).ExecuteCommand();
+ //淇敼绉诲嚭鍌ㄤ綅鐘舵��
+ locatModel.Status = "5";//绉诲嚭涓�
+ Db.Updateable(locatModel).ExecuteCommand();
- //淇敼绉诲叆鍌ㄤ綅鐘舵��
- endLocatInfo.Status = "4";//绉诲叆涓�
- Db.Updateable(endLocatInfo).ExecuteCommand();
+ //淇敼绉诲叆鍌ㄤ綅鐘舵��
+ endLocatInfo.Status = "4";//绉诲叆涓�
+ Db.Updateable(endLocatInfo).ExecuteCommand();
+ }
+ else//澶辫触
+ {
+ logTaskEntry.IsSuccess = 0;
+ logTaskEntry.Information = agvMsg;
+ Db.Updateable(logTaskEntry).ExecuteCommand();
+
+ throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
+ }
}
- else//澶辫触
+ else
{
logTaskEntry.IsSuccess = 0;
- logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ logTaskEntry.Information = agvBindMsg;
+ Db.Updateable(logTaskEntry).ExecuteCommand();
throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿detailInfo.PalletNo}");
}
+
}
}
//鎻愪氦浜嬪姟
@@ -1246,7 +1435,7 @@
/// <param name="standard">妗惰鏍�</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
- private SysStorageLocat GetLocatModel(string houseNo, string palletStatus,string skuNo="",string standard="")
+ private SysStorageLocat GetLocatModel(string houseNo, string palletStatus,string zonghong,string skuNo="",string standard="",string lotNo = "")
{
try
{
@@ -1254,6 +1443,7 @@
string areaNo = string.Empty;
switch (palletStatus)
{
+
case "0"://鍑�妗�
//鏌ュ埌鍒板噣妗跺尯鍩熺紪鍙�
areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "0").Select(s => s.AreaNo).First();
@@ -1263,44 +1453,88 @@
.OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
break;
case "2"://婊℃《
- //鏌ュ埌鍒版弧妗跺尯鍩熺紪鍙�
- areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "1").Select(s => s.AreaNo).First();
- //鍒嗛厤鍌ㄤ綅
- //鍏堟煡鍒板悓鐗╂枡鐨勭粍
- string sql = $@"select Row from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and LocatNo in(
- select LocatNo from DataStockDetail where SkuNo='{skuNo}' and Standard='{standard}' and WareHouseNo='{houseNo}' and AreaNo='{areaNo}'
- ) group by Row";
-
- List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList();
- foreach (var rowItem in RowList)
+ //鎬绘贩鍒嗛厤鍌ㄤ綅 锛堜粨搴撶紪鐮丮12,M13锛夛紝鍒嗛厤閫昏緫锛氫紭鍏堝垎閰嶅悓鐗╂枡鐨勭粍锛屽啀鍒嗛厤鍒�3妤间腑闂寸珯锛屾渶鍚庡垎閰嶅埌4妤间腑闂寸珯
+ if (zonghong == "M12" || zonghong == "M13")
{
- endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
- && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem)
- .OrderByDescending(o => o.Column).First();
+ //鍏堟煡鍒板悓鐗╂枡鐨勭粍
+ string sql = $@"select Row,AreaNo from SysStorageLocat where LocatNo in(
+ select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}'
+ and AreaNo in ('C02','C25')
+ ) group by Row,AreaNo";
+ var RowList = Db.Ado.SqlQuery<TableMan>(sql).ToList();
- if (endLocatInfo != null)
+ foreach (var rowItem in RowList)
{
- break;
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.Row == rowItem.Row && w.AreaNo == rowItem.AreaNo && (w.WareHouseNo == "M01"||w.WareHouseNo == "M16"))
+ .OrderByDescending(o => o.Column).First();
+ if (endLocatInfo.LocatNo != null)
+ {
+ break;
+ }
+ }
+ //娌℃湁鎵惧埌鐩稿悓鐗╂枡鍚岀粍鐨勭┖鍌ㄤ綅
+ if (endLocatInfo.LocatNo == null)
+ {
+
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && (w.AreaNo == "C02" || w.AreaNo == "C25"))
+ .OrderBy(o=>o.Layer).OrderByDescending(o => o.Column).OrderBy(o => o.Row).First();
+ }
+
+ }
+ else {//鍏朵粬鍖哄煙
+ //鏌ュ埌鍒版弧妗跺尯鍩熺紪鍙�
+ areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "1").Select(s => s.AreaNo).First();
+ //鍒嗛厤鍌ㄤ綅
+ //鍏堟煡鍒板悓鐗╂枡鐨勭粍
+ string sql = $@"select Row,AreaNo from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and Status = '0' and LocatNo in(
+ select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}' and WareHouseNo='{houseNo}' and AreaNo='{areaNo}'
+ ) group by Row,AreaNo";
+
+ var RowList = Db.Ado.SqlQuery<TableMan>(sql).ToList();
+ foreach (var rowItem in RowList)
+ {
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem.Row && w.AreaNo == rowItem.AreaNo && (w.WareHouseNo == "M01" || w.WareHouseNo == "M16"))
+ .OrderByDescending(o => o.Column).First();
+
+ if (endLocatInfo.LocatNo != null)
+ {
+ break;
+ }
+ }
+ //娌℃湁鎵惧埌鐩稿悓鐗╂枡鍚岀粍鐨勭┖鍌ㄤ綅
+ if (endLocatInfo.LocatNo == null)
+ {
+
+ endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
+ && w.WareHouseNo == houseNo && w.AreaNo == areaNo)
+ .OrderByDescending(o => o.Column).OrderBy(o => o.Row).First();
}
}
- //娌℃湁鎵惧埌鐩稿悓鐗╂枡鍚岀粍鐨勭┖鍌ㄤ綅
- if (endLocatInfo == null)
- {
- endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
- && w.WareHouseNo == houseNo && w.AreaNo == areaNo)
- .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
- }
-
break;
case "3"://鑴忔《
- //鏌ュ埌鍒拌剰妗跺尯鍩熺紪鍙�
- areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "2").Select(s => s.AreaNo).First();
+ //鏌ュ埌鍒拌剰妗跺尯鍩熺紪鍙凤紝瀛樻斁椤哄簭锛孋54 鏂欐枟娓呮礂鏆傚瓨闂达紝C26 3妤间腑闂寸珯鑴忔《鍖猴紝C03 4妤间腑闂寸珯鑴忔《鍖�
+ var ztAreaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Type == "2").Select(w => w.AreaNo).ToList();
+ //鏌ユ壘鎵�鏈夊彲鐢ㄨ剰妗跺簱浣�
+ var ztLocat = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && ztAreaNo.Contains(w.AreaNo))
+ .OrderBy(o => o.Row).OrderByDescending(o => o.Column).ToList();
+ //areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "2").Select(s => s.AreaNo).First();
//鍒嗛厤鍌ㄤ綅
- endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0"
- && w.WareHouseNo == houseNo && w.AreaNo == areaNo)
- .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First();
-
-
+ //鏂欐枟娓呮礂鏆傚瓨闂�
+ endLocatInfo = ztLocat.Where(w => w.AreaNo == "C54").FirstOrDefault();
+ if (endLocatInfo == null)
+ {
+ endLocatInfo = ztLocat.Where(w => w.AreaNo == "C26").FirstOrDefault();
+ if (endLocatInfo == null)
+ {
+ endLocatInfo = ztLocat.Where(w => w.AreaNo == "C03").FirstOrDefault();
+ if (endLocatInfo == null)
+ {
+ throw new Exception("鏃犲彲鐢ㄨ剰妗跺簱浣�");
+ }
+ }
+ }
break;
}
return endLocatInfo;
--
Gitblit v1.8.0