From 04611220d6ec06fb328c85210b5e3d3e305cfb3d Mon Sep 17 00:00:00 2001 From: liudl <673013083@qq.com> Date: 星期一, 29 九月 2025 17:28:49 +0800 Subject: [PATCH] 结批功能修改 --- Admin.NET/WCS.Application/PLC/PLCService.cs | 59 ++++++++++++------- Admin.NET/WCS.Application/Util/HttpService.cs | 24 ------- Admin.NET/WCS.Application/Configuration/Database.json | 2 Admin.NET/WCS.Application/Model/TaskRequest.cs | 76 +------------------------ 4 files changed, 43 insertions(+), 118 deletions(-) diff --git a/Admin.NET/WCS.Application/Configuration/Database.json b/Admin.NET/WCS.Application/Configuration/Database.json index a586878..4e16d32 100644 --- a/Admin.NET/WCS.Application/Configuration/Database.json +++ b/Admin.NET/WCS.Application/Configuration/Database.json @@ -11,7 +11,7 @@ //"ConnectionString": "PORT=5432;DATABASE=xxx;HOST=localhost;PASSWORD=xxx;USER ID=xxx", // PostgreSQL 搴撹繛鎺ュ瓧绗︿覆 //"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;", // MySql 搴撹繛鎺ュ瓧绗︿覆", //"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle 搴撹繛鎺ュ瓧绗︿覆 - "ConnectionString": "Server=10.18.99.10;Database=WCSnet6;User Id=sa;Password=sql2024;", // SqlServer 搴撹繛鎺ュ瓧绗︿覆 + "ConnectionString": "Server=10.18.99.10;Database=WCSnet6;User Id=sa;Password=sql2024;MultipleActiveResultSets=True;", // SqlServer 搴撹繛鎺ュ瓧绗︿覆 //"ConnectionString": "Server=192.168.62.200;Database=WCSnet6;User Id=sa;Password=sql2019;", // SqlServer 搴撹繛鎺ュ瓧绗︿覆 diff --git a/Admin.NET/WCS.Application/Model/TaskRequest.cs b/Admin.NET/WCS.Application/Model/TaskRequest.cs index 6cc2dac..f7a4e93 100644 --- a/Admin.NET/WCS.Application/Model/TaskRequest.cs +++ b/Admin.NET/WCS.Application/Model/TaskRequest.cs @@ -87,7 +87,7 @@ /// </summary> public int Order { get; set; } - + public string SkuName { get; set; } public string LotNo { get; set; } @@ -139,14 +139,6 @@ /// </summary> public decimal Qty { get; set; } /// <summary> - /// 绠辨暟閲� - /// </summary> - public decimal xQty { get; set; } - /// <summary> - /// 婊$鏁伴噺 - /// </summary> - public decimal FullQty { get; set; } - /// <summary> /// 鎵樼洏绫诲瀷 0鐗╂枡鎵� 1绌烘墭鐩樻墭 /// </summary> public string Type { get; set; } @@ -154,10 +146,6 @@ /// 鐗╂枡缂栫爜 /// </summary> public string SkuNo { get; set; } - /// <summary> - /// 鐗╂枡鍚嶇О - /// </summary> - public string SkuName { get; set; } /// <summary> /// 鎵规鍙� /// </summary> @@ -170,47 +158,7 @@ /// 渚涜揣鎵规 /// </summary> public string SupplierLot { get; set; } - /// <summary> - /// 鐢熶骇鏃ユ湡 - /// </summary> - public DateTime? ProductionTime { get; set; } - /// <summary> - /// 杩囨湡鏃堕棿 - /// </summary> - public DateTime? ExpirationTime { get; set; } - /// <summary> - /// 妫�楠屾爣璁� - /// </summary> - public string InspectMark { get; set; } - /// <summary> - /// 闆剁鏍囪 - /// </summary> - public string BitBoxMark { get; set; } - /// <summary> - /// 璐ㄦ鐘舵�� - /// </summary> - public string InspectStatus { get; set; } - /// <summary> - /// 鐗╂枡瑙勬牸 - /// </summary> - public string Standard { get; set; } - /// <summary> - /// 鍖呰瑙勬牸 - /// </summary> - public string PackageStandard { get; set; } - /// <summary> - /// 鍌ㄥ瓨鏈熻嚦 - /// </summary> - public DateTime? StoreTime { get; set; } - /// <summary> - /// 绗嚑浠� - /// </summary> - public int? QtyOrd { get; set; } - /// <summary> - /// 鎬讳欢鏁� - /// </summary> - public int? QtyCount { get; set; } - public List<BindBox> Detail { get; set; } + public List<WcsBoxInfo> Detail { get; set; } } //鐮佸灈绠辩爜鏄庣粏淇℃伅 public class BoxPalletBindDetailVm @@ -552,7 +500,7 @@ public string Message { get; set; } public RequestBoxInfoCheck data { get; set; } - + } public class RequestBoxInfoCheck @@ -652,22 +600,4 @@ /// 浠诲姟鍙� /// </summary> public string TaskNo { get; set; } -} - -//鑷姩鐮佸灈缁勭洏淇℃伅鍥炰紶 -public class BindBox -{ - /// <summary> - /// 绠辩爜 - /// </summary> - public string? BoxNo { get; set; } - /// <summary> - /// 鐩掔爜 - /// </summary> - public string? BoxNo2 { get; set; } - - /// <summary> - /// 鏀爜 - /// </summary> - public string? BoxNo3{ get; set; } } diff --git a/Admin.NET/WCS.Application/PLC/PLCService.cs b/Admin.NET/WCS.Application/PLC/PLCService.cs index 32d8e27..2775a0f 100644 --- a/Admin.NET/WCS.Application/PLC/PLCService.cs +++ b/Admin.NET/WCS.Application/PLC/PLCService.cs @@ -29,6 +29,7 @@ private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId); private static int fendao = 1; + public static void OnChangeEvent(object sender, EventArgs e) { @@ -934,6 +935,7 @@ private static void ConveyorLine(WcsDeviceDto modDevice) { var plcConn = modDevice.PLCUtil; + // 鑾峰彇妤煎眰鏁癱eshi var louCeng = PLCCommon.GetRoadwayByStationNew(modDevice.StationNum); if (louCeng == "") @@ -2519,6 +2521,7 @@ { lock (OLock) { + Thread.Sleep(2000); // 鏍规嵁宸ヤ綅鍙凤紝鑾峰彇鎵樼洏鍙� var checkTaskMedel = _db.Queryable<WcsCheckTask>().First(m => m.Port == modDevice.StationNum && m.IsDelete == false); // 鏍规嵁宸ヤ綅鍙疯幏鍙� 鎵樼洏绾胯宸ヤ綅鍙风殑閰嶇疆淇℃伅 @@ -2617,6 +2620,10 @@ } else { + if (string.IsNullOrEmpty(palletNo)) + { + break; + } // 鏍规嵁鎵樼洏鍙凤紝灏嗙粍鎵樹俊鎭彃鍏oxinfolog琛� 骞跺垹闄oxinfo琛ㄦ暟鎹� var boxInfoList = _db.Queryable<WcsBoxInfo>().Where(w => w.IsDelete == false && w.PalletNo == palletNo).ToList(); if (boxInfoList.Count <= 0) @@ -2627,29 +2634,30 @@ var retVal = plcConn.SetPlcDBValue(posModel.PosType, numModel.DbNumber, posModel.PlcPos, "234"); if (retVal.IsSucceed) { + //鏇存柊浠诲姟琛ㄦ暟閲忎俊鎭� + checkTaskMedel.Qty = 0; + _db.Updateable(checkTaskMedel).ExecuteCommand(); // 鍐欏叆缁勬墭鍥炲娴佺▼瀛� retVal = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "50"); } break; } + #region //鍒ゆ柇鎵樼洏涓婄殑绠辩爜鏄惁宸茬粍鐩� - foreach (var item in boxInfoList) - { - var groupBoxno = _db.Queryable<WcsBoxInfoLog>().Where(w => w.BoxNo == item.BoxNo).ToList(); - if (groupBoxno.Count>0) - { - Log.Error(string.Format("鐢宠宸烽亾澶辫触锛岀爜鍨涘伐浣峽0}锛岀鐮佷俊鎭笉瀛樺湪", modDevice.StationNum)); - // 鍐欏叆浜や簰宸ヤ綅鐩爣鍦板潃 - var retVal = plcConn.SetPlcDBValue(posModel.PosType, numModel.DbNumber, posModel.PlcPos, "234"); - if (retVal.IsSucceed) - { - // 鍐欏叆缁勬墭鍥炲娴佺▼瀛� - retVal = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "50"); - } - break; - } - } - + //var groupBoxno = _db.Queryable<WcsBoxInfoLog>().Where(w => w.BoxNo == item.BoxNo).ToList(); + //if (groupBoxno.Count>0) + //{ + // Log.Error(string.Format("鐢宠宸烽亾澶辫触锛岀爜鍨涘伐浣峽0}锛岀鐮佷俊鎭笉瀛樺湪", modDevice.StationNum)); + // // 鍐欏叆浜や簰宸ヤ綅鐩爣鍦板潃 + // var retVal = plcConn.SetPlcDBValue(posModel.PosType, numModel.DbNumber, posModel.PlcPos, "234"); + // if (retVal.IsSucceed) + // { + // // 鍐欏叆缁勬墭鍥炲娴佺▼瀛� + // retVal = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "50"); + // } + // break; + //} + #endregion // 缁勬墭鎴愬姛鍚庡皢淇℃伅瀛樺埌log琛� string sqlStr = $"insert into WCSBoxInfoLog select * from WCSBoxInfo where IsDelete=0 and PalletNo='{palletNo}'"; int insertCount = _db.Ado.ExecuteCommand(sqlStr); @@ -2658,10 +2666,6 @@ string sqlStr2 = $"delete from WCSBoxInfo where IsDelete=0 and PalletNo='{palletNo}'"; _db.Ado.ExecuteCommand(sqlStr2); } - //缁勭洏鎴愬姛鍚庢竻绌哄垎鎷h〃褰撳墠鎵樼洏涓婄墿鏂欐暟閲� - checkTaskMedel.Qty = 0; - _db.Updateable(checkTaskMedel).ExecuteCommand(); - // 鍚慦MS鐢宠宸烽亾 var http = new HttpService(); string TaskNo = "", EndLocate = ""; @@ -2670,10 +2674,23 @@ if (strMsg.Contains("-1")) { Log.Error(string.Format("鐢宠宸烽亾澶辫触锛岀爜鍨涘伐浣峽0};鍘熷洜{1}", modDevice.StationNum, strMsg)); + // 鍐欏叆浜や簰宸ヤ綅鐩爣鍦板潃 + var retVal = plcConn.SetPlcDBValue(posModel.PosType, numModel.DbNumber, posModel.PlcPos, "234"); + if (retVal.IsSucceed) + { + //鏇存柊浠诲姟琛ㄦ暟閲忎俊鎭� + checkTaskMedel.Qty = 0; + _db.Updateable(checkTaskMedel).ExecuteCommand(); + // 鍐欏叆缁勬墭鍥炲娴佺▼瀛� + retVal = plcConn.SetPlcDBValue(modDevice.PosType, modDevice.DbNumber, modDevice.WcsPos, "50"); + } break; } else { + //缁勭洏鎴愬姛鍚庢竻绌哄垎鎷h〃褰撳墠鎵樼洏涓婄墿鏂欐暟閲� + checkTaskMedel.Qty = 0; + _db.Updateable(checkTaskMedel).ExecuteCommand(); //鍒ゆ柇鏄惁缁撴壒涓� var (res, jiepi) = plcConn.GetPlcDBValue(checkTaskMedel.PosType, modDevice.DbNumber, checkTaskMedel.PosLot); if (jiepi == 2)//缁撴壒涓� diff --git a/Admin.NET/WCS.Application/Util/HttpService.cs b/Admin.NET/WCS.Application/Util/HttpService.cs index 08c0ffe..ad11265 100644 --- a/Admin.NET/WCS.Application/Util/HttpService.cs +++ b/Admin.NET/WCS.Application/Util/HttpService.cs @@ -108,15 +108,6 @@ var task = _db.Queryable<WcsTask>().First(m => m.IsDelete == false && (m.Status == TaskStatusEnum.Wait || m.Status == TaskStatusEnum.Doing) && m.TaskType == TaskTypeEnum.In && m.PalletNo == palletNo); if (task == null) { - var box = new BindBox(); - List<BindBox> bindBox = new List<BindBox>(); - foreach (var item in detail) - { - box.BoxNo = item.BoxNo; - box.BoxNo2 = item.BoxNo2; - box.BoxNo3 = item.BoxNo3; - bindBox.Add(box); - } var model = new BoxPalletBindVm() { OrderCode = "",//鏆傛棤涓婃父绯荤粺缂栧彿 @@ -124,25 +115,12 @@ AsnDetailNo = 0,//鏆傛棤鍏ュ簱鍗曟槑缁嗙紪鍙凤紝WMS鏍规嵁鐗╂枡鎵规鏌ユ壘 PalletNo = palletNo, Qty = qty, - xQty = (decimal)detail[0].Qty, - FullQty = (decimal)detail[0].FullQty, Type = type, SkuNo = skuNo, - SkuName = detail[0].SkuName, LotNo = lotNo, LotText = lotText, SupplierLot = supplierLot, - ProductionTime = detail[0].ProductionTime, - ExpirationTime = detail[0].ExpirationTime, - InspectMark = detail[0].InsPectMark, - BitBoxMark = detail[0].BitBoxMark, - InspectStatus = "", - Standard = detail[0].Standard, - PackageStandard = detail[0].PackageStandard, - StoreTime = detail[0].StoreTime, - QtyOrd = detail[0].QtyOrd, - QtyCount = detail[0].QtyCount, - Detail = bindBox + Detail = detail }; string url = Urls.WMSAddress + ":" + Urls.WMSPort; var result = (url + "/api/DownAPi/BindRequestRoadWay").SetBody(model, "application/json", Encoding.UTF8).PostAsAsync<ResponseTasks>().Result; -- Gitblit v1.8.0