From 8db84793a19b02df61c8fb9e5d539c57b827da45 Mon Sep 17 00:00:00 2001 From: Administrator <Administrator@DESKTOP-5BIMHQ3> Date: 星期五, 28 六月 2024 16:53:58 +0800 Subject: [PATCH] 修改问题 --- Wms/WMS.BLL/BllTransServer/RcsServer.cs | 159 ++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 109 insertions(+), 50 deletions(-) diff --git a/Wms/WMS.BLL/BllTransServer/RcsServer.cs b/Wms/WMS.BLL/BllTransServer/RcsServer.cs index 5cf982d..672a451 100644 --- a/Wms/WMS.BLL/BllTransServer/RcsServer.cs +++ b/Wms/WMS.BLL/BllTransServer/RcsServer.cs @@ -35,7 +35,7 @@ { var house = "W01";//鍙《浣嶇疆锛屽悗缁牴鎹綅缃叧鑱旀垨瀹氫箟锛屾潵鍒ゆ柇鍙《浣嶇疆鎵�灞炶溅闂� var url = "";//鍥炰紶MES鐨勬帴鍙e湴鍧� - var noticeno = "";//鍑哄叆搴撳崟鎹槑缁咺D + var noticeno = "0";//鍑哄叆搴撳崟鎹槑缁咺D var sql = "select PalletNo,LocatNo from DataStockDetail where Status = '0'"; switch (pallnetmsg.Type) { @@ -58,7 +58,7 @@ if (obj.Result != "0")//鍙敤锛岀敓鎴愬皬杞︽媺鍑�妗朵换鍔� { //鏌ユ壘鏄惁鏈夌┖浣欒剰妗朵綅 - sql = $"select LocatNo from SysStorageLocat where AreaNo like '%04' and WareHouseNo = wareno and Status = 0"; + sql = $"select LocatNo from SysStorageLocat where AreaNo like '%04' and WareHouseNo = '{house}' and Status = 0"; locat = Db.Ado.SqlQuery<SysStorageLocat>(sql).FirstOrDefault(); if (locat == null) { @@ -75,13 +75,25 @@ Startport = item.LocatNo, Endport = locat.LocatNo, Pallno = item.PalletNo, - Type = "4", + Type = "3", Crtype = "0", Noticedetailno = int.Parse(noticeno), }; CreateLotTask(ztask); - return; + continue; } + //涓嬪彂灏忚溅浠诲姟 + var task2 = new TaskDetial + { + Startport = item.LocatNo, + Endport = pallnetmsg.Location, + Pallno = item.PalletNo, + Type = pallnetmsg.Type, + Crtype = "1", + Noticedetailno = int.Parse(noticeno), + }; + CreateLotTask(task2); + return; } else { @@ -105,8 +117,8 @@ } noticeno = ArriveMes.Id.ToString();*/ //鏌ユ壘搴撳瓨涓槸鍚︽湁鍙敤鐨勬鎵规鐨勬贩鏂欐《 - sql= $"select PalletNo,LocatNo from DataStockDetail where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%02' " + - $"and a.WareHouseNo = '{house}' and b.status = '0' order by CompleteTime desc"; + sql= $"select PalletNo,LocatNo from DataStockDetail where LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%02' " + + $"and WareHouseNo = '{house}' and status = '0' order by CompleteTime desc"; pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault(); if (pallet == null) { @@ -122,7 +134,7 @@ throw new Exception("鎵规鍙蜂负绌猴紒"); } //鏌ユ壘鏄惁鏈夋鎵规鍑哄簱鍗� - sql = $"select * from BllSoNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; + sql = $"select * from BllExportNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; bllSo = Db.Ado.SqlQuery<BllExportNoticeDetail>(sql).FirstOrDefault(); if (bllSo == null) { @@ -130,8 +142,8 @@ } noticeno = bllSo.Id.ToString(); //鏌ユ壘搴撳瓨涓槸鍚︽湁姝ゆ壒娆$殑涓嬫枡妗� - sql += $"select PalletNo,LocatNo from DataStockDetail where a.LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%03' " + - $"and a.WareHouseNo = '{house}' and b.status = '0' order by CompleteTime desc"; + sql = $"select PalletNo,LocatNo from DataStockDetail where LotNo = '{pallnetmsg.LotNo}'and AreaNo like '%03' " + + $"and WareHouseNo = '{house}' and status = '0' order by CompleteTime desc"; pallet = Db.Ado.SqlQuery<DataStockDetail>(sql).FirstOrDefault(); if (pallet == null) { @@ -152,12 +164,13 @@ //涓嬪彂灏忚溅浠诲姟 var task = new TaskDetial { - Startport = pallnetmsg.Location, - Endport = pallet.LocatNo, - Pallno = pallet.PackagNo, + Startport = pallet.LocatNo, + Endport = pallnetmsg.Location, + Pallno = pallet.PalletNo, Type = pallnetmsg.Type, Crtype = "1", Noticedetailno = int.Parse(noticeno), + LotNo = pallnetmsg.LotNo, }; CreateLotTask(task); return; @@ -179,7 +192,7 @@ var sql = $"select LocatNo from SysStorageLocat where status = '0'"; var sql2 = ""; var house = "W01";//鈥︹�﹀彨妗朵綅缃紝鍚庣画鏍规嵁浣嶇疆鍏宠仈鎴栧畾涔夛紝鏉ュ垽鏂彨妗朵綅缃墍灞炶溅闂� - var noticeno = "";//鍑哄叆搴撳崟鎹槑缁咺D + var noticeno = "0";//鍑哄叆搴撳崟鎹槑缁咺D SysStorageLocat loction = new SysStorageLocat(); BllArrivalNoticeDetail ArriveMes = new BllArrivalNoticeDetail(); try @@ -187,7 +200,7 @@ switch (pallnetmsg.Type) { case "0"://鍑�妗剁敵璇峰偍浣� - sql += $"and AreaNo like '%01' and WareHouseNo = {house}"; + sql += $"and AreaNo like '%01' and WareHouseNo = '{house}'"; loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); if (loction == null) { @@ -208,7 +221,7 @@ throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍏ュ簱鍗�"); } noticeno = ArriveMes.Id.ToString();*/ - sql += $"and AreaNo like '%02' and WareHouseNo = {house}"; + sql += $"and AreaNo like '%02' and WareHouseNo = '{house}'"; loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); if (loction == null) { @@ -223,13 +236,13 @@ } //鏍¢獙姝ゆ壒娆℃槸鍚︽湁鍏ュ簱鍗� sql2 = $"select * from BllArrivalNoticeDetail where LotNo = '{pallnetmsg.LotNo}' order by CreateTime desc"; - ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql).FirstOrDefault(); + ArriveMes = Db.Ado.SqlQuery<BllArrivalNoticeDetail>(sql2).FirstOrDefault(); if (ArriveMes == null) { throw new Exception("璇ユ壒娆℃病鏈夊搴旂殑鍏ュ簱鍗�"); } noticeno = ArriveMes.Id.ToString(); - sql += $"and AreaNo like '%03' and WareHouseNo = {house}"; + sql += $"and AreaNo like '%03' and WareHouseNo = '{house}'"; loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); if (loction == null) { @@ -237,7 +250,7 @@ } break; case "3"://鑴忔《鐢宠鍌ㄤ綅 - sql += $"and AreaNo like '%04' and WareHouseNo = {house}"; + sql += $"and AreaNo like '%04' and WareHouseNo = '{house}'"; loction = Db.Ado.SqlQuery<SysStorageLocat>(sql).OrderByDescending(a => a.CreateTime).FirstOrDefault(); if (loction == null) { @@ -253,6 +266,7 @@ Type = pallnetmsg.Type, Crtype = "0", Noticedetailno = int.Parse(noticeno), + LotNo = pallnetmsg.LotNo, }; CreateLotTask(task); } @@ -355,37 +369,74 @@ { try { - var na = taskDetial.Crtype == "0"?"鍏ュ簱":"鍑哄簱"; - var sql = ""; - var sql2 = ""; //寮�鍚簨鍔� Db.BeginTran(); + var na = taskDetial.Crtype == "0"?"鍏ュ簱":"鍑哄簱"; + var bz = ""; + switch (taskDetial.Type) + { + case "0": + bz = "鍑�妗�"+na+"浠诲姟"; + break; + case "1": + bz = "棰勬贩鏂欐《" + na + "浠诲姟"; + break; + case "2": + bz = "鍗婃垚鍝佹枡妗�" + na + "浠诲姟"; + break; + case "3": + bz = "鑴忔《" + na + "浠诲姟"; + break; + } + var sql = ""; + var sql2 = ""; + var ordertype = "3"; + //娑夊強鍑哄叆搴撳崟鎹殑鐘舵�佷俊鎭敼鍙� + if (taskDetial.Type == "2" && taskDetial.Crtype =="1")//鍗婃垚鍝佸嚭搴� + { + ordertype = "1"; + sql = $"UPDATE BllExportNotice SET Status ='1' " + + $"where asnno = (select ASNNO from BllExportNoticeDetail where id = {taskDetial.Noticedetailno})"; + Db.Ado.ExecuteCommand(sql); + } + else if(taskDetial.Type =="2" && taskDetial.Crtype == "0")//鍗婃垚鍝佸叆搴� + { + ordertype = "0"; + var ArrivalMsg = Db.Queryable<BllArrivalNoticeDetail>().First(it => it.Id == taskDetial.Noticedetailno); + //淇敼鍏ュ簱鍗曟�昏〃涓崟鎹姸鎬佷负姝e湪鎵ц + sql = $"UPDATE BllArrivalNotice SET Status ='1' where asnno = '{ArrivalMsg.ASNNo}'"; + Db.Ado.ExecuteCommand(sql); + //搴撳瓨涓坊鍔犳鎵樼洏鐗╂枡缂栫爜鍜岀紪鐮佸悕绉� + sql2 = $"UPDATE DataStockDetail SET SkuNo = '{ArrivalMsg.SkuNo}',SkuName = '{ArrivalMsg.SkuName}' " + + $"where PalletNo = '{taskDetial.Pallno}'and LotNo = '{taskDetial.LotNo}'"; + Db.Ado.ExecuteCommand(sql2); + } + //鍒ゆ柇浠诲姟鏄惁涓烘柊浠诲姟 if (string.IsNullOrWhiteSpace(taskDetial.Taskno)) { - taskDetial.Taskno = new Common().GetMaxNo("T"); - - var logTaskEntry = new LogTask - { - TaskNo = taskDetial.Taskno, - Sender = "WMS", - Receiver = "RCS", - //IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛 - SendDate = DateTime.Now, //鍙戦�佹椂闂� - //BackDate = DateTime.Now, //杩斿洖鏃堕棿 - StartLocat = taskDetial.Startport,//璧峰浣嶇疆 - EndLocat = taskDetial.Endport,//鐩爣浣嶇疆 - PalletNo = taskDetial.Pallno,//鎵樼洏鐮� - IsSend = 1,//鏄惁鍙啀娆′笅鍙� - IsCancel = 1,//鏄惁鍙彇娑� - IsFinish = 1,//鏄惁鍙畬鎴� - Type = taskDetial.Crtype,//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟 - Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚 - NoticeDetailNo = int.Parse(taskDetial.Noticedetailno.ToString()), - Msg = $"{taskDetial.Endport}鐨剓na}浠诲姟", //鍏抽敭淇℃伅 - }; - Db.Insertable(logTaskEntry).ExecuteCommand(); + taskDetial.Taskno = new Common().GetMaxNo("TK"); } + var logTaskEntry = new LogTask + { + TaskNo = taskDetial.Taskno, + Sender = "WMS", + Receiver = "RCS", + //IsSuccess = 1, //鏄惁涓嬪彂鎴愬姛 0澶辫触 1鎴愬姛 + SendDate = DateTime.Now, //鍙戦�佹椂闂� + //BackDate = DateTime.Now, //杩斿洖鏃堕棿 + StartLocat = taskDetial.Startport,//璧峰浣嶇疆 + EndLocat = taskDetial.Endport,//鐩爣浣嶇疆 + PalletNo = taskDetial.Pallno,//鎵樼洏鐮� + IsSend = 1,//鏄惁鍙啀娆′笅鍙� + IsCancel = 1,//鏄惁鍙彇娑� + IsFinish = 1,//鏄惁鍙畬鎴� + Type = taskDetial.Crtype,//浠诲姟绫诲瀷 0 鍏ュ簱浠诲姟 1 鍑哄簱浠诲姟 2 绉诲簱浠诲姟 + OrderType = ordertype,//鍗曟嵁绫诲瀷 0 鍏ュ簱 1 鍑哄簱 3鍏朵粬 + Status = "0",//浠诲姟鐘舵��0锛氱瓑寰呮墽琛�1姝e湪鎵ц2鎵ц瀹屾垚 + NoticeDetailNo = int.Parse(taskDetial.Noticedetailno.ToString()), + Msg = bz, //鍏抽敭淇℃伅 + }; var Agv = new AgvTask { taskCode = taskDetial.Taskno, @@ -394,27 +445,35 @@ endPos = taskDetial.Endport, agvCode = "1",//鈥︹�﹂渶瑕佸拰AGV纭姝ゅ瓧娈靛�� }; + //璇锋眰灏忚溅 genAgvSchedulingTaskRep chrep =genAgvSchedulingTask(Agv, "url"); if (chrep.code != "0") { - sql = $"UPDATE LogTask SET IsSuccess = '0' WHERE TaskNo = {taskDetial.Taskno}"; - Db.Ado.ExecuteCommand(sql); + logTaskEntry.IsSuccess = 0; + Db.Insertable(logTaskEntry).ExecuteCommand(); Db.CommitTran(); - throw new Exception("RCS浠诲姟涓嬪彂閿欒锛孯CS杩斿洖娑堟伅锛�"+chrep.message); + throw new Exception("RCS浠诲姟涓嬪彂閿欒锛孯CS杩斿洖娑堟伅锛�" + chrep.message); } - sql = $"UPDATE LogTask SET IsSuccess = 1,BackDate = {DateTime.Now},Status = '1' WHERE TaskNo = {taskDetial.Taskno}"; - Db.Ado.ExecuteCommand(sql); + //璇锋眰鎴愬姛淇敼浠诲姟琛ㄧ浉搴斿瓧娈电姸鎬� + logTaskEntry.IsSuccess = 1; + logTaskEntry.BackDate = DateTime.Now; + logTaskEntry.Status = "1"; if (taskDetial.Crtype == "0") { sql = $"UPDATE SysStorageLocat SET Status = '2' where LocatNo = '{taskDetial.Endport}'"; - sql2 = $"UPDATE DataStockDetail SET PalletStatus = '{taskDetial.Type}' where PalletNo = '{taskDetial.Pallno}'"; - Db.Ado.ExecuteCommand(sql2); + if (taskDetial.Type == "2") + { + sql2 = $"UPDATE DataStockDetail SET PalletStatus = '{taskDetial.Type}',LotNo = '{taskDetial.LotNo}' " + + $"where PalletNo = '{taskDetial.Pallno}'"; + Db.Ado.ExecuteCommand(sql2); + } } else { sql = $"UPDATE SysStorageLocat SET Status = '3' where LocatNo = '{taskDetial.Startport}' "; } + Db.Insertable(logTaskEntry).ExecuteCommand(); Db.Ado.ExecuteCommand(sql); //鎻愪氦浜嬪姟 Db.CommitTran(); -- Gitblit v1.8.0