From 33572be8da5fd6534b56e1e22d70e8cf56f5fe41 Mon Sep 17 00:00:00 2001 From: wxw <Administrator@DESKTOP-5BIMHQ3> Date: 星期日, 27 四月 2025 17:00:11 +0800 Subject: [PATCH] 开发料桶转运功能 --- Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs | 466 +++++++++++++++++++++-------------- Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs | 2 Wms/Model/InterFaceModel/AgvModel.cs | 192 ++++++++++++++ Wms/Utility/Utility.csproj | 4 Wms/Utility/Tools/RcsHelper.cs | 69 +++++ 5 files changed, 550 insertions(+), 183 deletions(-) diff --git a/Wms/Model/InterFaceModel/AgvModel.cs b/Wms/Model/InterFaceModel/AgvModel.cs new file mode 100644 index 0000000..5baecce --- /dev/null +++ b/Wms/Model/InterFaceModel/AgvModel.cs @@ -0,0 +1,192 @@ +锘縰sing System; +using System.Collections; +using System.Collections.Generic; +using System.Security.Policy; +using System.Text; +using System.Threading.Channels; +using System.Threading; +using System.Text.RegularExpressions; + +namespace Model.InterFaceModel +{ + public class AgvCreateTaskModel + { + /// <summary> + /// 浠诲姟绫诲瀷 + /// </summary> + public string taskType { get; set; } = "PF-LMR-COMMON"; + /// <summary> + /// 鎵ц姝ラ闆嗗悎銆傛湰娆′换鍔℃満鍣ㄤ汉闇�瑕佹墽琛岀殑鍏抽敭璺緞锛屽璐ф灦璧风偣 A 鑷冲嚭搴撳伐浣滃彴 B + /// </summary> + public List<targetRoute> targetRoute { get; set; } + /// <summary> + /// 浠诲姟鎵ц鐨勫垵濮嬩紭鍏堥『搴忥紝鏁板�艰秺澶э紝浼樺厛绾ц秺楂樸�備絾鏈哄櫒浜鸿皟搴︾郴缁熶細鏍规嵁浠诲姟绻佸繖绋嬪害锛屾満鍣ㄤ汉鐨勫伐浣滅姸鎬侊紝浠ュ強鍏朵粬浼樺厛绾т慨姝f潯浠讹紝杩涜缁煎悎鍒ゅ畾鍚庯紝瀹炴椂鍔ㄦ�佽皟鏁翠换鍔″疄闄呯殑浼樺厛绾ф暟鍊笺�傝寖鍥达細1~120 + /// </summary> + public int initPriority { get; set; } + /// <summary> + /// 浠诲姟鎴鏃堕棿锛屼换鍔′紭鍏堢骇淇鏉′欢涔嬩竴銆傛埅姝㈡椂闂翠箣鍓嶉渶瑕佷换鍔℃墽琛屽畬鎴�, 瓒呰繃鏃堕棿鍚庯紝绯荤粺浼氬皢浠诲姟鍗曞仛鍑鸿秴鏃舵彁绀恒�傛牸寮忥細绉掔簿搴︺�� + /// </summary> + public string deadline { get; set; } + /// <summary> + /// 瑕佹眰璋冨害绯荤粺浠呭湪褰撳墠鎸囧畾鐨勮寖鍥村唴閫夋嫨鏈哄櫒浜烘墽琛岃浠诲姟銆傚彲鑳藉嚭鐜颁换鍔′笌鏈哄櫒浜虹被鍨嬩笉鍖归厤鐨勫紓甯革紝闇�瑕佷笟鍔$郴缁熺‘淇濅换鍔′笌鏈哄櫒浜虹被鍨嬬殑鍖归厤銆傚鏋滀笉鎸囧畾锛屽垯璋冨害绯荤粺浼氬湪鎵�鏈夊彲鐢ㄦ満鍣ㄤ汉鐨勮寖鍥村唴瀵绘壘鏈�浼樻柟妗堛�� + /// 鍥哄畾鏋氫妇鍊硷細 + /// GROUPS鏈哄櫒浜鸿祫婧愮粍缂栧彿 + /// ROBOTS鏈哄櫒浜虹紪鍙� + /// </summary> + public string robotType { get; set; } + /// <summary> + /// 涓� robotType 鍖归厤鐨勮祫婧愮被鍨嬪敮涓�鏍囪瘑銆傛敮鎸佸崟涓拰澶氫釜缂栧彿銆傝嫢鍐欏叆澶氫釜缂栧彿鏃讹紝涔嬮棿鐢ㄩ�楀彿闅斿紑銆� + /// </summary> + public string robotCode { get; set; } + /// <summary> + /// 鑳藉惁鎵撴柇锛� + /// 1:鍙墦鏂� + /// 璇ヨ揣鏋朵腑閫旀湁鍏朵粬浠诲姟鏃讹紝鎵撴柇褰撳墠浠诲姟銆� + /// 0:涓嶅彲鎵撴柇 + /// 璇ヨ揣鏋朵腑閫旀湁鍏朵粬浠诲姟鏃讹紝涓嶈兘鎵撴柇褰撳墠浠诲姟銆傞粯璁や笉鍙墦鏂�� + /// </summary> + public int interrupt { get; set; } + /// <summary> + /// 澶栭儴浠诲姟鍞竴缂栧彿,濡傛灉涓虹┖锛岀郴缁熺敓鎴愪换鍔″彿骞惰繑鍥炪�� + /// </summary> + public string robotTaskCode { get; set; } + /// <summary> + /// 浠诲姟缁勭紪鍙凤紝鍏ㄥ眬鍞竴 + /// </summary> + public string groupCode { get; set; } + /// <summary> + /// 鑷畾涔夋墿灞曞瓧娈碉紝鍙殢涓氬姟鐨勫樊寮傝�屼紶鍏ヤ笉鍚岀殑鎵╁睍鍐呭锛屽湪涓氬姟娴佺▼鐨勬墽琛屼腑浣跨敤 + /// </summary> + public extra extra { get; set; } + } + /// <summary> + /// 鎵ц姝ラ闆嗗悎銆傛湰娆′换鍔℃満鍣ㄤ汉闇�瑕佹墽琛岀殑鍏抽敭璺緞锛屽璐ф灦璧风偣 A 鑷冲嚭搴撳伐浣滃彴 B + /// </summary> + public class targetRoute + { + /// <summary> + /// 鐩爣璺緞搴忓垪銆備粠 0 寮�濮嬨�� + /// </summary> + public int seq { get; set; } + /// <summary> + /// 鐩爣绫诲瀷銆傚彲鎵╁睍鏋氫妇鍊笺�� + /// 棰勫埗鏋氫妇鍊硷細 + /// ZONE鐩爣鎵�澶勫尯鍩熺紪鍙� + /// SITE绔欑偣鍒悕 + /// STORAGE浠撲綅鍒悕 + /// MAT_LABEL鐗╂枡鏍囩 + /// CARRIER杞藉叿缂栧彿 + /// STACK宸烽亾缂栧彿 + /// STACK_LABEL宸烽亾鐗瑰緛鍊� + /// CHANNEL閫氶亾缂栧彿 + /// EQPT 澶栭儴璁惧 + /// PTL_WALL + /// CTU 缂撳瓨鏋� + /// CARRIER_TYPE杞藉叿绫诲瀷 + /// BIN_TYPE浠撲綅绫诲瀷 + /// AREA_STATION鍖哄煙宸ヤ綔鍙� + /// PILE_COUNT涓�娆℃惉鍑犱釜 + /// MIX_CONDITION鏉′欢缁勫悎 + /// DEGREE 鐑害 + /// MULTI_BIN_GROUP澶氭繁浣嶇粍鍙� + /// </summary> + public string type { get; set; } + /// <summary> + /// 鏈哄櫒浜哄埌杈剧洰鏍囦綅缃悗鐨勬搷浣溿�傚浗鏍囪姹傦紝 + /// 闈炲繀瑕併�傚 AMR 鍔ㄤ綔鏃犲奖鍝嶃�傚彲鎵╁睍鐨勬灇涓惧�笺�� + /// 棰勫埗鏋氫妇鍊硷細 + /// COLLECT鍙栬揣 + /// DELIVERY閫佽揣 + /// ROTATE鏃嬭浆 + /// </summary> + public string code { get; set; } + /// <summary> + /// 瑕佹眰璋冨害绯荤粺浠呭湪褰撳墠鎸囧畾鐨勮寖鍥村唴閫夋嫨鏈哄櫒浜烘墽琛岃姝ラ銆傚彲鑳藉嚭鐜颁换鍔℃楠や笌鏈哄櫒浜虹被鍨嬩笉鍖归厤鐨勫紓甯革紝闇�瑕佷笟鍔$郴缁熺‘淇濅换鍔′笌鏈哄櫒浜虹被鍨嬬殑鍖归厤銆傚鏋滄寚瀹氬綋鍓嶆楠ょ殑鏈哄櫒浜洪�夋嫨鑼冨洿锛屽垯璋冨害绯荤粺鏃犺浠诲姟涓瀹氱殑鏈哄櫒浜洪�夋嫨鑼冨洿锛涘鏋滀换鍔′腑涔熸病鏈夋寚瀹氭満鍣ㄤ汉閫夋嫨鑼冨洿锛屽垯璋冨害绯荤粺浼氬湪鎵�鏈夊彲鐢ㄦ満鍣ㄤ汉鐨勮寖鍥村唴瀵绘壘鏈�浼樻柟妗堛�� + /// 鍥哄畾鏋氫妇鍊硷細 + /// GROUPS鏈哄櫒浜鸿祫婧愮粍缂栧彿 + /// ROBOTS鏈哄櫒浜虹紪鍙� + /// </summary> + public string robotType { get; set; } + /// <summary> + /// 涓� robotType 鍖归厤鐨勮祫婧愮被鍨嬪敮涓�鏍囪瘑銆� + /// </summary> + public string robotCode { get; set; } + /// <summary> + /// 鑷畾涔夋墿灞曞瓧娈碉紝鍙殢涓氬姟鐨勫樊寮傝�屼紶鍏ヤ笉鍚岀殑鎵╁睍鍐呭锛屽湪涓氬姟娴佺▼鐨勬墽琛屼腑浣跨敤 + /// </summary> + public extra extra { get; set; } + } + public class extra + { + /// <summary> + /// 瑙掑害淇℃伅锛屽寘鍚搴︾被鍨嬩笌瑙掑害鍊笺�� + /// </summary> + public angleInfo angleInfo { get; set; } + /// <summary> + /// 杞藉叿鐨勪俊鎭紝鍖呭惈杞藉叿缂栧彿銆佸眰鍙枫�� + /// 浣跨敤鍦烘櫙锛� + /// 1.瑁呭嵏鏈烘垨杈撻�佺嚎涓撶敤 + /// 2.杞藉叿涓庣珯鐐规病鏈夌粦瀹氾紝浣嗛渶瑕佷紶鍏ヨ浇鍏风殑鍦烘櫙銆� + /// </summary> + public List<carrierInfo> carrierInfo { get; set; } + } + public class angleInfo + { + /// <summary> + /// 瑙掑害绫诲瀷銆傚彲鎵╁睍鏋氫妇鍊笺�� + /// 棰勫埗鏋氫妇鍊硷細 + ///缁濆瑙掑害(涓庡伐浣滅珯鐨勬柟鍚戞湁鍏�)ABSOLUTE + /// </summary> + public string type { get; set; } + /// <summary> + /// 涓� type 瀵瑰簲鐨勫�� + /// 瑙掑害鍊糩0, 90, 180, -90, 360] + /// </summary> + public string code { get; set; } + } + public class carrierInfo + { + /// <summary> + /// 杞藉叿绫诲瀷 + /// </summary> + public string carrierType { get; set; } + /// <summary> + /// 杞藉叿缂栧彿 + /// </summary> + public string carrierCode { get; set; } + /// <summary> + /// 灞傚彿锛� 浠� 0 寮�濮嬨�佷粠涓嬪線涓婄紪鍙� + /// </summary> + public int layer { get; set; } + } + + /// <summary> + /// 杩斿洖瀹炰綋 + /// </summary> + public class ResponseAgvDto + { + /// <summary> + /// 杩斿洖鐮� + /// SUCCESS锛氭垚鍔� + /// FAIL锛氬け璐� + /// 鏄惁蹇呭~锛氭槸 + /// </summary> + public string code { get; set; } + + /// <summary> + /// 杩斿洖娑堟伅 + /// 鏄惁蹇呭~锛氭槸 + /// </summary> + public string message { get; set; } + + /// <summary> + /// 杩斿洖鐨勬暟鎹粨鏋� + /// 鏄惁蹇呭~锛氬惁 + /// </summary> + public data data { get; set; } + } + public class data + { + public string robotTaskCode { get; set; } + } +} diff --git a/Wms/Utility/Tools/RcsHelper.cs b/Wms/Utility/Tools/RcsHelper.cs new file mode 100644 index 0000000..30c1662 --- /dev/null +++ b/Wms/Utility/Tools/RcsHelper.cs @@ -0,0 +1,69 @@ +锘縰sing Model.InterFaceModel; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using ZXing; +using static Model.InterFaceModel.RCSModel; + +namespace Utility.Tools +{ + public static class RcsHelper + { + public static bool CreateTaskForAgv(TaskDetial taskDetial, string url, out string agvMsg, string priority = null) + { + bool result = false; + + List<targetRoute> pahtList = new List<targetRoute>(); + //璧峰浣嶇疆 + targetRoute royte1 = new targetRoute(); + royte1.seq = 0; + royte1.type = "ZONE"; + royte1.code = taskDetial.Startport; + + pahtList.Add(royte1); + + //鐩爣浣嶇疆 + targetRoute royte2 = new targetRoute(); + royte2.seq = 0; + royte2.type = "ZONE"; + royte2.code = taskDetial.Endport; + + pahtList.Add(royte2); + + AgvCreateTaskModel taskModel = new AgvCreateTaskModel(); + taskModel.taskType = "PF-LMR-COMMON"; + taskModel.targetRoute = pahtList; + + // 姝e紡杩愯绋嬪簭鏀惧紑 + var jsonData = JsonConvert.SerializeObject(taskModel); + string response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橝GV杞繍鍛戒护", "AGV"); + //瑙f瀽杩斿洖鏁版嵁 + var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response); + if (agvModel.Code == "0") + { + result = true;//缁欎笅杞︿笅鍙戜换鍔℃垚鍔� + + agvMsg = ""; + } + else + { + string logMsg = ""; + if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛� + { + logMsg = "鐢宠鍙《"; + } + else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛� + { + logMsg = "鐢宠鍌ㄤ綅"; + } + var logStr = $@".\log\AGV\AGV{logMsg}" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; + LogFile.SaveLogToFile($"AGV{logMsg}寮傚父锛�( {agvModel.Message} ),", logStr); + + agvMsg = agvModel.Message; + } + + return result; + } + } +} diff --git a/Wms/Utility/Utility.csproj b/Wms/Utility/Utility.csproj index d2026ba..3e22383 100644 --- a/Wms/Utility/Utility.csproj +++ b/Wms/Utility/Utility.csproj @@ -18,4 +18,8 @@ <PackageReference Include="ZXing.Net" Version="0.16.7" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Model\Model.csproj" /> + </ItemGroup> + </Project> diff --git a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs index ed0d101..8856889 100644 --- a/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs +++ b/Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs @@ -6,10 +6,14 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Policy; using System.Text; using System.Threading.Tasks; using Utility.Tools; +using WMS.BLL.LogServer; using WMS.DAL; +using WMS.Entity.BllAsnEntity; +using WMS.Entity.BllSoEntity; using WMS.Entity.Context; using WMS.Entity.DataEntity; using WMS.Entity.LogEntity; @@ -354,7 +358,7 @@ string agvMsg = string.Empty; //缁欎笅杞︿笅鍙戜换鍔� logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂� - var agvResult = CreateTaskForAgv(task, url, out agvMsg); + var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg); if (agvResult)//鎴愬姛 { //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬� @@ -401,7 +405,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, int userId) + public void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight, string skuNo, string lotNo, string url,int userId) { try { @@ -409,7 +413,7 @@ if (string.IsNullOrWhiteSpace(areaNo) || string.IsNullOrWhiteSpace(StartLocate) || string.IsNullOrWhiteSpace(plnStatus)) { - throw new Exception("鍖哄煙/鐩爣浣�/妗剁被鍨嬩笉鑳戒负绌�"); + throw new Exception("鍖哄煙/璧峰浣�/妗剁被鍨嬩笉鑳戒负绌�"); } //if (plnStatus == "0" && string.IsNullOrWhiteSpace(standard)) @@ -421,29 +425,24 @@ { throw new Exception("婊℃《璇烽�夋嫨鐗╂枡涓庢壒娆�"); } - //鍒ゆ柇鐩爣鍙枡鍌ㄤ綅鐘舵�� - var endLocateInfo = Db.Queryable<SysStorageLocat>().First(m => m.IsDel == "0" && m.LocatNo == StartLocate && m.AreaNo == areaNo); - if (endLocateInfo == null) - { - throw new Exception("娌℃湁鏌ヨ鍒扮洰鏍囧偍浣嶄俊鎭�"); - } - if (endLocateInfo.Flag != "0") - { - throw new Exception("鐩爣鍌ㄤ綅鏍囪瘑涓嶆槸姝e父鍙敤鐨�"); - } - if (endLocateInfo.Status != "0") - { - throw new Exception("鐩爣鍌ㄤ綅鐘舵�佷笉鏄┖鍌ㄤ綅"); - } - #endregion + //寮�鍚簨鍔� + Db.BeginTran(); - var pln = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == plnNo); - var locate = Db.Queryable<SysStorageLocat>().First(m => m.IsDel == "0" && m.AreaNo == areaNo && m.LocatNo == StartLocate); - var skuName = ""; - var packagNo = ""; - if (plnStatus == "2") + //妗朵俊鎭� + var pln = Db.Queryable<SysPallets>().First(w => w.IsDel == "0" && w.PalletNo == plnNo); + if (pln == null) { + throw new Exception("鏈煡璇㈠埌妗朵俊鎭�"); + } + + //璧峰鍌ㄤ綅淇℃伅 + var startLoction = Db.Queryable<SysStorageLocat>().First(m => m.IsDel == "0" && m.AreaNo == areaNo && m.LocatNo == StartLocate); + var skuName = "";//鐗╂枡鍚嶇О + var packagNo = ""; + if (plnStatus == "2")//婊℃《 + { + //鐗╂枡淇℃伅 var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == skuNo); if (sku == null) { @@ -455,7 +454,17 @@ { } + //鐩爣妤煎眰 + var layer = startLoction.Layer; + var houseStr = layer == 3 ? "3妤间腑闂寸珯" : layer == 4 ? "4妤间腑闂寸珯" : ""; + //閫氳繃浠撳簱鍚嶇О鏌ヨ浠撳簱淇℃伅 + var house = Db.Queryable<SysWareHouse>().First(m => m.IsDel == "0" && m.WareHouseName == houseStr); + if (house == null) + { + throw new Exception("娌℃湁鏌ヨ鍒颁粨搴撲俊鎭�"); + } + //妗跺簱瀛樻槑缁� var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.PalletNo == plnNo); if (stockDetail == null) { @@ -471,7 +480,7 @@ FrozenQty = 0, InspectQty = 0, - WareHouseNo = locate.WareHouseNo, + WareHouseNo = startLoction.WareHouseNo, AreaNo = areaNo, LocatNo = StartLocate, PalletNo = plnNo, @@ -497,20 +506,26 @@ Db.Updateable(stockDetail).ExecuteCommand(); } - //鑾峰彇鍌ㄤ綅鍦板潃 + //鍒嗛厤鍌ㄤ綅 + var endLocatInfo = GetLocatModel(house.WareHouseNo, plnStatus, skuNo, pln.Standard);//鐩爣鍌ㄤ綅 + //娌℃湁鍙敤绌哄偍浣� + if (endLocatInfo == null) + { + throw new Exception("娌℃湁鎵惧埌鍚堥�傜殑鐩爣鍌ㄤ綅"); + } var taskNo = new Common().GetMaxNo("TK"); //娣诲姞浠诲姟 - var task = new LogTask + var logTaskEntry = new LogTask { TaskNo = taskNo, Sender = "WMS", Receiver = "WCS", IsSuccess = 0, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛 - StartLocat = "",//璧峰浣嶇疆 - EndLocat = StartLocate,//鐩爣浣嶇疆 - PalletNo = "",//鎵樼洏鐮� + StartLocat = StartLocate,//璧峰浣嶇疆 + EndLocat = endLocatInfo.LocatNo,//鐩爣浣嶇疆 + PalletNo = plnNo,//鎵樼洏鐮� IsSend = 1,//鏄惁鍙啀娆′笅鍙� IsCancel = 1,//鏄惁鍙彇娑� IsFinish = 1,//鏄惁鍙畬鎴� @@ -520,17 +535,187 @@ CreateTime = DateTime.Now }; - Db.Insertable(task).ExecuteCommand(); + Db.Insertable(logTaskEntry).ExecuteCommand(); + + //缁勭粐涓嬪彂灏忚溅浠诲姟淇℃伅 + var task = new TaskDetial + { + Taskno = taskNo,//浠诲姟鍙� + Startport = StartLocate,//璧峰浣嶇疆 + Endport = endLocatInfo.LocatNo,//鐩爣浣嶇疆 + Pallno = plnNo,//妗跺彿 + Crtype = "1",//鍙《 + }; //璋冪敤AGV鎺ュ彛涓嬪彂浠诲姟 + string agvMsg = string.Empty; + //缁欎笅杞︿笅鍙戜换鍔� + logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂� + 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.Insertable(logTaskEntry).ExecuteCommand(); + startLoction.Status = "3";//鍑哄簱涓� + Db.Updateable(startLoction).ExecuteCommand(); + endLocatInfo.Status = "2";//鍏ュ簱涓� + Db.Updateable(endLocatInfo).ExecuteCommand(); + } + else//澶辫触 + { + logTaskEntry.IsSuccess = 0; + logTaskEntry.Information = agvMsg; + Db.Insertable(logTaskEntry).ExecuteCommand(); + } + //鎻愪氦浜嬪姟 + Db.CommitTran(); } catch (Exception e) { + //鍥炴粴浜嬪姟 + Db.RollbackTran(); throw new Exception(e.Message); } } + + /// <summary> + /// 灏忚溅鍙嶉浠诲姟瀹屾垚 + /// </summary> + /// <param name="taskNo"></param> + /// <param name="status"></param> + /// <param name="comeFrom"></param> + /// <param name="userId"></param> + /// <exception cref="Exception"></exception> + public void RCSFinishTask(string taskNo, string status, string comeFrom, int userId = 0) + { + try + { + #region 鏉′欢鍒ゆ柇 + var resultModel = new ErpModel() { Success = -1, Message = "" }; + if (string.IsNullOrEmpty(taskNo)) + { + throw new Exception("浠诲姟鍙蜂笉鍙负绌�"); + } + //浠诲姟淇℃伅 + var taskInfo = Db.Queryable<LogTask>().First(w => w.TaskNo == taskNo); + if (taskInfo == null) + { + throw new Exception($"浠诲姟鍙蜂负:{taskNo}鐨勪换鍔′笉瀛樺湪!"); + } + if (taskInfo.Status != "1" && comeFrom != "WMS") + { + throw new Exception($"浠诲姟鍙蜂负:{taskNo}鐨勪换鍔$姸鎬佸紓甯�"); + } + #endregion + //寮�鍚簨鍔� + Db.BeginTran(); + var comTime = DateTime.Now; + + if (status == "0") + { + taskInfo.Status = "3";//寮傚父缁撴潫 + //淇敼浠诲姟鐘舵�� + Db.Updateable(taskInfo).ExecuteCommand(); + + resultModel.Success = 0; + resultModel.Message = "鎴愬姛"; + + //鎻愪氦浜嬪姟 + Db.CommitTran(); + + return; + } + //搴撳瓨鏄庣粏 + var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo); + if (stockDetail == null) + { + throw new Exception($"妗跺簱瀛樹俊鎭笉瀛樺湪"); + } + //璧峰鍌ㄤ綅淇℃伅 + var startLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.StartLocat && w.IsDel == "0"); + if (startLocatInfo == null) + { + throw new Exception($"璧峰鍌ㄤ綅淇℃伅涓嶅瓨鍦�"); + } + startLocatInfo.Status = "0";//绌哄偍浣� + //淇敼璧峰鍌ㄤ綅鐘舵�� + Db.Updateable(startLocatInfo).ExecuteCommand(); + + //鐩爣鍌ㄤ綅淇℃伅 + var endLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0"); + if (endLocatInfo == null) + { + throw new Exception($"鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�"); + } + endLocatInfo.Status = "1";//鏈夌墿鍝� + //淇敼鐩爣鍌ㄤ綅鐘舵�� + Db.Updateable(endLocatInfo).ExecuteCommand(); + + //鐩爣鍌ㄤ綅鎵�灞炲尯鍩� + var endAreaInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.WareHouseNo == endLocatInfo.WareHouseNo && w.AreaNo == endLocatInfo.AreaNo); + if (endAreaInfo == null) + { + throw new Exception($"鐩爣鍌ㄤ綅鎵�灞炲尯鍩熶俊鎭笉瀛樺湪"); + } + + stockDetail.WareHouseNo = endLocatInfo.WareHouseNo;//鎵�灞炰粨搴� + stockDetail.RoadwayNo = endLocatInfo.RoadwayNo;//鎵�灞炲贩閬� + stockDetail.AreaNo = endLocatInfo.AreaNo;//鎵�灞炲尯鍩� + stockDetail.LocatNo = endLocatInfo.LocatNo;//鍌ㄤ綅鍦板潃 + stockDetail.UpdateTime = DateTime.Now;//鏇存柊鏃堕棿 + if (endAreaInfo.Type == "0")//鍑�妗跺尯 + { + stockDetail.PalletStatus = "0"; + stockDetail.Status = "0";//寰呭垎閰� + } + else if (endAreaInfo.Type == "1")//婊℃《鍖� + { + stockDetail.PalletStatus = "1"; + stockDetail.Status = "0";//寰呭垎閰� + } + else if (endAreaInfo.Type == "2")//鑴忔《鍖� + { + stockDetail.PalletStatus = "3"; + stockDetail.LotNo = "";//鎵规 + stockDetail.SkuNo = ""; + stockDetail.SkuName = ""; + stockDetail.Status = "0";//寰呭垎閰� + stockDetail.InspectStatus = "0";//寰呮楠� + } + //淇敼搴撳瓨鏄庣粏 + Db.Updateable(stockDetail).ExecuteCommand(); + + taskInfo.Status = "2";//鎵ц瀹屾垚 + taskInfo.IsSend = 0; + taskInfo.IsCancel = 0; + taskInfo.IsFinish = 0; + taskInfo.FinishDate = DateTime.Now;//瀹屾垚鏃堕棿 + //淇敼浠诲姟鐘舵�� + Db.Updateable(taskInfo).ExecuteCommand(); + + if (comeFrom == "WMS") + { + //娣诲姞鎿嶄綔鏃ュ織璁板綍 + var k = new OperationCrServer().AddLogOperationCr("搴撳唴浣滀笟", "搴撳唴鏃ュ織", taskInfo.TaskNo, "瀹屾垚", $"鐐瑰嚮瀹屾垚鎸夐挳銆佷换鍔″彿涓猴細{taskInfo.TaskNo}鐨勪换鍔�", userId); + } + //鎻愪氦浜嬪姟 + Db.CommitTran(); + } + catch (Exception ex) + { + //鍥炴粴浜嬪姟 + Db.RollbackTran(); + throw new Exception(ex.Message); + } + } + private bool YikuTask(string palletNo, string taskNo, string url) { @@ -624,7 +809,7 @@ string agvMsg = string.Empty; //缁欎笅杞︿笅鍙戜换鍔� logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂� - var agvResult = CreateTaskForAgv(task, url, out agvMsg, "70"); + var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70"); if (agvResult)//鎴愬姛 { //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬� @@ -719,7 +904,7 @@ string agvMsg = string.Empty; //缁欎笅杞︿笅鍙戜换鍔� logTaskInfoZ.SendDate = DateTime.Now;//鍙戦�佹椂闂� - var agvResult = CreateTaskForAgv(task, url, out agvMsg, "70"); + var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg, "70"); if (agvResult)//鎴愬姛 { //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬� @@ -794,59 +979,7 @@ continue; } //鍒嗛厤鍌ㄤ綅 - var endLocatInfo = new SysStorageLocat();//鐩爣鍌ㄤ綅 - string areaNo = string.Empty; - switch (detailInfo.PalletStatus) - { - case "0"://鍑�妗� - //鏌ュ埌鍒板噣妗跺尯鍩熺紪鍙� - areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.Type == "0").Select(s => s.AreaNo).First(); - //鍒嗛厤鍌ㄤ綅 - endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" - && w.WareHouseNo == detailInfo.WareHouseNo && w.AreaNo == areaNo) - .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First(); - break; - case "2"://婊℃《 - //鏌ュ埌鍒版弧妗跺尯鍩熺紪鍙� - areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == itemHouseNo && w.Type == "1").Select(s => s.AreaNo).First(); - //鍒嗛厤鍌ㄤ綅 - //鍏堟煡鍒板悓鐗╂枡鐨勭粍 - string sql = $@"select Row from SysStorageLocat where WareHouseNo='{itemHouseNo}' and AreaNo='{areaNo}' and LocatNo in( - select LocatNo from DataStockDetail where SkuNo='{detailInfo.SkuNo}' and SkuName='{detailInfo.SkuName}' and Standard='{detailInfo.Standard}' and WareHouseNo='{itemHouseNo}' and AreaNo='{areaNo}' - ) group by Row"; - - List<int> RowList = Db.Ado.SqlQuery<int>(sql).ToList(); - foreach (var rowItem in RowList) - { - endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" - && w.WareHouseNo == detailInfo.WareHouseNo && w.AreaNo == areaNo && w.Row == rowItem) - .OrderByDescending(o => o.Column).First(); - - if (endLocatInfo != null) - { - break; - } - } - //娌℃湁鎵惧埌鐩稿悓鐗╂枡鍚岀粍鐨勭┖鍌ㄤ綅 - if (endLocatInfo == null) - { - endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" - && w.WareHouseNo == detailInfo.WareHouseNo && 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 == itemHouseNo && 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 == detailInfo.WareHouseNo && w.AreaNo == areaNo) - .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First(); - - - break; - } + var endLocatInfo = GetLocatModel(itemHouseNo,detailInfo.PalletStatus,detailInfo.SkuNo,detailInfo.Standard);//鐩爣鍌ㄤ綅 //娌℃湁鍙敤绌哄偍浣� if (endLocatInfo == null) { @@ -888,7 +1021,7 @@ string agvMsg = string.Empty; //缁欎笅杞︿笅鍙戜换鍔� logTaskEntry.SendDate = DateTime.Now;//鍙戦�佹椂闂� - var agvResult = CreateTaskForAgv(task, url, out agvMsg); + var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg); if (agvResult)//鎴愬姛 { //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬� @@ -928,110 +1061,79 @@ throw new Exception(e.Message); } } + /// <summary> - /// 缁欏皬杞︿笅鍙戜换鍔� + /// 鍒嗛厤鍌ㄤ綅 /// </summary> - /// <param name="req"></param> + /// <param name="houseNo">浠撳簱缂栧彿</param> + /// <param name="palletStatus">妗剁姸鎬�</param> + /// <param name="skuNo">鐗╂枡缂栫爜</param> + /// <param name="standard">妗惰鏍�</param> /// <returns></returns> - public bool CreateTaskForAgv(TaskDetial taskDetial, string url, out string agvMsg, string priority = null) + /// <exception cref="Exception"></exception> + private SysStorageLocat GetLocatModel(string houseNo, string palletStatus,string skuNo="",string standard="") { - bool result = false; - - #region 鍛煎彨灏忚溅浠g爜 - List<PositionCodePath> pahtList = new List<PositionCodePath>(); - //璧峰浣嶇疆 - PositionCodePath path1 = new PositionCodePath(); - path1.positionCode = taskDetial.Startport; - if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛� + try { - path1.type = "05"; - } - else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛� - { - path1.type = "00"; - } - else//鍚岃溅闂村钩灞傛惉杩� - { - path1.type = "05"; - } - pahtList.Add(path1); - - //鐩爣浣嶇疆 - PositionCodePath path2 = new PositionCodePath(); - path2.positionCode = taskDetial.Endport; - if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛� - { - path2.type = "00"; - } - else if (taskDetial.Crtype == "1")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛� - { - path2.type = "05"; - } - else //鍚岃溅闂村钩灞傛惉杩� - { - path2.type = "05"; - } - pahtList.Add(path2); - - //涓嬭溅浠诲姟鍗� - AgvSchedulingTask agvTask = new AgvSchedulingTask(); - agvTask.reqCode = taskDetial.Taskno;//璇锋眰缂栧彿 - agvTask.taskCode = taskDetial.Taskno;//浠诲姟鍙� - agvTask.ctnrCode = taskDetial.Pallno;//妗跺彿 - agvTask.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//璇锋眰鏃堕棿 - agvTask.wbCode = ""; - agvTask.positionCodePath = pahtList;//灏忚溅璺緞 - agvTask.podCode = ""; - agvTask.userCallCode = "";//taskDetial.Endport;//鐩爣浣嶇疆 - agvTask.priority = priority;//浼樺厛绾� - //鍒ゆ柇瀹瑰櫒绫诲瀷 - agvTask.ctnrTyp = "1";// 1锛氭《 2锛氭《锛堝皬锛� 3锛氭墭鐩� - - //鍒ゆ柇浠诲姟绫诲瀷 - if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛� - { - agvTask.taskTyp = "Z3";//浠诲姟绫诲瀷 绾胯竟鍒版墭鐩樻敹闆嗗櫒 Z1锛� 鎵樼洏鍨涚敵璇峰叆搴� Z2 - } - else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛� - { - agvTask.taskTyp = "Z4";//浠诲姟绫诲瀷 绾胯竟鍒版墭鐩樻敹闆嗗櫒 Z1锛� 鎵樼洏鍨涚敵璇峰叆搴� Z2 - } - else//鍚岃溅闂村钩灞傛惉杩� - { - agvTask.taskTyp = "Z5"; - } - - // 姝e紡杩愯绋嬪簭鏀惧紑 - var jsonData = JsonConvert.SerializeObject(agvTask); - string response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橝GV杞繍鍛戒护", "AGV"); - //瑙f瀽杩斿洖鏁版嵁 - var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response); - if (agvModel.Code == "0") - { - result = true;//缁欎笅杞︿笅鍙戜换鍔℃垚鍔� - - agvMsg = ""; - } - else - { - string logMsg = ""; - if (taskDetial.Crtype == "1")//鍙《锛堟《鍑哄簱锛� + var endLocatInfo = new SysStorageLocat();//鐩爣鍌ㄤ綅 + string areaNo = string.Empty; + switch (palletStatus) { - logMsg = "鐢宠鍙《"; - } - else if (taskDetial.Crtype == "0")//鐢宠鍌ㄤ綅锛堟《鍏ュ簱锛� - { - logMsg = "鐢宠鍌ㄤ綅"; - } - var logStr = $@".\log\AGV\AGV{logMsg}" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; - LogFile.SaveLogToFile($"AGV{logMsg}寮傚父锛�( {agvModel.Message} ),", logStr); + case "0"://鍑�妗� + //鏌ュ埌鍒板噣妗跺尯鍩熺紪鍙� + areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "0").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(); + 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"; - agvMsg = agvModel.Message; + List<int> RowList = Db.Ado.SqlQuery<int>(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) + .OrderByDescending(o => o.Column).First(); + + if (endLocatInfo != null) + { + break; + } + } + //娌℃湁鎵惧埌鐩稿悓鐗╂枡鍚岀粍鐨勭┖鍌ㄤ綅 + 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(); + //鍒嗛厤鍌ㄤ綅 + 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; + } + return endLocatInfo; } - return result; - #endregion + catch (Exception ex) + { + throw new Exception(ex.Message); + } } - - } } diff --git a/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs b/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs index baae27f..2c296cd 100644 --- a/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs +++ b/Wms/WMS.IBLL/IBllTransServer/IHopperTransportServer.cs @@ -17,7 +17,7 @@ List<string> GetSku(); void jiaoLiaoHopper(string areaNo, string endLocate, string plnStatus, string standard, string skuNo, string lotNo, string url, int userId); - void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight, string skuNo, string lotNo, int userId); + void jiaoCheHopper(string areaNo, string StartLocate, string plnNo, string plnStatus, decimal weight, string skuNo, string lotNo, string url, int userId); } -- Gitblit v1.8.0