From 1e26a7575d9969e728b0aa01466f490409cb173c Mon Sep 17 00:00:00 2001 From: chengsc <Demo@DESKTOP-CPA90BF> Date: 星期五, 18 十月 2024 18:41:30 +0800 Subject: [PATCH] Merge branch 'master' into csc --- Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs | 301 +++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 261 insertions(+), 40 deletions(-) diff --git a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs index 063f080..4b30086 100644 --- a/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs +++ b/Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs @@ -2,9 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Model.InterFaceModel; using Model.ModelDto.BllCheckDto; using Model.ModelDto.PdaDto; +using Model.ModelVm; +using Newtonsoft.Json; using SqlSugar; +using Utility.Tools; using WMS.BLL.LogServer; using WMS.DAL; using WMS.Entity.BllAsnEntity; @@ -171,7 +175,7 @@ } } - public void CrSetCheck(string crNo, string crDetail, string palletNo, string boxNo, string boxNo3, string result, int? qty, string isContinue, int userId) + public void CrSetCheck(string crNo, string crDetail, string palletNo, string boxNo, string boxNo3, string result, decimal? qty, string isContinue, int userId) { try { @@ -276,14 +280,14 @@ var list = checkLog.ToList(); - decimal num = 0; + var num = 0; foreach (var l in list) { l.RealQty = 0; l.CheckResult = 1; l.CheckDate = time; l.CheckUserId = userId; - num -= (decimal)l.RealQty; + num -= int.Parse(l.RealQty.ToString()); } if (checkDetail.RealQty == null) { @@ -776,7 +780,7 @@ var storageArea = new List<SysStorageArea>(); if (string.IsNullOrEmpty(palletNo)) { - storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o=>o.AreaNo).ToList(); + storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); } else { @@ -798,7 +802,7 @@ { throw new Exception("鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); } - + if (storageLocat.AreaNo.Contains("B0")) { storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B0") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); @@ -807,7 +811,7 @@ { storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B1") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); } - } + } return storageArea; } catch (Exception ex) @@ -823,7 +827,7 @@ { try { - var allotList = Db.Queryable<BllExportNotice>().Where(m => m.IsDel == "0" && m.Status == "2").Select(m => m.SONo).Distinct().ToList(); + var allotList = Db.Queryable<BllExportNotice>().Where(m => m.IsDel == "0" && (m.Status == "3" || m.Status == "4")).Select(m => m.SONo).Distinct().ToList(); return allotList; } catch (Exception ex) @@ -880,7 +884,7 @@ /// <param name="palletNo"></param> /// <param name="areaNo"></param> /// <param name="ruku"></param> - public void AgvTransport(string palletNo, string areaNo, string ruku, int userId) + public void AgvTransport(string palletNo, string areaNo, string ruku, int userId, string url) { if (string.IsNullOrEmpty(palletNo)) { @@ -893,7 +897,7 @@ if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku)) { throw new Exception("鐩爣鍖哄煙鍜屽叆搴撳彛涓嶈兘鍚屾椂閫夋嫨锛�"); - } + } try { string EndLocat = string.Empty;//鐩爣浣嶇疆 @@ -902,7 +906,7 @@ if (log != null) { throw new Exception("璇ユ墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔�!"); - } + } var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); if (stockDetail == null) { @@ -915,7 +919,7 @@ { throw new Exception("鎵�閫夊尯鍩熶俊鎭笉瀛樺湪,璇锋鏌�!"); } - EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo); + EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo, palletNo); } else { @@ -950,7 +954,7 @@ throw new Exception("鐩爣鍌ㄤ綅淇℃伅涓嶅瓨鍦�,璇锋鏌�!"); } } - + //寮�鍚簨鍔� Db.BeginTran(); @@ -980,11 +984,11 @@ //淇敼搴撳瓨鏄庣粏淇℃伅 stockDetail.Status = "4";//绉诲簱閿佸畾 - stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺 + //stockDetail.LockQty = stockDetail.Qty;//閿佸畾搴撳瓨鏁伴噺 Db.Updateable(stockDetail).ExecuteCommand(); //淇敼搴撳瓨淇℃伅 - stock.LockQty += (decimal)stockDetail.Qty; - Db.Updateable(stock).ExecuteCommand(); + //stock.LockQty += (decimal)stockDetail.Qty; + //Db.Updateable(stock).ExecuteCommand(); //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵�� storageLocat.Status = "5";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 @@ -995,15 +999,63 @@ { storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocatEnd).ExecuteCommand(); - } + } //娣诲姞鎿嶄綔鏃ュ織璁板綍 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); - //鎻愪氦浜嬪姟 - Db.CommitTran(); #region 鍛煎彨灏忚溅浠g爜 + + List<AgvSchedulingTask> agvTaskList = new List<AgvSchedulingTask>(); + + AgvSchedulingTask agvTask = new AgvSchedulingTask(); + agvTask.ReqCode = taskNo; + agvTask.TaskTyp = "F01"; + agvTask.WbCode = ""; + agvTask.PositionCodePath = null; + agvTask.PodCode = "-1"; + + agvTaskList.Add(agvTask); + + var IsTrue = false; + while (IsTrue == true) + { + // 姝e紡杩愯绋嬪簭鏀惧紑 + string str = ""; + var list2 = agvTaskList.Select(m => m.ReqCode).ToList(); + var jsonData = JsonConvert.SerializeObject(agvTaskList); + string response = ""; + + try + { + var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss") + response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橝GV杞繍鍛戒护", "AGV"); + var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss") + + //////瑙f瀽杩斿洖鏁版嵁 + var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response); + if (agvModel.Code == "0") + { + //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�// + new TaskServer().EditTaskIssueOk(list2, time1, time2); + str += "涓嬪彂鎴愬姛"; + IsTrue = true; + } + if (agvModel.Code == "1") + { + new TaskServer().EditTaskIssueNo(list2, time1, time2, agvModel.Message); + throw new Exception(agvModel.Message); + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } #endregion + + //鎻愪氦浜嬪姟 + Db.CommitTran(); } catch (Exception ex) { @@ -1018,7 +1070,7 @@ /// <param name="palletNo"></param> /// <param name="areaNo"></param> /// <param name="userId"></param> - public void AgvTransport2(string soNo,string palletNo, string areaNo, int userId) + public List<string> AgvTransport2(string soNo, string palletNo, string areaNo, int userId, string url) { if (string.IsNullOrEmpty(soNo)) { @@ -1032,6 +1084,8 @@ { //寮�鍚簨鍔� Db.BeginTran(); + List<AgvSchedulingTask> agvTaskList = new List<AgvSchedulingTask>(); + var strList = new List<string>();//閿欒淇℃伅闆嗗悎 //0 锛氶儴鍒嗘墭鐩樺凡鏈夊皬杞︾瓑寰呮墽琛屾垨姝e湪鎵ц鐨勪换鍔� //鍑哄簱鍗曚俊鎭� var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo); if (notice == null) @@ -1051,10 +1105,11 @@ } else//鏁翠釜鍑哄簱鍗曞彨璐� { - string sqlStr = $"select * from DataStockDetail where PalletNo in (select PalletNo from BllExportAllot where IsDel='0' and SONo='{soNo}')"; - stockDetailList = Db.Ado.SqlQuery<DataStockDetail>(sqlStr).ToList(); + // string sqlStr = $"select * from DataStockDetail where PalletNo in (select PalletNo from BllExportAllot where IsDel='0' and SONo='{soNo}')"; + // stockDetailList = Db.Ado.SqlQuery<DataStockDetail>(sqlStr).ToList(); + stockDetailList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SONo == soNo).ToList(); } - if (stockDetailList.Count<=0) + if (stockDetailList.Count <= 0) { throw new Exception("鎵樼洏鏄庣粏涓嶅瓨鍦�,璇锋鏌�!"); } @@ -1064,14 +1119,10 @@ var stock = Db.Queryable<DataStock>().Where(w => w.IsDel == "0");//搴撳瓨鎬昏〃 string EndLocat = string.Empty;//鐩爣浣嶇疆 string hasLocatNoList = string.Empty;//宸插垎閰嶇殑鍌ㄤ綅 + foreach (var item in stockDetailList) { - //浠诲姟淇℃伅 - var logInfo = log.First(w =>w.PalletNo == item.PalletNo); - if (logInfo != null) - { - throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}宸叉湁灏忚溅绛夊緟鎵ц鎴栨鍦ㄦ墽琛岀殑浠诲姟!"); - } + if (string.IsNullOrEmpty(item.LocatNo)) { throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}鐨勫偍浣嶄俊鎭笉瀛樺湪,璇锋鏌�!"); @@ -1079,6 +1130,17 @@ if (item.WareHouseNo != "W02") { throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}鏈湪骞冲簱鍐�,璇锋鏌�!"); + } + //浠诲姟淇℃伅 + var logInfo = log.First(w => w.PalletNo == item.PalletNo); + if (logInfo != null) + { + if (!strList.Contains("1")) + { + strList.Add("1"); + } + continue; + //throw new Exception($"鎵樼洏鍙凤細{item.PalletNo}宸叉湁灏忚溅绛夊緟鎵ц鎴栨鍦ㄦ墽琛岀殑浠诲姟!"); } //璧峰鍌ㄤ綅淇℃伅 var storageLocatBegin = storageLocat.First(w => w.LocatNo == item.LocatNo); @@ -1118,7 +1180,7 @@ Msg = string.Format("杞繍浠诲姟锛歿0}=>>{1}", item.LocatNo, EndLocat), StartLocat = item.LocatNo,//璧峰浣嶇疆 EndLocat = EndLocat,//鐩爣浣嶇疆 - PalletNo = palletNo,//鎵樼洏鐮� + PalletNo = item.PalletNo,//鎵樼洏鐮� IsSend = 1,//鏄惁鍙啀娆′笅鍙� IsCancel = 1,//鏄惁鍙彇娑� IsFinish = 1,//鏄惁鍙畬鎴� @@ -1130,9 +1192,18 @@ }; Db.Insertable(exTask).ExecuteCommand(); + AgvSchedulingTask agvTask = new AgvSchedulingTask(); + agvTask.ReqCode = taskNo; + agvTask.TaskTyp = "F01"; + agvTask.WbCode = ""; + agvTask.PositionCodePath = null; + agvTask.PodCode = "-1"; + + agvTaskList.Add(agvTask); + //淇敼搴撳瓨鏄庣粏淇℃伅 item.Status = "4";//绉诲簱閿佸畾 - item.LockQty = item.Qty;//閿佸畾搴撳瓨鏁伴噺 + //item.LockQty = item.Qty;//閿佸畾搴撳瓨鏁伴噺 Db.Updateable(item).ExecuteCommand(); //淇敼璧峰鍌ㄤ綅鍦板潃鐘舵�� @@ -1141,11 +1212,16 @@ //淇敼鐩爣鍌ㄤ綅鍦板潃鐘舵�� storageLocatEnd.Status = "4";//0锛氱┖鍌ㄤ綅 1锛氭湁鐗╁搧 2锛氬叆搴撲腑 3锛氬嚭搴撲腑 4锛氱Щ鍏ヤ腑 5锛氱Щ鍑轰腑 Db.Updateable(storageLocatEnd).ExecuteCommand(); + + if (!strList.Contains("0")) + { + strList.Add("0"); + } - var stockInfo = stock.First(w => w.SkuNo == item.SkuNo && w.LotNo == item.LotNo); - //淇敼搴撳瓨淇℃伅 - stockInfo.LockQty += (decimal)item.Qty;//閿佸畾鏁伴噺 - Db.Updateable(stockInfo).ExecuteCommand(); + //var stockInfo = stock.First(w => w.SkuNo == item.SkuNo && w.LotNo == item.LotNo); + ////淇敼搴撳瓨淇℃伅 + //stockInfo.LockQty += (decimal)item.Qty;//閿佸畾鏁伴噺 + //Db.Updateable(stockInfo).ExecuteCommand(); } if (string.IsNullOrEmpty(palletNo)) { @@ -1157,12 +1233,52 @@ //娣诲姞鎿嶄綔鏃ュ織璁板綍 var k = new OperationCrServer().AddLogOperationCr("PDA妯″潡", "AGV杞繍", palletNo, "绉诲簱", $"PDA鍛煎彨灏忚溅瀵规墭鐩樺彿锛歿palletNo}鍙戣捣杞繍", userId); } - //鎻愪氦浜嬪姟 - Db.CommitTran(); #region 鍛煎彨灏忚溅浠g爜 + + + var IsTrue = false; + while (IsTrue == true) + { + // 姝e紡杩愯绋嬪簭鏀惧紑 + string str = ""; + var list2 = agvTaskList.Select(m => m.ReqCode).ToList(); + var jsonData = JsonConvert.SerializeObject(agvTaskList); + string response = ""; + + try + { + var time1 = DateTime.Now;//鍙戦�佹椂闂� .ToString("yyyy-MM-dd HH:mm:ss") + response = HttpHelper.DoPost(url, jsonData, "涓嬪彂缁橝GV杞繍鍙栬揣鍛戒护", "AGV"); + var time2 = DateTime.Now;//杩斿洖鏃堕棿 .ToString("yyyy-MM-dd HH:mm:ss") + + //////瑙f瀽杩斿洖鏁版嵁 + var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response); + if (agvModel.Code == "0") + { + //鏇存敼浠诲姟鐨勫彂閫佽繑鍥炴椂闂�// + new TaskServer().EditTaskIssueOk(list2, time1, time2); + str += "涓嬪彂鎴愬姛"; + IsTrue = true; + } + if (agvModel.Code == "1") + { + new TaskServer().EditTaskIssueNo(list2, time1, time2, agvModel.Message); + throw new Exception(agvModel.Message); + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + #endregion + + //鎻愪氦浜嬪姟 + Db.CommitTran(); + return strList; } catch (Exception ex) { @@ -1177,16 +1293,16 @@ /// <param name="skuNo"></param> /// <param name="lotNo"></param> /// <returns></returns> - private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo,string hasLocatNoList="") + private string GetLocat(string areaNo, string skuNo, string lotNo, string palletNo, string hasLocatNoList = "") { 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(); + .OrderByDescending(o => o.LocatNo).Select(s => s.LocatNo).Distinct().ToList(); foreach (var item in locatList) { var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First(); @@ -1201,7 +1317,7 @@ if (string.IsNullOrEmpty(endLocat)) { var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0" && !hasLocatNoList.Contains(w.LocatNo)) - .OrderByDescending(m => m.Layer).OrderByDescending(m=>m.Column).OrderByDescending(m=> m.Row).First(); + .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First(); if (locatInfo3 != null) { @@ -1217,5 +1333,110 @@ } #endregion + #region 绠辩爜鏌ヨ + /// <summary> + /// 绠辩爜鏌ヨ + /// </summary> + /// <param name="boxNo">绠辩爜</param> + /// <returns></returns> + public DataBoxDto GetBoxQueryList(string boxNo) + { + // 瀹炰緥鍖栬繑鍥炵被 + DataBoxDto boxModel = new DataBoxDto(); + List<DataBoxInfoDto> list = new List<DataBoxInfoDto>(); + + // 鏍规嵁绠辩爜鑾峰彇绠变俊鎭� + var boxData = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo); + + if (boxData.Count() == 0) + { + // 鏍规嵁鐩掔爜鑾峰彇绠变俊鎭� + boxData = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo2 == boxNo); + if (boxData.Count() == 0) + { + boxModel = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo3 == boxNo).Select(it => new DataBoxDto() { Qty = it.Qty }, true).First(); + return boxModel; + } + + list = boxData.Select(it => new DataBoxInfoDto() + { + BoxNo2 = it.BoxNo3, + Qty2 = it.Qty + }).ToList(); + + boxData = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo2 == boxNo); + boxModel = boxData.GroupBy(m => new + { + m.BoxNo, + m.SkuName, + m.SkuNo, + m.LotNo, + m.SupplierLot, + m.InspectStatus + }).Select(it => new DataBoxDto() + { + BoxNo = it.BoxNo, + SkuName = it.SkuName, + SkuNo = it.SkuNo, + LotNo = it.LotNo, + SupplierLot = it.SupplierLot, + InspectStatus = it.InspectStatus == "0" ? "寰呮" : it.InspectStatus == "1" ? "鍚堟牸":"涓嶅悎鏍�", + Qty = SqlFunc.AggregateSum(it.Qty) + }).First(); + + boxModel.InfoList = list; + return boxModel; + } + else //绠辩爜鍐呮暟鎹� + { + // 澶勭悊澶氱骇鐮� + var num = boxData.Count(m => !string.IsNullOrWhiteSpace(m.BoxNo2)); + if (num > 0) + { + list = boxData.GroupBy(m => new + { + m.BoxNo2 + }).Select(it => new DataBoxInfoDto() + { + BoxNo2 = it.BoxNo2, + Qty2 = SqlFunc.AggregateSum(it.Qty) + }).ToList(); + } + else + { + list = boxData.Select(it => new DataBoxInfoDto() + { + BoxNo2 = SqlFunc.IsNull(it.BoxNo3,""), + Qty2 = it.Qty + }).ToList(); + } + + // 绠辩爜淇℃伅璧嬪�� + boxData = Db.Queryable<DataBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo); + boxModel = boxData.GroupBy(m => new + { + m.BoxNo, + m.SkuName, + m.SkuNo, + m.LotNo, + m.SupplierLot, + m.InspectStatus + }).Select(it => new DataBoxDto() + { + BoxNo = it.BoxNo, + SkuName = it.SkuName, + SkuNo = it.SkuNo, + LotNo = it.LotNo, + SupplierLot = it.SupplierLot, + InspectStatus = it.InspectStatus == "0" ? "寰呮" : it.InspectStatus == "1" ? "鍚堟牸" : "涓嶅悎鏍�", + Qty = SqlFunc.AggregateSum(it.Qty) + }).First(); + boxModel.InfoList = list; + + return boxModel; + } + } + #endregion + } } -- Gitblit v1.8.0