From 71d1dcdf796f08fa01cbc2d3faab86eea28b295b Mon Sep 17 00:00:00 2001
From: zhaowc <526854230@qq.com>
Date: 星期三, 17 十二月 2025 08:59:03 +0800
Subject: [PATCH] 物料管理页面修改
---
Wms/WMS.BLL/BllTransServer/RcsServer.cs | 143 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 129 insertions(+), 14 deletions(-)
diff --git a/Wms/WMS.BLL/BllTransServer/RcsServer.cs b/Wms/WMS.BLL/BllTransServer/RcsServer.cs
index 3db34c0..3744350 100644
--- a/Wms/WMS.BLL/BllTransServer/RcsServer.cs
+++ b/Wms/WMS.BLL/BllTransServer/RcsServer.cs
@@ -338,7 +338,7 @@
//logTaskEntry2.IsCancel = 0;
logTaskEntry2.BackDate = DateTime.Now;
logTaskEntry2.Status = "1";
- Db.Insertable(logTaskEntry2).ExecuteCommand();
+ Db.Updateable(logTaskEntry2).ExecuteCommand();
startLoction2.Status = "3";//鍑哄簱涓�
Db.Updateable(startLoction2).ExecuteCommand();
@@ -350,7 +350,7 @@
{
logTaskEntry2.IsSuccess = 0;
logTaskEntry2.Information = agvMsg;
- Db.Insertable(logTaskEntry2).ExecuteCommand();
+ Db.Updateable(logTaskEntry2).ExecuteCommand();
}
//鎻愪氦浜嬪姟
@@ -414,7 +414,7 @@
//logTaskEntry.IsCancel = 0;
logTaskEntry.BackDate = DateTime.Now;
logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ Db.Updateable(logTaskEntry).ExecuteCommand();
startLoction.Status = "3";//鍑哄簱涓�
Db.Updateable(startLoction).ExecuteCommand();
@@ -426,7 +426,7 @@
{
logTaskEntry.IsSuccess = 0;
logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ Db.Updateable(logTaskEntry).ExecuteCommand();
}
//鎻愪氦浜嬪姟
@@ -706,7 +706,7 @@
//logTaskEntry.IsCancel = 0;
logTaskEntry.BackDate = DateTime.Now;
logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ Db.Updateable(logTaskEntry).ExecuteCommand();
deviceLocatInfo.Status = "3";//鍑哄簱涓�
Db.Updateable(deviceLocatInfo).ExecuteCommand();
@@ -718,7 +718,7 @@
{
logTaskEntry.IsSuccess = 0;
logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ Db.Updateable(logTaskEntry).ExecuteCommand();
}
//鎻愪氦浜嬪姟
Db.CommitTran();
@@ -1052,7 +1052,7 @@
/// <param name="taskNo"></param>
/// <param name="userId"></param>
/// <exception cref="Exception"></exception>
- public void CancelTask(string taskNo, int userId)
+ public void CancelTask(string taskNo, string url, int userId)
{
try
{
@@ -1063,6 +1063,20 @@
if (task == null)
{
throw new Exception("鏈煡璇㈠埌浠诲姟淇℃伅");
+ }
+ //鏍¢獙璧风偣鏄惁宸茬粡鐢熸垚浠诲姟
+ var taskHave = Db.Queryable<LogTask>().First(m => m.EndLocat == task.StartLocat && m.IsDel == "0" && (m.Status == "0"|| m.Status == "1"));
+ if (taskHave == null)
+ {
+ var locateHave = Db.Queryable<SysStorageLocat>().First(m => m.LocatNo == task.StartLocat);
+ if (locateHave.Status != "3")
+ {
+ throw new Exception("璧峰鍌ㄤ綅宸叉湁鍏朵粬鏂欐枟瀛樺湪锛屾棤娉曞彇娑堝綋鍓嶄换鍔★紒");
+ }
+ }
+ else
+ {
+ throw new Exception("璧峰鍌ㄤ綅宸叉湁浠诲姟鐢熸垚锛屾棤娉曞彇娑堝綋鍓嶄换鍔★紒");
}
//if (task.Status != "0")
//{
@@ -1097,16 +1111,25 @@
//淇敼搴撳瓨鏄庣粏
var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == task.PalletNo);
- if (stockDetail == null)
+ if (stockDetail == null)
{
throw new Exception("鏈煡璇㈠埌璇ユ《搴撳瓨淇℃伅,璇锋鏌�!");
}
stockDetail.Status = "0";//寰呭垎閰�
Db.Updateable(stockDetail).ExecuteCommand();
-
- //娣诲姞鎿嶄綔鏃ュ織璁板綍
- var k = new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "搴撳唴鏃ュ織", taskNo, "鍙栨秷", $"鐐瑰嚮鍙栨秷鎸夐挳銆佸彇娑堜簡浠诲姟鍙蜂负锛歿taskNo}鐨勪换鍔�", userId);
- Db.CommitTran();
+
+ string agvMsg = "";
+ bool t = CancleTaskForAgv(taskNo, url, out agvMsg);
+ if (t)
+ {
+ //娣诲姞鎿嶄綔鏃ュ織璁板綍
+ var k = new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "搴撳唴鏃ュ織", taskNo, "鍙栨秷", $"鐐瑰嚮鍙栨秷鎸夐挳銆佸彇娑堜簡浠诲姟鍙蜂负锛歿taskNo}鐨勪换鍔�", userId);
+ Db.CommitTran();
+ }
+ else
+ {
+ throw new Exception("涓嬪彂鍙栨秷灏忚溅浠诲姟澶辫触");
+ }
}
catch (Exception e)
{
@@ -1327,6 +1350,43 @@
}
/// <summary>
+ /// 涓嬪彂鍙栨秷浠诲姟缁橝GV
+ /// </summary>
+ /// <param name="req"></param>
+ /// <returns></returns>
+ public bool CancleTaskForAgv(string taskno, string url, out string agvMsg, string priority = null)
+ {
+ bool result = false;
+ #region 鍛煎彨灏忚溅浠g爜
+ AgvCancelTask cancelTask = new AgvCancelTask();
+ cancelTask.robotTaskCode = taskno;
+ cancelTask.cancelType = "DROP";
+
+ // 姝e紡杩愯绋嬪簭鏀惧紑
+ //AGV浠诲姟涓嬪彂鏃跺鍔爃earder:X-LR-REQUEST-ID,鍊间负闅忔満鏁�
+ long ran = DateTime.Now.Ticks;
+ Dictionary<string, string> key = new Dictionary<string, string>();
+ key.Add("X-LR-REQUEST-ID", ran.ToString());
+ var jsonData = JsonConvert.SerializeObject(cancelTask);
+ string response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橝GV杞繍鍛戒护", "AGV", key);
+ //瑙f瀽杩斿洖鏁版嵁
+ var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response);
+ if (agvModel.Code == "SUCCESS")
+ {
+ result = true;//缁欎笅杞︿笅鍙戜换鍔℃垚鍔�
+ agvMsg = "";
+ }
+ else
+ {
+ var logStr = $@".\log\AGV\AGV鍙栨秷浠诲姟" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+ LogFile.SaveLogToFile($"AGV鍙栨秷浠诲姟寮傚父锛�( {agvModel.Message} ),", logStr);
+ agvMsg = agvModel.Message;
+ }
+ return result;
+ #endregion
+ }
+
+ /// <summary>
/// 鍒嗛厤妗跺悗鍒ゆ柇璇ユ《澶栦晶鍌ㄤ綅鏄惁闇�瑕佺Щ搴�
/// </summary>
/// <param name="palletNo"></param>
@@ -1458,7 +1518,7 @@
//logTaskEntry.IsCancel = 0;
logTaskEntry.BackDate = DateTime.Now;
logTaskEntry.Status = "1";//姝e湪鎵ц
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ Db.Updateable(logTaskEntry).ExecuteCommand();
locatInfo.Status = "5";//绉诲嚭涓�
@@ -1471,7 +1531,7 @@
{
logTaskEntry.IsSuccess = 0;
logTaskEntry.Information = agvMsg;
- Db.Insertable(logTaskEntry).ExecuteCommand();
+ Db.Updateable(logTaskEntry).ExecuteCommand();
throw new Exception($"缁欏皬杞︿笅鍙戠Щ搴撲换鍔″け璐ワ紝妗跺彿锛歿palletInfoYi.PalletNo}");
}
@@ -1484,5 +1544,60 @@
throw new Exception(e.Message);
}
}
+
+ public bool DelStockWms(int stockId,string url,int userId,out string errMsg)
+ {
+ try
+ {
+ errMsg = "";
+ //鑾峰彇褰撳墠搴撳瓨淇℃伅
+ var stock = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.Id == stockId);
+ if (stock == null)
+ {
+ throw new Exception("鏈湪搴撳瓨涓壘鍒板綋鍓嶆枡妗�");
+ }
+ //鑾峰彇褰撳墠鏂欐枟浠诲姟淇℃伅
+ var taskInfo = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == stock.PalletNo && (w.Status == "0" || w.Status == "1"));
+ if (taskInfo != null)
+ {
+ throw new Exception("褰撳墠鏂欐《鏈夌瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�");
+ }
+ //鑾峰彇褰撳墠鏂欐枟鍌ㄤ綅鐘舵��
+ var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stock.LocatNo && w.Status == "1");
+ if (locatInfo == null)
+ {
+ throw new Exception("褰撳墠鏂欐《鍌ㄤ綅鐘舵�侀敊璇�");
+ }
+ var pallnoInfo = Db.Queryable<SysPallets>().First(w => w.IsDel == "0" && w.PalletNo == stock.PalletNo);
+ if (pallnoInfo == null)
+ {
+ throw new Exception("鏈壘鍒板綋鍓嶆枡妗舵潯鐮�");
+ }
+ Db.BeginTran();
+ //涓嬪彂缁橝GV瑙g粦淇℃伅
+ bool t = RcsHelper.UnBindPalletAndSite(stock.PalletNo, stock.LocatNo, url,out errMsg);
+ if (t)
+ {
+ //鍒犻櫎搴撳瓨
+ Db.Deleteable(stock).ExecuteCommand();
+ Db.Deleteable(pallnoInfo).ExecuteCommand();
+ locatInfo.Status = "0";
+ Db.Updateable(locatInfo).ExecuteCommand();
+
+
+ //娣诲姞鎿嶄綔鏃ュ織璁板綍
+ var k = new OperationCrServer().AddLogOperationCr("缁熻鎶ヨ〃", "妗舵槑缁�", "", "鍒犻櫎", $"鐐瑰嚮鍒犻櫎鎸夐挳銆佸垹闄や簡妗跺彿锛歿stock.PalletNo}", userId);
+ }
+ Db.CommitTran();
+ return t;
+ }
+ catch (Exception e)
+ {
+
+ Db.RollbackTran();
+ throw new Exception(e.Message);
+ }
+
+ }
}
}
--
Gitblit v1.8.0